diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.java index 8809efa..75fb171 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.java @@ -28,6 +28,7 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; public class ManageProductWidget extends Composite{ @@ -81,7 +82,7 @@ public class ManageProductWidget extends Composite{ Image loadingImage; public static final String LOADING_IMAGE_URL = GWT.getModuleBaseURL() + "../images/loader.gif"; - private final static List STATUS = Arrays.asList("confirmed", "rejected", "pending"); + private final static List STATUS = Arrays.asList("Confirmed", "Rejected", "Pending"); private final static String STATUS_UPDATE_SUCCESS = "The product was correctly updated. Thanks for your collaboration!"; private final static String STATUS_UPDATE_ERROR = "Sorry, there was a problem while trying to update the status of this product"; protected static final String ERROR_ON_RETRIEVING_BEAN = "It seems there is a problem while contacting the service..."; @@ -121,12 +122,13 @@ public class ManageProductWidget extends Composite{ currentStatus.setText(bean.getCurrentStatus()); productType.setText(bean.getProductType()); List statusToShow = new ArrayList(STATUS); - statusToShow.remove(bean.getCurrentStatus().toLowerCase()); + statusToShow.remove(bean.getCurrentStatus()); listBoxStatus.addItem("Select the new status"); listBoxStatus.getElement().cast().getOptions().getItem(0).setDisabled(true); for (String availableStatus : statusToShow) { listBoxStatus.addItem(availableStatus); } + listBoxStatus.setSelectedIndex(0); } else{ showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR); @@ -158,7 +160,7 @@ public class ManageProductWidget extends Composite{ listBoxStatusGroup.setType(ControlGroupType.NONE); - if(listBoxStatus.getSelectedIndex() < 0){ + if(listBoxStatus.getSelectedIndex() <= 0){ listBoxStatusGroup.setType(ControlGroupType.ERROR); return; } @@ -169,7 +171,7 @@ public class ManageProductWidget extends Composite{ loaderIcon.setVisible(true); // set new values - bean.setAnnotation(annotationArea.getText()); + bean.setAnnotation(new HTML(annotationArea.getText()).getText()); bean.setNewStatus(listBoxStatus.getSelectedItemText()); service.notifyProductUpdate(bean, new AsyncCallback() { diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GRSFNotificationServices.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GRSFNotificationServices.java index 557a01f..b6aca2f 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GRSFNotificationServices.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GRSFNotificationServices.java @@ -37,6 +37,7 @@ public class GRSFNotificationServices { private static final String PRODUCT_TYPE = "type"; private static final String STATUS = "status"; private static final String ANNOTATION = "annotation_msg"; + private static final String ERROR = "error"; private static final int STATUS_SUCCESS = 200; /** @@ -72,7 +73,7 @@ public class GRSFNotificationServices { obj.put(CATALOGUE_ID, bean.getCatalogueIdentifier()); obj.put(KB_ID, bean.getKnowledgeBaseIdentifier()); obj.put(PRODUCT_TYPE, bean.getProductType().toLowerCase()); - obj.put(STATUS, bean.getNewStatus()); + obj.put(STATUS, bean.getNewStatus().toLowerCase()); String annotation = bean.getAnnotation(); if(annotation != null) @@ -96,7 +97,7 @@ public class GRSFNotificationServices { if(response.getStatusLine().getStatusCode() > STATUS_SUCCESS) throw new IllegalArgumentException( "Error while performing the update request: " + response.getStatusLine().getReasonPhrase() + - "and error in the result bean is " + parsedJSON.get("error")); + "and error in the result bean is " + parsedJSON.get(ERROR)); // patch the catalogue product Map> statusMap = new HashMap>(); @@ -116,7 +117,7 @@ public class GRSFNotificationServices { /** * Convert an input stream to a string * @param is - * @return + * @return the json string inside */ private static String convertStreamToString(InputStream is) { @@ -139,6 +140,5 @@ public class GRSFNotificationServices { } return sb.toString(); } - - + }