From 7b347dd923ae19fd99af2628b417f83e4769b40d Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 13 Oct 2016 13:34:47 +0000 Subject: [PATCH] better check of version value provided git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@133173 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../services/GrsfPublisherFisheryService.java | 4 +++- .../services/GrsfPublisherStockService.java | 4 +++- .../gcube/data_catalogue/grsf_publish_ws/JTests.java | 11 +++++++---- 3 files changed, 13 insertions(+), 6 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 b8e21b0..feeb2ee 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 @@ -212,6 +212,8 @@ public class GrsfPublisherFisheryService { if(HelperMethods.existsLicenseId(record.getLicense())) license = record.getLicense(); else throw new Exception("Please check the license id!"); + + long version = record.getVersion() == null ? 1 : record.getVersion(); // create the product id = catalogue.createCKanDataset( @@ -222,7 +224,7 @@ public class GrsfPublisherFisheryService { authorMail, record.getMaintainer(), record.getMaintainerContact(), - record.getVersion(), + version, record.getDescription(), license, tags, 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 21543da..8e007a2 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 @@ -203,6 +203,8 @@ public class GrsfPublisherStockService { if(HelperMethods.existsLicenseId(record.getLicense())) license = record.getLicense(); else throw new Exception("Please check the license id!"); + + long version = record.getVersion() == null ? 1 : record.getVersion(); // create the product id = catalogue.createCKanDataset( @@ -213,7 +215,7 @@ public class GrsfPublisherStockService { authorMail, record.getMaintainer(), record.getMaintainerContact(), - record.getVersion(), + version, record.getDescription(), license, tags, diff --git a/src/test/java/org/gcube/data_catalogue/grsf_publish_ws/JTests.java b/src/test/java/org/gcube/data_catalogue/grsf_publish_ws/JTests.java index 1eda4ca..b8caf06 100644 --- a/src/test/java/org/gcube/data_catalogue/grsf_publish_ws/JTests.java +++ b/src/test/java/org/gcube/data_catalogue/grsf_publish_ws/JTests.java @@ -17,11 +17,12 @@ import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group; import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag; import org.gcube.data_catalogue.grsf_publish_ws.json.input.DatabaseSource; import org.gcube.data_catalogue.grsf_publish_ws.json.input.FisheryRecord; +import org.gcube.data_catalogue.grsf_publish_ws.json.input.StockRecord; +import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean; import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods; import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level; import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status; import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type; -import org.junit.Test; import com.fasterxml.jackson.databind.ObjectMapper; @@ -113,10 +114,10 @@ public class JTests { System.out.println(res.name()); } - @Test + //@Test public void testJSONMapping() throws IOException{ - FisheryRecord record = new FisheryRecord(); + StockRecord record = new StockRecord(); // record.setType(Type.Assessment_Unit); // record.setFisheryId("sajhdskajda"); // record.setScientificName("assadsadada"); @@ -184,8 +185,10 @@ public class JTests { ObjectMapper mapper = new ObjectMapper(); //Object to JSON in String - String jsonInString = mapper.writeValueAsString(record); + String jsonInString = mapper.writeValueAsString(new ResponseCreationBean()); System.out.println(jsonInString); + + // // // JSON back to object // StockRecord converted = mapper.readValue(jsonInString, recordStock.getClass());