Michael Pasternak has uploaded a new change for review.

Change subject: restapi: /current query parameter is inconsistent with the rest 
of url parameters
......................................................................

restapi: /current query parameter is inconsistent with the rest of url 
parameters

?current=true query parameter is depreciated and supported
for backward compatibility only - should be dropped at 4.0

https://bugzilla.redhat.com/show_bug.cgi?id=869257

Change-Id: Iced7ff2587d557f0574996515793920e9ab15650
Signed-off-by: Michael Pasternak <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata_v-3.1.yaml
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
3 files changed, 41 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/8765/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata_v-3.1.yaml
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata_v-3.1.yaml
index 9f778a4..208754f 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata_v-3.1.yaml
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata_v-3.1.yaml
@@ -241,7 +241,7 @@
         optionalArguments: {cdrom.file.id: 'xs:string'}
     urlparams:
       async: {context: matrix, type: 'xs:boolean', value: true|false, 
required: false}
-      current: {context: query, type: 'xs:boolean', value: true|false, 
required: false}
+      current: {context: matrix, type: 'xs:boolean', value: true|false, 
required: false}
     headers:
       Content-Type: {value: application/xml|json, required: true}
       Correlation-Id: {value: 'any string', required: false}
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResource.java
index c148cad..94363b8 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResource.java
@@ -27,7 +27,10 @@
 
     @Override
     public CdRom update(CdRom resource) {
-        if (QueryHelper.hasConstraint(getUriInfo().getQueryParameters(), 
CURRENT_CONSTRAINT_PARAMETER)) {
+        // TODO: CURRENT_CONSTRAINT_PARAMETER as query parameter is 
depreciated and supported
+        // for backward compatibility only - should be dropped at 4.0.
+        if (QueryHelper.hasConstraint(getUriInfo().getQueryParameters(), 
CURRENT_CONSTRAINT_PARAMETER) ||
+                QueryHelper.hasMatrixParam(getUriInfo(), 
CURRENT_CONSTRAINT_PARAMETER)) {
             validateParameters(resource, requiredUpdateFields);
             performAction(VdcActionType.ChangeDisk,
                           new 
ChangeDiskCommandParameters(getEntity(entityResolver, true).getId(),
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
index ce38a4d..b660df9 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
@@ -5,6 +5,7 @@
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
 
 import org.junit.Test;
@@ -124,8 +125,8 @@
     }
 
     @Test
-    public void testChangeCd() throws Exception {
-        resource.setUriInfo(setUpChangeCdUriExpectations());
+    public void testChangeCdUsingQueryParameter() throws Exception {
+        resource.setUriInfo(setUpChangeCdUriQueryExpectations());
         setUpGetEntityExpectations(1, VMStatus.Up);
         setUpActionExpectations(VdcActionType.ChangeDisk,
                 ChangeDiskCommandParameters.class,
@@ -137,7 +138,21 @@
         assertTrue(cdrom.isSetFile());
     }
 
-    protected UriInfo setUpChangeCdUriExpectations() {
+    @Test
+    public void testChangeCdUsingMatrixParameter() throws Exception {
+        resource.setUriInfo(setUpChangeCdUriMatrixExpectations());
+        setUpGetEntityExpectations(1, VMStatus.Up);
+        setUpActionExpectations(VdcActionType.ChangeDisk,
+                ChangeDiskCommandParameters.class,
+                new String[] { "CdImagePath" },
+                new Object[] { ISO_PATH },
+                true,
+                true);
+        CdRom cdrom = resource.update(getUpdate());
+        assertTrue(cdrom.isSetFile());
+    }
+
+    protected UriInfo setUpChangeCdUriQueryExpectations() {
         UriInfo uriInfo = setUpBasicUriExpectations();
         MultivaluedMap<String, String> queries = 
control.createMock(MultivaluedMap.class);
         expect(queries.containsKey("current")).andReturn(true).anyTimes();
@@ -145,6 +160,24 @@
         return uriInfo;
     }
 
+    protected UriInfo setUpChangeCdUriMatrixExpectations() {
+        UriInfo uriInfo = control.createMock(UriInfo.class);;
+
+        List<PathSegment> psl = new ArrayList<PathSegment>();
+
+        PathSegment ps = control.createMock(PathSegment.class);
+        MultivaluedMap<String, String> matrixParams = 
control.createMock(MultivaluedMap.class);
+        expect(matrixParams.isEmpty()).andReturn(false);
+        expect(matrixParams.containsKey("current")).andReturn(true);
+        expect(ps.getMatrixParameters()).andReturn(matrixParams);
+
+        psl.add(ps);
+
+        expect(uriInfo.getPathSegments()).andReturn(psl).anyTimes();
+
+        return uriInfo;
+    }
+
     @Test
     public void testUpdateNotFound() throws Exception {
         BackendDeviceResource<CdRom, CdRoms, VM> resource = 
getNotFoundResource();


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

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

Reply via email to