minor fixes for grsf-update feature. There is one bug left: the annotation message is overridden and not appended

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@139867 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-12-09 19:09:27 +00:00
parent 1b8d716148
commit f0527298af
2 changed files with 8 additions and 8 deletions

View File

@ -122,7 +122,7 @@ public class GRSFNotificationService {
String annotation = bean.getAnnotation();
if(annotation != null)
obj.put(ANNOTATION, annotation);
obj.put(ANNOTATION, annotation.replaceAll("\"", ""));
logger.debug("Update request looks like " + obj.toJSONString());

View File

@ -48,19 +48,19 @@ public class PatchProductThread extends Thread{
// remove the "Status" field
catalogue.removeCustomField(bean.getCatalogueIdentifier(), STATUS_CUSTOM_FIELD_KEY, bean.getCurrentStatus().toString(), apiKey);
catalogue.removeTag(bean.getCatalogueIdentifier(), apiKey, bean.getCurrentStatus().toString());
catalogue.removeDatasetFromGroup(bean.getCurrentStatus().toString().toLowerCase(), bean.getCatalogueIdentifier(), apiKey);
catalogue.removeDatasetFromGroup("grsf" + "-" + bean.getCurrentStatus().toString().toLowerCase(), bean.getCatalogueIdentifier(), apiKey);
Map<String, List<String>> statusMap = new HashMap<String, List<String>>();
statusMap.put(STATUS_CUSTOM_FIELD_KEY, Arrays.asList(bean.getNewStatus().toString()));
statusMap.put(ANNOTATION_KEY, Arrays.asList("date = " + DATE_FORMAT.format(new Date())
+ ", admin = " + username
+ ", annotation = " + (bean.getAnnotation() != null ? bean.getAnnotation() : "none")
+ ", new status = " + bean.getNewStatus().toString()
+ ", old status = " + bean.getCurrentStatus().toString()
statusMap.put(ANNOTATION_KEY, Arrays.asList("date: " + DATE_FORMAT.format(new Date())
+ ", admin: " + username
+ ", annotation: " + (bean.getAnnotation() != null ? bean.getAnnotation().replaceAll("\"", "") : "none")
+ ", new status: " + bean.getNewStatus().toString()
+ ", old status: " + bean.getCurrentStatus().toString()
));
catalogue.patchProductCustomFields(bean.getCatalogueIdentifier(), apiKey, statusMap);
catalogue.addTag(bean.getCatalogueIdentifier(), apiKey, bean.getNewStatus().toString());
catalogue.assignDatasetToGroup(bean.getCurrentStatus().toString().toLowerCase(), bean.getCatalogueIdentifier(), apiKey);
catalogue.assignDatasetToGroup("grsf" + "-" + bean.getCurrentStatus().toString().toLowerCase(), bean.getCatalogueIdentifier(), apiKey);
logger.info("Record patched ...");
}