Skip to content

Commit

Permalink
Skip recording usage event if administrator
Browse files Browse the repository at this point in the history
(cherry picked from commit 73e5c43)
  • Loading branch information
amgciadev authored and github-actions[bot] committed Jan 18, 2024
1 parent c86a0cf commit 9a0db2a
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.Collection;
Expand Down Expand Up @@ -146,6 +147,8 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
private SolrStatisticsCore solrStatisticsCore;
@Autowired
private GeoIpService geoIpService;
@Autowired
private AuthorizeService authorizeService;

/** URL to the current-year statistics core. Prior-year shards will have a year suffixed. */
private String statisticsCoreURL;
Expand Down Expand Up @@ -219,6 +222,16 @@ public void postView(DSpaceObject dspaceObject, HttpServletRequest request,
@Override
public void postView(DSpaceObject dspaceObject, HttpServletRequest request,
EPerson currentUser, String referrer) {
Context context = new Context();
// Do not record statistics for Admin users
try {
if (authorizeService.isAdmin(context, currentUser)) {
return;
}
} catch (SQLException e) {
throw new RuntimeException(e);
}

if (solr == null) {
return;
}
Expand Down

0 comments on commit 9a0db2a

Please sign in to comment.