From 44055ded61095578b80c069147473c42df7c085d Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 25 Jan 2018 13:16:15 +0000 Subject: [PATCH] minor fixes git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@162588 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../grsf_publish_ws/utils/csv/CSVUtils.java | 2 +- .../utils/csv/ManageTimeSeriesThread.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/CSVUtils.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/CSVUtils.java index 75017d5..cdd309f 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/CSVUtils.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/CSVUtils.java @@ -41,7 +41,7 @@ public class CSVUtils { }else try{ - String fileName = UPLOAD_LOCATION_LOCAL + File.separator + GRSF_SUB_PATH + File.separator + "time_series_" + System.currentTimeMillis() + CSV_EXTENSION; + String fileName = UPLOAD_LOCATION_LOCAL + File.separator + GRSF_SUB_PATH + File.separator + "time_series_" + System.nanoTime() + CSV_EXTENSION; File file = new File(fileName); file.getParentFile().mkdirs(); file.createNewFile(); diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/ManageTimeSeriesThread.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/ManageTimeSeriesThread.java index c2bdba9..5d70937 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/ManageTimeSeriesThread.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/csv/ManageTimeSeriesThread.java @@ -156,11 +156,11 @@ public class ManageTimeSeriesThread extends Thread{ // -files (e.g, kbuuid.csv) String recordTypeFolderName = record.getDomain().toLowerCase(); - String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName(); + String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName(); String csvFileName = replaceIllegalChars(productName, " "); csvFileName = generateCSVFileName(csvFileName); logger.debug("CSV file name (without custom key) is going to be " + csvFileName); - + // find the first space in the name, if any char firstLetter = uuidKB.charAt(0); @@ -194,14 +194,15 @@ public class ManageTimeSeriesThread extends Thread{ CkanResourceBase ckanResource = null; ExternalFile createdFileOnWorkspace = null; String[] relevantSources = new String[1]; - File csvFile = CSVUtils.listToCSV(asList, relevantSources); + File csvFile = CSVUtils.listToCSV(asList, relevantSources); if(csvFile != null){ for (int i = 0; i < CHANCES; i++) { // upload this file on ckan if(ckanResource == null) - ckanResource = uploadFileOnCatalogue(csvFile, uuidKB, catalogue, username, resourceToAttachOnCkanName, resourceToAttachOnCkanDescription, apiKeyUser, "text/csv", "text/csv"); + ckanResource = uploadFileOnCatalogue(csvFile, uuidKB, catalogue, username, resourceToAttachOnCkanName, resourceToAttachOnCkanDescription, + apiKeyUser, "text/csv", "text/csv"); //upload this file on the folder of the vre (under .catalogue) and change the url of the resource if(ckanResource != null){ @@ -214,12 +215,14 @@ public class ManageTimeSeriesThread extends Thread{ String publicUrlToSetOnCkan = createdFileOnWorkspace.getPublicLink(true); // wait for patching.. - Thread.sleep(1000); + Thread.sleep(1500); + logger.debug("Going to patch the created resource with id " + ckanResource.getId() + " with url " + publicUrlToSetOnCkan); boolean updated = catalogue.patchResource(ckanResource.getId(), publicUrlToSetOnCkan, resourceToAttachOnCkanName, resourceToAttachOnCkanDescription, "", apiKeyUser); if(updated){ logger.info("Resource has been updated with the new url"); + csvFile.delete(); break; }else logger.error("Error while patching resource..."); @@ -228,8 +231,6 @@ public class ManageTimeSeriesThread extends Thread{ } - // delete the file - csvFile.delete(); } } } @@ -268,7 +269,7 @@ public class ManageTimeSeriesThread extends Thread{ } } - + /** * Replace chars * @param productName