Skip to content

Commit

Permalink
Add some logging at the debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
abollini committed Mar 27, 2024
1 parent 727080e commit e7e2373
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ItemEnhancer> itemEnhancers;

Expand All @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e7e2373

Please sign in to comment.