mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 02:24:18 +00:00
Merge pull request #9252 from amgciadev/fix-9223-b
Skip recording usage events if user is administrator
This commit is contained in:
@@ -81,6 +81,7 @@ import org.apache.solr.common.params.MapSolrParams;
|
|||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.apache.solr.common.params.ShardParams;
|
import org.apache.solr.common.params.ShardParams;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
@@ -146,6 +147,8 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
|||||||
private SolrStatisticsCore solrStatisticsCore;
|
private SolrStatisticsCore solrStatisticsCore;
|
||||||
@Autowired
|
@Autowired
|
||||||
private GeoIpService geoIpService;
|
private GeoIpService geoIpService;
|
||||||
|
@Autowired
|
||||||
|
private AuthorizeService authorizeService;
|
||||||
|
|
||||||
/** URL to the current-year statistics core. Prior-year shards will have a year suffixed. */
|
/** URL to the current-year statistics core. Prior-year shards will have a year suffixed. */
|
||||||
private String statisticsCoreURL;
|
private String statisticsCoreURL;
|
||||||
@@ -219,6 +222,16 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
|||||||
@Override
|
@Override
|
||||||
public void postView(DSpaceObject dspaceObject, HttpServletRequest request,
|
public void postView(DSpaceObject dspaceObject, HttpServletRequest request,
|
||||||
EPerson currentUser, String referrer) {
|
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) {
|
if (solr == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user