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 ec17a83..8b85659 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 @@ -72,7 +72,7 @@ import com.google.gwt.user.client.ui.Widget; * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) */ public class CreateDatasetForm extends Composite{ - + /** * Create a remote service proxy to talk to the server-side ckan service. */ @@ -152,7 +152,7 @@ public class CreateDatasetForm extends Composite{ @UiField Icon infoIconResources; @UiField FocusPanel focusPanelResources; @UiField Popover popoverResources; - + protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later"; // tab panel @@ -1139,21 +1139,28 @@ public class CreateDatasetForm extends Composite{ } /** - * Add the tag as an element + * Add the tag as an element (inserted by the user) */ private void addTagElement(TextBox itemBox){ + GWT.log("value is " + itemBox.getValue()); + if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) { - if(tagsList.contains(itemBox.getValue())) + if(tagsList.contains(itemBox.getValue())){ + itemBox.setValue(""); return; + } // ckan accepts only alphanumeric values - if(!itemBox.getValue().matches("^[a-zA-Z0-9]*$")) - return; - - if(itemBox.getValue().length() <= 1) - return; + String[] subTags = itemBox.getValue().split(" "); + for (int i = 0; i < subTags.length; i++) { + String subTag = subTags[i]; + if(!subTag.matches("^[a-zA-Z0-9]*$")) + return; + if(subTag.length() <= 1) + return; + } final String value = itemBox.getValue(); final ListItem displayItem = new ListItem(); @@ -1179,13 +1186,23 @@ public class CreateDatasetForm extends Composite{ } /** - * Add the tag as an element + * Add the tag as an element (when publishing from workspace) */ private void addTagElement(final String tag){ if(tagsList.contains(tag)) return; + // ckan accepts only alphanumeric values + String[] subTags = tag.split(" "); + for (int i = 0; i < subTags.length; i++) { + String subTag = subTags[i]; + if(!subTag.matches("^[a-zA-Z0-9]*$")) + return; + if(subTag.length() <= 1) + return; + } + final ListItem displayItem = new ListItem(); displayItem.setStyleName("tag-style"); Span p = new Span(tag); diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java index 11f35d1..d082abd 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java @@ -9,7 +9,9 @@ public class InfoIconsLabels { // TAGS public static final String TAGS_INFO_ID_POPUP = "tags-popup-panel-info"; public static final String TAGS_INFO_CAPTION = "Tags"; - public static final String TAGS_INFO_TEXT = "Tags are meaningful information that can be associated to the product and by means of them it can be retrieved. A tag cannot contain white spaces and can contain only alphanumeric characters. It must be at least of two characters."; + public static final String TAGS_INFO_TEXT = "Tags are meaningful information that can be associated to the " + + "product and by means of them it can be retrieved. A tag can contain only alphanumeric characters. " + + "Any string of the tag must be at least of two characters. Examples of good tags: \"This is my sample tag\", \"tagY\". Examples of bad tags: \"This is a tag\", \"c\"."; // VISIBILITY public static final String VISIBILITY_INFO_ID_POPUP = "visibility-popup-panel-info"; 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 f06de10..e9c9d8d 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 @@ -560,7 +560,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C } - String datasetId = utils.createCKanDataset(getUserCKanTokenFromSession(), null, title, organizationNameOrId, author, + String datasetId = utils.createCKanDataset(getUserCKanTokenFromSession(), title, organizationNameOrId, author, authorMail, maintainer, maintainerMail, version, description, licenseId, listOfTags, customFields, resources, setPublic);