Revision 34103
Added by Alessia Bardi almost 10 years ago
modules/cnr-data-information-oai-publisher-common/branches/4.x/src/main/java/eu/dnetlib/data/information/oai/publisher/core/AbstractOAICore.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import eu.dnetlib.data.information.oai.publisher.CannotDisseminateFormatException; |
13 | 13 |
import eu.dnetlib.data.information.oai.publisher.OaiPublisherException; |
14 |
import eu.dnetlib.data.information.oai.publisher.OaiPublisherRuntimeException; |
|
15 | 14 |
import eu.dnetlib.data.information.oai.publisher.conf.ISLookUpClient; |
16 | 15 |
import eu.dnetlib.data.information.oai.publisher.conf.OAIConfigurationExistReader; |
17 | 16 |
import eu.dnetlib.data.information.oai.publisher.info.ListDocumentsInfo; |
... | ... | |
66 | 65 |
* could happen |
67 | 66 |
*/ |
68 | 67 |
public RecordInfo getInfoRecord(final String identifier, final String prefix) throws OaiPublisherException { |
69 |
setCurrentDBFromIS(false); |
|
70 | 68 |
MDFInfo mdf = obtainMDFInfo(prefix); |
71 | 69 |
return getRecordById(mdf, identifier); |
72 | 70 |
} |
... | ... | |
90 | 88 |
*/ |
91 | 89 |
public ListRecordsInfo listRecords(final boolean onlyIdentifiers, final String metadataPrefix, final String set, final String from, final String until) |
92 | 90 |
throws OaiPublisherException { |
93 |
setCurrentDBFromIS(false); |
|
94 | 91 |
final ListRecordsInfo res = new ListRecordsInfo(); |
95 | 92 |
|
96 | 93 |
if (from != null) { |
... | ... | |
139 | 136 |
* could happen |
140 | 137 |
*/ |
141 | 138 |
public ListRecordsInfo listRecords(final boolean onlyIdentifiers, final String resumptionToken) throws OaiPublisherException { |
142 |
setCurrentDBFromIS(false); |
|
143 | 139 |
ListDocumentsInfo docs = getDocuments(onlyIdentifiers, resumptionToken); |
144 | 140 |
|
145 | 141 |
final ListRecordsInfo res = new ListRecordsInfo(); |
... | ... | |
165 | 161 |
} |
166 | 162 |
|
167 | 163 |
public List<? extends SetInfo> listSets() throws OaiPublisherException { |
168 |
setCurrentDBFromIS(false); |
|
169 | 164 |
return this.setCollection.getAllSets(true, getCurrentDBName()); |
170 | 165 |
} |
171 | 166 |
|
172 | 167 |
public List<MDFInfo> listMetadataFormats() throws OaiPublisherException { |
173 |
setCurrentDBFromIS(false); |
|
174 | 168 |
return this.oaiConfigurationExistReader.getMetadataFormatInfo(true); |
175 | 169 |
} |
176 | 170 |
|
177 | 171 |
public boolean existSet(final String setSpec) { |
178 |
try { |
|
179 |
setCurrentDBFromIS(false); |
|
180 |
} catch (OaiPublisherException e) { |
|
181 |
throw new OaiPublisherRuntimeException(e); |
|
182 |
} |
|
183 | 172 |
return this.setCollection.containEnabledSet(setSpec, getCurrentDBName()); |
184 | 173 |
} |
185 | 174 |
|
... | ... | |
203 | 192 |
* true to update the currentDB when the current value is not blank |
204 | 193 |
* @throws OaiPublisherException |
205 | 194 |
*/ |
206 |
protected void setCurrentDBFromIS(final boolean force) throws OaiPublisherException {
|
|
195 |
public void setCurrentDBFromIS(final boolean force) throws OaiPublisherException {
|
|
207 | 196 |
try { |
208 | 197 |
if (force || StringUtils.isBlank(currentDBName)) { |
209 | 198 |
currentDBName = getLookupClient().getCurrentDB(); |
modules/cnr-data-information-oai-publisher-common/branches/4.x/src/main/java/eu/dnetlib/data/information/oai/publisher/OAIController.java | ||
---|---|---|
202 | 202 |
} else return oaiError("badArgument", verb, map); |
203 | 203 |
if (params.entrySet().size() > 0) return oaiError("badArgument", verb, map); |
204 | 204 |
|
205 |
this.core.setCurrentDBFromIS(true); |
|
205 | 206 |
map.addAttribute("record", core.getInfoRecord(identifier, prefix)); |
206 | 207 |
|
207 | 208 |
return "oai/OAI_GetRecord"; |
... | ... | |
223 | 224 |
if (params.containsKey("resumptionToken")) { |
224 | 225 |
resumptionToken = params.get("resumptionToken"); |
225 | 226 |
params.remove("resumptionToken"); |
227 |
this.core.setCurrentDBFromIS(false); |
|
226 | 228 |
} else { |
229 |
this.core.setCurrentDBFromIS(true); |
|
227 | 230 |
if (params.containsKey("metadataPrefix")) { |
228 | 231 |
metadataPrefix = params.get("metadataPrefix"); |
229 | 232 |
params.remove("metadataPrefix"); |
... | ... | |
271 | 274 |
params.remove("verb"); |
272 | 275 |
} |
273 | 276 |
if (params.entrySet().size() > 0) return oaiError("badArgument", verb, map); |
277 |
this.core.setCurrentDBFromIS(true); |
|
274 | 278 |
map.addAttribute("sets", core.listSets()); |
275 | 279 |
return "oai/OAI_ListSets"; |
276 | 280 |
} |
... | ... | |
287 | 291 |
params.remove("identifier"); |
288 | 292 |
} |
289 | 293 |
if (params.entrySet().size() > 0) return oaiError("badArgument", verb, map); |
290 |
|
|
294 |
this.core.setCurrentDBFromIS(true); |
|
291 | 295 |
map.addAttribute("formats", core.listMetadataFormats()); |
292 | 296 |
if (id != null) { |
293 | 297 |
map.addAttribute("identifier", id); |
modules/cnr-data-information-oai-publisher-common/branches/4.x/pom.xml | ||
---|---|---|
10 | 10 |
<groupId>eu.dnetlib</groupId> |
11 | 11 |
<artifactId>cnr-data-information-oai-publisher-common</artifactId> |
12 | 12 |
<packaging>jar</packaging> |
13 |
<version>4.0.1</version>
|
|
13 |
<version>4.0.2</version>
|
|
14 | 14 |
<scm> |
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-data-information-oai-publisher-common/tags/cnr-data-information-oai-publisher-common-4.0.1</developerConnection>
|
|
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-data-information-oai-publisher-common/branches/4.x</developerConnection>
|
|
16 | 16 |
</scm> |
17 | 17 |
<dependencies> |
18 | 18 |
<dependency> |
Also available in: Unified diff
Merged changed from trunk: go and check for the OAI db to use without restarting, but only when the resumption token is not involved.