diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/CreateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/CreateDatasetForm.java index f50e30d..ee850eb 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/CreateDatasetForm.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/CreateDatasetForm.java @@ -343,7 +343,7 @@ public class CreateDatasetForm extends Composite{ @Override public void onChange(ChangeEvent event) { - + event.preventDefault(); organizationsListboxChangeHandlerBody(); } @@ -437,26 +437,29 @@ public class CreateDatasetForm extends Composite{ */ private void organizationsListboxChangeHandlerBody() { - // disable the list of organizations name so that the user doesn't change it again - organizationsListbox.setEnabled(false); - metadataProfilesFormatListbox.setEnabled(false); - - // remove any other product profiles but "none" + // remove any other product profiles int presentItems = metadataProfilesFormatListbox.getItemCount(); - for (int i = 0; i < presentItems; i++) { - if(!metadataProfilesFormatListbox.getValue(i).equals("none")) - metadataProfilesFormatListbox.removeItem(i); + for (int i = presentItems - 1; i >= 0; i--) { + metadataProfilesFormatListbox.removeItem(i); } + // add "none" item again + metadataProfilesFormatListbox.addItem("none"); + // select "none" metadataProfilesFormatListbox.setSelectedIndex(0); // get the name of the organization from the title - String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText()); + String selectedOrganizationTitle = organizationsListbox.getSelectedItemText(); + String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle); // try to retrieve the profiles setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true); + // disable the list of organizations name so that the user doesn't change it again + organizationsListbox.setEnabled(false); + metadataProfilesFormatListbox.setEnabled(false); + // perform remote request of profiles for the selected organization ckanServices.getProfiles(orgName, new AsyncCallback>() { @@ -467,6 +470,8 @@ public class CreateDatasetForm extends Composite{ receivedBean.setMetadataList(result); prepareMetadataList(receivedBean); + organizationsListbox.setEnabled(true); + metadataProfilesFormatListbox.setEnabled(true); // everything went ok setAlertBlock("", AlertType.ERROR, false); diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java index fa1acb7..542dee2 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java @@ -545,10 +545,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C @Override public List getProfiles(String orgName) { + + logger.debug("Requested profiles for products into orgName " + orgName); List toReturn = new ArrayList(); try{ - toReturn = Utils.getMetadataProfilesList(Utils.retrieveScopeFromOrganizationName(orgName), getThreadLocalRequest().getSession(), getASLSession(), CKAN_PROFILES_KEY); + String evaluatedScope = Utils.retrieveScopeFromOrganizationName(orgName); + logger.debug("Evaluated scope is " + evaluatedScope); + toReturn = Utils.getMetadataProfilesList(evaluatedScope, getThreadLocalRequest().getSession(), getASLSession(), CKAN_PROFILES_KEY); }catch(Exception e){ logger.error("Failed to retrieve profiles for scope coming from organization name " + orgName, e); }