From 679e6097d86d31c5af4464753be2c5f1fadc78e1 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 7 Jun 2017 09:51:12 +0000 Subject: [PATCH] minor fix on refers_to empty field when grsf records are going to be published git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@149333 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../services/GrsfPublisherFisheryService.java | 5 ++++- .../services/GrsfPublisherStockService.java | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java index 4b6ef58..6ecdf4e 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java @@ -196,6 +196,8 @@ public class GrsfPublisherFisheryService { // manage the refers to if(sourceInPath.equals(Sources.GRSF)){ List refersTo = record.getRefersTo(); + if(refersTo == null || refersTo.isEmpty()) + throw new Exception("refers_to is empty"); for (RefersToBean refersToBean : refersTo) { resources.add(new ResourceBean(refersToBean.getUrl(), "Source of item " + futureTitle + " in the catalogue has id: " + refersToBean.getId(), "Information of a source of the item " + futureTitle, null, username, null, null)); @@ -270,7 +272,8 @@ public class GrsfPublisherFisheryService { // add the "Product URL" to the field Map> addField = new HashMap>(); - addField.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl)); + String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD; + addField.put(modifiedUUIDKey, Arrays.asList(itemUrl)); catalogue.patchProductCustomFields(id, apiKey, addField); if(!groups.isEmpty()){ diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java index 725a875..dac4337 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java @@ -187,6 +187,10 @@ public class GrsfPublisherStockService { if(sourceInPath.equals(Sources.GRSF)){ List refersTo = record.getRefersTo(); + + if(refersTo == null || refersTo.isEmpty()) + throw new Exception("refers_to is empty"); + for (RefersToBean refersToBean : refersTo) { resources.add(new ResourceBean(refersToBean.getUrl(), "Source of item " + futureTitle + " in the catalogue has id: " + refersToBean.getId(), "Information of a source of the item " + futureTitle, null, username, null, null)); @@ -263,7 +267,8 @@ public class GrsfPublisherStockService { // add the "Product URL" to the field Map> addField = new HashMap>(); - addField.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl)); + String modifiedUUIDKey = namespaces.containsKey(CommonServiceUtils.ITEM_URL_FIELD) ? namespaces.get(CommonServiceUtils.ITEM_URL_FIELD) : CommonServiceUtils.ITEM_URL_FIELD; + addField.put(modifiedUUIDKey, Arrays.asList(itemUrl)); catalogue.patchProductCustomFields(id, apiKey, addField); if(!groups.isEmpty()){