Skip to content

Commit 12465f9

Browse files
bram-atmireMykhaylo Boychuk
authored andcommitted
[DSC-2782] Migrate SHERPA/RoMEO integration to Jisc Open Policy Finder API
1 parent 08b2c80 commit 12465f9

52 files changed

Lines changed: 1273 additions & 892 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dspace-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
</exclusions>
378378
</dependency>
379379
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-cache
380-
Caching dependencies for sherpa service. -->
380+
Caching dependencies for Open Policy Finder service. -->
381381
<dependency>
382382
<groupId>org.springframework.boot</groupId>
383383
<artifactId>spring-boot-starter-cache</artifactId>

dspace-api/src/main/java/org/dspace/app/sherpa/SHERPAService.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/OpenPolicyFinderService.java

Lines changed: 125 additions & 94 deletions
Large diffs are not rendered by default.

dspace-api/src/main/java/org/dspace/app/sherpa/cache/SherpaCacheEvictService.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/cache/OpenPolicyFinderCacheEvictService.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.cache;
8+
package org.dspace.app.openpolicyfinder.cache;
99

1010
import java.util.Objects;
1111
import java.util.Set;
1212

13-
import org.dspace.app.sherpa.submit.SHERPASubmitService;
13+
import org.dspace.app.openpolicyfinder.submit.OpenPolicyFinderSubmitService;
1414
import org.dspace.content.Item;
1515
import org.dspace.core.Context;
1616
import org.springframework.cache.CacheManager;
1717

