From: remillet Date: Fri, 14 Aug 2015 01:29:38 +0000 (-0700) Subject: CSPACE-6770: Late commit after all tests passing. More changes for RESTEasy client... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=3764d96a646fc57094061afac4008cee32181063;p=tmp%2Fjakarta-migration.git CSPACE-6770: Late commit after all tests passing. More changes for RESTEasy client framework upgrade from 2.x to 3.0 --- diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java index c7b598880..8fe6645c7 100644 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java @@ -42,7 +42,6 @@ import org.collectionspace.services.collectionobject.TitleGroupList; import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.relation.RelationsCommon; -import org.jboss.resteasy.client.ClientResponse; /** * The Class CollectionSpaceIntegrationTest. @@ -138,26 +137,6 @@ public abstract class CollectionSpaceIntegrationTest { return Long.toString(identifier); } - /** - * Extract id. - * - * @param res the res - * - * @return the string - */ - String extractId(ClientResponse res) { - String result = null; - - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - verbose("extractId:uri=" + uri); - String[] segments = uri.split("/"); - result = segments[segments.length - 1]; - verbose("id=" + result); - - return result; - } - String extractId(Response res) { String result = null; diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java index 6e8c33e3b..22eea86d8 100644 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java @@ -38,8 +38,6 @@ import org.testng.annotations.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jboss.resteasy.client.ClientResponse; - import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.DimensionClient; import org.collectionspace.services.client.DimensionFactory; @@ -190,6 +188,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { Response workflowResponse = dimensionClient.updateWorkflowWithTransition( dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK); System.out.println("Locked dimension record with CSID=" + dimensionCsid1); + workflowResponse.close(); // Finally, try to delete the relationship @@ -204,6 +203,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { // Also, try to soft-delete. This should also fail. workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE); System.out.println("Locked dimension record with CSID=" + dimensionCsid1); + workflowResponse.close(); } @Test void createCollectionObjectRelationshipToManyDimensions() { @@ -461,7 +461,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { // Now try to retrieve the Intake record of the CollectionObject. // String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString(); - ClientResponse resultResponse = relationClient.readList( + Response resultResponse = relationClient.readList( collectionObjectCsid, null, //CollectionobjectsCommon.class.getSimpleName(), predicate, @@ -470,7 +470,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { RelationsCommonList relationList = null; try { Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode()); - relationList = resultResponse.getEntity(); + relationList = resultResponse.readEntity(RelationsCommonList.class); } finally { resultResponse.close(); } @@ -492,7 +492,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { multiPartResponse = relationClient.read(foundCsid); int responseStatus = multiPartResponse.getStatus(); Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode()); - PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class)); resultRelation = (RelationsCommon) extractPart(input, relationClient.getCommonPartName(), RelationsCommon.class); @@ -591,7 +591,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString(); RelationsCommonList relationList = null; for (String collectionObjectCsid : collectionObjectIDList) { - ClientResponse resultResponse = relationClient.readList( + Response resultResponse = relationClient.readList( intakeCsid, null, //IntakesCommon.class.getSimpleName(), //subject predicate, @@ -600,7 +600,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { try { Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode()); - relationList = resultResponse.getEntity(); + relationList = resultResponse.readEntity(RelationsCommonList.class); } finally { resultResponse.close(); } @@ -621,7 +621,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { multiPartResponse = relationClient.read(foundCsid); int responseStatus = multiPartResponse.getStatus(); Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode()); - PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class)); resultRelation = (RelationsCommon) extractPart(input, relationClient.getCommonPartName(), RelationsCommon.class); diff --git a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java index 282013877..77c13bdc3 100644 --- a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java +++ b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java @@ -41,7 +41,6 @@ import org.collectionspace.services.collectionobject.TitleGroupList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationshipType; -import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -139,26 +138,6 @@ public abstract class CollectionSpacePerformanceTest { return Long.toString(identifier); } - /** - * Extract id. - * - * @param res the res - * - * @return the string - */ - String extractId(ClientResponse res) { - String result = null; - - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - verbose("extractId:uri=" + uri); - String[] segments = uri.split("/"); - result = segments[segments.length - 1]; - verbose("id=" + result); - - return result; - } - String extractId(Response res) { String result = null; diff --git a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java index 415d9a0b4..387ce3f4b 100644 --- a/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java +++ b/services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java @@ -28,13 +28,13 @@ import java.util.Random; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.jboss.resteasy.util.HttpResponseCodes; import org.testng.Assert; import org.testng.annotations.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.util.HttpResponseCodes; + import org.collectionspace.services.client.AbstractCommonListUtils; import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.PayloadOutputPart; @@ -86,7 +86,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest { CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); long totalTime = 0; - ClientResponse response; + Response response; for (int i = 0; i < numOfCalls; i++) { Date startTime = new Date(); response = collectionObjectClient.roundtrip(0); diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java index 9bbe68de8..9f74353e0 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java @@ -27,7 +27,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.account.AccountsCommon; import org.collectionspace.services.account.AccountsCommonList; @@ -74,11 +73,11 @@ public class AccountClient extends AbstractServiceClientImpl readList() { + public Response readList() { return getProxy().readList(); } - public ClientResponse readSearchList(String screenName, String uid, String email) { + public Response readSearchList(String screenName, String uid, String email) { return getProxy().readSearchList(screenName, uid, email); } @@ -87,7 +86,7 @@ public class AccountClient extends AbstractServiceClientImpl read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } @@ -97,7 +96,7 @@ public class AccountClient extends AbstractServiceClientImpl create(AccountsCommon multipart) { + public Response create(AccountsCommon multipart) { return getProxy().create(multipart); } @@ -108,7 +107,7 @@ public class AccountClient extends AbstractServiceClientImpl update(String csid, AccountsCommon multipart) { + public Response update(String csid, AccountsCommon multipart) { return getProxy().update(csid, multipart); } } diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java index dd13fe7c0..95bf2edfe 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java @@ -38,7 +38,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.account.AccountsCommon; import org.collectionspace.services.account.AccountsCommonList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -50,23 +49,23 @@ public interface AccountProxy extends CollectionSpaceProxy { @GET @Produces({"application/xml"}) - ClientResponse readList(); + Response readList(); @GET @Produces({"application/xml"}) - ClientResponse readSearchList(@QueryParam("sn") String screenName, @QueryParam("uid") String uid, @QueryParam("email") String email); + Response readSearchList(@QueryParam("sn") String screenName, @QueryParam("uid") String uid, @QueryParam("email") String email); //(C)reate @POST - ClientResponse create(AccountsCommon multipart); + Response create(AccountsCommon multipart); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, AccountsCommon multipart); + Response update(@PathParam("csid") String csid, AccountsCommon multipart); } diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleClient.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleClient.java index 2b771d5b7..7bbba3d1e 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleClient.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleClient.java @@ -27,7 +27,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.authorization.AccountRole; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -68,7 +67,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl read(String csid, String arcsid) { + public Response read(String csid, String arcsid) { return getProxy().read(csid, arcsid); } @@ -79,7 +78,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } @@ -89,7 +88,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl create(String csid, AccountRole accRole) { + public Response create(String csid, AccountRole accRole) { return getProxy().create(csid, accRole); } @@ -99,7 +98,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl update(String csid, AccountRole payload) { + public Response update(String csid, AccountRole payload) { throw new RuntimeException("You cannot update an AccountRole object. You must delete and recreate it instead."); } @@ -109,7 +108,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl delete(String csid, AccountRole accRole) { + public Response delete(String csid, AccountRole accRole) { return getProxy().delete(csid, "delete", accRole); } @@ -117,13 +116,13 @@ public class AccountRoleClient extends AbstractServiceClientImpl create(AccountRole payload) { + public Response create(AccountRole payload) { // Use the create(String csid, AccountRole accRole) method instead throw new UnsupportedOperationException(); } @Override - public ClientResponse readList() { + public Response readList() { throw new UnsupportedOperationException(); } } diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleProxy.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleProxy.java index 861612364..8267c38bd 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleProxy.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleProxy.java @@ -39,7 +39,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.authorization.AccountRole; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -52,34 +51,34 @@ public interface AccountRoleProxy extends CollectionSpaceProxy create(@PathParam("csid") String csid, AccountRole accRole); + Response create(@PathParam("csid") String csid, AccountRole accRole); //(R)ead @GET @Path("/{csid}/accountroles") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(R)ead @GET @Path("/{csid}/accountroles/{arcsid}") - ClientResponse read(@PathParam("csid") String csid, + Response read(@PathParam("csid") String csid, @PathParam("arcsid") String arcsid); //(D)elete @POST @Path("/{csid}/accountroles") - ClientResponse delete(@PathParam("csid") String csid, + Response delete(@PathParam("csid") String csid, @QueryParam("_method") String method, AccountRole accRole); //(U)pdate @PUT @Path("/{csid}/accountroles") - ClientResponse update(@PathParam("csid") String csid, AccountRole role); + Response update(@PathParam("csid") String csid, AccountRole role); //(D)elete @Override @DELETE @Path("/{csid}/accountroles") - ClientResponse delete(@PathParam("csid") String csid); + Response delete(@PathParam("csid") String csid); } diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/TenantClient.java b/services/account/client/src/main/java/org/collectionspace/services/client/TenantClient.java index a27e6c099..254a90196 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/TenantClient.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/TenantClient.java @@ -27,7 +27,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.account.Tenant; import org.collectionspace.services.account.TenantsList; @@ -69,11 +68,11 @@ public class TenantClient extends AbstractServiceClientImpl readList() { + public Response readList() { return getProxy().readList(); } - public ClientResponse readSearchList(String name, String disabled) { + public Response readSearchList(String name, String disabled) { return getProxy().readSearchList(name, disabled); } @@ -82,7 +81,7 @@ public class TenantClient extends AbstractServiceClientImpl read(String id) { + public Response read(String id) { return getProxy().read(id); } @@ -92,7 +91,7 @@ public class TenantClient extends AbstractServiceClientImpl create(Tenant multipart) { + public Response create(Tenant multipart) { return getProxy().create(multipart); } @@ -103,7 +102,7 @@ public class TenantClient extends AbstractServiceClientImpl update(String id, Tenant multipart) { + public Response update(String id, Tenant multipart) { return getProxy().update(id, multipart); } } diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/TenantProxy.java b/services/account/client/src/main/java/org/collectionspace/services/client/TenantProxy.java index 43bfbfb66..1e2530eb0 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/TenantProxy.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/TenantProxy.java @@ -38,7 +38,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.account.Tenant; import org.collectionspace.services.account.TenantsList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -50,25 +49,25 @@ public interface TenantProxy extends CollectionSpaceProxy { @GET @Produces({"application/xml"}) - ClientResponse readList(); + Response readList(); @GET @Produces({"application/xml"}) - ClientResponse readSearchList( + Response readSearchList( @QueryParam("name") String name, @QueryParam("disabled") String disabled); //(C)reate @POST - ClientResponse create(Tenant multipart); + Response create(Tenant multipart); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("id") String id); + Response read(@PathParam("id") String id); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("id") String id, Tenant multipart); + Response update(@PathParam("id") String id, Tenant multipart); } diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java index 79340c43d..c31019d4b 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java @@ -46,7 +46,6 @@ import org.collectionspace.services.client.test.ServiceRequestType; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.testng.Assert; import org.testng.annotations.Test; import org.testng.annotations.AfterClass; @@ -167,7 +166,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = client.create(av.getAccountId(), accRole); + Response res = client.create(av.getAccountId(), accRole); try { assertStatusCode(res, testName); knownResourceId = av.getAccountId(); @@ -177,7 +176,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = client.read( + Response res = client.read( accValues.get("acc-role-user2").getAccountId()); try { // Check the status code of the response: does it match // the expected response(s)? assertStatusCode(res, testName); - AccountRole output = res.getEntity(); + AccountRole output = res.readEntity(AccountRole.class); if(logger.isDebugEnabled()) { org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory(); String sOutput = objectAsXmlString(objectFactory.createAccountRole(output), AccountRole.class); @@ -208,7 +207,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = client.create(av.getAccountId(), accRole); + Response res = client.create(av.getAccountId(), accRole); try { assertStatusCode(res, testName); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } @@ -250,13 +249,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = roleClient.readRoleAccounts( + Response res = roleClient.readRoleAccounts( roleValues.get("ROLE_CO1").getRoleId()); try { // Check the status code of the response: does it match // the expected response(s)? assertStatusCode(res, testName); - AccountRole output = res.getEntity(); + AccountRole output = res.readEntity(AccountRole.class); // Now verify that the role has 2 accounts associate to it. Assert.assertEquals(output.getAccount().size(), 1); @@ -266,7 +265,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl readResponse = client.read( + Response readResponse = client.read( accValues.get("acc-role-user1").getAccountId()); AccountRole toDelete = null; try { assertStatusCode(readResponse, testName); - toDelete = readResponse.getEntity(); + toDelete = readResponse.readEntity(AccountRole.class); Assert.assertNotNull(toDelete); } finally { if (readResponse != null) { - readResponse.releaseConnection(); + readResponse.close(); } } setupDelete(); - ClientResponse res = client.delete( + Response res = client.delete( toDelete.getAccount().get(0).getAccountId(), toDelete); // delete form #1 try { assertStatusCode(readResponse, testName); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } // @@ -361,10 +360,10 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = accClient.create(account); + Response res = accClient.create(account); try { assertStatusCode(res, "CreateAccount"); result = extractId(res); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } @@ -516,11 +515,10 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = - client.readSearchList(null, this.prebuiltAdminUserId, null); + Response res = client.readSearchList(null, this.prebuiltAdminUserId, null); try { assertStatusCode(res, "findPrebuiltAdminAccount"); - AccountsCommonList list = res.getEntity(); + AccountsCommonList list = res.readEntity(AccountsCommonList.class); List items = list.getAccountListItem(); Assert.assertEquals(1, items.size(), "Found more than one Admin account!"); AccountListItem item = items.get(0); @@ -530,7 +528,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl res = roleClient.create(role); + Response res = roleClient.create(role); try { assertStatusCode(res, "CreateRole"); result = extractId(res); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java index 2c39ac72b..4c91ec3e2 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java @@ -26,7 +26,6 @@ import java.util.List; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.client.AccountClient; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.account.AccountsCommon; @@ -135,14 +134,18 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -160,15 +163,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -186,15 +193,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -212,15 +223,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -238,15 +253,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -264,15 +283,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -290,15 +313,19 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(account); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } // @@ -312,34 +339,46 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account1); - int statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - allResourceIdsCreated.add(extractId(res)); + Response res = client.create(account1); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + allResourceIdsCreated.add(extractId(res)); + } finally { + res.close(); + } AccountsCommon account2 = createAccountInstance("tom", "tom", "hithere09", "tom@jerry.com", client.getTenantId(), true, false, true, true); res = client.create(account2); - statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - Assert.assertEquals(statusCode, testExpectedStatusCode); - allResourceIdsCreated.add(extractId(res)); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + Assert.assertEquals(statusCode, testExpectedStatusCode); + allResourceIdsCreated.add(extractId(res)); + } finally { + res.close(); + } AccountsCommon account3 = createAccountInstance("mj", "mj", "hithere10", "mj@dinoland.com", client.getTenantId(), true, false, true, true); res = client.create(account3); - statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - Assert.assertEquals(statusCode, testExpectedStatusCode); - allResourceIdsCreated.add(extractId(res)); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + Assert.assertEquals(statusCode, testExpectedStatusCode); + allResourceIdsCreated.add(extractId(res)); + } finally { + res.close(); + } } // @@ -386,11 +425,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = + Response res = client.readSearchList("tom", null, null); try { assertStatusCode(res, testName); - AccountsCommonList list = res.getEntity(); + AccountsCommonList list = res.readEntity(AccountsCommonList.class); Assert.assertEquals(1, list.getAccountListItem().size()); // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; @@ -399,7 +438,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.readSearchList(null, "tom", null); + Response res = client.readSearchList(null, "tom", null); try { assertStatusCode(res, testName); - AccountsCommonList list = res.getEntity(); + AccountsCommonList list = res.readEntity(AccountsCommonList.class); Assert.assertEquals(1, list.getAccountListItem().size()); // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; @@ -435,7 +474,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.readSearchList(null, null, "dinoland"); + Response res = client.readSearchList(null, null, "dinoland"); try { assertStatusCode(res, testName); - AccountsCommonList list = res.getEntity(); + AccountsCommonList list = res.readEntity(AccountsCommonList.class); Assert.assertEquals(2, list.getAccountListItem().size()); // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; @@ -465,7 +504,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.readSearchList("tom", null, "jerry"); + Response res = client.readSearchList("tom", null, "jerry"); try { assertStatusCode(res, testName); - AccountsCommonList list = res.getEntity(); + AccountsCommonList list = res.readEntity(AccountsCommonList.class); Assert.assertEquals(1, list.getAccountListItem().size()); // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; @@ -495,7 +534,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.read(knownResourceId); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), testExpectedStatusCode); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": got object to update password with ID: " + knownResourceId); + Response res = client.read(knownResourceId); + AccountsCommon accountFound = null; + try { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), testExpectedStatusCode); + + if (logger.isDebugEnabled()) { + logger.debug(testName + ": got object to update password with ID: " + knownResourceId); + } + accountFound = res.readEntity(AccountsCommon.class); + Assert.assertNotNull(accountFound); + } finally { + res.close(); } - AccountsCommon accountFound = - (AccountsCommon) res.getEntity(); - Assert.assertNotNull(accountFound); //create a new account object to test partial updates AccountsCommon accountToUpdate = new AccountsCommon(); @@ -544,20 +587,24 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.update(knownResourceId, accountToUpdate); - int statusCode = res.getStatus(); - // Check the status code of the response: does it match the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.update(knownResourceId, accountToUpdate); + try { + int statusCode = res.getStatus(); + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); - } /** @@ -607,16 +657,21 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.read(knownResourceId); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), testExpectedStatusCode); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": got object to update password with ID: " + knownResourceId); + Response res = client.read(knownResourceId); + AccountsCommon accountFound = null; + try { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), testExpectedStatusCode); + + if (logger.isDebugEnabled()) { + logger.debug(testName + ": got object to update password with ID: " + knownResourceId); + } + accountFound = res.readEntity(AccountsCommon.class); + } finally { + res.close(); } - AccountsCommon accountFound = (AccountsCommon) res.getEntity(); AccountsCommon accountToUpdate = new AccountsCommon(); accountToUpdate.setCsid(knownResourceId); @@ -633,14 +688,18 @@ public class AccountServiceTest extends AbstractServiceTestImpl items = list.getAccountListItem(); Assert.assertEquals(1, items.size(), "Found more than one Admin account!"); AccountListItem item = items.get(0); @@ -662,7 +720,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.read(prebuiltAdminCSID); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), testExpectedStatusCode); - - if (logger.isDebugEnabled()) { - logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID); + Response res = client.read(prebuiltAdminCSID); + AccountsCommon accountFound = null; + try { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), testExpectedStatusCode); + + if (logger.isDebugEnabled()) { + logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID); + } + accountFound = res.readEntity(AccountsCommon.class); + Assert.assertNotNull(accountFound); + } finally { + res.close(); } - AccountsCommon accountFound = (AccountsCommon) res.getEntity(); - Assert.assertNotNull(accountFound); - + //create a new account object to test partial updates AccountsCommon accountToUpdate = new AccountsCommon(); accountToUpdate.setCsid(prebuiltAdminCSID); @@ -702,21 +765,25 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.create(account); + Response res = client.create(account); String testResourceId = null; try { assertStatusCode(res, testName); @@ -743,17 +810,17 @@ public class AccountServiceTest extends AbstractServiceTestImpl accountRes = client.read(testResourceId); + Response accountRes = client.read(testResourceId); try { assertStatusCode(accountRes, testName); - AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity(); + AccountsCommon accountRead = accountRes.readEntity(AccountsCommon.class); Assert.assertNotNull(accountRead); String mdProtection = accountRead.getMetadataProtection(); String rolesProtection = accountRead.getRolesProtection(); @@ -767,7 +834,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.read(knownResourceId); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), testExpectedStatusCode); - - if (logger.isDebugEnabled()) { - logger.debug("got object to update with ID: " + knownResourceId); + Response res = client.read(knownResourceId); + AccountsCommon accountFound = null; + try { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), testExpectedStatusCode); + + if (logger.isDebugEnabled()) { + logger.debug("got object to update with ID: " + knownResourceId); + } + accountFound = res.readEntity(AccountsCommon.class); + } finally { + res.close(); } - AccountsCommon accountFound = (AccountsCommon) res.getEntity(); - + //create a new account object to test partial updates AccountsCommon accountToUpdate = new AccountsCommon(); accountToUpdate.setCsid(knownResourceId); @@ -839,21 +911,25 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = - client.update(NON_EXISTENT_ID, account); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.update(NON_EXISTENT_ID, account); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); } /** @@ -926,18 +1004,22 @@ public class AccountServiceTest extends AbstractServiceTestImpl res = client.read(knownResourceId); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), testExpectedStatusCode); - - if (logger.isDebugEnabled()) { - logger.debug("got object to update with ID: " + knownResourceId); + Response res = client.read(knownResourceId); + AccountsCommon accountToUpdate = null; + try { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), testExpectedStatusCode); + + if (logger.isDebugEnabled()) { + logger.debug("got object to update with ID: " + knownResourceId); + } + accountToUpdate = res.readEntity(AccountsCommon.class); + Assert.assertNotNull(accountToUpdate); + } finally { + res.close(); } - AccountsCommon accountToUpdate = - (AccountsCommon) res.getEntity(); - Assert.assertNotNull(accountToUpdate); accountToUpdate.setUserId("barneyFake"); if (logger.isDebugEnabled()) { @@ -947,16 +1029,20 @@ public class AccountServiceTest extends AbstractServiceTestImpl readList() { + public Response readList() { return getProxy().readList(); } - public ClientResponse readSearchList(String resourceName) { + public Response readSearchList(String resourceName) { return getProxy().readSearchList(resourceName); } @@ -83,7 +82,7 @@ public class PermissionClient extends AbstractServiceClientImpl read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } @@ -92,7 +91,7 @@ public class PermissionClient extends AbstractServiceClientImpl create(Permission permission) { + public Response create(Permission permission) { return getProxy().create(permission); } @@ -102,7 +101,7 @@ public class PermissionClient extends AbstractServiceClientImpl update(String csid, Permission permission) { + public Response update(String csid, Permission permission) { return getProxy().update(csid, permission); } } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionProxy.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionProxy.java index 5621f95a0..1341263df 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionProxy.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionProxy.java @@ -38,7 +38,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.authorization.perms.Permission; import org.collectionspace.services.authorization.perms.PermissionsList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -50,22 +49,22 @@ public interface PermissionProxy extends CollectionSpaceProxy { @GET @Produces({"application/xml"}) - ClientResponse readList(); + Response readList(); @GET - ClientResponse readSearchList(@QueryParam("res") String resourceName); + Response readSearchList(@QueryParam("res") String resourceName); //(C)reate @POST - ClientResponse create(Permission permission); + Response create(Permission permission); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, Permission permission); + Response update(@PathParam("csid") String csid, Permission permission); } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java index 885572ef9..34aa4d132 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java @@ -27,7 +27,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.authorization.PermissionRole; /** @@ -66,7 +65,7 @@ public class PermissionRoleClient extends AbstractServiceClientImpl read(String csid, String prcsid) { + public Response read(String csid, String prcsid) { return getProxy().read(csid, prcsid); } @@ -78,7 +77,7 @@ public class PermissionRoleClient extends AbstractServiceClientImpl read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } @@ -90,7 +89,7 @@ public class PermissionRoleClient extends AbstractServiceClientImpl create(String csid, PermissionRole permRole) { + public Response create(String csid, PermissionRole permRole) { return getProxy().create(csid, permRole); } @@ -101,23 +100,23 @@ public class PermissionRoleClient extends AbstractServiceClientImpl delete(String csid, PermissionRole permRole) { + public Response delete(String csid, PermissionRole permRole) { return getProxy().delete(csid, "delete", permRole); } @Override - public ClientResponse create(PermissionRole payload) { + public Response create(PermissionRole payload) { throw new UnsupportedOperationException(); //method not supported nor needed } @Override - public ClientResponse update(String csid, + public Response update(String csid, PermissionRole payload) { throw new UnsupportedOperationException(); //method not supported nor needed } @Override - public ClientResponse readList() { + public Response readList() { throw new UnsupportedOperationException(); //method not supported nor needed } } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleProxy.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleProxy.java index bfaa5a316..615d28820 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleProxy.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleProxy.java @@ -36,9 +36,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; - import org.collectionspace.services.authorization.PermissionRole; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -50,28 +48,28 @@ public interface PermissionRoleProxy extends CollectionSpaceProxy create(@PathParam("csid") String csid, PermissionRole permRole); + Response create(@PathParam("csid") String csid, PermissionRole permRole); //(R)ead @GET @Path("/{csid}/permroles") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(R)ead @GET @Path("/{csid}/permroles/{prcsid}") - ClientResponse read(@PathParam("csid") String csid, + Response read(@PathParam("csid") String csid, @PathParam("prcsid") String prcsid); //(D)elete @DELETE @Path("/{csid}/permroles") - ClientResponse delete(@PathParam("csid") String csid); + Response delete(@PathParam("csid") String csid); //(D)elete - with a payload @POST @Path("/{csid}/permroles") - ClientResponse delete(@PathParam("csid") String csid, + Response delete(@PathParam("csid") String csid, @QueryParam("_method") String method, PermissionRole permRole); } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleClient.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleClient.java index 6f477b8e2..69f8abb96 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleClient.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleClient.java @@ -32,7 +32,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.authorization.AccountRole; import org.collectionspace.services.authorization.Role; import org.collectionspace.services.authorization.RolesList; -import org.jboss.resteasy.client.ClientResponse; /** * A RoleClient. @@ -59,21 +58,21 @@ public class RoleClient extends AbstractServiceClientImpl readList() { + public Response readList() { return getProxy().readList(); } - public ClientResponse readSearchList(String roleName) { + public Response readSearchList(String roleName) { return getProxy().readSearchList(roleName); } - public ClientResponse read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } - public ClientResponse readRoleAccounts(String csid) { + public Response readRoleAccounts(String csid) { return getProxy().readRoleAccounts(csid); } @@ -83,7 +82,7 @@ public class RoleClient extends AbstractServiceClientImpl create(Role role) { + public Response create(Role role) { return getProxy().create(role); } @@ -92,7 +91,7 @@ public class RoleClient extends AbstractServiceClientImpl update(String csid, Role role) { + public Response update(String csid, Role role) { return getProxy().update(csid, role); } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionClient.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionClient.java index 2633bca5c..0064a3203 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionClient.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionClient.java @@ -27,7 +27,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.authorization.PermissionRole; // TODO: Auto-generated Javadoc @@ -66,7 +65,7 @@ public class RolePermissionClient extends AbstractServiceClientImpl read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } @@ -77,7 +76,7 @@ public class RolePermissionClient extends AbstractServiceClientImpl read(String csid, String prcsid) { + public Response read(String csid, String prcsid) { return getProxy().read(csid, prcsid); } @@ -89,7 +88,7 @@ public class RolePermissionClient extends AbstractServiceClientImpl create(String csid, PermissionRole permRole) { + public Response create(String csid, PermissionRole permRole) { return getProxy().create(csid, permRole); } @@ -100,23 +99,23 @@ public class RolePermissionClient extends AbstractServiceClientImpl delete(String csid, PermissionRole permRole) { + public Response delete(String csid, PermissionRole permRole) { return getProxy().delete(csid, "delete", permRole); } @Override - public ClientResponse create(PermissionRole payload) { + public Response create(PermissionRole payload) { throw new UnsupportedOperationException(); //method not supported nor needed } @Override - public ClientResponse update(String csid, + public Response update(String csid, PermissionRole payload) { throw new UnsupportedOperationException(); //method not supported nor needed } @Override - public ClientResponse readList() { + public Response readList() { throw new UnsupportedOperationException(); //method not supported nor needed } } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionProxy.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionProxy.java index 08623912f..cd9fea96d 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionProxy.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionProxy.java @@ -38,7 +38,6 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.authorization.PermissionRole; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -51,28 +50,28 @@ public interface RolePermissionProxy extends CollectionSpaceProxy create(@PathParam("csid") String csid, PermissionRole permRole); + Response create(@PathParam("csid") String csid, PermissionRole permRole); //(R)ead @GET @Path("/{csid}/permroles") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(R)ead @GET @Path("/{csid}/permroles/{prcsid}") - ClientResponse read(@PathParam("csid") String csid, + Response read(@PathParam("csid") String csid, @PathParam("prcsid") String prcsid); //(D)elete @DELETE @Path("/{csid}/permroles") - ClientResponse delete(@PathParam("csid") String csid); + Response delete(@PathParam("csid") String csid); //(D)elete - with a payload @POST @Path("/{csid}/permroles") - ClientResponse delete(@PathParam("csid") String csid, + Response delete(@PathParam("csid") String csid, @QueryParam("_method") String method, PermissionRole permRole); } diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleProxy.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleProxy.java index 176b764f4..62ebe9c3b 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleProxy.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleProxy.java @@ -36,11 +36,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; - -import org.collectionspace.services.authorization.AccountRole; import org.collectionspace.services.authorization.Role; import org.collectionspace.services.authorization.RolesList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -52,27 +49,27 @@ public interface RoleProxy extends CollectionSpaceProxy { @GET @Produces({"application/xml"}) - ClientResponse readList(); + Response readList(); @GET - ClientResponse readSearchList(@QueryParam("r") String roleName); + Response readSearchList(@QueryParam("r") String roleName); //(C)reate @POST - ClientResponse create(Role role); + Response create(Role role); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); //(R)ead accounts associate with this role @GET @Path("{csid}/accountroles") - ClientResponse readRoleAccounts(@PathParam("csid") String csid); + Response readRoleAccounts(@PathParam("csid") String csid); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, Role role); + Response update(@PathParam("csid") String csid, Role role); } diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java index 9599b45a5..608e3d215 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java @@ -47,8 +47,6 @@ import org.collectionspace.services.client.RoleFactory; import org.collectionspace.services.client.test.AbstractServiceTestImpl; import org.collectionspace.services.client.test.ServiceRequestType; -import org.jboss.resteasy.client.ClientResponse; - import org.testng.Assert; import org.testng.annotations.Test; @@ -189,9 +187,9 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + + Response res = client.create(pv.getPermissionId(), permRole); try { - res = client.create(pv.getPermissionId(), permRole); int statusCode = res.getStatus(); if (logger.isDebugEnabled()) { @@ -266,10 +264,9 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + Response res = client.read( + permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId()); try { - res = client.read( - permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId()); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -281,11 +278,11 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + Response res = null; try { res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -318,7 +315,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + Response res = null; try { res = client.read( permValues.get(TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX).getPermissionId()); // Check the status code of the response: does it match // the expected response(s)? assertStatusCode(res, testName); - PermissionRole output = (PermissionRole) res.getEntity(); + PermissionRole output = res.readEntity(PermissionRole.class); String sOutput = objectAsXmlString(output, PermissionRole.class); if (logger.isDebugEnabled()) { @@ -346,7 +343,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl readResponse = client.read( + Response readResponse = client.read( permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId()); PermissionRole toDelete = null; try { - toDelete = readResponse.getEntity(); + toDelete = readResponse.readEntity(PermissionRole.class); } finally { - readResponse.releaseConnection(); + readResponse.close(); } - ClientResponse res = client.delete( + Response res = client.delete( toDelete.getPermission().get(0).getPermissionId(), toDelete); try { int statusCode = res.getStatus(); @@ -455,7 +452,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + Response res = permClient.create(permission); try { - res = permClient.create(permission); - int statusCode = res.getStatus(); if (logger.isDebugEnabled()) { logger.debug("createPermission: resName=" + resName @@ -601,7 +596,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = null; + Response res = null; String id = null; try { res = roleClient.create(role); @@ -665,7 +660,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl res = client.create(permission); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(permission); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -149,10 +152,10 @@ public class PermissionServiceTest extends AbstractServiceTestImpl res = client.readSearchList("acquisition"); + Response res = client.readSearchList("acquisition"); try { assertStatusCode(res, testName); - PermissionsList list = res.getEntity(PermissionsList.class); + PermissionsList list = res.readEntity(PermissionsList.class); int EXPECTED_ITEMS = 2 + 4; //2 seeded base resource permissions and 4 workflow-related permissions int actual = list.getPermission().size(); if (logger.isDebugEnabled()) { @@ -168,7 +171,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl res = client.update(knownResourceId, permToUpdate); + Response res = client.update(knownResourceId, permToUpdate); int statusCode = res.getStatus(); // Check the status code of the response: does it match the expected response(s)? if (logger.isDebugEnabled()) { @@ -247,7 +250,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl res = client.update(knownResourceId, permToUpdate); + Response res = client.update(knownResourceId, permToUpdate); int statusCode = res.getStatus(); // Check the status code of the response: does it match the expected response(s)? if (logger.isDebugEnabled()) { @@ -257,7 +260,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl res = - client.update(NON_EXISTENT_ID, permission); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.update(NON_EXISTENT_ID, permission); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); } // --------------------------------------------------------------- @@ -345,6 +351,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = client.create(rv.getRoleId(), permRole); try { - res = client.create(rv.getRoleId(), permRole); int statusCode = res.getStatus(); if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); @@ -192,7 +190,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = client.read(roleValues.get(getRoleName()).getRoleId()); try { - res = client.read(roleValues.get(getRoleName()).getRoleId()); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -265,11 +262,11 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = client.read(NON_EXISTENT_ID); try { - - res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -302,7 +297,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId()); try { - - res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId()); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -326,7 +319,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl readResponse = client.read(rv.getRoleId()); - PermissionRole toDelete = readResponse.getEntity(); - readResponse.releaseConnection(); + Response readResponse = client.read(rv.getRoleId()); + PermissionRole toDelete = null; + try { + toDelete = readResponse.readEntity(PermissionRole.class); + } finally { + readResponse.close(); + } rv = toDelete.getRole().get(0); - ClientResponse res = null; + Response res = client.delete(rv.getRoleId(), toDelete); try { - res = client.delete( - rv.getRoleId(), toDelete); int statusCode = res.getStatus(); Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } @@ -575,7 +570,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = null; String id = null; try { res = permClient.create(permission); @@ -590,7 +585,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl res = null; + Response res = null; String id = null; try { res = roleClient.create(role); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java index 25fcdd223..56c4e5cbc 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java @@ -32,7 +32,6 @@ import org.collectionspace.services.authorization.Role; import org.collectionspace.services.authorization.RolesList; import org.collectionspace.services.client.RoleFactory; import org.collectionspace.services.client.test.AbstractServiceTestImpl; -import org.jboss.resteasy.client.ClientResponse; import org.testng.Assert; import org.testng.annotations.Test; @@ -110,7 +109,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); + Response res = client.create(role); try { int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -149,31 +148,33 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - // - // Specifically: - // Does it fall within the set of valid status codes? - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - - // Store the ID returned from this create operation - // for additional tests below. - String csid = extractId(res); - allResourceIdsCreated.add(csid); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": csid=" + csid); + Response res = client.create(role); + try { + int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + // + // Specifically: + // Does it fall within the set of valid status codes? + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + // Store the ID returned from this create operation + // for additional tests below. + String csid = extractId(res); + allResourceIdsCreated.add(csid); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": csid=" + csid); + } + } finally { + res.close(); } } @@ -192,20 +193,23 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); - int statusCode = res.getStatus(); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": Role with name \"" + - knownRoleName + "\" should already exist, so this request should fail."); - logger.debug(testName + ": status = " + statusCode); - logger.debug(testName + ": " + res); + "role users", true); + Response res = client.create(role); + try { + int statusCode = res.getStatus(); + + if (logger.isDebugEnabled()) { + logger.debug(testName + ": Role with name \"" + + knownRoleName + "\" should already exist, so this request should fail."); + logger.debug(testName + ": status = " + statusCode); + logger.debug(testName + ": " + res); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } /** @@ -225,26 +229,30 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); - int statusCode = res.getStatus(); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": Role with name \"" + - knownRoleName + "\" should already exist, so this request should fail."); - logger.debug(testName + ": status = " + statusCode); - logger.debug(testName + ": " + res); - } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) { - // If the test fails then we've just created a Role that we need to delete, so - // store the ID returned from this create operation. - String csid = extractId(res); - allResourceIdsCreated.add(csid); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": csid=" + csid); - } - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + Response res = client.create(role); + try { + int statusCode = res.getStatus(); + + if (logger.isDebugEnabled()) { + logger.debug(testName + ": Role with name \"" + + knownRoleName + "\" should already exist, so this request should fail."); + logger.debug(testName + ": status = " + statusCode); + logger.debug(testName + ": " + res); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) { + // If the test fails then we've just created a Role that we need to delete, so + // store the ID returned from this create operation. + String csid = extractId(res); + allResourceIdsCreated.add(csid); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": csid=" + csid); + } + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } + } finally { + res.close(); } } @@ -264,15 +272,19 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); - int statusCode = res.getStatus(); - // Does it exactly match the expected status code? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.create(role); + try { + int statusCode = res.getStatus(); + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode()); } //to not cause uniqueness violation for role, createList is removed @@ -290,37 +302,46 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role1); - int statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - verifyResourceId = extractId(res); - allResourceIdsCreated.add(verifyResourceId); + "collection manager", true); + Response res = client.create(role1); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + verifyResourceId = extractId(res); + allResourceIdsCreated.add(verifyResourceId); + } finally { + res.close(); + } Role role2 = createRoleInstance("ROLE_COLLECTIONS_CURATOR_TEST", - "collections curator", - true); + "collections curator", true); res = client.create(role2); - statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - Assert.assertEquals(statusCode, testExpectedStatusCode); - allResourceIdsCreated.add(extractId(res)); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + Assert.assertEquals(statusCode, testExpectedStatusCode); + allResourceIdsCreated.add(extractId(res)); + } finally { + res.close(); + } Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST", - "moving image admin", - true); + "moving image admin", true); res = client.create(role3); - statusCode = res.getStatus(); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - Assert.assertEquals(statusCode, testExpectedStatusCode); - allResourceIdsCreated.add(extractId(res)); + try { + int statusCode = res.getStatus(); + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + Assert.assertEquals(statusCode, testExpectedStatusCode); + allResourceIdsCreated.add(extractId(res)); + } finally { + res.close(); + } } // Failure outcomes @@ -366,20 +387,24 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.read(knownResourceId); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.read(knownResourceId); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + Role output = res.readEntity(Role.class); + Assert.assertNotNull(output); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - - Role output = (Role) res.getEntity(); - Assert.assertNotNull(output); } @Test(dataProvider = "testName", @@ -390,7 +415,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.read(verifyResourceId); + Response res = client.read(verifyResourceId); try { int statusCode = res.getStatus(); @@ -403,7 +428,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.read(NON_EXISTENT_ID); + Response res = client.read(NON_EXISTENT_ID); try { int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -462,12 +487,12 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.readList(); + Response res = client.readList(); try { // Check the status code of the response: does it match // the expected response(s)? assertStatusCode(res, testName); - RolesList list = res.getEntity(); + RolesList list = res.readEntity(RolesList.class); // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; if (iterateThroughList && logger.isDebugEnabled()) { @@ -494,10 +519,10 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.readSearchList("movingImage"); + Response res = client.readSearchList("movingImage"); try { assertStatusCode(res, testName); - RolesList list = res.getEntity(); + RolesList list = res.readEntity(RolesList.class); int EXPECTED_ITEMS = 1; if (logger.isDebugEnabled()) { logger.debug(testName + ": received = " + list.getRole().size() @@ -547,7 +572,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.update(knownResourceId, roleToUpdate); + Response res = client.update(knownResourceId, roleToUpdate); try { // Check the status code of the response: does it match the expected response(s)? int statusCode = res.getStatus(); @@ -559,7 +584,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.create(role); + Response res = client.create(role); String testResourceId = null; try { int statusCode = res.getStatus(); @@ -603,14 +628,14 @@ public class RoleServiceTest extends AbstractServiceTestImpl roleRes = client.read(testResourceId); + Response roleRes = client.read(testResourceId); try { int statusCode = roleRes.getStatus(); Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); - Role roleRead = (Role) roleRes.getEntity(); + Role roleRead = roleRes.readEntity(Role.class); Assert.assertNotNull(roleRead); String mdProtection = roleRead.getMetadataProtection(); String permsProtection = roleRead.getPermsProtection(); @@ -645,7 +670,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = client.update(knownResourceId, roleToUpdate); + Response res = client.update(knownResourceId, roleToUpdate); try { int statusCode = res.getStatus(); // Check the status code of the response: does it match the expected response(s)? @@ -744,8 +769,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl res = - client.update(NON_EXISTENT_ID, role); + Response res = client.update(NON_EXISTENT_ID, role); try { int statusCode = res.getStatus(); diff --git a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java index 392fdd371..2e5dbd6b8 100644 --- a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java +++ b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java @@ -19,7 +19,6 @@ package org.collectionspace.services.client; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; /** @@ -65,19 +64,19 @@ public class BlobClient extends AbstractCommonListPoxServiceClientImpl createBlobFromFormData(MultipartFormDataOutput formDataOutput) { + public Response createBlobFromFormData(MultipartFormDataOutput formDataOutput) { return getProxy().createBlobFromFormData(formDataOutput); } - public ClientResponse createBlobFromURI(String blobUri) { + public Response createBlobFromURI(String blobUri) { return getProxy().createBlobFromURI("".getBytes(), blobUri); } - public ClientResponse getBlobContent(String csid) { + public Response getBlobContent(String csid) { return getProxy().getBlobContent(csid); } - public ClientResponse getDerivativeContent( + public Response getDerivativeContent( @PathParam("csid") String csid, @PathParam("derivativeTerm") String derivativeTerm) { return getProxy().getDerivativeContent(csid, derivativeTerm); diff --git a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java index b1c85d54f..0e0c327f7 100644 --- a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java +++ b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java @@ -9,7 +9,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; @@ -22,21 +21,21 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; public interface BlobProxy extends CollectionSpaceCommonListPoxProxy { //(C)reate @POST - ClientResponse createBlobFromURI(byte[] xmlPayload, + Response createBlobFromURI(byte[] xmlPayload, @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri); //(C)reate @POST @Consumes("multipart/form-data") - ClientResponse createBlobFromFormData(MultipartFormDataOutput formDataOutput); + Response createBlobFromFormData(MultipartFormDataOutput formDataOutput); @GET @Path("{csid}/content") - ClientResponse getBlobContent(@PathParam("csid") String csid); + Response getBlobContent(@PathParam("csid") String csid); @GET @Path("{csid}/derivatives/{derivativeTerm}/content") - public ClientResponse getDerivativeContent( + public Response getDerivativeContent( @PathParam("csid") String csid, @PathParam("derivativeTerm") String derivativeTerm); } \ No newline at end of file diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobAuthRefsTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobAuthRefsTest.java index 7c4fbe7f3..14b84c364 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobAuthRefsTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobAuthRefsTest.java @@ -193,7 +193,7 @@ public class BlobAuthRefsTest extends BaseServiceTest { BlobsCommon blob = null; try { assertStatusCode(res, testName); - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class); Assert.assertNotNull(blob); logger.debug(objectAsXmlString(blob, BlobsCommon.class)); @@ -210,7 +210,7 @@ public class BlobAuthRefsTest extends BaseServiceTest { res = blobClient.getAuthorityRefs(knownResourceId); try { assertStatusCode(res, testName); - AuthorityRefList list = (AuthorityRefList)res.getEntity(); + AuthorityRefList list = res.readEntity(AuthorityRefList.class); List items = list.getAuthorityRefItem(); int numAuthRefsFound = items.size(); logger.debug("Authority references, found " + numAuthRefsFound); @@ -253,7 +253,7 @@ public class BlobAuthRefsTest extends BaseServiceTest { // Delete Person resource(s) (before PersonAuthority resources). for (String resourceId : personIdsCreated) { // Note: Any non-success responses are ignored and not reported. - personAuthClient.deleteItem(personAuthCSID, resourceId); + personAuthClient.deleteItem(personAuthCSID, resourceId).close(); } // Delete PersonAuthority resource(s). // Note: Any non-success response is ignored and not reported. @@ -263,7 +263,7 @@ public class BlobAuthRefsTest extends BaseServiceTest { BlobClient blobClient = new BlobClient(); for (String resourceId : blobIdsCreated) { // Note: Any non-success responses are ignored and not reported. - blobClient.delete(resourceId); + blobClient.delete(resourceId).close(); } } } diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java index 8e8246946..b03b84de5 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java @@ -19,7 +19,6 @@ import org.collectionspace.services.client.BlobClient; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.Profiler; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Test; @@ -84,10 +83,14 @@ public class BlobScaleTest extends BaseServiceTest { Thread.sleep(3000); // sleep for 3 seconds for (int i = 0; i < allGeneratedImages.size(); i++) { - ClientResponse res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail"); - assertStatusCode(res, testName); - logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.", - allGeneratedImages.get(i))); + Response res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail"); + try { + assertStatusCode(res, testName); + logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.", + allGeneratedImages.get(i))); + } finally { + res.close(); + } } } @@ -104,7 +107,7 @@ public class BlobScaleTest extends BaseServiceTest { URL url = jpegFile.toURI().toURL(); profiler.start(); - ClientResponse res = client.createBlobFromURI("http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString()); + Response res = client.createBlobFromURI("http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString()); try { profiler.stop(); assertStatusCode(res, testName); @@ -123,7 +126,7 @@ public class BlobScaleTest extends BaseServiceTest { allGeneratedImages.add(csid); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java index 0f8f633ea..2f95c99ef 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java @@ -133,7 +133,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl 0) { for (File child : children) { if (isBlobbable(child) == true) { - ClientResponse res = null; + Response res = null; String mimeType = this.getMimeType(child); logger.debug("Processing file URI: " + child.getAbsolutePath()); logger.debug("MIME type is: " + mimeType); @@ -187,7 +187,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl res = null; + Response res = null; res = client.createBlobFromURI(uri); String blobCsid = null; try { diff --git a/services/client/pom.xml b/services/client/pom.xml index 80efbc41d..3a3be105f 100644 --- a/services/client/pom.xml +++ b/services/client/pom.xml @@ -57,6 +57,11 @@ httpclient 4.3.3 + + xerces + xercesImpl + 2.9.1 + org.jboss.resteasy resteasy-jaxrs diff --git a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClientUtils.java b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClientUtils.java index 138b87181..7202e5654 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClientUtils.java +++ b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClientUtils.java @@ -38,7 +38,6 @@ import javax.xml.bind.Unmarshaller; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.commons.io.FileUtils; -import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.slf4j.Logger; @@ -70,17 +69,6 @@ public class CollectionSpaceClientUtils { Response.Status.NOT_FOUND.getStatusCode(); protected static final int STATUS_OK = Response.Status.OK.getStatusCode(); - - /** - * Extract id. - * - * @param res the res - * @return the string - */ - static public String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - return extractIdFromResponseMetadata(mvm); - } /** * Extract id. diff --git a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java index 95f2edfd0..0a0b3e91a 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java +++ b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java @@ -16,20 +16,20 @@ public interface CollectionSpaceCommonListPoxProxy extends CollectionSpacePoxPro @Override @GET @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( + Response readIncludeDeleted( @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @Override @GET @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( + Response keywordSearchIncludeDeleted( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @Override @GET @Produces({ "application/xml" }) - ClientResponse advancedSearchIncludeDeleted( + Response advancedSearchIncludeDeleted( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_AS) String whereClause, @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); } diff --git a/services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java b/services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java index b3eb1d964..58060dc2a 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java +++ b/services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java @@ -24,7 +24,6 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.jaxb.AbstractCommonList; /** @@ -58,22 +57,22 @@ public final class TestServiceClient extends AbstractServiceClientImpl create(Object payload) { + public Response create(Object payload) { throw new UnsupportedOperationException(); } @Override - public ClientResponse update(String csid, Object payload) { + public Response update(String csid, Object payload) { throw new UnsupportedOperationException(); } @Override - public ClientResponse read(String csid) { + public Response read(String csid) { throw new UnsupportedOperationException(); } @Override - public ClientResponse readList() { + public Response readList() { throw new UnsupportedOperationException(); } } diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java index a47dca1dc..b223797a9 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java @@ -173,9 +173,13 @@ public abstract class AbstractAuthorityServiceTest { // FIXME: Move some or all of the methods below to a common client and // server utilities package, when this package becomes available. - /** - * Extract id. - * - * @param res the res - * @return the string - */ - static protected String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((List) mvm.get("Location")).get(0); - if (logger.isDebugEnabled()) { - logger.debug("extractId:uri=" + uri); - } - String[] segments = uri.split("/"); - String id = segments[segments.length - 1]; - if (logger.isDebugEnabled()) { - logger.debug("id=" + id); - } - return id; - } - /** * Extract id. * @@ -676,18 +655,6 @@ public abstract class BaseServiceTest { } return className; } - - public int assertStatusCode(ClientResponse res, String testName) { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - logger.debug(testName + ": status = " + statusCode); - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - - return statusCode; - } public int assertStatusCode(Response res, String testName) { int statusCode = res.getStatus(); diff --git a/services/client/src/main/java/org/collectionspace/services/client/workflow/WorkflowClient.java b/services/client/src/main/java/org/collectionspace/services/client/workflow/WorkflowClient.java index 60e0d4435..5491864e4 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/workflow/WorkflowClient.java +++ b/services/client/src/main/java/org/collectionspace/services/client/workflow/WorkflowClient.java @@ -17,10 +17,7 @@ package org.collectionspace.services.client.workflow; import javax.ws.rs.core.Response; - -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.client.AbstractCommonListPoxServiceClientImpl; -import org.jboss.resteasy.client.ClientResponse; /** * WorkflowClient.java @@ -84,7 +81,7 @@ public class WorkflowClient extends AbstractCommonListPoxServiceClientImpl readList() { + public Response readList() { throw new UnsupportedOperationException(); } @@ -92,7 +89,7 @@ public class WorkflowClient extends AbstractCommonListPoxServiceClientImpl delete(String csid) { + public Response delete(String csid) { throw new UnsupportedOperationException(); } diff --git a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectClient.java b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectClient.java index e41e3e0de..842e85171 100644 --- a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectClient.java +++ b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectClient.java @@ -26,7 +26,6 @@ */ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.core.Response; // FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 @@ -70,9 +69,9 @@ public class CollectionObjectClient extends AbstractCommonListPoxServiceClientIm * @see org.collectionspace.services.client.CollectionObjectProxy#roundtrip() * @return the client response< response> */ - public ClientResponse roundtrip(int ms) { + public Response roundtrip(int ms) { getLogger().debug(">>>>Roundtrip start."); - ClientResponse result = getProxy().roundtrip(ms); + Response result = getProxy().roundtrip(ms); getLogger().debug("<<< roundtrip(@PathParam("ms") int ms); + Response roundtrip(@PathParam("ms") int ms); /** * Keyword search. diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml index ec8ede2b8..b4f254698 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml @@ -470,6 +470,16 @@ default-domain org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler + + + + + dimension + dimension + + + + { +public class DimensionClient extends AbstractCommonListPoxServiceClientImpl { public static final String SERVICE_NAME = "dimensions"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; @@ -56,14 +51,5 @@ public class DimensionClient extends AbstractPoxServiceClientImpl getProxyClass() { return DimensionProxy.class; - } - - /* - * Proxied service calls - */ - - public Response readList() { - DimensionProxy proxy = (DimensionProxy)getProxy(); - return proxy.readList(); - } + } } diff --git a/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java index 64ac3dfea..9d45d5002 100644 --- a/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java +++ b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java @@ -1,15 +1,8 @@ package org.collectionspace.services.client; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; - -import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.dimension.DimensionsCommonList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -17,21 +10,6 @@ import org.jboss.resteasy.client.ClientResponse; @Path("/dimensions/") @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface DimensionProxy extends CollectionSpacePoxProxy { - @GET - @Produces({"application/xml"}) - Response readList(); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); +public interface DimensionProxy extends CollectionSpaceCommonListPoxProxy { + // Intentionally left blank } diff --git a/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java index b7c8b2266..743c9fd55 100644 --- a/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java +++ b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java @@ -24,19 +24,16 @@ package org.collectionspace.services.client.test; //import java.util.ArrayList; import java.math.BigDecimal; -import java.util.List; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.DimensionClient; import org.collectionspace.services.client.DimensionFactory; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.dimension.DimensionsCommon; -import org.collectionspace.services.dimension.DimensionsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.testng.Assert; -//import org.testng.annotations.AfterClass; import org.testng.annotations.Test; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +44,7 @@ import org.slf4j.LoggerFactory; * $LastChangedRevision: 917 $ * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $ */ -public class DimensionServiceTest extends AbstractPoxServiceTestImpl { +public class DimensionServiceTest extends AbstractPoxServiceTestImpl { /** The logger. */ private final String CLASS_NAME = DimensionServiceTest.class.getName(); @@ -74,33 +71,6 @@ public class DimensionServiceTest extends AbstractPoxServiceTestImpl getCommonListType() { - return DimensionsCommonList.class; - } - - /* - * This method gets called by the parent's method public void readList(String testName) - */ - protected void printList(String testName, DimensionsCommonList list) { - // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getDimensionListItem(); - int i = 0; - for (DimensionsCommonList.DimensionListItem item : items) { - logger.debug(testName + ": list-item[" + i + "] csid=" - + item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] objectNumber=" - + item.getDimension()); - logger.debug(testName + ": list-item[" + i + "] URI=" - + item.getUri()); - i++; - } - } - } protected void compareInstances(DimensionsCommon original, DimensionsCommon updated) throws Exception { Assert.assertEquals(original.getValueDate(), diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java index 6bd499298..e1b33db45 100644 --- a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java @@ -23,21 +23,8 @@ */ package org.collectionspace.services.dimension.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.dimension.DimensionJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.dimension.DimensionsCommon; -import org.collectionspace.services.dimension.DimensionsCommonList; -import org.collectionspace.services.dimension.DimensionsCommonList.DimensionListItem; - -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** * DimensionDocumentModelHandler @@ -46,94 +33,6 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class DimensionDocumentModelHandler - extends RemoteDocumentModelHandlerImpl { - - private final Logger logger = LoggerFactory.getLogger(DimensionDocumentModelHandler.class); - /** - * dimension is used to stash JAXB object to use when handle is called - * for Action.CREATE, Action.UPDATE or Action.GET - */ - private DimensionsCommon dimension; - /** - * intakeList is stashed when handle is called - * for ACTION.GET_ALL - */ - private DimensionsCommonList intakeList; - - - /** - * getCommonPart get associated dimension - * @return - */ - @Override - public DimensionsCommon getCommonPart() { - return dimension; - } - - /** - * setCommonPart set associated dimension - * @param dimension - */ - @Override - public void setCommonPart(DimensionsCommon dimension) { - this.dimension = dimension; - } - - /** - * getCommonPartList get associated dimension (for index/GET_ALL) - * @return - */ - @Override - public DimensionsCommonList getCommonPartList() { - return intakeList; - } - - @Override - public void setCommonPartList(DimensionsCommonList intakeList) { - this.intakeList = intakeList; - } - - @Override - public DimensionsCommon extractCommonPart(DocumentWrapper wrapDoc) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void fillCommonPart(DimensionsCommon intakeObject, DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public DimensionsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DimensionsCommonList coList = extractPagingInfo(new DimensionsCommonList(), wrapDoc) ; - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("dimension|uri|csid"); - List list = coList.getDimensionListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - DimensionListItem ilistItem = new DimensionListItem(); - ilistItem.setDimension((String) docModel.getProperty(getServiceContext().getCommonPartLabel(), - DimensionJAXBSchema.DIMENSION)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - - /** - * getQProperty converts the given property to qualified schema property - * @param prop - * @return - */ - @Override - public String getQProperty(String prop) { - return DimensionConstants.NUXEO_SCHEMA_NAME + ":" + prop; - } - + extends NuxeoDocumentModelHandler { + } - diff --git a/services/exhibition/client/src/test/java/org/collectionspace/services/client/test/ExhibitionServiceTest.java b/services/exhibition/client/src/test/java/org/collectionspace/services/client/test/ExhibitionServiceTest.java index 9a08e4c14..2fd2135d6 100644 --- a/services/exhibition/client/src/test/java/org/collectionspace/services/client/test/ExhibitionServiceTest.java +++ b/services/exhibition/client/src/test/java/org/collectionspace/services/client/test/ExhibitionServiceTest.java @@ -256,7 +256,7 @@ public class ExhibitionServiceTest extends AbstractPoxServiceTestImpl create(String xmlPayload) { + public Response create(String xmlPayload) { return getProxy().create(xmlPayload); } - public ClientResponse read(String csid) { + public Response read(String csid) { return getProxy().read(csid); } - public ClientResponse readList() { + public Response readList() { return getProxy().readList(); } @Override - public ClientResponse delete(String csid) { + public Response delete(String csid) { return getProxy().delete(csid); } // Operations on IDs - public ClientResponse createId(String csid) { + public Response createId(String csid) { return getProxy().createId(csid); } @Override - public ClientResponse update(String csid, String payload) { + public Response update(String csid, String payload) { throw new UnsupportedOperationException("ID client does not support an update operation."); } } diff --git a/services/id/client/src/main/java/org/collectionspace/services/client/IdProxy.java b/services/id/client/src/main/java/org/collectionspace/services/client/IdProxy.java index 062c41348..da9e86e23 100644 --- a/services/id/client/src/main/java/org/collectionspace/services/client/IdProxy.java +++ b/services/id/client/src/main/java/org/collectionspace/services/client/IdProxy.java @@ -8,7 +8,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; /** * IDProxy. @@ -27,30 +26,30 @@ public interface IdProxy extends CollectionSpaceProxy { @POST @Consumes({"application/xml"}) @Produces({"*/*"}) - ClientResponse create(String xmlPayload); + Response create(String xmlPayload); //(R)ead ID Generator @GET @Path("/{csid}") @Produces({"application/xml"}) - ClientResponse read(@PathParam("csid") String csid); + Response read(@PathParam("csid") String csid); // Read (L)ist of ID Generators @GET @Produces({"application/xml"}) - ClientResponse readList(); + Response readList(); //(D)elete ID Generator @DELETE @Path("/{csid}") @Override - ClientResponse delete(@PathParam("csid") String csid); + Response delete(@PathParam("csid") String csid); // Operations on IDs //(C)reate ID @POST @Path("/{csid}/ids") - ClientResponse createId(@PathParam("csid") String csid); + Response createId(@PathParam("csid") String csid); } diff --git a/services/id/service/src/test/java/org/collectionspace/services/id/IdServiceTest.java b/services/id/service/src/test/java/org/collectionspace/services/id/IdServiceTest.java index 187b550ba..c53664b54 100644 --- a/services/id/service/src/test/java/org/collectionspace/services/id/IdServiceTest.java +++ b/services/id/service/src/test/java/org/collectionspace/services/id/IdServiceTest.java @@ -88,7 +88,7 @@ public class IdServiceTest extends BaseServiceTest { String xmlPayload = getSampleSerializedIdGenerator(); logger.debug("payload=\n" + xmlPayload); - ClientResponse res = client.create(xmlPayload); + Response res = client.create(xmlPayload); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -128,11 +128,11 @@ public class IdServiceTest extends BaseServiceTest { // Submit the request to the service and store the response. IdClient client = new IdClient(); - ClientResponse res = client.createId(knownResourceId); + Response res = client.createId(knownResourceId); String generatedId = null; try { assertStatusCode(res, testName); - generatedId = res.getEntity(); + generatedId = res.readEntity(String.class); Assert.assertNotNull(generatedId); Assert.assertFalse(generatedId.isEmpty()); if (logger.isDebugEnabled()) { @@ -140,7 +140,7 @@ public class IdServiceTest extends BaseServiceTest { } } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } // Create a second ID. Verify that it is different from the first. @@ -149,7 +149,7 @@ public class IdServiceTest extends BaseServiceTest { res = client.createId(knownResourceId); try { assertStatusCode(res, testName); - String secondGeneratedId = res.getEntity(); + String secondGeneratedId = res.readEntity(String.class); Assert.assertNotNull(secondGeneratedId); Assert.assertFalse(secondGeneratedId.isEmpty()); Assert.assertFalse(secondGeneratedId.equals(generatedId)); @@ -158,7 +158,7 @@ public class IdServiceTest extends BaseServiceTest { } } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } @@ -185,7 +185,7 @@ public class IdServiceTest extends BaseServiceTest { // Submit the request to the service and store the response. IdClient client = new IdClient(); - ClientResponse res = client.read(knownResourceId); + Response res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -197,7 +197,7 @@ public class IdServiceTest extends BaseServiceTest { invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); - String entity = res.getEntity(); + String entity = res.readEntity(String.class); Assert.assertNotNull(entity); if (logger.isDebugEnabled()) { logger.debug("entity body=\r" + entity); @@ -221,33 +221,36 @@ public class IdServiceTest extends BaseServiceTest { // Submit the request to the service and store the response. IdClient client = new IdClient(); - ClientResponse res = client.readList(); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); + Response res = client.readList(); + try { + int statusCode = res.getStatus(); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); - String entity = res.getEntity(); - Assert.assertNotNull(entity); - if (logger.isDebugEnabled()) { - logger.debug("entity body=\r" + entity); + String entity = res.readEntity(String.class); + Assert.assertNotNull(entity); + if (logger.isDebugEnabled()) { + logger.debug("entity body=\r" + entity); + } + } finally { + res.close(); } - } // Failure outcomes @@ -261,7 +264,7 @@ public class IdServiceTest extends BaseServiceTest { // Submit the request to the service and store the response. IdClient client = new IdClient(); - ClientResponse res = client.delete(knownResourceId); + Response res = client.delete(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match diff --git a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java index beb1e9a8d..d1eaa709f 100644 --- a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java +++ b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java @@ -36,4 +36,5 @@ import javax.ws.rs.Produces; @Produces({"application/xml"}) @Consumes({"application/xml"}) public interface IntakeProxy extends CollectionSpaceCommonListPoxProxy { + // Intentionally left blank } diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java index 6c60884fb..eaeed2fa5 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java @@ -250,7 +250,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { Response res = intakeClient.read(knownResourceId); try { assertStatusCode(res, testName); - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); IntakesCommon intake = (IntakesCommon) extractPart(input, intakeClient.getCommonPartName(), IntakesCommon.class); Assert.assertNotNull(intake); @@ -269,7 +269,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { AuthorityRefList list = null; try { assertStatusCode(res, testName); - list = (AuthorityRefList)res.getEntity(); + list = res.readEntity(AuthorityRefList.class); } finally { if (res != null) { res.close(); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index 237e090f0..e95c8e67b 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -41,7 +41,7 @@ import org.collectionspace.services.intake.CurrentLocationGroup; import org.collectionspace.services.intake.CurrentLocationGroupList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; + import org.testng.Assert; import org.testng.annotations.Test; import org.slf4j.Logger; @@ -271,7 +271,7 @@ public class IntakeServiceTest extends AbstractPoxServiceTestImpl orgInfo = new HashMap(); orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId); @@ -226,12 +235,18 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { try { assertStatusCode(res, testName); // Extract the common part from the response. - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); loaninCommon = (LoansinCommon) extractPart(input, loaninClient.getCommonPartName(), LoansinCommon.class); Assert.assertNotNull(loaninCommon); @@ -280,7 +280,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { AuthorityRefList list = null; try { assertStatusCode(res2, testName); - list = (AuthorityRefList)res2.getEntity(); + list = res2.readEntity(AuthorityRefList.class); Assert.assertNotNull(list); } finally { if (res2 != null) { diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java index 3bacb0a2d..6b87d4e15 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java @@ -266,7 +266,7 @@ public class LoaninServiceTest extends AbstractPoxServiceTestImpl { invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); newId = extractId(res); + Assert.assertNotNull(newId, "Could not create a new LoanOut record."); } finally { res.close(); } @@ -249,7 +248,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { try { assertStatusCode(res, testName); // Extract the common part from the response. - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); loanoutCommon = (LoansoutCommon) extractPart(input, loanoutClient.getCommonPartName(), LoansoutCommon.class); Assert.assertNotNull(loanoutCommon); @@ -273,7 +272,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { AuthorityRefList list = null; try { assertStatusCode(res2, testName); - list = (AuthorityRefList)res2.getEntity(); + list = res2.readEntity(AuthorityRefList.class); } finally { if (res2 != null) { res2.close(); @@ -337,17 +336,17 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { // Delete Person resource(s) (before PersonAuthority resources). for (String resourceId : personIdsCreated) { // Note: Any non-success responses are ignored and not reported. - personAuthClient.deleteItem(personAuthCSID, resourceId); + personAuthClient.deleteItem(personAuthCSID, resourceId).close(); } // Delete PersonAuthority resource(s). // Note: Any non-success response is ignored and not reported. if (personAuthCSID != null) { - personAuthClient.delete(personAuthCSID); + personAuthClient.delete(personAuthCSID).close(); // Delete Loans In resource(s). LoanoutClient loanoutClient = new LoanoutClient(); for (String resourceId : loanoutIdsCreated) { // Note: Any non-success responses are ignored and not reported. - loanoutClient.delete(resourceId); + loanoutClient.delete(resourceId).close(); } } } diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java index b7397abe6..36d00af2a 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java @@ -281,7 +281,7 @@ public class LoanoutServiceTest extends AbstractPoxServiceTestImpl createBlobFromFormData(String csid, // this is the Media resource CSID + public Response createBlobFromFormData(String csid, // this is the Media resource CSID MultipartFormDataOutput formDataOutput) { return getProxy().createBlobFromFormData(csid, formDataOutput); } @@ -71,14 +71,14 @@ public class MediaClient extends AbstractCommonListPoxServiceClientImpl createBlobFromUri(String csid, String blobUri) { + public Response createBlobFromUri(String csid, String blobUri) { return getProxy().createBlobFromUri(csid, blobUri, blobUri); //send the URI as both a query param and as content } /* * Create both a new media record */ - public ClientResponse createMediaAndBlobWithUri(PoxPayloadOut xmlPayload, String blobUri, boolean purgeOriginal) { + public Response createMediaAndBlobWithUri(PoxPayloadOut xmlPayload, String blobUri, boolean purgeOriginal) { return getProxy().createMediaAndBlobWithUri(xmlPayload.getBytes(), blobUri, purgeOriginal); } diff --git a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java index 9d39f503e..e78c14e5a 100644 --- a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java +++ b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java @@ -1,6 +1,5 @@ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput; import javax.ws.rs.Consumes; @@ -24,21 +23,21 @@ public interface MediaProxy extends CollectionSpaceCommonListPoxProxy { @POST @Path("{csid}") @Consumes("multipart/form-data") - ClientResponse createBlobFromFormData(@PathParam("csid") String csid, + Response createBlobFromFormData(@PathParam("csid") String csid, MultipartFormDataOutput formDataOutput); @POST @Path("{csid}") @Produces("application/xml") @Consumes("application/xml") - ClientResponsecreateBlobFromUri(@PathParam("csid") String csid, + Response createBlobFromUri(@PathParam("csid") String csid, @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri, String emptyXML); //this "emptyXML" param is needed to force RESTEasy to produce a Content-Type header for this POST @POST @Produces("application/xml") @Consumes("application/xml") - ClientResponsecreateMediaAndBlobWithUri(byte[] xmlPayload, + Response createMediaAndBlobWithUri(byte[] xmlPayload, @QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri, @QueryParam(BlobClient.BLOB_PURGE_ORIGINAL) boolean purgeOriginal); } diff --git a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java index 8e4596d9f..ac26cf8bc 100644 --- a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java +++ b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java @@ -196,7 +196,7 @@ public class MediaAuthRefsTest extends BaseServiceTest { MediaCommon media = null; try { assertStatusCode(res, testName); - input = new PoxPayloadIn((String)res.getEntity()); + input = new PoxPayloadIn(res.readEntity(String.class)); media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class); Assert.assertNotNull(media); logger.debug(objectAsXmlString(media, MediaCommon.class)); @@ -214,7 +214,7 @@ public class MediaAuthRefsTest extends BaseServiceTest { AuthorityRefList list = null; try { assertStatusCode(res2, testName); - list = (AuthorityRefList)res2.getEntity(); + list = res2.readEntity(AuthorityRefList.class); } finally { if (res2 != null) { res2.close(); @@ -258,7 +258,7 @@ public class MediaAuthRefsTest extends BaseServiceTest { // Delete Person resource(s) (before PersonAuthority resources). for (String resourceId : personIdsCreated) { // Note: Any non-success responses are ignored and not reported. - personAuthClient.deleteItem(personAuthCSID, resourceId); + personAuthClient.deleteItem(personAuthCSID, resourceId).close(); } // Delete PersonAuthority resource(s). // Note: Any non-success response is ignored and not reported. diff --git a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java index 52ec0a60c..b690e1c86 100644 --- a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java +++ b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java @@ -154,20 +154,18 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl res = null; + Response res = null; String mimeType = this.getMimeType(blobFile); logger.debug("Processing file URI: " + blobFile.getAbsolutePath()); logger.debug("MIME type is: " + mimeType); if (fromUri == true) { URL childUrl = blobFile.toURI().toURL(); - res = client.createBlobFromUri(mediaCsid, - childUrl.toString()); + res = client.createBlobFromUri(mediaCsid, childUrl.toString()); } else { MultipartFormDataOutput formData = new MultipartFormDataOutput(); OutputPart outputPart = formData.addFormData("file", blobFile, MediaType.valueOf(mimeType)); - res = client - .createBlobFromFormData(mediaCsid, formData); + res = client.createBlobFromFormData(mediaCsid, formData); } try { assertStatusCode(res, testName); @@ -178,7 +176,7 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true); // purge the original + Response mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true); // purge the original String mediaCsid = null; try { assertStatusCode(mediaRes, testName); @@ -214,7 +212,7 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl res = client.create(multipart); +// Response res = client.create(multipart); // assertStatusCode(res, testName); // String csid = extractId(res); // diff --git a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java index 544d0fcf6..42d623bbb 100644 --- a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java +++ b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java @@ -17,8 +17,7 @@ package org.collectionspace.services.client; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; +import javax.ws.rs.core.Response; /** * MovementClient.java @@ -55,7 +54,7 @@ public class MovementClient extends AbstractCommonListPoxServiceClientImpl readListSortedBy(String sortFieldName) { + public Response readListSortedBy(String sortFieldName) { return getProxy().readListSortedBy(sortFieldName); } @@ -65,7 +64,7 @@ public class MovementClient extends AbstractCommonListPoxServiceClientImpl keywordSearchSortedBy(String keywords, String sortFieldName) { + public Response keywordSearchSortedBy(String keywords, String sortFieldName) { return getProxy().keywordSearchSortedBy(keywords, sortFieldName); } } diff --git a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java index d5554a5d9..17fd5f539 100644 --- a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java +++ b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java @@ -24,15 +24,14 @@ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.jaxb.AbstractCommonList; /** * MovementProxy.java @@ -48,25 +47,25 @@ public interface MovementProxy extends CollectionSpaceCommonListPoxProxy { // Sorted list @GET @Produces({"application/xml"}) - ClientResponse readListSortedBy( + Response readListSortedBy( @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName); @Override @GET @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( + Response readIncludeDeleted( @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @Override @GET @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( + Response keywordSearchIncludeDeleted( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @GET @Produces({"application/xml"}) - ClientResponse keywordSearchSortedBy( + Response keywordSearchSortedBy( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName); } diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java index ebcb49a73..bea5e5446 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java @@ -226,7 +226,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { try { assertStatusCode(res, testName); // Extract and return the common part of the record. - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); PayloadInputPart payloadInputPart = input.getPart(movementClient.getCommonPartName()); if (payloadInputPart != null) { movementCommon = (MovementsCommon) payloadInputPart.getBody(); @@ -249,7 +249,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { AuthorityRefList list = null; try { assertStatusCode(res2, testName); - list = (AuthorityRefList)res2.getEntity(); + list = res2.readEntity(AuthorityRefList.class); } finally { if (res2 != null) { res2.close(); @@ -313,18 +313,18 @@ public class MovementAuthRefsTest extends BaseServiceTest { // Delete Person resource(s) (before PersonAuthority resources). for (String resourceId : personIdsCreated) { // Note: Any non-success responses are ignored and not reported. - personAuthClient.deleteItem(personAuthCSID, resourceId); + personAuthClient.deleteItem(personAuthCSID, resourceId).close(); } // Delete PersonAuthority resource(s). // Note: Any non-success response is ignored and not reported. if (personAuthCSID != null) { - personAuthClient.delete(personAuthCSID); + personAuthClient.delete(personAuthCSID).close(); } // Delete Movement resource(s). MovementClient movementClient = new MovementClient(); for (String resourceId : movementIdsCreated) { // Note: Any non-success responses are ignored and not reported. - movementClient.delete(resourceId); + movementClient.delete(resourceId).close(); } } diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java index 2c6e27093..eb020ff11 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java @@ -430,13 +430,12 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); final String EMPTY_SORT_FIELD_NAME = ""; - ClientResponse res = - client.readListSortedBy(EMPTY_SORT_FIELD_NAME); + Response res = client.readListSortedBy(EMPTY_SORT_FIELD_NAME); try { assertStatusCode(res, testName); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } @@ -454,13 +453,12 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - ClientResponse res = - client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE); + Response res = client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE); try { assertStatusCode(res, testName); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } @@ -476,14 +474,13 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); final String INVALID_SORT_ORDER_IDENTIFIER = "NO_DIRECTION"; - ClientResponse res = - client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE + Response res = client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE + " " + INVALID_SORT_ORDER_IDENTIFIER); try { assertStatusCode(res, testName); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } } @@ -636,7 +633,7 @@ public class MovementSortByTest extends BaseServiceTest { try { assertStatusCode(res, testName); // Extract and return the common part of the record. - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); if (payloadInputPart != null) { movementCommon = (MovementsCommon) payloadInputPart.getBody(); @@ -677,11 +674,11 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - ClientResponse res = client.readListSortedBy(sortFieldName); + Response res = client.readListSortedBy(sortFieldName); AbstractCommonList list = null; try { assertStatusCode(res, testName); - list = res.getEntity(); + list = res.readEntity(AbstractCommonList.class); } finally { if (res != null) { res.close(); @@ -702,15 +699,14 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - ClientResponse res = - client.keywordSearchSortedBy(keywords, sortFieldName); + Response res = client.keywordSearchSortedBy(keywords, sortFieldName); AbstractCommonList list = null; try { assertStatusCode(res, testName); - list = res.getEntity(); + list = res.readEntity(AbstractCommonList.class); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } diff --git a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java index 2445fb38b..a1997c3c2 100644 --- a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java +++ b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java @@ -45,8 +45,6 @@ import org.collectionspace.services.objectexit.StructuredDateGroup; import org.collectionspace.services.objectexit.ObjectexitCommon; import org.collectionspace.services.person.PersonTermGroup; -import org.jboss.resteasy.client.ClientResponse; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; @@ -125,23 +123,28 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest PoxPayloadOut multipart = createObjectExitInstance(depositorRefName, "exitNumber-" + identifier, CURRENT_DATE_UTC); Response res = objectexitClient.create(multipart); + String newId = null; try { assertStatusCode(res, testName); + newId = extractId(res); + Assert.assertNotNull(newId, "Could not create a new ObjectExit record."); if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below. - knownResourceId = extractId(res); + knownResourceId = newId; } } finally { if (res != null) { res.close(); } } - objectexitIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup + + objectexitIdsCreated.add(newId);// Store the IDs from every resource created; delete on cleanup } protected void createPersonRefs() { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified. - PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); Response res = personAuthClient.create(multipart); try { assertStatusCode(res, "createPersonRefs (not a surefire test)"); @@ -203,7 +206,7 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest ObjectexitCommon objectexit = null; try { assertStatusCode(res, testName); - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); objectexit = (ObjectexitCommon) extractPart(input, objectexitClient.getCommonPartName(), ObjectexitCommon.class); Assert.assertNotNull(objectexit); logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class)); @@ -222,7 +225,7 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest AuthorityRefList list = null; try { assertStatusCode(res2, testName); - list = (AuthorityRefList)res2.getEntity(); + list = res2.readEntity(AuthorityRefList.class); } finally { if (res2 != null) { res2.close(); @@ -265,17 +268,17 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest // Delete Person resource(s) (before PersonAuthority resources). for (String resourceId : personIdsCreated) { // Note: Any non-success responses are ignored and not reported. - personAuthClient.deleteItem(personAuthCSID, resourceId); + personAuthClient.deleteItem(personAuthCSID, resourceId).close(); } // Delete PersonAuthority resource(s). // Note: Any non-success response is ignored and not reported. if (personAuthCSID != null) { - personAuthClient.delete(personAuthCSID); + personAuthClient.delete(personAuthCSID).close(); // Delete Loans In resource(s). ObjectExitClient objectexitClient = new ObjectExitClient(); for (String resourceId : objectexitIdsCreated) { // Note: Any non-success responses are ignored and not reported. - objectexitClient.delete(resourceId); + objectexitClient.delete(resourceId).close(); } } } diff --git a/services/organization/client/pom.xml b/services/organization/client/pom.xml index 1543ec943..ed9089b84 100644 --- a/services/organization/client/pom.xml +++ b/services/organization/client/pom.xml @@ -34,7 +34,7 @@ org.collectionspace.services org.collectionspace.services.common true - + org.collectionspace.services org.collectionspace.services.client diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java index 53c37e3cd..ba52d76fd 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java @@ -92,8 +92,10 @@ public class OrgAuthorityClientUtils { * @return */ public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client){ - if(client==null) + if (client == null) { client = new OrgAuthorityClient(); + } + Response res = client.readItem(inAuthority, csid); try { int statusCode = res.getStatus(); diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java index db57d8aa7..58f7e5866 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java @@ -302,7 +302,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTestorg.collectionspace.services org.collectionspace.services.jaxb ${project.version} - + org.collectionspace.services org.collectionspace.services.authority.jaxb diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java index cb4fb2989..16aca218f 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -43,11 +43,10 @@ import org.collectionspace.services.person.PersonTermGroupList; import org.collectionspace.services.person.PersonsCommon; import org.collectionspace.services.person.PersonauthoritiesCommon; import org.collectionspace.services.person.SchoolOrStyleList; -import org.jboss.resteasy.client.ClientResponse; -//import org.jboss.resteasy.plugins.providers.multipart.OutputPart; +import org.collectionspace.services.person.StructuredDateGroup; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.collectionspace.services.person.StructuredDateGroup; /** * The Class PersonAuthorityClientUtils. @@ -77,7 +76,7 @@ public class PersonAuthorityClientUtils { } //FIXME: remove the following try catch once Aron fixes signatures try { - PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class)); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input, client.getCommonPartName(), PersonauthoritiesCommon.class); @@ -111,7 +110,7 @@ public class PersonAuthorityClientUtils { } //FIXME: remove the following try catch once Aron fixes signatures try { - PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class)); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); PersonsCommon person = (PersonsCommon) CollectionSpaceClientUtils.extractPart(input, client.getItemCommonPartName(), PersonsCommon.class); @@ -382,23 +381,7 @@ public class PersonAuthorityClientUtils { logger.debug("id=" + id); } return id; - } - - public static String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - // FIXME: This may throw an NPE if the Location: header isn't present - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - if(logger.isDebugEnabled()){ - logger.debug("extractId:uri=" + uri); - } - String[] segments = uri.split("/"); - String id = segments[segments.length - 1]; - if(logger.isDebugEnabled()){ - logger.debug("id=" + id); - } - return id; - } - + } /** * Returns an error message indicating that the status code returned by a diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index b47f32065..57dfce266 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -529,7 +529,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest readList() { + public Response readList() { return getProxy().readList(); } @@ -80,7 +81,7 @@ public class RelationClient extends AbstractPoxServiceClientImpl readList(String subjectCsid, + public Response readList(String subjectCsid, String subjectType, String predicate, String objectCsid, @@ -88,7 +89,7 @@ public class RelationClient extends AbstractPoxServiceClientImpl readList(String subjectCsid, + public Response readList(String subjectCsid, String subjectType, String predicate, String objectCsid, diff --git a/services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java b/services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java index 0ea4d843d..d31813795 100644 --- a/services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java +++ b/services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java @@ -9,8 +9,8 @@ import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.client.IRelationsManager; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; /** * @version $Revision:$ @@ -22,24 +22,24 @@ public interface RelationProxy extends CollectionSpacePoxProxy readList(); + Response readList(); @Override @GET @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( + Response readIncludeDeleted( @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @Override @GET @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( + Response keywordSearchIncludeDeleted( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState); @GET @Produces({"application/xml"}) - ClientResponse readList( + Response readList( @QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid, @QueryParam(IRelationsManager.SUBJECT_TYPE_QP) String subjectType, @QueryParam(IRelationsManager.PREDICATE_QP) String predicate, @@ -48,7 +48,7 @@ public interface RelationProxy extends CollectionSpacePoxProxy readList( + Response readList( @QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid, @QueryParam(IRelationsManager.SUBJECT_TYPE_QP) String subjectType, @QueryParam(IRelationsManager.PREDICATE_QP) String predicate, diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java index 2ab912cec..a2bb52280 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java @@ -26,12 +26,8 @@ */ package org.collectionspace.services.client; -import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; - import org.collectionspace.services.common.invocable.InvocationContext; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; /** * A ReportClient. @@ -80,12 +76,12 @@ public class ReportClient extends AbstractCommonListPoxServiceClientImpl readListFiltered( + public Response readListFiltered( String docType, String mode) { return getProxy().readListFiltered(docType, mode); } - public ClientResponse publishReport(String csid, + public Response publishReport(String csid, InvocationContext invContext) { return getProxy().publishReport(csid, invContext); } diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java index 8dc0a5886..2d20da2cb 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java @@ -36,8 +36,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.invocable.InvocationContext; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -50,13 +48,13 @@ public interface ReportProxy extends CollectionSpaceCommonListPoxProxy { @GET @Produces({"application/xml"}) - ClientResponse readListFiltered( + Response readListFiltered( @QueryParam(IQueryManager.SEARCH_TYPE_DOCTYPE) String docType, @QueryParam(IQueryManager.SEARCH_TYPE_INVOCATION_MODE) String mode); @POST @Path("{csid}/publish") - ClientResponse publishReport(@PathParam("csid") String csid, + Response publishReport(@PathParam("csid") String csid, InvocationContext invContext); } diff --git a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java index 03cf45177..e9f753bb5 100644 --- a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java +++ b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java @@ -128,21 +128,25 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl res = client.publishReport(reportCsid, invocationContext); - int statusCode = res.getStatus(); - setupCreate(); - - // Check the status code of the response: does it match - // the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res = client.publishReport(reportCsid, invocationContext); + try { + int statusCode = res.getStatus(); + setupCreate(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + String publicItemCsid = extractId(res); + Assert.assertNotNull(publicItemCsid); + } finally { + res.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - - String publicItemCsid = extractId(res); - Assert.assertNotNull(publicItemCsid); } /* (non-Javadoc) @@ -161,16 +165,17 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl res = client.readListFiltered(testDocType, "single"); + Response res = client.readListFiltered(testDocType, "single"); AbstractCommonList list = null; try { assertStatusCode(res, testName); - list = res.getEntity(); + list = res.readEntity(AbstractCommonList.class); } finally { if (res != null) { - res.releaseConnection(); + res.close(); } } + List items = list.getListItem(); // We must find the basic one we created boolean fFoundBaseItem = false; @@ -181,7 +186,8 @@ public class ReportServiceTest extends AbstractPoxServiceTestImplorg.jboss.resteasy resteasy-multipart-provider + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + commons-httpclient commons-httpclient diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java index 2c74259bb..f7e8de43a 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java @@ -110,7 +110,7 @@ public class AuthenticationServiceTest extends BaseServiceTest res = accountClient.create(account); + Response res = accountClient.create(account); try { int statusCode = res.getStatus(); @@ -146,23 +146,26 @@ public class AuthenticationServiceTest extends BaseServiceTest res = accountClient.create(account); - int statusCode = res.getStatus(); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": george status = " + statusCode); - } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - - // Store the ID returned from this create operation - // for additional tests below. - georgeAccountId = extractId(res); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": georgeAccountId=" + georgeAccountId); + Response res = accountClient.create(account); + try { + int statusCode = res.getStatus(); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": george status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + // Store the ID returned from this create operation + // for additional tests below. + georgeAccountId = extractId(res); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": georgeAccountId=" + georgeAccountId); + } + } finally { + res.close(); } - res.releaseConnection(); + //deactivate setupUpdate(); account.setStatus(Status.INACTIVE); @@ -173,16 +176,19 @@ public class AuthenticationServiceTest extends BaseServiceTest res1 = accountClient.update(georgeAccountId, account); - statusCode = res1.getStatus(); - // Check the status code of the response: does it match the expected response(s)? - if (logger.isDebugEnabled()) { - logger.debug(testName + ": status = " + statusCode); + Response res1 = accountClient.update(georgeAccountId, account); + try { + int statusCode = res1.getStatus(); + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + res1.close(); } - Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), - invalidStatusCodeMessage(testRequestType, statusCode)); - Assert.assertEquals(statusCode, testExpectedStatusCode); - res1.releaseConnection(); } diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java index c9f079ec1..264d04445 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java @@ -35,7 +35,6 @@ import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.account.AccountsCommon; import org.collectionspace.services.authorization.AccountRole; @@ -414,7 +413,7 @@ public class AuthorizationServiceTest extends BaseServiceTest res = permClient.create(permission); + Response res = permClient.create(permission); try { assertStatusCode(res, "CreatePermission"); result = extractId(res); @@ -693,7 +692,7 @@ public class AuthorizationServiceTest extends BaseServiceTest res = roleClient.create(role); + Response res = roleClient.create(role); try { assertStatusCode(res, "CreateRole"); result = extractId(res); @@ -727,7 +726,7 @@ public class AuthorizationServiceTest extends BaseServiceTest res = accountClient.create(account); + Response res = accountClient.create(account); try { assertStatusCode(res, "CreateAccount"); result = extractId(res); @@ -762,7 +761,7 @@ public class AuthorizationServiceTest extends BaseServiceTest res = client.create(av.getAccountId(), accRole); + Response res = client.create(av.getAccountId(), accRole); try { assertStatusCode(res, "CreateAccountRole"); result = extractId(res); @@ -803,7 +802,7 @@ public class AuthorizationServiceTest extends BaseServiceTest res = client.create(pv.getPermissionId(), permRole); + Response res = client.create(pv.getPermissionId(), permRole); try { assertStatusCode(res, "CreatePermissionRole"); result = extractId(res); diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java index 2e28b189a..9cfb592b4 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java @@ -33,6 +33,7 @@ import java.util.Date; import java.util.Hashtable; import java.util.List; import javax.ws.rs.core.Response; + import org.collectionspace.services.account.AccountsCommon; import org.collectionspace.services.authorization.AccountRole; import org.collectionspace.services.authorization.AccountValue; @@ -64,7 +65,6 @@ import org.collectionspace.services.client.RoleFactory; import org.collectionspace.services.client.test.BaseServiceTest; import org.collectionspace.services.dimension.DimensionsCommon; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.client.ClientResponse; import org.testng.Assert; import org.testng.annotations.Test; @@ -371,7 +371,7 @@ public class MultiTenancyTest extends BaseServiceTest { Response res = client.read(id); try { assertStatusCode(res, testName); - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); result = (DimensionsCommon) extractPart(input, client.getCommonPartName(), DimensionsCommon.class); } finally { @@ -571,7 +571,7 @@ public class MultiTenancyTest extends BaseServiceTest { "default permissions for " + resName, actions, effect, true, true, true); permission.setTenantId(tenantId); - ClientResponse res = permClient.create(permission); + Response res = permClient.create(permission); try { assertStatusCode(res, "CreatePermission"); result = extractId(res); @@ -610,7 +610,7 @@ public class MultiTenancyTest extends BaseServiceTest { roleName, //the display name "role for " + roleName, true); role.setTenantId(tenantId); - ClientResponse res = roleClient.create(role); + Response res = roleClient.create(role); try { assertStatusCode(res, "CreateRole"); result = extractId(res); @@ -648,7 +648,7 @@ public class MultiTenancyTest extends BaseServiceTest { AccountsCommon account = AccountFactory.createAccountInstance( userName, userName, userName, email, tenantId, true, false, true, true); - ClientResponse res = accountClient.create(account); + Response res = accountClient.create(account); try { assertStatusCode(res, "CreateAccount"); result = extractId(res); @@ -687,7 +687,7 @@ public class MultiTenancyTest extends BaseServiceTest { AccountRoleClient client = new AccountRoleClient(); UserInfo ui = tenantAdminUsers.get(tenantId); client.setAuth(true, ui.userName, true, ui.password, true); - ClientResponse res = client.create(av.getAccountId(), accRole); + Response res = client.create(av.getAccountId(), accRole); try { assertStatusCode(res, "CreateAccountRole"); result = extractId(res); @@ -733,7 +733,7 @@ public class MultiTenancyTest extends BaseServiceTest { PermissionRoleClient client = new PermissionRoleClient(); UserInfo ui = tenantAdminUsers.get(tenantId); client.setAuth(true, ui.userName, true, ui.password, true); - ClientResponse res = client.create(pv.getPermissionId(), permRole); + Response res = client.create(pv.getPermissionId(), permRole); try { assertStatusCode(res, "createPermissionRole"); result = extractId(res); diff --git a/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java b/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java index 5ec63fdea..5125a8e7d 100644 --- a/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java +++ b/services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java @@ -95,7 +95,7 @@ public class ServiceGroupServiceTest extends BaseServiceTest if (getLogger().isDebugEnabled()) { getLogger().debug("Reading part " + partLabel + " ..."); } - PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity()); + PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class)); PayloadInputPart payloadInputPart = input.getPart(partLabel); Assert.assertNotNull(payloadInputPart, "Part " + partLabel + " was unexpectedly null."); diff --git a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java index 49fc0d455..9fda7e044 100644 --- a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java +++ b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java @@ -203,7 +203,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest