User name during manual block deleting
Requirements
Find the most effective approach (effort + implementation complexity).
APPROACH 1: Retrieve user id from the headers when deleting record and re-send it in the metadata during manual block deleting flow.
Steps to implement:
- Change org.folio.rest.impl.ManualBlocksAPI in mod-feesfines module by adding the following line in the deleteManualblocksByManualblockId method:
String source = okapiHeaders.get("x-okapi-user-id");
JsonObject payload = JsonObject.mapFrom(getByIdReply.result());
payload.getJsonObject("metadata").put("updatedByUserId", source); - Change org.folio.builder.service.ManualBlockRecordBuilder in mod-audit module by changing the logic in the getSource method where 'source' is alwaysnull when log event type is MANUAL_BLOCK_DELETED (requires minimum effort).
As a result, mod-audit can recognize source correctly: https://github.com/folio-org/mod-audit/blob/master/mod-audit-server/src/main/java/org/folio/builder/service/ManualBlockRecordBuilder.java#L46.
APPROACH 2: Change deleting flow, introduce fake deleting with key isDeleted to mark manual block as deleted. One need to change all CRUD operations.
Steps to implement:
- Change manual patron block schema by adding additional field 'isDeleted' that can be true or false (initially false).
- Change org.folio.rest.impl.ManualBlocksAPI in mod-feesfines module by adding filter in getManualblocks method to return manualblocks only with isDeleted=false.
- Change org.folio.rest.impl.ManualBlocksAPI in mod-feesfines module by adding filter in getManualblocksByManualblockId method to return manualblock only if isDeleted=false.
- Change org.folio.rest.impl.ManualBlocksAPI in mod-feesfines module by setting isDeleted field in Manualblock entity to 'true' in deleteManualblocksByManualblockId method
As a result, all 'delete' operations are stored in manualblocks table, and user id can be found in updatedBy column using RMB.
Advantages | Disadvantages | |
---|---|---|
APPROACH 1 | Need to add only a few lines of code in one class, minimum modifications in one method of another module. | Need to modify another module. |
APPROACH 2 | Changes are only in one module. | Need to modify schema and 3 methods. |