minor fixes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@162588 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a0a567e378
commit
44055ded61
|
@ -41,7 +41,7 @@ public class CSVUtils {
|
||||||
}else
|
}else
|
||||||
|
|
||||||
try{
|
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 file = new File(fileName);
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
|
|
|
@ -156,11 +156,11 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
// -files (e.g, kbuuid.csv)
|
// -files (e.g, kbuuid.csv)
|
||||||
|
|
||||||
String recordTypeFolderName = record.getDomain().toLowerCase();
|
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, " ");
|
String csvFileName = replaceIllegalChars(productName, " ");
|
||||||
csvFileName = generateCSVFileName(csvFileName);
|
csvFileName = generateCSVFileName(csvFileName);
|
||||||
logger.debug("CSV file name (without custom key) is going to be " + csvFileName);
|
logger.debug("CSV file name (without custom key) is going to be " + csvFileName);
|
||||||
|
|
||||||
// find the first space in the name, if any
|
// find the first space in the name, if any
|
||||||
char firstLetter = uuidKB.charAt(0);
|
char firstLetter = uuidKB.charAt(0);
|
||||||
|
|
||||||
|
@ -194,14 +194,15 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
CkanResourceBase ckanResource = null;
|
CkanResourceBase ckanResource = null;
|
||||||
ExternalFile createdFileOnWorkspace = null;
|
ExternalFile createdFileOnWorkspace = null;
|
||||||
String[] relevantSources = new String[1];
|
String[] relevantSources = new String[1];
|
||||||
File csvFile = CSVUtils.listToCSV(asList, relevantSources);
|
File csvFile = CSVUtils.listToCSV(asList, relevantSources);
|
||||||
if(csvFile != null){
|
if(csvFile != null){
|
||||||
|
|
||||||
for (int i = 0; i < CHANCES; i++) {
|
for (int i = 0; i < CHANCES; i++) {
|
||||||
|
|
||||||
// upload this file on ckan
|
// upload this file on ckan
|
||||||
if(ckanResource == null)
|
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
|
//upload this file on the folder of the vre (under .catalogue) and change the url of the resource
|
||||||
if(ckanResource != null){
|
if(ckanResource != null){
|
||||||
|
@ -214,12 +215,14 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
String publicUrlToSetOnCkan = createdFileOnWorkspace.getPublicLink(true);
|
String publicUrlToSetOnCkan = createdFileOnWorkspace.getPublicLink(true);
|
||||||
|
|
||||||
// wait for patching..
|
// wait for patching..
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1500);
|
||||||
|
|
||||||
logger.debug("Going to patch the created resource with id " + ckanResource.getId() + " with url " + publicUrlToSetOnCkan);
|
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);
|
boolean updated = catalogue.patchResource(ckanResource.getId(), publicUrlToSetOnCkan, resourceToAttachOnCkanName, resourceToAttachOnCkanDescription, "", apiKeyUser);
|
||||||
|
|
||||||
if(updated){
|
if(updated){
|
||||||
logger.info("Resource has been updated with the new url");
|
logger.info("Resource has been updated with the new url");
|
||||||
|
csvFile.delete();
|
||||||
break;
|
break;
|
||||||
}else
|
}else
|
||||||
logger.error("Error while patching resource...");
|
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
|
* Replace chars
|
||||||
* @param productName
|
* @param productName
|
||||||
|
|
Loading…
Reference in New Issue