70906: Process IRUS DSpace 7 PR feedback

This commit is contained in:
Yana De Pauw
2020-09-18 11:52:19 +02:00
parent 7d793ec2d9
commit 9945ab1bc3
10 changed files with 36 additions and 36 deletions

View File

@@ -38,7 +38,7 @@ public class IrusExportUsageEventListener extends AbstractUsageEventListener {
* @param event includes all the information related to the event that occurred
*/
public void receiveEvent(Event event) {
if (configurationService.getBooleanProperty("stats.tracker.enabled", false)) {
if (configurationService.getBooleanProperty("irus.statistics.tracker.enabled", false)) {
if (event instanceof UsageEvent) {
UsageEvent ue = (UsageEvent) event;
Context context = ue.getContext();

View File

@@ -44,7 +44,7 @@ public class BitstreamEventProcessor extends ExportEventProcessor {
throws SQLException {
super(context, request);
this.bitstream = bitstream;
this.item = getItem();
this.item = getItem(request);
}
/**
@@ -53,7 +53,7 @@ public class BitstreamEventProcessor extends ExportEventProcessor {
* @return parent item of the bitstream
* @throws SQLException
*/
private Item getItem() throws SQLException {
private Item getItem(HttpServletRequest request) throws SQLException {
if (0 < bitstream.getBundles().size()) {
if (!SpiderDetector.isSpider(request)) {
Bundle bundle = bitstream.getBundles().get(0);

View File

@@ -56,8 +56,8 @@ public abstract class ExportEventProcessor {
private OpenUrlService openUrlService = OpenURLTrackerLoggerServiceFactory.getInstance().getOpenUrlService();
protected Context context;
protected HttpServletRequest request;
private Context context;
private HttpServletRequest request;
/**
* Creates a new ExportEventProcessor based on the params and initializes the services
@@ -87,10 +87,10 @@ public abstract class ExportEventProcessor {
*/
protected void processObject(String urlParameters) throws IOException, SQLException {
String baseUrl;
if (StringUtils.equals(configurationService.getProperty("stats.tracker.environment"), "production")) {
baseUrl = configurationService.getProperty("stats.tracker.produrl");
if (StringUtils.equals(configurationService.getProperty("irus.statistics.tracker.environment"), "production")) {
baseUrl = configurationService.getProperty("irus.statistics.tracker.produrl");
} else {
baseUrl = configurationService.getProperty("stats.tracker.testurl");
baseUrl = configurationService.getProperty("irus.statistics.tracker.testurl");
}
openUrlService.processUrl(context, baseUrl + "?" + urlParameters);
@@ -127,7 +127,7 @@ public abstract class ExportEventProcessor {
//Start adding our data
StringBuilder data = new StringBuilder();
data.append(URLEncoder.encode("url_ver", UTF_8) + "=" +
URLEncoder.encode(configurationService.getProperty("stats.tracker.urlversion"), UTF_8));
URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8));
data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=")
.append(URLEncoder.encode(clientIP, UTF_8));
data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=")
@@ -194,7 +194,7 @@ public abstract class ExportEventProcessor {
Entity entity = entityService.findByItemId(context, item.getID());
EntityType type = entityService.getType(context, entity);
String[] entityTypeStrings = configurationService.getArrayProperty("stats.tracker.entity-types");
String[] entityTypeStrings = configurationService.getArrayProperty("irus.statistics.tracker.entity-types");
List<String> entityTypes = new ArrayList<>();
if (entityTypeStrings.length != 0) {
@@ -216,8 +216,8 @@ public abstract class ExportEventProcessor {
* @return whether the item should be processed
*/
protected boolean shouldProcessItemType(Item item) {
String trackerTypeMetadataField = configurationService.getProperty("stats.tracker.type-field");
String[] metadataValues = configurationService.getArrayProperty("stats.tracker.type-value");
String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field");
String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value");
List<String> trackerTypeMetadataValues;
if (metadataValues.length > 0) {
trackerTypeMetadataValues = new ArrayList<>();

View File

@@ -111,9 +111,9 @@ public class ITIrusExportUsageEventListener extends AbstractIntegrationTestWithD
public void setUp() throws Exception {
super.setUp();
configurationService.setProperty("stats.tracker.enabled", true);
configurationService.setProperty("stats.tracker.type-field", "dc.type");
configurationService.setProperty("stats.tracker.type-value", "Excluded type");
configurationService.setProperty("irus.statistics.tracker.enabled", true);
configurationService.setProperty("irus.statistics.tracker.type-field", "dc.type");
configurationService.setProperty("irus.statistics.tracker.type-value", "Excluded type");
context.turnOffAuthorisationSystem();

View File

@@ -46,7 +46,7 @@ public class BitstreamEventProcessorTest extends AbstractIntegrationTestWithData
@Before
public void setUp() throws Exception {
super.setUp();
configurationService.setProperty("stats.tracker.enabled", true);
configurationService.setProperty("irus.statistics.tracker.enabled", true);
String dspaceUrl = configurationService.getProperty("dspace.server.url");
try {

View File

@@ -56,10 +56,10 @@ public class ExportEventProcessorTest extends AbstractIntegrationTestWithDatabas
public void setUp() throws Exception {
super.setUp();
configurationService.setProperty("stats.tracker.urlversion", "Z39.88-2004");
configurationService.setProperty("stats.tracker.enabled", true);
configurationService.setProperty("stats.tracker.type-field", "dc.type");
configurationService.setProperty("stats.tracker.type-value", "Excluded type");
configurationService.setProperty("irus.statistics.tracker.urlversion", "Z39.88-2004");
configurationService.setProperty("irus.statistics.tracker.enabled", true);
configurationService.setProperty("irus.statistics.tracker.type-field", "dc.type");
configurationService.setProperty("irus.statistics.tracker.type-value", "Excluded type");
context.turnOffAuthorisationSystem();
publication = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();

View File

@@ -39,7 +39,7 @@ public class ItemEventProcessorTest extends AbstractIntegrationTestWithDatabase
@Before
public void setUp() throws Exception {
super.setUp();
configurationService.setProperty("stats.tracker.enabled", true);
configurationService.setProperty("irus.statistics.tracker.enabled", true);
String dspaceUrl = configurationService.getProperty("dspace.ui.url");
try {

View File

@@ -2012,4 +2012,4 @@ include = ${module_dir}/translator.cfg
include = ${module_dir}/usage-statistics.cfg
include = ${module_dir}/versioning.cfg
include = ${module_dir}/workflow.cfg
include = ${module_dir}/stats.cfg
include = ${module_dir}/irus-statistics.cfg

View File

@@ -1,35 +1,35 @@
# Enable the IRUS tracker. By default or when omitted, the tracker will be disabled
stats.tracker.enabled = false
irus.statistics.tracker.enabled = false
# OPTIONAL metadata field used for filtering.
# If items with specific values for the "dc.type" field should be excluded, "dc.type" should be placed here.
# This should comply to the syntax schema.element.qualified or schema.element if the qualifier is null.
# stats.tracker.type-field = dc.type
# irus.statistics.tracker.type-field = dc.type
# If "tracker.type-field" is set, the list of values must be defined in "tracker.type-value".
# This lists a comma separated list of values that will be excluded for the given field.
# stats.tracker.type-value = Article, Postprint
# irus.statistics.tracker.type-value = Article, Postprint
# This lists a comma separated list of entities that will be included
# When no list is provided, the default value "Publication" will be used
# stats.tracker.entity-types = Publication
# irus.statistics.tracker.entity-types = Publication
# Set the tracker environment to "test" or "production". Defaults to "test" if empty.
# The URL used by the test environment can be configured in property tracker.testurl
# The URL used by the production environment can be configured in property tracker.produrl
stats.tracker.environment = test
irus.statistics.tracker.environment = test
# The url used to test the submission of tracking info to.
stats.tracker.testurl = https://irus.jisc.ac.uk/counter/test/
irus.statistics.tracker.testurl = https://irus.jisc.ac.uk/counter/test/
# The base url for submitting the tracking info to.
stats.tracker.produrl = https://irus.jisc.ac.uk/counter/
irus.statistics.tracker.produrl = https://irus.jisc.ac.uk/counter/
# Identifies data as OpenURL 1.0
stats.tracker.urlversion = Z39.88-2004
irus.statistics.tracker.urlversion = Z39.88-2004
# Add the agentregex configuration below uncommented to local.cfg to include the bot agents list by
# Project COUNTER when filtering bots in DSpace. The agents file is downloaded by the Apache ant
# stage of the build process.
# Location of the COUNTER agents file
# stats.spider.agentregex.regexfile = ${dspace.dir}/config/spiders/agents/COUNTER_Robots_list.txt
# irus.statistics.spider.agentregex.regexfile = ${dspace.dir}/config/spiders/agents/COUNTER_Robots_list.txt
# External URL to COUNTER the agents file
# stats.spider.agentregex.url = https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/generated/COUNTER_Robots_list.txt
# irus.statistics.spider.agentregex.url = https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/generated/COUNTER_Robots_list.txt

View File

@@ -862,18 +862,18 @@ Common usage:
<!-- installs and/or updates Project Counter Robot List resolution database -->
<target name="update_spiders">
<echo>Downloading: ${stats.spider.agentregex.url}</echo>
<get src="${stats.spider.agentregex.url}" dest="${stats.spider.agentregex.regexfile}" verbose="true" />
<echo>Downloading: ${irus.statistics.spider.agentregex.url}</echo>
<get src="${irus.statistics.spider.agentregex.url}" dest="${irus.statistics.spider.agentregex.regexfile}" verbose="true" />
</target>
<target name="check_spiders">
<condition property="need.spiders">
<and>
<not>
<available file="${stats.spider.agentregex.regexfile}" />
<available file="${irus.statistics.spider.agentregex.regexfile}" />
</not>
<not>
<contains string="${stats.spider.agentregex.url}" substring="stats.spider.agentregex.url"/>
<contains string="${irus.statistics.spider.agentregex.url}" substring="irus.statistics.spider.agentregex.url"/>
</not>
</and>
</condition>