From d7c4922e804276c9ac2687cd0c190e6faa722312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20von=20B=C3=B6selager?= Date: Wed, 28 Oct 2020 16:45:44 +0100 Subject: [PATCH] Fixing package upload from new UI (#274) --- grails-app/services/ygor/EnrichmentService.groovy | 4 +++- .../de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy | 3 ++- .../de/hbznrw/ygor/processing/UploadThreadGokb.groovy | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/grails-app/services/ygor/EnrichmentService.groovy b/grails-app/services/ygor/EnrichmentService.groovy index 6f4d65bd..c92712c3 100644 --- a/grails-app/services/ygor/EnrichmentService.groovy +++ b/grails-app/services/ygor/EnrichmentService.groovy @@ -301,7 +301,7 @@ class EnrichmentService{ } // Main processing finished here. // Upload is following - send package with integrated title data - String uri = Holders.config.gokbApi.xrPackageUri + String uri = Holders.config.gokbApi.xrPackageUri.concat("?async=true") SendPackageThreadGokb sendPackageThreadGokb if (!StringUtils.isEmpty(enrichment.dataContainer.pkgHeader.token)){ // send with token-based authentication @@ -315,6 +315,8 @@ class EnrichmentService{ uploadJob.start() while (uploadJob.status in [UploadThreadGokb.Status.PREPARATION, UploadThreadGokb.Status.STARTED]){ Thread.sleep(1000) + uploadJob.updateCount() + uploadJob.refreshStatus() } return uploadJob } diff --git a/src/groovy/de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy b/src/groovy/de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy index 9f95e349..f34c1ffe 100644 --- a/src/groovy/de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy +++ b/src/groovy/de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy @@ -69,6 +69,7 @@ class SendPackageThreadGokb extends UploadThreadGokb{ else{ result << GokbExporter.sendText(uri, json.getText(), user, password, locale) } + gokbJobId = result[0].get("info")?.get("job_id")?.toString() } @@ -125,7 +126,7 @@ class SendPackageThreadGokb extends UploadThreadGokb{ private String getJobId(){ if (gokbJobId == null && result != null && result.size() > 0 && result[0].get("info") != null){ - gokbJobId = result[0].get("info")?.get("job_id") + gokbJobId = result[0].get("info")?.get("job_id").toString() } return gokbJobId } diff --git a/src/groovy/de/hbznrw/ygor/processing/UploadThreadGokb.groovy b/src/groovy/de/hbznrw/ygor/processing/UploadThreadGokb.groovy index bae29483..33f5a194 100644 --- a/src/groovy/de/hbznrw/ygor/processing/UploadThreadGokb.groovy +++ b/src/groovy/de/hbznrw/ygor/processing/UploadThreadGokb.groovy @@ -21,9 +21,6 @@ abstract class UploadThreadGokb extends Thread{ void refreshStatus(){ if (status == Status.STARTED){ - if (count >= total){ - status = Status.FINISHED_UNDEFINED - } String responseStatus = getGokbResponseValue("responseStatus", true) if (responseStatus == null && status == Status.STARTED){ if (result.size() > 0 && result[0].get("error") != null){ @@ -40,6 +37,9 @@ abstract class UploadThreadGokb extends Thread{ status = Status.ERROR return } + if (count >= total){ + status = Status.SUCCESS + } } }