Skip to content

CIRC-2364 Anonymize Single Request Post API#1632

Merged
yuntianhu merged 16 commits intomasterfrom
CIRC-2364
Nov 24, 2025
Merged

CIRC-2364 Anonymize Single Request Post API#1632
yuntianhu merged 16 commits intomasterfrom
CIRC-2364

Conversation

@yuntianhu
Copy link
Contributor

@yuntianhu yuntianhu commented Nov 12, 2025

CIRC-2364-Anonymize Single Request Post API #1632

Ticket Description

Purpose/Overview:
Create a /request-anonymization/{request UUID} Post API for anonymizing one a single closed request

Requirements/Scope:

Verify that the user has the UI-Requests Request-Anonymize Single Execute capability

Anonymizes request as described in https://folio-org.atlassian.net/browse/CIRC-2292

Returns an error message if anonymization fails

Acceptance Criteria:

Post API for single request anonymization by UUID is created

Summary of Work Completed for Request Anonymization (CIRC-2364 / CIRC-2292)

I implemented backend support for manual single-request anonymization in mod-circulation, including all core API logic, data scrubbing, integration with storage, permissions, event publishing, and automated tests. This work completes a brand-new FOLIO circulation feature.

  1. Added the new backend API endpoint POST /request-anonymization/{requestId}
  2. Implemented full service logic including ID validation, request fetching, status validation, PII scrubbing, persistence, and event publishing.
  3. Implemented scrubbing of requesterId, proxyUserId, requester, proxy, and delivery address fields.
  4. Integrated updates with requestRepository and eventPublisher.
  5. Created comprehensive tests for the anonymization workflow.
  6. Corrected ModuleDescriptor-template.json structure and permissions.
  7. Added new permission capability for anonymization operations.
  8. Verified PubSub integration through LOG_RECORD audit events.

Approach for Single Request Anonymization

  1. Introduced dedicated service layer with validation, scrub PII, update and publish logging
  2. Designed for future dependency injection
  3. Added new API endpoint
  4. Capability set / permission work
  5. Test suite creation
  6. Debugging & stability work
  7. Architectural alignment

Create a /request-anonymization/{request UUID} Post API for anonymizing one a single closed request

Requirements/Scope:

Verify that the user has the UI-Requests Request-Anonymize Single Execute capability

Anonymizes request as described in https://folio-org.atlassian.net/browse/CIRC-2292

Returns an error message if anonymization fails

Acceptance Criteria:

Post API for single request anonymization by UUID is created
@yuntianhu yuntianhu requested review from a team, alexanderkurash and longvo-cv November 14, 2025 15:48
@yuntianhu yuntianhu changed the title CIRC 2364-Anonymize Single Request Post API CIRC-2364-Anonymize Single Request Post API Nov 17, 2025
@yuntianhu yuntianhu requested review from a team and roman-barannyk November 18, 2025 17:33
Copy link

@longvo-cv longvo-cv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Solid implementation

@OleksandrVidinieiev
Copy link
Contributor

@yuntianhu In the future, please mention Jira ticket name in your commit messages: CIRC-2364 My awesome commit message. And when you are ready to merge your PR, please use "Squash and merge" button instead of "Create a merge commit". This makes future release process much easier.

@yuntianhu
Copy link
Contributor Author

@OleksandrVidinieiev Thank you for the reminder, I will surely remember to do it 😄

- Add permissionsRequired and modulePermissions for /request-anonymization/{requestId} handler in ModuleDescriptor-template.json
- Use UuidUtil.isUuid in RequestAnonymizationService and return failed validation when requestId is invalid
- Simplify fetchRequest to delegate to requestRepository.getById without extra failWhen logic
- Change scrubPii to return Request instead of Result and call it via mapResult
- Simplify publishLog to return Result<Void> from eventPublisher without remapping
- Fix Result chain to use flatMapResult for validateStatus and after(...) for async update/log
- Remove unused validationError helper that relied on old ValidationError constructor
- Update RequestAnonymizationServiceTest to inject mocks via constructor (remove reflection)
- Adjust not-found test to return failed RecordNotFoundFailure instead of succeeded(null)
- Reorder imports in tests to follow mod-circulation import order convention
@yuntianhu yuntianhu requested a review from a team November 21, 2025 15:46
Fix displayName/description wording: "anonymize request" instead of "anonymize requests".

Update permission name to modperms.circulation.requests.anonymize.single.

Remove redundant modulePermission already included in anonymize.single.

Inline RequestRepository.using(...) initializer into single line.

Condense ValidationErrorFailure.failedValidation(...) into one line.

Add UUID format validation to requestId in anonymize-single-request-response.json.

Remove extra spacing alignment in EventPublisher .put() calls.

Replace wildcard imports in RequestAnonymizationServiceTest with explicit imports.

Reorder imports to follow mod-circulation import convention.

Adjust permission naming to follow FOLIO scope convention (item vs collection).
@sonarqubecloud
Copy link

@alexanderkurash alexanderkurash changed the title CIRC-2364-Anonymize Single Request Post API CIRC-2364 Anonymize Single Request Post API Nov 24, 2025
@yuntianhu yuntianhu merged commit 23a0ace into master Nov 24, 2025
8 checks passed
@yuntianhu yuntianhu deleted the CIRC-2364 branch December 8, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants