From 82f9301cd5ebd871e4a3d2430bdd3cd5527ba8d5 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 4 Jun 2024 16:15:41 -0500 Subject: [PATCH 1/4] Fix NullPointerException by correcting the XPath query to locate the total results element. --- .../service/OpenAireImportMetadataSourceServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java b/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java index 7a0a92564f72..bbc1d346982e 100644 --- a/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java @@ -252,10 +252,10 @@ public Integer call() throws Exception { Document document = saxBuilder.build(new StringReader(responseString)); Element root = document.getRootElement(); - XPathExpression xpath = XPathFactory.instance().compile("/header/total", + XPathExpression xpath = XPathFactory.instance().compile("//header/total", Filters.element(), null); - Element totalItem = (Element) xpath.evaluateFirst(root); + Element totalItem = xpath.evaluateFirst(root); return totalItem != null ? Integer.parseInt(totalItem.getText()) : null; } else { From b8d19bed86b8f3147bb991a617370f26a3e4c55a Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 4 Jun 2024 16:16:44 -0500 Subject: [PATCH 2/4] Cleanup noisy logs for external services (move some to debug). Provide more details in logs about which service is being called --- .../service/components/AbstractRemoteMetadataSource.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/importer/external/service/components/AbstractRemoteMetadataSource.java b/dspace-api/src/main/java/org/dspace/importer/external/service/components/AbstractRemoteMetadataSource.java index 83b5d4eaab25..e15ffff6e6bb 100644 --- a/dspace-api/src/main/java/org/dspace/importer/external/service/components/AbstractRemoteMetadataSource.java +++ b/dspace-api/src/main/java/org/dspace/importer/external/service/components/AbstractRemoteMetadataSource.java @@ -167,9 +167,9 @@ protected T retry(Callable callable) throws MetadataSourceException { } catch (Exception e) { throwSourceException(retry, e, operationId); } - log.info("operation " + operationId + " started"); + log.debug("Operation {} started. Calling {}", operationId, callable.getClass().getName()); T response = callable.call(); - log.info("operation " + operationId + " successful"); + log.debug("Operation {} successful", operationId); return response; } catch (Exception e) { this.error = e; @@ -180,7 +180,8 @@ protected T retry(Callable callable) throws MetadataSourceException { // No MetadataSourceException has interrupted the loop retry++; - log.warn("Error in trying operation " + operationId + " " + retry + " " + warning + ", retrying !", e); + log.warn("Error in calling {} in operation {} {} {}, retrying!", callable.getClass().getName(), + operationId, retry, warning, e); } finally { this.lastRequest = System.currentTimeMillis(); From afc2f3de889457430ce8f4451dfe3f329e3bcd7f Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 4 Jun 2024 16:19:46 -0500 Subject: [PATCH 3/4] Rename "openaire.base.url" to "openaire.search.url" to clarify purpose. Add comments to describe it. --- .../service/OpenAireImportMetadataSourceServiceImpl.java | 3 ++- dspace/config/modules/openaire-client.cfg | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java b/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java index bbc1d346982e..0e7bc5e532e8 100644 --- a/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/importer/external/openaire/service/OpenAireImportMetadataSourceServiceImpl.java @@ -187,7 +187,8 @@ public String getQueryParam() { public void init() throws Exception { Client client = ClientBuilder.newClient(); if (baseAddress == null) { - baseAddress = configurationService.getProperty("openaire.base.url"); + baseAddress = configurationService.getProperty("openaire.search.url", + "https://api.openaire.eu/search/publications"); } if (queryParam == null) { queryParam = "title"; diff --git a/dspace/config/modules/openaire-client.cfg b/dspace/config/modules/openaire-client.cfg index 26d36fa816f5..09659299f26d 100644 --- a/dspace/config/modules/openaire-client.cfg +++ b/dspace/config/modules/openaire-client.cfg @@ -34,4 +34,6 @@ openaire.token.clientSecret = CLIENT_SECRET_HERE # URL of Openaire Rest API openaire.api.url = https://api.openaire.eu -openaire.base.url = http://api.openaire.eu/search/publications \ No newline at end of file +# OpenAIRE Search API to use for metadata import via external sources +# (e.g. importing metadata from OpenAIRE via submission) +openaire.search.url = https://api.openaire.eu/search/publications \ No newline at end of file From 9e63a4457c83b9629a2a287a27ff8476d206f7ba Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 11 Jun 2024 15:31:30 -0500 Subject: [PATCH 4/4] Fix configuration for OpenAIRE input sources. They only return Publications/Items, not any other Entities. --- dspace/config/spring/api/external-services.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dspace/config/spring/api/external-services.xml b/dspace/config/spring/api/external-services.xml index 129602d7e5ef..e3a842efa094 100644 --- a/dspace/config/spring/api/external-services.xml +++ b/dspace/config/spring/api/external-services.xml @@ -74,12 +74,24 @@ + + + Publication + none + + + + + Publication + none + +