Skip to content

Commit

Permalink
Add logs for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanChernetskyi committed Jun 18, 2024
1 parent 8aa13c5 commit 1c8b33c
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ private CompletableFuture<List<String>> updateOwnershipOfHoldingsRecords(Holding
List<NotUpdatedEntity> notUpdatedEntities, RoutingContext routingContext,
WebContext context, Context targetTenantContext) {
try {
LOGGER.info("updateOwnershipOfHoldingsRecords:: Updating ownership of holdingsRecord: {}, to tenant: {}",
holdingsUpdateOwnership.getHoldingsRecordIds(), targetTenantContext.getTenantId());

CollectionResourceClient holdingsStorageClient = createHoldingsStorageClient(createHttpClient(client, routingContext, context),
context);
MultipleRecordsFetchClient holdingsRecordFetchClient = createHoldingsRecordsFetchClient(holdingsStorageClient);
Expand All @@ -140,10 +143,12 @@ private CompletableFuture<List<String>> updateOwnershipOfHoldingsRecords(Holding

return holdingsRecordFetchClient.find(holdingsUpdateOwnership.getHoldingsRecordIds(), MoveApiUtil::fetchByIdCql)
.thenCompose(jsons -> {
LOGGER.info("updateOwnershipOfHoldingsRecords:: Founded holdings to update ownership: {}", jsons);
processNotFoundedInstances(holdingsUpdateOwnership.getHoldingsRecordIds(), notUpdatedEntities, context, jsons);
return createHoldings(jsons, notUpdatedEntities, holdingsUpdateOwnership.getToInstanceId(), targetTenantHoldingsRecordCollection);
})
.thenCompose(createdHoldings -> {
LOGGER.info("updateOwnershipOfHoldingsRecords:: Created holdings: {}, for tenant: {}", createdHoldings, targetTenantContext.getTenantId());
List<String> createdHoldingsIds = createdHoldings.stream().map(HoldingsRecord::getId).toList();

return transferAttachedItems(createdHoldingsIds, notUpdatedEntities, routingContext, context, targetTenantContext)
Expand All @@ -160,15 +165,24 @@ private CompletableFuture<List<String>> updateOwnershipOfHoldingsRecords(Holding
private CompletableFuture<List<String>> transferAttachedItems(List<String> holdingsRecordIds, List<NotUpdatedEntity> notUpdatedEntities,
RoutingContext routingContext, WebContext context, Context targetTenantContext) {
try {
LOGGER.info("transferAttachedItems:: Transfer items of holdingsRecordIds: {}, to tenant: {}",
holdingsRecordIds, targetTenantContext.getTenantId());

CollectionResourceClient itemsStorageClient = createItemStorageClient(createHttpClient(client, routingContext, context), context);
MultipleRecordsFetchClient itemsFetchClient = createItemsFetchClient(itemsStorageClient);

ItemCollection sourceTenantItemCollection = storage.getItemCollection(context);
ItemCollection targetTenantItemCollection = storage.getItemCollection(targetTenantContext);

return itemsFetchClient.find(holdingsRecordIds, MoveApiUtil::fetchByHoldingsRecordIdCql)
.thenCompose(jsons -> createItems(jsons, notUpdatedEntities, targetTenantItemCollection))
.thenCompose(items -> deleteItems(items, notUpdatedEntities, sourceTenantItemCollection));
.thenCompose(jsons -> {
LOGGER.info("transferAttachedItems:: Found items to transfer: {}", jsons);
return createItems(jsons, notUpdatedEntities, targetTenantItemCollection);
})
.thenCompose(items -> {
LOGGER.info("transferAttachedItems:: Created items: {}", items);
return deleteItems(items, notUpdatedEntities, sourceTenantItemCollection);
});
} catch (Exception e) {
LOGGER.warn("transferAttachedItems:: Error during transfer attached items for holdings {}, to tenant: {}",
holdingsRecordIds, targetTenantContext.getTenantId(), e);
Expand Down

0 comments on commit 1c8b33c

Please sign in to comment.