Tal Nisan has uploaded a new change for review.

Change subject: core: Fixing I18N validation to allow empty strings
......................................................................

core: Fixing I18N validation to allow empty strings

The I18N validation in the validation framework was set to pass validation
an empty string, this behavior is incorrect since the I18N validation should
only care for extisting characters within the string and since an empty
string contains no illegal characters, validation should pass, for
validating a strings length the size validation should be used.
The regular expression was changed to pass validation on an empty string
and the places which used this validation without minimum string length
validation were changed to validate a minimum string length of 1 in order
not to have regressions.
This solves a validation problem when creating a VM disk via REST and
not specifying an alias, validation should not fail in that case and an
alias should be generated by the add disk command

Signed-off-by: Tal Nisan <[email protected]>
https://bugzilla.redhat.com/show_bug.cgi?id=1065727
Change-Id: I6d6cf47a0ccaf1d8af3d46e5dee9c264e9a29bb3
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Tags.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/24652/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
index fec9f1c..4c51844 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
@@ -30,7 +30,7 @@
     private HashMap<Guid, DiskImage> diskInfoDestinationMap;
     private VmEntityType templateType;
 
-    @Size(max = 40, message = "VALIDATION.VM_TEMPLATE.NAME.MAX", groups = { 
CreateEntity.class, UpdateEntity.class })
+    @Size(min = 1, max = 40, message = "VALIDATION.VM_TEMPLATE.NAME.MAX", 
groups = { CreateEntity.class, UpdateEntity.class })
     @ValidI18NName(message = 
"ACTION_TYPE_FAILED_NAME_MAY_NOT_CONTAIN_SPECIAL_CHARS")
     private String _name;
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Tags.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Tags.java
index c86b224..c224534 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Tags.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Tags.java
@@ -15,7 +15,7 @@
 
     private Guid id;
 
-    @Size(max = BusinessEntitiesDefinitions.TAG_NAME_SIZE)
+    @Size(min = 1, max = BusinessEntitiesDefinitions.TAG_NAME_SIZE)
     @Pattern(regexp = ValidationUtils.NO_SPECIAL_CHARACTERS_I18N, message = 
"VALIDATION.TAGS.INVALID_TAG_NAME")
     private String name;
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
index 65f95be..30ef466 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/ValidationUtils.java
@@ -16,7 +16,7 @@
 
 public class ValidationUtils {
 
-    public static final String NO_SPECIAL_CHARACTERS_I18N = 
"^[\\p{L}0-9._-]+$";
+    public static final String NO_SPECIAL_CHARACTERS_I18N = 
"^[\\p{L}0-9._-]*$";
     public static final String NO_SPECIAL_CHARACTERS = "[0-9a-zA-Z_-]+";
     public static final String ONLY_I18N_ASCII_OR_NONE = "[\\p{ASCII}\\p{L}]*";
     public static final String ONLY_ASCII_OR_NONE = "[\\p{ASCII}]*";


-- 
To view, visit http://gerrit.ovirt.org/24652
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d6cf47a0ccaf1d8af3d46e5dee9c264e9a29bb3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to