From 5c37e2b25efaf4272d334df96d5503226e89b1d9 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 7 Nov 2013 17:27:56 +0000 Subject: [PATCH] Inserted regular expression to validate new folder names git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@85201 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../portlets/user/workspace/client/ConstantsExplorer.java | 2 +- .../workspace/client/view/sharing/DialogShareFolder.java | 2 ++ .../client/view/windows/DialogAddFolderAndSmart.java | 6 ++++-- .../user/workspace/client/view/windows/DialogText.java | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index 36e6569..5cde389 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -73,7 +73,7 @@ public class ConstantsExplorer { public static final String NUMREQUESTS = "numrequests"; public static final String MESSAGE_WEBDAV_URL = "View Url WebDAV "; public static final String URL_WEBDAV = "WebDAV URL"; - public static final String MESSAGE_NAME_FORCE_APHANUMERIC = "Field name must be alphanumeric and not contain special chars!"; + public static final String REGEX_FOLDER_NAME = "Field name must not begin with one of the following characters"; public static final String MESSAGE_SEARCH_FORCE_APHANUMERIC = "Field search must be alphanumeric and not contain special chars!"; public static final String MESSAGE_CREATE_NEW_MESSAGE = "Create New Message"; public static final String FORWARDTO = "Forward to"; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java index 1caaaa1..15d31bd 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java @@ -218,6 +218,8 @@ public class DialogShareFolder extends Dialog { txtName.setAllowBlank(false); txtName.setAutoValidate(true); txtName.setFieldLabel("Folder Name"); + txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$"); + txtName.setRegex("^[^.<>\\|?/*%$]*$"); textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION); textAreaDescription.setHeight(heightTextArea); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogAddFolderAndSmart.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogAddFolderAndSmart.java index 424f55b..e46cc34 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogAddFolderAndSmart.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogAddFolderAndSmart.java @@ -59,10 +59,12 @@ public class DialogAddFolderAndSmart extends Dialog { txtName.setAllowBlank(false); // txtName.setRegex("^[a-zA-Z0-9]+[ ]*[a-zA-Z0-9_-]+$"); // txtName.setRegex("^[a-zA-Z0-9_]+[-]*[a-zA-Z0-9_\\s]*$"); - + +// txtName.setRegex("^[a-zA-Z0-9]+[^.<>\\|?/*%$]*$"); txtName.setAutoValidate(true); - txtName.getMessages().setRegexText(ConstantsExplorer.MESSAGE_NAME_FORCE_APHANUMERIC); + txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$"); + txtName.setRegex("^[^.<>\\|?/*%$]*$"); // txt.setMinLength(2); txtName.setFieldLabel(ConstantsExplorer.DIALOG_NAME); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogText.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogText.java index 96e3ea6..b7a2f70 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogText.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogText.java @@ -42,8 +42,9 @@ public class DialogText extends Dialog { txt.setFieldLabel(msgTitle); txt.setValue(msgTxt); // txt.setRegex("^[a-zA-Z0-9]+[ a-zA-Z0-9_()-]*"); - txt.setRegex("^[a-zA-Z0-9]+[^<>\\|?/*%$]*$"); - txt.getMessages().setRegexText(ConstantsExplorer.MESSAGE_NAME_FORCE_APHANUMERIC); +// txt.setRegex("^[a-zA-Z0-9]+[^.<>\\|?/*%$]*$"); + txt.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$"); + txt.setRegex("^[^.<>\\|?/*%$]*$"); txt.setAutoValidate(true); txt.setAllowBlank(false);