Tomas Jelinek has uploaded a new change for review.

Change subject: frontend: MaxVmNameLength(Non)Windows ignored
......................................................................

frontend: MaxVmNameLength(Non)Windows ignored

It has already been fixed but not completly correctly. There is
still a chance that the static variables will be inited sooner than
the cache from which the values are taken.

Fixed by moving the corresponding logic to AsyncDataProvider which
is anyway a better place for it and postpone the calling of it until
it is really needed so the cache will be inited for sure (otherwise
it would be not possible to reach to the code which uses it).

Change-Id: I9a1ac29aadc731f6fe4a0e62db7e78a5160ededa
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/PoolNameLengthValidation.java
4 files changed, 16 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/18989/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index c450bc8..37e30d8 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -3266,4 +3266,14 @@
                 new IdQueryParameters(providerId),
                 aQuery);
     }
+
+    public static Integer getMaxVmNameLenghtWin() {
+        Integer maxVmNameLengthWindows = (Integer) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxVmNameLengthWindows);
+        return maxVmNameLengthWindows == null ? 15 : maxVmNameLengthWindows;
+    }
+
+    public static Integer getMaxVmNameLenghtNonWin() {
+        Integer maxVmNameLengthNonWindows = (Integer) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxVmNameLengthNonWindows);
+        return maxVmNameLengthNonWindows == null ? 64 : 
maxVmNameLengthNonWindows;
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java
index d20c3ba..1f58f04 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java
@@ -357,8 +357,8 @@
 
     protected int getMaxClonedNameLength(Object object) {
         VM vm = ((ImportVmData) object).getVm();
-        return AsyncDataProvider.isWindowsOsType(vm.getOs()) ? 
UnitVmModel.WINDOWS_VM_NAME_MAX_LIMIT
-                : UnitVmModel.NON_WINDOWS_VM_NAME_MAX_LIMIT;
+        return AsyncDataProvider.isWindowsOsType(vm.getOs()) ? 
AsyncDataProvider.getMaxVmNameLenghtWin()
+                : AsyncDataProvider.getMaxVmNameLenghtNonWin();
     }
 
     protected boolean validateName(String newVmName, EntityModel entity, 
IValidation[] validators) {
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 16d18b6..2fd1ca4 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
@@ -59,18 +59,8 @@
 
 public class UnitVmModel extends Model {
 
-    public static final Integer WINDOWS_VM_NAME_MAX_LIMIT;
-    public static final Integer NON_WINDOWS_VM_NAME_MAX_LIMIT;
     public static final int VM_TEMPLATE_NAME_MAX_LIMIT = 40;
     public static final int DESCRIPTION_MAX_LIMIT = 255;
-
-    static {
-        Integer maxVmNameLengthWindows = (Integer) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxVmNameLengthWindows);
-        WINDOWS_VM_NAME_MAX_LIMIT = maxVmNameLengthWindows == null ? 15 : 
maxVmNameLengthWindows;
-
-        Integer maxVmNameLengthNonWindows = (Integer) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxVmNameLengthNonWindows);
-        NON_WINDOWS_VM_NAME_MAX_LIMIT = maxVmNameLengthNonWindows == null ? 64 
: maxVmNameLengthNonWindows;
-    }
 
     private boolean privateIsNew;
 
@@ -2082,8 +2072,8 @@
                             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),
+                                            : 
AsyncDataProvider.isWindowsOsType(osType) ? 
AsyncDataProvider.getMaxVmNameLenghtWin()
+                                                    : 
AsyncDataProvider.getMaxVmNameLenghtNonWin()),
                             isPoolTabValid ? new PoolNameValidation() : new 
I18NNameValidation()
                     });
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/PoolNameLengthValidation.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/PoolNameLengthValidation.java
index 7757cbc..d8d0975 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/PoolNameLengthValidation.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/PoolNameLengthValidation.java
@@ -49,8 +49,8 @@
 
     protected int getMaxNameLength() {
         return isWindows() ?
-                UnitVmModel.WINDOWS_VM_NAME_MAX_LIMIT :
-                UnitVmModel.NON_WINDOWS_VM_NAME_MAX_LIMIT;
+                AsyncDataProvider.getMaxVmNameLenghtWin() :
+                AsyncDataProvider.getMaxVmNameLenghtNonWin();
     }
 
     /**


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

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

Reply via email to