mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #11069 from DSpace/backport-10356-to-dspace-8_x
[Port dspace-8_x] Live Import - PubMed - support optional apiKey config
This commit is contained in:
@@ -55,6 +55,7 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
|
||||
private String urlFetch;
|
||||
private String urlSearch;
|
||||
private String apiKey;
|
||||
|
||||
private int attempt = 3;
|
||||
|
||||
@@ -210,6 +211,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
URIBuilder uriBuilder = new URIBuilder(urlSearch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder.addParameter("db", "pubmed");
|
||||
uriBuilder.addParameter("term", query.getParameterAsClass("query", String.class));
|
||||
Map<String, Map<String, String>> params = new HashMap<String, Map<String,String>>();
|
||||
@@ -286,6 +290,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
List<ImportRecord> records = new LinkedList<ImportRecord>();
|
||||
|
||||
URIBuilder uriBuilder = new URIBuilder(urlSearch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder.addParameter("db", "pubmed");
|
||||
uriBuilder.addParameter("retstart", start.toString());
|
||||
uriBuilder.addParameter("retmax", count.toString());
|
||||
@@ -316,6 +323,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
String webEnv = getSingleElementValue(response, "WebEnv");
|
||||
|
||||
URIBuilder uriBuilder2 = new URIBuilder(urlFetch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder2.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder2.addParameter("db", "pubmed");
|
||||
uriBuilder2.addParameter("retstart", start.toString());
|
||||
uriBuilder2.addParameter("retmax", count.toString());
|
||||
@@ -388,6 +398,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
public ImportRecord call() throws Exception {
|
||||
|
||||
URIBuilder uriBuilder = new URIBuilder(urlFetch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder.addParameter("db", "pubmed");
|
||||
uriBuilder.addParameter("retmode", "xml");
|
||||
uriBuilder.addParameter("id", query.getParameterAsClass("id", String.class));
|
||||
@@ -428,6 +441,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
public Collection<ImportRecord> call() throws Exception {
|
||||
|
||||
URIBuilder uriBuilder = new URIBuilder(urlSearch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder.addParameter("db", "pubmed");
|
||||
uriBuilder.addParameter("usehistory", "y");
|
||||
uriBuilder.addParameter("term", query.getParameterAsClass("term", String.class));
|
||||
@@ -457,6 +473,9 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
String queryKey = getSingleElementValue(response, "QueryKey");
|
||||
|
||||
URIBuilder uriBuilder2 = new URIBuilder(urlFetch);
|
||||
if (StringUtils.isNotBlank(apiKey)) {
|
||||
uriBuilder.addParameter("api_key", apiKey);
|
||||
}
|
||||
uriBuilder2.addParameter("db", "pubmed");
|
||||
uriBuilder2.addParameter("retmode", "xml");
|
||||
uriBuilder2.addParameter("WebEnv", webEnv);
|
||||
@@ -532,4 +551,8 @@ public class PubmedImportMetadataSourceServiceImpl extends AbstractImportMetadat
|
||||
this.urlSearch = urlSearch;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@
|
||||
<property name="metadataFieldMapping" ref="pubmedMetadataFieldMapping"/>
|
||||
<property name="urlFetch" value="${pubmed.url.fetch}"/>
|
||||
<property name="urlSearch" value="${pubmed.url.search}"/>
|
||||
<property name="apiKey" value="${pubmed.apiKey}"/>
|
||||
<property name="generateQueryForItem" ref="pubmedService"></property>
|
||||
<property name="interRequestTime" value="500"/>
|
||||
<property name="supportedExtensions">
|
||||
|
@@ -45,6 +45,9 @@ epo.searchUrl = https://ops.epo.org/rest-services/published-data/search
|
||||
#################################################################
|
||||
#---------------------- PubMed -----------------------------#
|
||||
#---------------------------------------------------------------#
|
||||
# If apiKey is set then it's used, if not set or blank then it's not
|
||||
# Max amount of requests per ip per second with apiKey is 10; without 3
|
||||
pubmed.apiKey =
|
||||
pubmed.url.search = https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi
|
||||
pubmed.url.fetch = https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi
|
||||
#################################################################
|
||||
|
Reference in New Issue
Block a user