|
5 | 5 | * |
6 | 6 | * http://www.dspace.org/license/ |
7 | 7 | */ |
8 | | -package org.dspace.app.sherpa.submit; |
| 8 | +package org.dspace.app.openpolicyfinder.submit; |
9 | 9 |
|
10 | 10 | import java.util.Iterator; |
11 | 11 | import java.util.LinkedHashSet; |
12 | 12 | import java.util.List; |
13 | 13 | import java.util.Set; |
14 | 14 |
|
15 | 15 | 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; |
18 | 18 | import org.dspace.content.Item; |
19 | 19 | import org.dspace.core.Context; |
20 | 20 | import org.dspace.core.LogHelper; |
21 | 21 |
|
22 | 22 | /** |
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 | + * |
25 | 26 | * @author Kim Shepherd |
26 | 27 | */ |
27 | | -public class SHERPASubmitService { |
| 28 | +public class OpenPolicyFinderSubmitService { |
28 | 29 |
|
29 | 30 | /** |
30 | 31 | * Spring beans for configuration and API service |
31 | 32 | */ |
32 | | - protected SHERPAService sherpaService; |
33 | | - protected SHERPASubmitConfigurationService configuration; |
| 33 | + protected OpenPolicyFinderService openPolicyFinderService; |
| 34 | + protected OpenPolicyFinderSubmitConfigurationService configuration; |
34 | 35 |
|
35 | 36 | /** |
36 | 37 | * log4j logger |
37 | 38 | */ |
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); |
39 | 40 |
|
40 | 41 | /** |
41 | 42 | * Setter for configuration (from Spring) |
42 | | - * @see "dspace-dspace-addon-sherpa-configuration-services.xml" |
| 43 | + * @see "spring-dspace-addon-openpolicyfinder-services.xml" |
43 | 44 | * @param configuration |
44 | 45 | */ |
45 | | - public void setConfiguration(SHERPASubmitConfigurationService configuration) { |
| 46 | + public void setConfiguration(OpenPolicyFinderSubmitConfigurationService configuration) { |
46 | 47 | this.configuration = configuration; |
47 | 48 | } |
48 | 49 |
|
49 | 50 | /** |
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 |
53 | 54 | */ |
54 | | - public void setSherpaService(SHERPAService sherpaService) { |
55 | | - this.sherpaService = sherpaService; |
| 55 | + public void setOpenPolicyFinderService(OpenPolicyFinderService openPolicyFinderService) { |
| 56 | + this.openPolicyFinderService = openPolicyFinderService; |
56 | 57 | } |
57 | 58 |
|
58 | 59 | /** |
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. |
60 | 61 | * Rather than a 'search' query for any/all ISSNs, the v2 API requires a separate |
61 | 62 | * 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. |
63 | 64 | * The ISSNs are not validated with a regular expression or other rules - any values |
64 | 65 | * 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" |
67 | 68 | * @param context DSpace context |
68 | 69 | * @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) |
70 | 71 | */ |
71 | | - public SHERPAResponse searchRelatedJournals(Context context, Item item) { |
| 72 | + public OpenPolicyFinderResponse searchRelatedJournals(Context context, Item item) { |
72 | 73 | Set<String> issns = getISSNs(context, item); |
73 | 74 | if (issns == null || issns.size() == 0) { |
74 | 75 | return null; |
75 | 76 | } 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 |
77 | 78 | Iterator<String> issnIterator = issns.iterator(); |
78 | 79 | while (issnIterator.hasNext()) { |
79 | 80 | String issn = issnIterator.next(); |
80 | | - SHERPAResponse response = sherpaService.searchByJournalISSN(issn); |
| 81 | + OpenPolicyFinderResponse response = openPolicyFinderService.searchByJournalISSN(issn); |
81 | 82 | if (response.isError()) { |
82 | 83 | // 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 |
84 | 85 | + ": " + response.getMessage()); |
85 | 86 | return response; |
86 | 87 | } else if (!response.getJournals().isEmpty()) { |
87 | 88 | // return this response, if it is not empty |
88 | 89 | return response; |
89 | 90 | } |
90 | 91 | } |
91 | | - return new SHERPAResponse(); |
| 92 | + return new OpenPolicyFinderResponse(); |
92 | 93 | } |
93 | 94 | } |
94 | 95 |
|
95 | 96 | /** |
96 | | - * Search SHERPA for journal policies matching the passed ISSN. |
| 97 | + * Search Open Policy Finder for journal policies matching the passed ISSN. |
97 | 98 | * The ISSN are not validated with a regular expression or other rules - any String |
98 | 99 | * passed to this method will be considered an ISSN for the purposes of an API query |
99 | 100 | * @param issn ISSN string |
100 | | - * @return SHERPA v2 API response object (policy data) |
| 101 | + * @return Open Policy Finder API response object (policy data) |
101 | 102 | */ |
102 | | - public SHERPAResponse searchRelatedJournalsByISSN(String issn) { |
103 | | - return sherpaService.searchByJournalISSN(issn); |
| 103 | + public OpenPolicyFinderResponse searchRelatedJournalsByISSN(String issn) { |
| 104 | + return openPolicyFinderService.searchByJournalISSN(issn); |
104 | 105 | } |
105 | 106 |
|
106 | 107 | /** |
107 | | - * Using the configured itemIssnExtractors from SHERPA configuration, extract |
| 108 | + * Using the configured itemIssnExtractors from Open Policy Finder configuration, extract |
108 | 109 | * ISSNs from item metadata or authority values |
109 | 110 | * @param context DSpace context |
110 | 111 | * @param item Item containing metadata / authority values |
|
0 commit comments