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 3de1309..97f3e0f 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 @@ -79,7 +79,7 @@ public class ManageProductWidget extends Composite{ @UiField TextBox productType; - + @UiField Image loadingImage; @@ -104,7 +104,7 @@ public class ManageProductWidget extends Composite{ // start loader service loadingImage.setUrl(LOADING_IMAGE_URL); loadingImage.setVisible(true); - + // async request to fetch the product retrieveProductBean(productIdentifier); manageProductModal.show(); @@ -135,8 +135,10 @@ public class ManageProductWidget extends Composite{ } else{ showInfo(ERROR_ON_RETRIEVING_BEAN, AlertType.ERROR); + formUpdate.setVisible(false); + confirmButton.setEnabled(false); } - + loadingImage.setVisible(false); } @@ -146,7 +148,11 @@ public class ManageProductWidget extends Composite{ if(caught instanceof NoGRSFRecordException) showInfo(NO_GRSF_RECORD_BEAN, AlertType.WARNING); else - showInfo(caught.getMessage(), AlertType.ERROR); + showInfo(caught.getMessage(), AlertType.ERROR); + + // hide the form and disable the send button + formUpdate.setVisible(false); + confirmButton.setEnabled(false); loadingImage.setVisible(false); } }); @@ -163,7 +169,7 @@ public class ManageProductWidget extends Composite{ if(bean == null) return; - + listBoxStatusGroup.setType(ControlGroupType.NONE); if(listBoxStatus.getSelectedIndex() <= 0){ diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.ui.xml b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.ui.xml index 1f915d7..5ffd5d2 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.ui.xml +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/ui/ManageProductWidget.ui.xml @@ -24,11 +24,11 @@ - Product Name: + Product Name: @@ -36,10 +36,10 @@ - Product Current Status: + Product Current Status: @@ -48,10 +48,10 @@ - Product New Status: + Product New Status: @@ -59,20 +59,20 @@ - Product Type: + Product Type: + width="97%" title="The product type" enabled="false" ui:field="productType"> - Annotation: + Annotation: diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java index 65de3a0..8fa8421 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java @@ -52,7 +52,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem private static final String HTTP = "http"; public static String CKANCONNECTORCONTEXT = "CkanConnectorContext"; public static String CKANCONNECTORLOGOUT = "CkanConnectorLogout"; - public static String GRSFUPDATERSERVICE = "GRSFUpdaterEndPoint"; + public static final String GRSF_UPDATER_SERVICE = "GRSFUpdaterEndPoint"; private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class); /** @@ -534,7 +534,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem DataCatalogue catalogue = getCatalogue(context); // check if the base url of the service is in session - String keyPerContext = UtilMethods.concatenateSessionKeyScope(GRSFUPDATERSERVICE, context); + String keyPerContext = UtilMethods.concatenateSessionKeyScope(GRSF_UPDATER_SERVICE, context); String baseUrl = (String)getThreadLocalRequest().getSession().getAttribute(keyPerContext); if(baseUrl == null || baseUrl.isEmpty()){ baseUrl = GRSFNotificationService.discoverEndPoint(context); @@ -546,7 +546,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem return true; }catch(Exception e){ - logger.error("Unable to update the product..", e); + logger.error("Unable to update the product.." + e.getMessage()); } return false; } @@ -556,42 +556,37 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem ManageProductBean toReturn = null; - try{ - // retrieve scope per current portlet url - String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest()); - DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl); - String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername(); - CkanDataset product = catalogue.getDataset(productIdentifier, catalogue.getApiKeyFromUsername(username)); + // retrieve scope per current portlet url + String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest()); + DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl); + String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername(); + CkanDataset product = catalogue.getDataset(productIdentifier, catalogue.getApiKeyFromUsername(username)); - // get extras - Map extras = product.getExtrasAsHashMap(); - String status = extras.get("Status"); - String uuidKB = extras.get("UUID Knowledge Base"); - String productType = extras.get("Product type"); - String recordType = extras.get("Record type"); - String title = product.getTitle(); + // get extras + Map extras = product.getExtrasAsHashMap(); + String status = extras.get("Status"); + String uuidKB = extras.get("UUID Knowledge Base"); + String productType = extras.get("Product type"); + String recordType = extras.get("Record type"); + String title = product.getTitle(); - // it cannot be enabled in this case ... - if(recordType == null || recordType.equals("Source")) - throw new NoGRSFRecordException(); + // it cannot be enabled in this case ... + if(recordType == null || recordType.equals("Source")) + throw new NoGRSFRecordException("This is not a GRSF record"); - if(status == null || uuidKB == null || productType == null) - throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB + - ", and product type is = " + productType); + if(status == null || uuidKB == null || productType == null) + throw new Exception("Some information is missing in this record: Status = " + status + ", knowledge_base_uuid = " + uuidKB + + ", and product type is = " + productType); - toReturn = new ManageProductBean(); - toReturn.setCatalogueIdentifier(productIdentifier); - toReturn.setCurrentStatus(GRSFStatus.fromString(status)); - toReturn.setKnowledgeBaseIdentifier(uuidKB); - toReturn.setProductName(title); - toReturn.setProductType(productType); + toReturn = new ManageProductBean(); + toReturn.setCatalogueIdentifier(productIdentifier); + toReturn.setCurrentStatus(GRSFStatus.fromString(status)); + toReturn.setKnowledgeBaseIdentifier(uuidKB); + toReturn.setProductName(title); + toReturn.setProductType(productType); - logger.info("Returning product bean " + toReturn); + logger.info("Returning product bean " + toReturn); - }catch(Exception e){ - logger.error("Failed to retrieve the information for the product with identifier " + productIdentifier, e); - throw new Exception("Failed to retrieve the information for the product with identifier " + productIdentifier + ". " + e.getMessage()); - } return toReturn; }