Arik Hadas has uploaded a new change for review.

Change subject: webadmin & engine: Add validation for snapshot description 
length
......................................................................

webadmin & engine: Add validation for snapshot description length

Add validation which checks that the length of the snapshot
description does not exceed 4000 (GENERAL_MAX_SIZE) characters
at the webadmin dialog for creating snapshot

Add validation which checks that the length of the
snapshot description does not exceed GENERAL_MAX_SIZE
for CreateAllSnapshhotsFromVmCommand in the engine

Change-Id: I780eec76b6eb576d28b3650f4d34384594a8044d
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=871029
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/CreateAllSnapshotsFromVmParameters.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SnapshotModel.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
5 files changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/9011/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/CreateAllSnapshotsFromVmParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/CreateAllSnapshotsFromVmParameters.java
index 4d527ff..a09fb58 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/CreateAllSnapshotsFromVmParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/CreateAllSnapshotsFromVmParameters.java
@@ -1,6 +1,9 @@
 package org.ovirt.engine.core.common.action;
 
+import javax.validation.constraints.Size;
+
 import org.hibernate.validator.constraints.NotEmpty;
+import 
org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions;
 import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType;
 import org.ovirt.engine.core.common.validation.annotation.ValidDescription;
 import org.ovirt.engine.core.common.validation.group.CreateEntity;
@@ -12,6 +15,8 @@
     @NotEmpty(groups = { CreateEntity.class },
             message = "VALIDATION.DISK_IMAGE.DESCRIPTION.NOT_EMPTY")
     @ValidDescription(message = "VALIDATION.DISK_IMAGE.DESCRIPTION.NOT_ASCII", 
groups = { CreateEntity.class})
+    @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE, groups = { 
CreateEntity.class},
+            message = "VALIDATION_DISK_IMAGE_DESCRIPTION_MAX")
     private String _description;
 
     private boolean needsLocking = true;
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 6f8de4b..891fdc6 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1534,6 +1534,9 @@
     @DefaultStringValue("Snapshot description cannot be empty")
     String VALIDATION_DISK_IMAGE_DESCRIPTION_NOT_EMPTY();
 
+    @DefaultStringValue("Snapshot description must not exceed 4000 characters")
+    String VALIDATION_DISK_IMAGE_DESCRIPTION_MAX();
+
     @DefaultStringValue("MAC Address must be in the following format: 
XX:XX:XX:XX:XX:XX, (XX=0-9 or A-F)")
     String VALIDATION_VMINTERFACE_MACADDRESS();
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SnapshotModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SnapshotModel.java
index 21755f8..fd12573 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SnapshotModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SnapshotModel.java
@@ -15,6 +15,7 @@
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
 import org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.IValidation;
+import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation;
 
 @SuppressWarnings("unused")
@@ -145,7 +146,7 @@
 
     public boolean Validate()
     {
-        getDescription().ValidateEntity(new IValidation[] { new 
NotEmptyValidation(), new AsciiOrNoneValidation()});
+        getDescription().ValidateEntity(new IValidation[] { new 
NotEmptyValidation(), new AsciiOrNoneValidation(), new LengthValidation(4000)});
 
         return getDescription().getIsValid();
     }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index a653c12..bd198c8 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -578,6 +578,7 @@
 VALIDATION_VOLUME_FORMAT_NOT_NULL=Volume format is required
 VALIDATION_DISK_IMAGE_DESCRIPTION_NOT_ASCII=Snapshot description cannot 
contain non-ASCII chars
 VALIDATION_DISK_IMAGE_DESCRIPTION_NOT_EMPTY=Snapshot description cannot be 
empty
+VALIDATION_DISK_IMAGE_DESCRIPTION_MAX=Snapshot description must not exceed 
4000 characters
 VALIDATION_DATA_CENTER_DESCRIPTION_INVALID="Data Center description must be 
formed of ASCII charis only"
 VALIDATION_DATA_CENTER_NAME_INVALID=Data Center name must be formed of 
"a-z0-9A-Z" or "-_"
 VALIDATION_VMINTERFACE_MACADDRESS=MAC Address must be in the following format: 
XX:XX:XX:XX:XX:XX, (XX=0-9 or A-F)
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 8604db7..e68d7ed 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -571,6 +571,7 @@
 VALIDATION_VOLUME_FORMAT_NOT_NULL=Volume format is required
 VALIDATION_DISK_IMAGE_DESCRIPTION_NOT_ASCII=Snapshot description cannot 
contain non-ASCII chars
 VALIDATION_DISK_IMAGE_DESCRIPTION_NOT_EMPTY=Snapshot description cannot be 
empty
+VALIDATION_DISK_IMAGE_DESCRIPTION_MAX=Snapshot description must not exceed 
4000 characters
 VALIDATION_VMINTERFACE_MACADDRESS=MAC Address must be in the following format: 
XX:XX:XX:XX:XX:XX, (XX=0-9 or A-F)
 VALIDATION_EVENTS_EMAIL_FORMAT=email format is not valid
 VALIDATION_INVALID_CORRELATION_ID=The correlation ID must be formed of 
"a-z0-9A-Z" or "-_"


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

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

Reply via email to