1818
/**
19-
* This service is responsible to deal with the SherpaService cache.
19+
* This service is responsible to deal with the Open Policy Finder service cache.
2020
*
2121
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
2222
*/
23-
public class SherpaCacheEvictService {
23+
public class OpenPolicyFinderCacheEvictService {
2424

2525
// The cache that is managed by this service.
26-
static final String CACHE_NAME = "sherpa.searchByJournalISSN";
26+
static final String CACHE_NAME = "opf.searchByJournalISSN";
2727

2828
private CacheManager cacheManager;
2929

30-
private SHERPASubmitService sherpaSubmitService;
30+
private OpenPolicyFinderSubmitService opfSubmitService;
3131

3232
/**
3333
* Remove immediately from the cache all the response that are related to a specific item
@@ -37,14 +37,14 @@ public class SherpaCacheEvictService {
3737
* @param item an Item
3838
*/
3939
public void evictCacheValues(Context context, Item item) {
40-
Set<String> ISSNs = sherpaSubmitService.getISSNs(context, item);
40+
Set<String> ISSNs = opfSubmitService.getISSNs(context, item);
4141
for (String issn : ISSNs) {
4242
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).evictIfPresent(issn);
4343
}
4444
}
4545

4646
/**
47-
* Invalidate immediately the Sherpa cache
47+
* Invalidate the Open Policy Finder cache immediately
4848
*/
4949
public void evictAllCacheValues() {
5050
Objects.requireNonNull(cacheManager.getCache(CACHE_NAME)).invalidate();
@@ -60,12 +60,12 @@ public void setCacheManager(CacheManager cacheManager) {
6060
}
6161

6262
/**
63-
* Set the reference to the SherpaSubmitService
63+
* Set the reference to the OpenPolicyFinderSubmitService
6464
*
65-
* @param sherpaSubmitService
65+
* @param opfSubmitService
6666
*/
67-
public void setSherpaSubmitService(SHERPASubmitService sherpaSubmitService) {
68-
this.sherpaSubmitService = sherpaSubmitService;
67+
public void setOpenPolicyFinderSubmitService(OpenPolicyFinderSubmitService opfSubmitService) {
68+
this.opfSubmitService = opfSubmitService;
6969
}
7070

7171
}

dspace-api/src/main/java/org/dspace/app/sherpa/cache/SherpaCacheLogger.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/cache/OpenPolicyFinderCacheLogger.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.cache;
8+
package org.dspace.app.openpolicyfinder.cache;
99

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
1212
import org.ehcache.event.CacheEvent;
1313
import org.ehcache.event.CacheEventListener;
1414

1515
/**
16-
* This is a EHCache listner responsible for logging sherpa cache events. It is
17-
* bound to the sherpa cache via the dspace/config/ehcache.xml file. We need a
16+
* This is a EHCache listner responsible for logging Open Policy Finder cache events. It is
17+
* bound to the Open Policy Finder cache via the dspace/config/ehcache.xml file. We need a
1818
* dedicated Logger for each cache as the CacheEvent doesn't include details
1919
* about where the event occur
2020
*
2121
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
2222
*
2323
*/
24-
public class SherpaCacheLogger implements CacheEventListener<Object, Object> {
24+
public class OpenPolicyFinderCacheLogger implements CacheEventListener<Object, Object> {
2525

26-
private static final Logger log = LogManager.getLogger(SherpaCacheLogger.class);
26+
private static final Logger log = LogManager.getLogger(OpenPolicyFinderCacheLogger.class);
2727

2828
@Override
2929
public void onEvent(CacheEvent<?, ?> cacheEvent) {
30-
log.debug("Sherpa Cache Event Type: {} | Key: {} ",
30+
log.debug("Open Policy Finder Cache Event Type: {} | Key: {} ",
3131
cacheEvent.getType(), cacheEvent.getKey());
3232
}
3333

dspace-api/src/main/java/org/dspace/app/sherpa/submit/ISSNItemExtractor.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/submit/ISSNItemExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.submit;
8+
package org.dspace.app.openpolicyfinder.submit;
99

1010
import java.util.List;
1111

dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataAuthorityISSNExtractor.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/submit/MetadataAuthorityISSNExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.submit;
8+
package org.dspace.app.openpolicyfinder.submit;
99

1010
import java.util.ArrayList;
1111
import java.util.List;

dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataValueISSNExtractor.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/submit/MetadataValueISSNExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.submit;
8+
package org.dspace.app.openpolicyfinder.submit;
99

1010
import java.util.ArrayList;
1111
import java.util.List;

dspace-api/src/main/java/org/dspace/app/sherpa/submit/SHERPASubmitConfigurationService.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/submit/OpenPolicyFinderSubmitConfigurationService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.submit;
8+
package org.dspace.app.openpolicyfinder.submit;
99

1010
import java.util.List;
1111

12-
public class SHERPASubmitConfigurationService {
12+
public class OpenPolicyFinderSubmitConfigurationService {
1313
private List<ISSNItemExtractor> issnItemExtractors;
1414

1515
public void setIssnItemExtractors(List<ISSNItemExtractor> issnItemExtractors) {

dspace-api/src/main/java/org/dspace/app/sherpa/submit/SHERPASubmitService.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/submit/OpenPolicyFinderSubmitService.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,106 +5,106 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.submit;
8+
package org.dspace.app.openpolicyfinder.submit;
99

1010
import java.util.Iterator;
1111
import java.util.LinkedHashSet;
1212
import java.util.List;
1313
import java.util.Set;
1414

1515
import org.apache.logging.log4j.Logger;
16-
import org.dspace.app.sherpa.SHERPAService;
17-
import org.dspace.app.sherpa.v2.SHERPAResponse;
16+
import org.dspace.app.openpolicyfinder.OpenPolicyFinderService;
17+
import org.dspace.app.openpolicyfinder.v2.OpenPolicyFinderResponse;
1818
import org.dspace.content.Item;
1919
import org.dspace.core.Context;
2020
import org.dspace.core.LogHelper;
2121

2222
/**
23-
* SHERPASubmitService is
23+
* OpenPolicyFinderSubmitService is
2424
* @see
2525
* @author Kim Shepherd
2626
*/
27-
public class SHERPASubmitService {
27+
public class OpenPolicyFinderSubmitService {
2828

2929
/**
3030
* Spring beans for configuration and API service
3131
*/
32-
protected SHERPAService sherpaService;
33-
protected SHERPASubmitConfigurationService configuration;
32+
protected OpenPolicyFinderService openPolicyFinderService;
33+
protected OpenPolicyFinderSubmitConfigurationService configuration;
3434

3535
/**
3636
* log4j logger
3737
*/
38-
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPASubmitService.class);
38+
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(OpenPolicyFinderSubmitService.class);
3939

4040
/**
4141
* Setter for configuration (from Spring)
42-
* @see "dspace-dspace-addon-sherpa-configuration-services.xml"
42+
* @see "spring-dspace-addon-openpolicyfinder-services.xml"
4343
* @param configuration
4444
*/
45-
public void setConfiguration(SHERPASubmitConfigurationService configuration) {
45+
public void setConfiguration(OpenPolicyFinderSubmitConfigurationService configuration) {
4646
this.configuration = configuration;
4747
}
4848

4949
/**
50-
* Setter for SHERPA service, reponsible for actual HTTP API calls
51-
* @see "dspace-dspace-addon-sherpa-configuration-services.xml"
52-
* @param sherpaService
50+
* Setter for Open Policy Finder service, reponsible for actual HTTP API calls
51+
* @see "spring-dspace-addon-openpolicyfinder-services.xml"
52+
* @param openPolicyFinderService
5353
*/
54-
public void setSherpaService(SHERPAService sherpaService) {
55-
this.sherpaService = sherpaService;
54+
public void setOpenPolicyFinderService(OpenPolicyFinderService openPolicyFinderService) {
55+
this.openPolicyFinderService = openPolicyFinderService;
5656
}
5757

5858
/**
59-
* Search SHERPA for journal policies matching the ISSNs in the item.
59+
* Search Open Policy Finder for journal policies matching the ISSNs in the item.
6060
* Rather than a 'search' query for any/all ISSNs, the v2 API requires a separate
6161
* query for each ISSN found in the item. The ISSNs are extracted using the configured
62-
* issnItemExtractor(s) in the SHERPA spring configuration.
62+
* issnItemExtractor(s) in the Open Policy Finder spring configuration.
6363
* The ISSNs are not validated with a regular expression or other rules - any values
6464
* extracted will be included in API queries.
65-
* Return the first not empty response from Sherpa
66-
* @see "dspace-dspace-addon-sherpa-configuration-services.xml"
65+
* Return the first non-empty response from Open Policy Finder
66+
* @see "spring-dspace-addon-openpolicyfinder-services.xml"
6767
* @param context DSpace context
6868
* @param item DSpace item containing ISSNs to be checked
69-
* @return SHERPA v2 API response (policy data)
69+
* @return Open Policy Finder API response (policy data)
7070
*/
71-
public SHERPAResponse searchRelatedJournals(Context context, Item item) {
71+
public OpenPolicyFinderResponse searchRelatedJournals(Context context, Item item) {
7272
Set<String> issns = getISSNs(context, item);
7373
if (issns == null || issns.size() == 0) {
7474
return null;
7575
} else {
76-
// SHERPA v2 API no longer supports "OR'd" ISSN search, perform individual searches instead
76+
// Open Policy Finder API no longer supports "OR'd" ISSN search, perform individual searches instead
7777
Iterator<String> issnIterator = issns.iterator();
7878
while (issnIterator.hasNext()) {
7979
String issn = issnIterator.next();
80-
SHERPAResponse response = sherpaService.searchByJournalISSN(issn);
80+
OpenPolicyFinderResponse response = openPolicyFinderService.searchByJournalISSN(issn);
8181
if (response.isError()) {
8282
// Continue with loop
83-
log.warn("Failed to look up SHERPA ROMeO result for ISSN: " + issn
83+
log.warn("Failed to look up Open Policy Finder result for ISSN: " + issn
8484
+ ": " + response.getMessage());
8585
return response;
8686
} else if (!response.getJournals().isEmpty()) {
8787
// return this response, if it is not empty
8888
return response;
8989
}
9090
}
91-
return new SHERPAResponse();
91+
return new OpenPolicyFinderResponse();
9292
}
9393
}
9494

9595
/**
96-
* Search SHERPA for journal policies matching the passed ISSN.
96+
* Search Open Policy Finder for journal policies matching the passed ISSN.
9797
* The ISSN are not validated with a regular expression or other rules - any String
9898
* passed to this method will be considered an ISSN for the purposes of an API query
9999
* @param issn ISSN string
100-
* @return SHERPA v2 API response object (policy data)
100+
* @return Open Policy Finder API response object (policy data)
101101
*/
102-
public SHERPAResponse searchRelatedJournalsByISSN(String issn) {
103-
return sherpaService.searchByJournalISSN(issn);
102+
public OpenPolicyFinderResponse searchRelatedJournalsByISSN(String issn) {
103+
return openPolicyFinderService.searchByJournalISSN(issn);
104104
}
105105

106106
/**
107-
* Using the configured itemIssnExtractors from SHERPA configuration, extract
107+
* Using the configured itemIssnExtractors from Open Policy Finder configuration, extract
108108
* ISSNs from item metadata or authority values
109109
* @param context DSpace context
110110
* @param item Item containing metadata / authority values

dspace-api/src/main/java/org/dspace/app/sherpa/v2/SHERPAEmbargo.java renamed to dspace-api/src/main/java/org/dspace/app/openpolicyfinder/v2/OpenPolicyFinderEmbargo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
package org.dspace.app.sherpa.v2;
8+
package org.dspace.app.openpolicyfinder.v2;
99

1010
import java.io.Serializable;
1111

1212
/**
13-
* Model class for the Embargo of SHERPAv2 API (JSON)
13+
* Model class for the Embargo of Open Policy Finder API (JSON)
1414
*
1515
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
1616
*/
17-
public class SHERPAEmbargo implements Serializable {
17+
public class OpenPolicyFinderEmbargo implements Serializable {
1818

1919
private static final long serialVersionUID = 6140668058547523656L;
2020

2121
private int amount;
2222
private String units;
2323

24-
public SHERPAEmbargo(int amount, String units) {
24+
public OpenPolicyFinderEmbargo(int amount, String units) {
2525
this.amount = amount;
2626
this.units = units;
2727
}

0 commit comments

Comments
 (0)