From e7e2373acae939a98e2d817d23ec8306ac2d059f Mon Sep 17 00:00:00 2001 From: Andrea Bollini Date: Wed, 27 Mar 2024 22:40:01 +0100 Subject: [PATCH] Add some logging at the debug level --- .../service/impl/ItemEnhancerServiceImpl.java | 14 +++++++++++--- .../enhancer/RelatedItemEnhancerUpdatePoller.java | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/content/enhancer/service/impl/ItemEnhancerServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/enhancer/service/impl/ItemEnhancerServiceImpl.java index 97816515ea36..ee2444e05ee1 100644 --- a/dspace-api/src/main/java/org/dspace/content/enhancer/service/impl/ItemEnhancerServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/enhancer/service/impl/ItemEnhancerServiceImpl.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.UUID; +import org.apache.logging.log4j.Logger; import org.dspace.authorize.AuthorizeException; import org.dspace.content.Item; import org.dspace.content.dao.ItemForMetadataEnhancementUpdateDAO; @@ -28,6 +29,11 @@ */ public class ItemEnhancerServiceImpl implements ItemEnhancerService { + /** + * log4j category + */ + private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemEnhancerServiceImpl.class); + @Autowired private List itemEnhancers; @@ -41,14 +47,15 @@ public class ItemEnhancerServiceImpl implements ItemEnhancerService { public void enhance(Context context, Item item, boolean deepMode) { boolean isUpdateNeeded = false; if (deepMode) { - itemForMetadataEnhancementUpdateDAO.removeItemForUpdate(context, item.getID()); + final UUID id = item.getID(); + log.debug("deepMode enabled, removing item with uuid {} from the queue", id); + itemForMetadataEnhancementUpdateDAO.removeItemForUpdate(context, id); } for (ItemEnhancer itemEnhancer : itemEnhancers) { if (itemEnhancer.canEnhance(context, item)) { isUpdateNeeded = itemEnhancer.enhance(context, item, deepMode) || isUpdateNeeded; } } - if (isUpdateNeeded) { updateItem(context, item); try { @@ -61,7 +68,8 @@ public void enhance(Context context, Item item, boolean deepMode) { @Override public void saveAffectedItemsForUpdate(Context context, UUID uuid) throws SQLException { - itemForMetadataEnhancementUpdateDAO.saveAffectedItemsForUpdate(context, uuid); + int queued = itemForMetadataEnhancementUpdateDAO.saveAffectedItemsForUpdate(context, uuid); + log.debug("queued {} items for metadata enhancement check", queued); } @Override diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/enhancer/RelatedItemEnhancerUpdatePoller.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/enhancer/RelatedItemEnhancerUpdatePoller.java index c8c6cd72eb5a..b4af863e6542 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/enhancer/RelatedItemEnhancerUpdatePoller.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/enhancer/RelatedItemEnhancerUpdatePoller.java @@ -34,14 +34,17 @@ public class RelatedItemEnhancerUpdatePoller { @Scheduled(fixedDelayString = "${related-item-enhancer-poller.delay}") public void pollItemToUpdateAndProcess() { try { + log.debug("item enhancer poller executed"); Context context = new Context(); context.turnOffAuthorisationSystem(); UUID extractedUuid; while ((extractedUuid = itemEnhancerService.pollItemToUpdate(context)) != null) { + log.debug("item enhancer poller processing {}", extractedUuid); Item item = itemService.find(context, extractedUuid); if (item != null) { itemEnhancerService.enhance(context, item, true); } + log.debug("item enhancer poller committing"); context.commit(); } context.restoreAuthSystemState();