Skip to content

Commit

Permalink
Add logging of downloading restricted bitstreams.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Nov 27, 2023
1 parent 7d1fdb8 commit c8bc409
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.dspace.content.service.ItemService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.matomo.java.tracking.CustomVariable;
Expand Down Expand Up @@ -132,6 +133,19 @@ public void trackBitstreamDownload(Context context, HttpServletRequest request,
return;
}

// Log the user which is downloading the restricted bitstream
this.logUserDownloadingBitstream(context, bit);
// Track the bitstream downloading event
trackPage(context, request, item, "Bitstream Download / Single File");
}

private void logUserDownloadingBitstream(Context context, Bitstream bit) {
EPerson eperson = context.getCurrentUser();
if (Objects.isNull(eperson)) {
log.error("Cannot log user which is downloading restricted bitstream.");
}

log.info("User: " + eperson.getFullName() + " with ID: " + eperson.getID() + " is downloading restricted" +
" bitstream " + bit.getName() + " with ID: " + bit.getID());
}
}

0 comments on commit c8bc409

Please sign in to comment.