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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.dspace.app.statistics.clarin;

import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -22,6 +23,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 +134,24 @@ public void trackBitstreamDownload(Context context, HttpServletRequest request,
return;
}

// Log the user which is downloading the 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();
String pattern = "The user name: {0}, uuid: {1} is downloading bitstream name: {2}, uuid: {3}.";
String logMessage = Objects.isNull(eperson)
? MessageFormat.format(pattern, "ANONYMOUS", "null", bit.getName(), bit.getID())
: MessageFormat.format(pattern, eperson.getFullName(), eperson.getID(), bit.getName(), bit.getID());

log.info(logMessage);
}
}
Loading