Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufal/be-license-download-statistics #462

Merged
merged 7 commits into from
Dec 1, 2023
Merged
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,26 @@ public void trackBitstreamDownload(Context context, HttpServletRequest request,
return;
}

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

/**
* Log the user which is downloading the bitstream
* @param context DSpace context object
* @param bit Bitstream which is downloading
*/
private void logUserDownloadingBitstream(Context context, Bitstream bit) {
EPerson eperson = context.getCurrentUser();
if (Objects.isNull(eperson)) {
log.info("ANONYMOUS user is trying to download bitstream " + bit.getName() + " with ID: " +
bit.getID());
return;
}

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