Skip to content

Commit 3f28c26

Browse files
Micheleboychukvins01-4science
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2782-OPF (pull request DSpace#5695)
DSC-2782: [2024] Transizione API SherpaRomeo > Open Policy Finder API Approved-by: Vincenzo Mecca
1 parent 5d2c619 commit 3f28c26

59 files changed

Lines changed: 1416 additions & 1071 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: 143 additions & 121 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: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,106 +5,107 @@
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
24-
* @see
23+
* OpenPolicyFinderSubmitService is responsible for querying the Open Policy Finder API
24+
* during item submission to retrieve journal publishing policies by ISSN.
25+
*
2526
* @author Kim Shepherd
2627
*/
27-
public class SHERPASubmitService {
28+
public class OpenPolicyFinderSubmitService {
2829

2930
/**
3031
* Spring beans for configuration and API service
3132
*/
32-
protected SHERPAService sherpaService;
33-
protected SHERPASubmitConfigurationService configuration;
33+
protected OpenPolicyFinderService openPolicyFinderService;
34+
protected OpenPolicyFinderSubmitConfigurationService configuration;
3435

3536
/**
3637
* log4j logger
3738
*/
38-
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPASubmitService.class);
39+
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(OpenPolicyFinderSubmitService.class);
3940

4041
/**
4142
* Setter for configuration (from Spring)
42-
* @see "dspace-dspace-addon-sherpa-configuration-services.xml"
43+
* @see "spring-dspace-addon-openpolicyfinder-services.xml"
4344
* @param configuration
4445
*/
45-
public void setConfiguration(SHERPASubmitConfigurationService configuration) {
46+
public void setConfiguration(OpenPolicyFinderSubmitConfigurationService configuration) {
4647
this.configuration = configuration;
4748
}
4849

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

5859
/**
59-
* Search SHERPA for journal policies matching the ISSNs in the item.
60+
* Search Open Policy Finder for journal policies matching the ISSNs in the item.
6061
* Rather than a 'search' query for any/all ISSNs, the v2 API requires a separate
6162
* query for each ISSN found in the item. The ISSNs are extracted using the configured
62-
* issnItemExtractor(s) in the SHERPA spring configuration.
63+
* issnItemExtractor(s) in the Open Policy Finder spring configuration.
6364
* The ISSNs are not validated with a regular expression or other rules - any values
6465
* 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"
66+
* Return the first non-empty response from Open Policy Finder
67+
* @see "spring-dspace-addon-openpolicyfinder-services.xml"
6768
* @param context DSpace context
6869
* @param item DSpace item containing ISSNs to be checked
69-
* @return SHERPA v2 API response (policy data)
70+
* @return Open Policy Finder API response (policy data)
7071
*/
71-
public SHERPAResponse searchRelatedJournals(Context context, Item item) {
72+
public OpenPolicyFinderResponse searchRelatedJournals(Context context, Item item) {
7273
Set<String> issns = getISSNs(context, item);
7374
if (issns == null || issns.size() == 0) {
7475
return null;
7576
} else {
76-
// SHERPA v2 API no longer supports "OR'd" ISSN search, perform individual searches instead
77+
// Open Policy Finder API no longer supports "OR'd" ISSN search, perform individual searches instead
7778
Iterator<String> issnIterator = issns.iterator();
7879
while (issnIterator.hasNext()) {
7980
String issn = issnIterator.next();
80-
SHERPAResponse response = sherpaService.searchByJournalISSN(issn);
81+
OpenPolicyFinderResponse response = openPolicyFinderService.searchByJournalISSN(issn);
8182
if (response.isError()) {
8283
// Continue with loop
83-
log.warn("Failed to look up SHERPA ROMeO result for ISSN: " + issn
84+
log.warn("Failed to look up Open Policy Finder result for ISSN: " + issn
8485
+ ": " + response.getMessage());
8586
return response;
8687
} else if (!response.getJournals().isEmpty()) {
8788
// return this response, if it is not empty
8889
return response;
8990
}
9091
}
91-
return new SHERPAResponse();
92+
return new OpenPolicyFinderResponse();
9293
}
9394
}
9495

9596
/**
96-
* Search SHERPA for journal policies matching the passed ISSN.
97+
* Search Open Policy Finder for journal policies matching the passed ISSN.
9798
* The ISSN are not validated with a regular expression or other rules - any String
9899
* passed to this method will be considered an ISSN for the purposes of an API query
99100
* @param issn ISSN string
100-
* @return SHERPA v2 API response object (policy data)
101+
* @return Open Policy Finder API response object (policy data)
101102
*/
102-
public SHERPAResponse searchRelatedJournalsByISSN(String issn) {
103-
return sherpaService.searchByJournalISSN(issn);
103+
public OpenPolicyFinderResponse searchRelatedJournalsByISSN(String issn) {
104+
return openPolicyFinderService.searchByJournalISSN(issn);
104105
}
105106

106107
/**
107-
* Using the configured itemIssnExtractors from SHERPA configuration, extract
108+
* Using the configured itemIssnExtractors from Open Policy Finder configuration, extract
108109
* ISSNs from item metadata or authority values
109110
* @param context DSpace context
110111
* @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)