Ori Liel has uploaded a new change for review.

Change subject: restapi: Validate Step Enum (#1092448)
......................................................................

restapi: Validate Step Enum (#1092448)

Up until now, if user supplied invalid step-type, the server would fail.

This patch adds a validation that the step-type is valid

Change-Id: I7768fb15b0f9c5924cab0f4e2238cf49d21eb655
Signed-off-by: Ori Liel <ol...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepsResource.java
A 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/StepValidator.java
2 files changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/27232/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepsResource.java
index cd58bf1..3eba79e 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepsResource.java
@@ -40,6 +40,7 @@
     @Override
     public Response add(Step step) {
         validateParameters(step, "type", "description");
+        validateEnums(Step.class, step);
         String id;
         if (step.isSetParentStep()) {
             validateParameters(step, "parentStep.id");
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/StepValidator.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/StepValidator.java
new file mode 100644
index 0000000..f35bfe4
--- /dev/null
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/StepValidator.java
@@ -0,0 +1,17 @@
+package org.ovirt.engine.api.restapi.resource.validation;
+
+import org.ovirt.engine.api.model.Step;
+import org.ovirt.engine.api.model.StepEnum;
+
+import static org.ovirt.engine.api.common.util.EnumValidator.validateEnum;
+
+@ValidatedClass(clazz = Step.class)
+public class StepValidator implements Validator<Step> {
+
+    @Override
+    public void validateEnums(Step step) {
+        if (step.isSetType()) {
+            validateEnum(StepEnum.class, step.getType(), true);
+        }
+    }
+}


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

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

Reply via email to