minor fixes for tags generation (some urecognized chars are removed) and an exception is reported when creation fails

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@135030 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-11-29 11:44:36 +00:00
parent 388206d5a7
commit 4c740c7a95
3 changed files with 17 additions and 10 deletions

View File

@ -237,7 +237,7 @@ public class GrsfPublisherFisheryService {
responseBean.setError(null);
responseBean.setProductUrl(catalogue.getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + futureName, "UTF-8"));
responseBean.setKbUuid(record.getUuid());
if(!groups.isEmpty()){
logger.info("Launching thread for association to the list of groups " + groups);
AssociationToGroupThread threadGroups = new AssociationToGroupThread(groups, id, organization, username, catalogue);
@ -251,7 +251,9 @@ public class GrsfPublisherFisheryService {
logger.info("Launching thread for time series handling");
new ManageTimeSeriesThread(record, futureName, username, catalogue, context, token).start();
}
}else
throw new Exception("There was an error during the product generation, sorry");
}
}
}
@ -302,7 +304,7 @@ public class GrsfPublisherFisheryService {
throw new Exception("There was a problem while serving your request. This product was not found");
}
// get extras and check there is the product type
if(fisheryInCkan.getExtrasAsHashMap().get(Common.PRODUCT_TYPE_KEY).equals(THIS_TYPE)){
logger.warn("Ok, this is a fishery, removing it");

View File

@ -239,7 +239,8 @@ public class GrsfPublisherStockService {
// manage time series
logger.info("Launching thread for time series handling");
new ManageTimeSeriesThread(record, futureName, username, catalogue, context, token).start();
}
}else
throw new Exception("There was an error during the product generation, sorry");
}
}
}

View File

@ -54,6 +54,7 @@ public abstract class HelperMethods {
private static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
private static final String CSV_MIME = "text/csv";
private static final String PATH_SEPARATOR = "/";
private static final String REGEX_TAGS = "[^\\s\\w-_.]";
/**
@ -118,21 +119,24 @@ public abstract class HelperMethods {
elementsToConsider = Math.min(elementsToConsider, TIME_SERIES_TAKE_LAST_VALUES);
for (int i = (asList.size() - elementsToConsider); i < asList.size(); i++) {
logger.debug(asList.get(i).toString().trim());
tags.add(asList.get(i).toString().trim());
String finalTag = asList.get(i).toString().trim().replaceAll(REGEX_TAGS, "");
logger.debug(finalTag);
tags.add(finalTag);
}
}else{
// else add all the available elements
for (int i = 0; i < elementsToConsider; i++) {
logger.debug(asList.get(i).toString().trim());
tags.add(asList.get(i).toString().trim());
String finalTag = asList.get(i).toString().trim().replaceAll(REGEX_TAGS, "");
logger.debug(finalTag);
tags.add(finalTag);
}
}
}
}else{
logger.debug("The object annotated with @Tag is a simple one. Adding ... ");
logger.debug(f.toString().trim());
tags.add(f.toString().trim());
String finalTag = f.toString().trim().replaceAll(REGEX_TAGS, "");
logger.debug(finalTag);
tags.add(finalTag);
}
}