Libor Spevak has uploaded a new change for review.

Change subject: webadmin: Template name restricted to 40 characters for all OS
......................................................................

webadmin: Template name restricted to 40 characters for all OS

Fixed validation of create/edit template name validation.
VM name is restricted to 15 characters for Windows host, 64 characters for 
other hosts.
VM template name is max. 40 characters long.

Change-Id: Id7bb03dea4c6030a485f0d60d775dd308c4c7155
Bug-Url: https://bugzilla.redhat.com/848398
Signed-off-by: Libor Spevak <lspe...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
1 file changed, 6 insertions(+), 14 deletions(-)


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

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index 5fdbf53..41792b0 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -55,6 +55,8 @@
 
     public static final int WINDOWS_VM_NAME_MAX_LIMIT = 15;
     public static final int NON_WINDOWS_VM_NAME_MAX_LIMIT = 64;
+    public static final int VM_TEMPLATE_NAME_MAX_LIMIT = 40;
+    public static final int DESCRIPTION_MAX_LIMIT = 255;
 
     private boolean privateIsNew;
 
@@ -1926,17 +1928,6 @@
         }
     }
 
-    private LengthValidation createNameLengthValidation(VmOsType osType) {
-        // for template dialog, name max length is 40 chars
-        if (this.getBehavior() instanceof TemplateVmModelBehavior) {
-            return new LengthValidation(40);
-        }
-
-        // for VM it depends on the OS type
-        return new LengthValidation(AsyncDataProvider.IsWindowsOsType(osType) 
? WINDOWS_VM_NAME_MAX_LIMIT
-                : NON_WINDOWS_VM_NAME_MAX_LIMIT);
-    }
-
     public boolean Validate()
     {
         getDataCenter().ValidateSelectedItem(new IValidation[] { new 
NotEmptyValidation() });
@@ -1961,14 +1952,15 @@
             getName().ValidateEntity(
                     new IValidation[] {
                             new NotEmptyValidation(),
-                            new LengthValidation(this.getBehavior() instanceof 
TemplateVmModelBehavior ? 40 :
-                                AsyncDataProvider.IsWindowsOsType(osType) ? 
WINDOWS_VM_NAME_MAX_LIMIT : NON_WINDOWS_VM_NAME_MAX_LIMIT),
+                            new LengthValidation(
+                                (getBehavior() instanceof 
TemplateVmModelBehavior || getBehavior() instanceof NewTemplateVmModelBehavior)
+                                    ? VM_TEMPLATE_NAME_MAX_LIMIT : 
AsyncDataProvider.IsWindowsOsType(osType) ? WINDOWS_VM_NAME_MAX_LIMIT : 
NON_WINDOWS_VM_NAME_MAX_LIMIT),
                             new I18NNameValidation()
                     });
 
             getDescription().ValidateEntity(
                     new IValidation[] {
-                            new LengthValidation(255),
+                            new LengthValidation(DESCRIPTION_MAX_LIMIT),
                             new SpecialAsciiI18NOrNoneValidation()
                     });
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7bb03dea4c6030a485f0d60d775dd308c4c7155
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Libor Spevak <lspe...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to