Ori Liel has uploaded a new change for review. Change subject: restapi: Move Vnic-Profile remove to entity ......................................................................
restapi: Move Vnic-Profile remove to entity This patch moves the method that implements the DELETE operation from the collection interface to the entity interface. This is needed to avoid issues with newer versions of Resteasy. Change-Id: Ic603af4dbe08cec8e4487f44e2a8aa513d51cb59 Signed-off-by: Ori Liel <ol...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfileResource.java M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfilesResource.java M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfileResource.java M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfilesResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResource.java A backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResourceTest.java 8 files changed, 31 insertions(+), 90 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/42068/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfileResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfileResource.java index cbc2724..2a42c90 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfileResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfileResource.java @@ -16,9 +16,11 @@ package org.ovirt.engine.api.resource; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; import org.ovirt.engine.api.model.VnicProfile; @@ -30,4 +32,7 @@ @Path("permissions") public AssignedPermissionsResource getPermissionsResource(); + + @DELETE + public Response remove(); } diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfilesResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfilesResource.java index a5f5420..7812d5a 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfilesResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/AssignedVnicProfilesResource.java @@ -17,7 +17,6 @@ package org.ovirt.engine.api.resource; import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -38,10 +37,6 @@ @POST @Consumes({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML }) public Response add(VnicProfile vnicProfile); - - @DELETE - @Path("{id}") - public Response remove(@PathParam("id") String id); @Path("{id}") public AssignedVnicProfileResource getAssignedVnicProfileSubResource(@PathParam("id") String id); diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfileResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfileResource.java index db1984d..47d04fd 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfileResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfileResource.java @@ -16,8 +16,10 @@ package org.ovirt.engine.api.resource; +import javax.ws.rs.DELETE; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; import org.ovirt.engine.api.model.VnicProfile; @@ -26,4 +28,7 @@ @Path("permissions") public AssignedPermissionsResource getPermissionsResource(); + + @DELETE + public Response remove(); } diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfilesResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfilesResource.java index 3d921ef..c45f562 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfilesResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VnicProfilesResource.java @@ -1,7 +1,6 @@ package org.ovirt.engine.api.resource; import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -22,10 +21,6 @@ @POST @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) public Response add(VnicProfile vnicProfile); - - @DELETE - @Path("{id}") - public Response remove(@PathParam("id") String id); @Path("{id}") public VnicProfileResource getVnicProfileSubResource(@PathParam("id") String id); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResource.java index 834051f..81a8406 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResource.java @@ -1,10 +1,14 @@ package org.ovirt.engine.api.restapi.resource; +import javax.ws.rs.core.Response; + import org.ovirt.engine.api.model.BaseResource; import org.ovirt.engine.api.model.DataCenter; import org.ovirt.engine.api.model.VnicProfile; import org.ovirt.engine.api.resource.AssignedPermissionsResource; import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VnicProfileParameters; import org.ovirt.engine.core.common.businessentities.qos.QosBase; import org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters; import org.ovirt.engine.core.common.queries.IdQueryParameters; @@ -51,4 +55,16 @@ } return super.addLinks(model, suggestedParent, subCollectionMembersToExclude); } + + public Response remove() { + get(); + return performAction(VdcActionType.RemoveVnicProfile, new VnicProfileParameters(getVnicProfile(id))); + } + + protected org.ovirt.engine.core.common.businessentities.network.VnicProfile getVnicProfile(String id) { + return getEntity(org.ovirt.engine.core.common.businessentities.network.VnicProfile.class, + VdcQueryType.GetVnicProfileById, + new IdQueryParameters(asGuidOr404(id)), + "VnicProfiles"); + } } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResource.java index f2042a5..aae7855 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResource.java @@ -77,18 +77,6 @@ protected abstract void validateParameters(VnicProfile vnicProfile); @Override - protected Response performRemove(String id) { - return performAction(VdcActionType.RemoveVnicProfile, new VnicProfileParameters(getVnicProfile(id))); - } - - protected org.ovirt.engine.core.common.businessentities.network.VnicProfile getVnicProfile(String id) { - return getEntity(org.ovirt.engine.core.common.businessentities.network.VnicProfile.class, - VdcQueryType.GetVnicProfileById, - new IdQueryParameters(asGuidOr404(id)), - "VnicProfiles"); - } - - @Override protected VnicProfile doPopulate(VnicProfile model, org.ovirt.engine.core.common.businessentities.network.VnicProfile entity) { return model; diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResourceTest.java new file mode 100644 index 0000000..79b2725 --- /dev/null +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfileResourceTest.java @@ -0,0 +1,5 @@ +package org.ovirt.engine.api.restapi.resource; + +public class AbstractBackendVnicProfileResourceTest { + +} diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResourceTest.java index e313e78..d5dfb27 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/AbstractBackendVnicProfilesResourceTest.java @@ -40,74 +40,6 @@ } @Test - public void testRemoveNotFound() throws Exception { - setUpEntityQueryExpectations(1, 0, true); - control.replay(); - try { - collection.remove(GUIDS[0].toString()); - fail("expected WebApplicationException"); - } catch (WebApplicationException wae) { - verifyNotFoundException(wae); - } - } - - @Test - public void testRemove() throws Exception { - setUpEntityQueryExpectations(2, 0, false); - setUriInfo(setUpActionExpectations(VdcActionType.RemoveVnicProfile, - VnicProfileParameters.class, - new String[] {}, - new Object[] {}, - true, - true)); - verifyRemove(collection.remove(GUIDS[0].toString())); - } - - @Test - public void testRemoveNonExistant() throws Exception { - setUpEntityQueryExpectations(VdcQueryType.GetVnicProfileById, - IdQueryParameters.class, - new String[] { "Id" }, - new Object[] { NON_EXISTANT_GUID }, - null); - control.replay(); - try { - collection.remove(NON_EXISTANT_GUID.toString()); - fail("expected WebApplicationException"); - } catch (WebApplicationException wae) { - assertNotNull(wae.getResponse()); - assertEquals(404, wae.getResponse().getStatus()); - } - } - - @Test - public void testRemoveCantDo() throws Exception { - doTestBadRemove(false, true, CANT_DO); - } - - @Test - public void testRemoveFailed() throws Exception { - doTestBadRemove(true, false, FAILURE); - } - - protected void doTestBadRemove(boolean canDo, boolean success, String detail) throws Exception { - setUpEntityQueryExpectations(2, 0, false); - - setUriInfo(setUpActionExpectations(VdcActionType.RemoveVnicProfile, - VnicProfileParameters.class, - new String[] {}, - new Object[] {}, - canDo, - success)); - try { - collection.remove(GUIDS[0].toString()); - fail("expected WebApplicationException"); - } catch (WebApplicationException wae) { - verifyFault(wae, detail); - } - } - - @Test public void testAddVnicProfile() throws Exception { setUriInfo(setUpBasicUriExpectations()); setUpNetworkQueryExpectations(); -- To view, visit https://gerrit.ovirt.org/42068 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic603af4dbe08cec8e4487f44e2a8aa513d51cb59 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