Skip to content

Commit

Permalink
Merge pull request DSpace#9264 from DSpace/backport-9252-to-dspace-7_x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] Skip recording usage events if user is administrator
  • Loading branch information
alanorth authored Jan 18, 2024
2 parents c86a0cf + 9a0db2a commit 8a59c12
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 8a59c12

Please sign in to comment.