diff --git a/dhp-workflows/dhp-dedup-openaire/src/main/java/eu/dnetlib/dhp/oa/dedup/UpdateOpenorgsJob.java b/dhp-workflows/dhp-dedup-openaire/src/main/java/eu/dnetlib/dhp/oa/dedup/UpdateOpenorgsJob.java
new file mode 100644
index 000000000..f23c54e2e
--- /dev/null
+++ b/dhp-workflows/dhp-dedup-openaire/src/main/java/eu/dnetlib/dhp/oa/dedup/UpdateOpenorgsJob.java
@@ -0,0 +1,115 @@
+package eu.dnetlib.dhp.oa.dedup;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import eu.dnetlib.dhp.application.ArgumentApplicationParser;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+
+public class UpdateOpenorgsJob {
+
+ private static final Logger log = LoggerFactory.getLogger(UpdateOpenorgsJob.class);
+
+ public static void main(String[] args) throws Exception {
+ ArgumentApplicationParser parser = new ArgumentApplicationParser(
+ IOUtils.toString(SparkCreateSimRels.class.getResourceAsStream("/eu/dnetlib/dhp/oa/dedup/updateOpenorgsJob_parameters.json")));
+ parser.parseArgument(args);
+
+ final String apiUrl = parser.get("apiUrl");
+ final int delay = Integer.parseInt(parser.get("delay"));
+
+ log.info("apiUrl: '{}'", apiUrl);
+ log.info("delay: '{}'", delay);
+
+ APIResponse res = httpCall(apiUrl);
+ while(res!=null && res.getStatus().equals(ImportStatus.RUNNING)){
+ TimeUnit.MINUTES.sleep(delay);
+ res = httpCall(apiUrl + "/status");
+ }
+
+ if (res==null) {
+ log.error("Openorgs Update FAILED: No response");
+ throw new RuntimeException("Openorgs Update FAILED: No response");
+ }
+
+ if (res.getStatus()==null || !res.getStatus().equals(ImportStatus.SUCCESS)) {
+ log.error("Openorgs Update FAILED: '{}' - '{}'", res.getStatus(), res.getMessage());
+ throw new RuntimeException(res.getMessage());
+ }
+
+ }
+
+ private static APIResponse httpCall(final String url) throws Exception {
+ final HttpGet req = new HttpGet(url);
+
+ try (final CloseableHttpClient client = HttpClients.createDefault()) {
+ try (final CloseableHttpResponse response = client.execute(req)) {
+ final String s = IOUtils.toString(response.getEntity().getContent());
+ return (new ObjectMapper()).readValue(s, APIResponse.class);
+ }
+ }
+ }
+
+}
+
+class APIResponse {
+ private String id;
+ private Long dateStart;
+ private Long dateEnd;
+ private ImportStatus status;
+ private String message;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Long getDateStart() {
+ return dateStart;
+ }
+
+ public void setDateStart(Long dateStart) {
+ this.dateStart = dateStart;
+ }
+
+ public Long getDateEnd() {
+ return dateEnd;
+ }
+
+ public void setDateEnd(Long dateEnd) {
+ this.dateEnd = dateEnd;
+ }
+
+ public ImportStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ImportStatus status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
+
+enum ImportStatus {
+ SUCCESS,
+ FAILED,
+ RUNNING,
+ NOT_LAUNCHED,
+ NOT_YET_STARTED
+}
diff --git a/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/openorgs/oozie_app/workflow.xml b/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/openorgs/oozie_app/workflow.xml
index 30442406c..c7c6c9257 100644
--- a/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/openorgs/oozie_app/workflow.xml
+++ b/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/openorgs/oozie_app/workflow.xml
@@ -28,6 +28,11 @@
dbPwd
password to access the OpenOrgs database
+
+ dbConnections
+ 10
+ number of connections to the postgres db
+
workingPath
path for the working directory
@@ -223,7 +228,7 @@
--dbTable${dbTable}
--dbUser${dbUser}
--dbPwd${dbPwd}
- --numConnections20
+ --numConnections${dbConnections}
@@ -254,19 +259,18 @@
--dbTable${dbTable}
--dbUser${dbUser}
--dbPwd${dbPwd}
- --numConnections20
+ --numConnections${dbConnections}
-
- ${jobTracker}
- ${nameNode}
- /usr/bin/curl
- ${apiUrl}
-
+
+ eu.dnetlib.dhp.oa.dedup.UpdateOpenorgsJob
+ --apiUrl${apiUrl}
+ --delay5
+
diff --git a/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/updateOpenorgsJob_parameters.json b/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/updateOpenorgsJob_parameters.json
new file mode 100644
index 000000000..5ca4a3dba
--- /dev/null
+++ b/dhp-workflows/dhp-dedup-openaire/src/main/resources/eu/dnetlib/dhp/oa/dedup/updateOpenorgsJob_parameters.json
@@ -0,0 +1,14 @@
+[
+ {
+ "paramName": "api",
+ "paramLongName": "apiUrl",
+ "paramDescription": "the url of the API",
+ "paramRequired": true
+ },
+ {
+ "paramName": "d",
+ "paramLongName": "delay",
+ "paramDescription": "delay for the HTTP call in minutes",
+ "paramRequired": true
+ }
+]
\ No newline at end of file