From 8b6ad78ca1c37eac5d870b41d678a3225fa35ed5 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 16 Feb 2011 00:16:30 +0000 Subject: [PATCH] CSPACE-3574: Merging Plain Old XML payload work into trunk. --- services/account/client/.classpath | 267 ++++++- services/account/client/.project | 48 +- .../services/client/AccountClient.java | 10 +- .../services/client/AccountRoleClient.java | 6 + .../client/test/AccountRoleServiceTest.java | 8 +- .../client/test/AccountServiceTest.java | 5 + services/account/jaxb/.classpath | 76 +- services/account/jaxb/.project | 40 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/account/pstore/.classpath | 72 +- services/account/pstore/.project | 41 +- services/account/service/.classpath | 323 ++++++++- services/account/service/.project | 51 +- .../nuxeo-platform-cs-acquisition/.classpath | 14 +- .../nuxeo-platform-cs-acquisition/.project | 38 +- services/acquisition/client/.classpath | 320 ++++++++- services/acquisition/client/.project | 53 +- .../services/client/AcquisitionClient.java | 34 +- .../services/client/AcquisitionProxy.java | 16 +- .../client/test/AcquisitionAuthRefsTest.java | 679 +++++++++--------- .../client/test/AcquisitionServiceTest.java | 80 ++- services/acquisition/jaxb/.classpath | 39 +- services/acquisition/jaxb/.project | 40 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/acquisition/service/.classpath | 317 +++++++- services/acquisition/service/.project | 53 +- services/acquisition/service/pom.xml | 5 + .../acquisition/AcquisitionResource.java | 70 +- services/authentication/client/.classpath | 258 ++++++- services/authentication/client/.project | 47 +- services/authentication/jaxb/.classpath | 75 +- services/authentication/jaxb/.project | 38 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/authentication/pstore/.classpath | 71 +- services/authentication/pstore/.project | 41 +- services/authentication/service/.classpath | 49 +- services/authentication/service/.project | 38 +- services/authorization-mgt/client/.classpath | 290 +++++++- services/authorization-mgt/client/.project | 44 +- .../services/client/PermissionClient.java | 12 +- .../services/client/PermissionRoleClient.java | 5 + .../services/client/RoleClient.java | 10 +- .../services/client/RolePermissionClient.java | 5 + .../test/PermissionRoleServiceTest.java | 7 +- .../client/test/PermissionServiceTest.java | 12 +- .../test/RolePermissionServiceTest.java | 12 +- .../client/test/RoleServiceTest.java | 12 +- services/authorization-mgt/import/.classpath | 338 ++++++++- services/authorization-mgt/import/.project | 47 +- services/authorization-mgt/service/.classpath | 351 ++++++++- services/authorization-mgt/service/.project | 49 +- .../services/authorization/RoleResource.java | 2 +- services/authorization/jaxb/.classpath | 71 +- services/authorization/jaxb/.project | 38 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/authorization/pstore/.classpath | 71 +- services/authorization/pstore/.project | 40 +- services/authorization/service/.classpath | 114 ++- services/authorization/service/.project | 42 +- .../.classpath | 14 +- .../.project | 38 +- services/collectionobject/client/.classpath | 322 ++++++++- services/collectionobject/client/.project | 55 +- .../client/CollectionObjectClient.java | 32 +- .../client/CollectionObjectFactory.java | 25 +- .../client/CollectionObjectProxy.java | 20 +- .../test/CollectionObjectAuthRefsTest.java | 45 +- .../test/CollectionObjectSearchTest.java | 40 +- .../test/CollectionObjectServiceTest.java | 274 +++---- .../test-data/cspace-2779-utf-8-create.xml | 4 +- services/collectionobject/jaxb/.classpath | 39 +- services/collectionobject/jaxb/.project | 41 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- .../client/sample/Sample.java | 94 +-- services/collectionobject/service/.classpath | 333 ++++++++- services/collectionobject/service/.project | 59 +- services/collectionobject/service/pom.xml | 10 + .../CollectionObjectResource.java | 81 ++- .../CollectionObjectValidatorHandler.java | 7 +- 79 files changed, 4983 insertions(+), 1484 deletions(-) diff --git a/services/account/client/.classpath b/services/account/client/.classpath index 425cd1620..127af1355 100644 --- a/services/account/client/.classpath +++ b/services/account/client/.classpath @@ -1,10 +1,259 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/account/client/.project b/services/account/client/.project index 0498931c0..4d5024773 100644 --- a/services/account/client/.project +++ b/services/account/client/.project @@ -1,26 +1,24 @@ - - org.collectionspace.services.account.client - - - org.collectionspace.services.client - org.collectionspace.services.common - org.collectionspace.services.account.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.account.client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.account.jaxb + org.collectionspace.services.authorization-mgt.client + org.collectionspace.services.authorization.jaxb + org.collectionspace.services.client + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file 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 8c0b0bd8e..758b172c1 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 @@ -43,18 +43,24 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * @version $Revision:$ */ public class AccountClient extends AbstractServiceClientImpl { + public static final String SERVICE_NAME = "accounts"; /** * */ private AccountProxy accountProxy; - /* (non-Javadoc) + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* (non-Javadoc) * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() */ @Override public String getServicePathComponent() { - return "accounts"; + return SERVICE_NAME; } /** 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 265c2c1c4..f29dab264 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 @@ -42,6 +42,12 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * @version $Revision:$ */ public class AccountRoleClient extends AbstractServiceClientImpl { + public static final String SERVICE_NAME = "accountroles"; + + @Override + public String getServiceName() { + return AccountRoleClient.SERVICE_NAME; + } /** * 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 9326589c5..b3fbbeef7 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 @@ -506,7 +506,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { * @throws Exception */ @Test(dependsOnMethods = {"create"}) - public void testSubmitRequest() throws Exception { + public void testSubmitRequest() throws Exception { //FIXME: REM - This is not testing a submit /accounts/*/accountroles, but instead just to /accounts // Expected status code: 200 OK final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); @@ -698,4 +698,10 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { res.releaseConnection(); } } + + @Override + protected String getServiceName() { + // AccountRoles service is a sub-service of the Account service, so we return Account's service name + return AccountClient.SERVICE_NAME; + } } 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 66e478fd7..9e75092ac 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 @@ -62,6 +62,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { /** The add tenant. */ static boolean addTenant = true; + @Override + public String getServiceName() { + return AccountClient.SERVICE_NAME; + } + /* * This method is called only by the parent class, AbstractServiceTestImpl */ diff --git a/services/account/jaxb/.classpath b/services/account/jaxb/.classpath index 1707f3e6f..fe7bcbbe4 100644 --- a/services/account/jaxb/.classpath +++ b/services/account/jaxb/.classpath @@ -1,11 +1,67 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/account/jaxb/.project b/services/account/jaxb/.project index 2d3d17c62..52f364deb 100644 --- a/services/account/jaxb/.project +++ b/services/account/jaxb/.project @@ -1,23 +1,19 @@ - - org.collectionspace.services.account.jaxb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.account.jaxb + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.hyperjaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/account/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/account/jaxb/.settings/org.maven.ide.eclipse.prefs index c9f591419..75847f06f 100644 --- a/services/account/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/account/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:14:19 PST 2010 +#Wed Jan 19 22:49:28 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/account/pstore/.classpath b/services/account/pstore/.classpath index 1ca941f44..bf7e302fa 100644 --- a/services/account/pstore/.classpath +++ b/services/account/pstore/.classpath @@ -1,8 +1,66 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/account/pstore/.project b/services/account/pstore/.project index 2281d2829..5e557af3e 100644 --- a/services/account/pstore/.project +++ b/services/account/pstore/.project @@ -1,23 +1,20 @@ - - org.collectionspace.services.account.pstore - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.account.pstore + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.account.jaxb + org.collectionspace.services.hyperjaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/account/service/.classpath b/services/account/service/.classpath index 425cd1620..6e273edbf 100644 --- a/services/account/service/.classpath +++ b/services/account/service/.classpath @@ -1,10 +1,315 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/account/service/.project b/services/account/service/.project index b0a5945b2..cd240626c 100644 --- a/services/account/service/.project +++ b/services/account/service/.project @@ -1,27 +1,26 @@ - - org.collectionspace.services.account.service - - - org.collectionspace.services.account.jaxb - org.collectionspace.services.authentication.jaxb - org.collectionspace.services.authorization.jaxb - org.collectionspace.services.common - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.account.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.account.jaxb + org.collectionspace.services.authentication.jaxb + org.collectionspace.services.authorization.jaxb + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.classpath b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.classpath index 199bbbbdb..8ad8fad8e 100644 --- a/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.classpath +++ b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.classpath @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.project b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.project index 669e34edd..d2ac5a656 100644 --- a/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.project +++ b/services/acquisition/3rdparty/nuxeo-platform-cs-acquisition/.project @@ -1,23 +1,17 @@ - - org.collectionspace.services.acquisition.3rdparty.nuxeo - Acquisition Nuxeo Document Type - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.acquisition.3rdparty.nuxeo + Acquisition Nuxeo Document Type. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/acquisition/client/.classpath b/services/acquisition/client/.classpath index 425cd1620..5506e7b69 100644 --- a/services/acquisition/client/.classpath +++ b/services/acquisition/client/.classpath @@ -1,10 +1,312 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/acquisition/client/.project b/services/acquisition/client/.project index 24658c589..e799aeda3 100644 --- a/services/acquisition/client/.project +++ b/services/acquisition/client/.project @@ -1,27 +1,28 @@ - - org.collectionspace.services.acquisition.client - - - org.collectionspace.services.acquisition.jaxb - org.collectionspace.services.client - org.collectionspace.services.common - org.collectionspace.services.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.acquisition.client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.acquisition.jaxb + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java index f8bd3aef6..e78a7ebbb 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java @@ -8,8 +8,6 @@ import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.spi.ResteasyProviderFactory; /** @@ -18,18 +16,22 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * @version $Revision:$ */ public class AcquisitionClient extends AbstractServiceClientImpl { + public static final String SERVICE_NAME = "acquisitions"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; - /* (non-Javadoc) - * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() - */ + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override public String getServicePathComponent() { - return "acquisitions"; + return SERVICE_PATH_COMPONENT; } - // FIXME: Is the "instance" member still needed/used? - /** - * - */ -// private static final AcquisitionClient instance = new AcquisitionClient(); + /** * */ @@ -86,7 +88,7 @@ public class AcquisitionClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return acquisitionProxy.read(csid); } @@ -104,8 +106,8 @@ public class AcquisitionClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.hello.client.IntakeProxy#createIntake(org.collectionspace.hello.Intake) */ - public ClientResponse create(MultipartOutput multipart) { - return acquisitionProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return acquisitionProxy.create(xmlPayload.getBytes()); } /** @@ -114,8 +116,8 @@ public class AcquisitionClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.hello.client.IntakeProxy#updateIntake(java.lang.Long, org.collectionspace.hello.Intake) */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return acquisitionProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut xmlPayload) { + return acquisitionProxy.update(csid, xmlPayload.getBytes()); } /** diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java index 6ba5e01a9..3aaf02907 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java @@ -13,40 +13,36 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; /** * @version $Revision:$ */ -@Path("/acquisitions/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Path(AcquisitionClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) public interface AcquisitionProxy extends CollectionSpaceProxy { @GET - @Produces({"application/xml"}) ClientResponse readList(); //(C)reate @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(byte[] xmlPayload); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); // List Authority references @GET - @Produces({"application/xml"}) @Path("/{csid}/authorityrefs/") ClientResponse getAuthorityRefs(@PathParam("csid") String csid); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, byte[] xmlPayload); //(D)elete @DELETE diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java index f5b72ef5a..09ff900c4 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java @@ -33,8 +33,11 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.AcquisitionClient; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.acquisition.AcquisitionsCommon; @@ -45,8 +48,6 @@ import org.collectionspace.services.acquisition.OwnerList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -64,117 +65,117 @@ import org.slf4j.LoggerFactory; */ public class AcquisitionAuthRefsTest extends BaseServiceTest { - private final String CLASS_NAME = AcquisitionAuthRefsTest.class.getName(); - private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - - // Instance variables specific to this test. - final String SERVICE_PATH_COMPONENT = "acquisitions"; - final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; - private String knownResourceId = null; - private List acquisitionIdsCreated = new ArrayList(); - private List personIdsCreated = new ArrayList(); - private String personAuthCSID = null; - private String acquisitionAuthorizerRefName = null; - private List acquisitionFundingSourcesRefNames = new ArrayList(); - private List ownersRefNames = new ArrayList(); - private List acquisitionSourcesRefNames = new ArrayList(); - private final int NUM_AUTH_REFS_EXPECTED = 5; - - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() - */ - @Override - protected CollectionSpaceClient getClientInstance() { - throw new UnsupportedOperationException(); //method not supported (or needed) in this test class - } - - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override + private final String CLASS_NAME = AcquisitionAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + + // Instance variables specific to this test. + // final String SERVICE_PATH_COMPONENT = AcquisitionClient.SERVICE_PATH_COMPONENT;//"acquisitions"; + final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; + private String knownResourceId = null; + private List acquisitionIdsCreated = new ArrayList(); + private List personIdsCreated = new ArrayList(); + private String personAuthCSID = null; + private String acquisitionAuthorizerRefName = null; + private List acquisitionFundingSourcesRefNames = new ArrayList(); + private List ownersRefNames = new ArrayList(); + private List acquisitionSourcesRefNames = new ArrayList(); + private final int NUM_AUTH_REFS_EXPECTED = 5; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() { + throw new UnsupportedOperationException(); //method not supported (or needed) in this test class + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) + */ + @Override protected AbstractCommonList getAbstractCommonList( ClientResponse response) { - throw new UnsupportedOperationException(); //method not supported (or needed) in this test class - } - - // --------------------------------------------------------------- - // CRUD tests : CREATE tests - // --------------------------------------------------------------- - // Success outcomes - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) - public void createWithAuthRefs(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - }; - - // Perform setup. - testSetup(STATUS_CREATED, ServiceRequestType.CREATE); - - // Submit the request to the service and store the response. - String identifier = createIdentifier(); - - // Create all the person refs and entities - createPersonRefs(); - - MultipartOutput multipart = createAcquisitionInstance( - "April 1, 2010", - acquisitionAuthorizerRefName, - acquisitionFundingSourcesRefNames, - ownersRefNames, - acquisitionSourcesRefNames); - - AcquisitionClient acquisitionClient = new AcquisitionClient(); - ClientResponse res = acquisitionClient.create(multipart); - - 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(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Store the ID returned from the first resource created - // for additional tests below. - if (knownResourceId == null){ - knownResourceId = extractId(res); - if (logger.isDebugEnabled()) { - logger.debug(testName + ": knownResourceId=" + knownResourceId); - } - } - - // Store the IDs from every resource created by tests, - // so they can be deleted after tests have been run. - acquisitionIdsCreated.add(extractId(res)); - } - - protected void createPersonRefs(){ - PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( - PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); - ClientResponse res = personAuthClient.create(multipart); - int statusCode = res.getStatus(); - - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, STATUS_CREATED); - personAuthCSID = extractId(res); - - String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); - - String csid = createPerson("Annie", "Authorizer", "annieAuth", authRefName); - acquisitionAuthorizerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); - personIdsCreated.add(csid); - - /* + throw new UnsupportedOperationException(); //method not supported (or needed) in this test class + } + + // --------------------------------------------------------------- + // CRUD tests : CREATE tests + // --------------------------------------------------------------- + // Success outcomes + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) + public void createWithAuthRefs(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); + + // Submit the request to the service and store the response. + String identifier = createIdentifier(); + + // Create all the person refs and entities + createPersonRefs(); + + PoxPayloadOut multipart = createAcquisitionInstance( + "April 1, 2010", + acquisitionAuthorizerRefName, + acquisitionFundingSourcesRefNames, + ownersRefNames, + acquisitionSourcesRefNames); + + AcquisitionClient acquisitionClient = new AcquisitionClient(); + ClientResponse res = acquisitionClient.create(multipart); + + 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(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Store the ID returned from the first resource created + // for additional tests below. + if (knownResourceId == null){ + knownResourceId = extractId(res); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": knownResourceId=" + knownResourceId); + } + } + + // Store the IDs from every resource created by tests, + // so they can be deleted after tests have been run. + acquisitionIdsCreated.add(extractId(res)); + } + + protected void createPersonRefs(){ + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); + ClientResponse res = personAuthClient.create(multipart); + int statusCode = res.getStatus(); + + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, STATUS_CREATED); + personAuthCSID = extractId(res); + + String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); + + String csid = createPerson("Annie", "Authorizer", "annieAuth", authRefName); + acquisitionAuthorizerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); + personIdsCreated.add(csid); + + /* csid = createPerson("Fran", "Funding-SourceOne", "franFundingSourceOne", authRefName); acquisitionFundingSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); personIdsCreated.add(csid); @@ -182,80 +183,80 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { csid = createPerson("Fahd", "Funding-SourceTwo", "fahdFundingSourceTwo", authRefName); acquisitionFundingSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); personIdsCreated.add(csid); - */ - - csid = createPerson("Owen", "OwnerOne", "owenOwnerOne", authRefName); - ownersRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); - personIdsCreated.add(csid); - - csid = createPerson("Orelia", "OwnerTwo", "oreliaOwnerTwo", authRefName); - ownersRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); - personIdsCreated.add(csid); - - csid = createPerson("Sammy", "SourceOne", "sammySourceOne", authRefName); - acquisitionSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); - personIdsCreated.add(csid); - - csid = createPerson("Serena", "SourceTwo", "serenaSourceTwo", authRefName); - acquisitionSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); - personIdsCreated.add(csid); - } - - protected String createPerson(String firstName, String surName, String shortId, String authRefName ) { - Map personInfo = new HashMap(); - personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); - personInfo.put(PersonJAXBSchema.SUR_NAME, surName); - personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); - PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - MultipartOutput multipart = - PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, - authRefName, personInfo, personAuthClient.getItemCommonPartName()); - ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); - int statusCode = res.getStatus(); - - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, STATUS_CREATED); - return extractId(res); - } - - // Success outcomes - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"createWithAuthRefs"}) - public void readAndCheckAuthRefs(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - }; - - // Perform setup. - testSetup(STATUS_OK, ServiceRequestType.READ); - - // Submit the request to the service and store the response. - AcquisitionClient acquisitionClient = new AcquisitionClient(); - ClientResponse res = acquisitionClient.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 + ".read: status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - MultipartInput input = (MultipartInput) res.getEntity(); - AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input, - acquisitionClient.getCommonPartName(), AcquisitionsCommon.class); - Assert.assertNotNull(acquisition); - - // Check a couple of fields - // Scalar fields - Assert.assertEquals(acquisition.getAcquisitionAuthorizer(), acquisitionAuthorizerRefName); - - // In repeatable groups of fields - /* + */ + + csid = createPerson("Owen", "OwnerOne", "owenOwnerOne", authRefName); + ownersRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); + personIdsCreated.add(csid); + + csid = createPerson("Orelia", "OwnerTwo", "oreliaOwnerTwo", authRefName); + ownersRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); + personIdsCreated.add(csid); + + csid = createPerson("Sammy", "SourceOne", "sammySourceOne", authRefName); + acquisitionSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); + personIdsCreated.add(csid); + + csid = createPerson("Serena", "SourceTwo", "serenaSourceTwo", authRefName); + acquisitionSourcesRefNames.add(PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null)); + personIdsCreated.add(csid); + } + + protected String createPerson(String firstName, String surName, String shortId, String authRefName ) { + Map personInfo = new HashMap(); + personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); + personInfo.put(PersonJAXBSchema.SUR_NAME, surName); + personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); + PoxPayloadOut multipart = + PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, + authRefName, personInfo, personAuthClient.getItemCommonPartName()); + ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); + int statusCode = res.getStatus(); + + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, STATUS_CREATED); + return extractId(res); + } + + // Success outcomes + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, + dependsOnMethods = {"createWithAuthRefs"}) + public void readAndCheckAuthRefs(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + testSetup(STATUS_OK, ServiceRequestType.READ); + + // Submit the request to the service and store the response. + AcquisitionClient acquisitionClient = new AcquisitionClient(); + ClientResponse res = acquisitionClient.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 + ".read: status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input, + acquisitionClient.getCommonPartName(), AcquisitionsCommon.class); + Assert.assertNotNull(acquisition); + + // Check a couple of fields + // Scalar fields + Assert.assertEquals(acquisition.getAcquisitionAuthorizer(), acquisitionAuthorizerRefName); + + // In repeatable groups of fields + /* AcquisitionFundingList acqFundingList = acquisition.getAcquisitionFundingList(); List acqFundings = acqFundingList.getAcquisitionFunding(); List acqFundingSourceRefNamesFound = new ArrayList(); @@ -264,128 +265,134 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { acqFundingSourceRefNamesFound.add(acqFundingSourceRefName); } Assert.assertTrue(acqFundingSourceRefNamesFound.containsAll(acquisitionFundingSourcesRefNames)); - */ - - // In scalar repeatable fields - OwnerList ownersList = acquisition.getOwners(); - List owners = ownersList.getOwner(); - for (String refName : owners) { - Assert.assertTrue(ownersRefNames.contains(refName)); - } - - AcquisitionSourceList acquisitionSources = acquisition.getAcquisitionSources(); - List sources = acquisitionSources.getAcquisitionSource(); - for (String refName : sources) { - Assert.assertTrue(acquisitionSourcesRefNames.contains(refName)); - } - - // Get the auth refs and check them - ClientResponse res2 = - acquisitionClient.getAuthorityRefs(knownResourceId); - statusCode = res2.getStatus(); - - if(logger.isDebugEnabled()){ - logger.debug(testName + ".getAuthorityRefs: status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - AuthorityRefList list = res2.getEntity(); - - List items = list.getAuthorityRefItem(); - int numAuthRefsFound = items.size(); - if(logger.isDebugEnabled()){ - logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED + - " authority references, found " + numAuthRefsFound); - } - Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED, - "Did not find all expected authority references! " + - "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound); - - // Optionally output additional data about list members for debugging. - boolean iterateThroughList = true; - if(iterateThroughList && logger.isDebugEnabled()){ - int i = 0; - for(AuthorityRefList.AuthorityRefItem item : items){ - logger.debug(testName + ": list-item[" + i + "] Field:" + - item.getSourceField() + "= " + - item.getAuthDisplayName() + - item.getItemDisplayName()); - logger.debug(testName + ": list-item[" + i + "] refName=" + - item.getRefName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - i++; - } - } - } - - - // --------------------------------------------------------------- - // Cleanup of resources created during testing - // --------------------------------------------------------------- - - /** - * Deletes all resources created by tests, after all tests have been run. - * - * This cleanup method will always be run, even if one or more tests fail. - * For this reason, it attempts to remove all resources created - * at any point during testing, even if some of those resources - * may be expected to be deleted by certain tests. - */ - @AfterClass(alwaysRun=true) - public void cleanUp() { - String noTest = System.getProperty("noTestCleanup"); - if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { - if (logger.isDebugEnabled()) { - logger.debug("Skipping Cleanup phase ..."); - } - return; - } - if (logger.isDebugEnabled()) { - logger.debug("Cleaning up temporary resources created for testing ..."); - } - AcquisitionClient acquisitionClient = new AcquisitionClient(); - for (String resourceId : acquisitionIdsCreated) { - // Note: Any non-success responses are ignored and not reported. - ClientResponse res = acquisitionClient.delete(resourceId); - res.releaseConnection(); - } - PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - // Delete persons before PersonAuth - for (String resourceId : personIdsCreated) { - // Note: Any non-success responses are ignored and not reported. - ClientResponse res = personAuthClient.deleteItem(personAuthCSID, resourceId); - res.releaseConnection(); - } - // Note: Any non-success response is ignored and not reported. - ClientResponse res = personAuthClient.delete(personAuthCSID); - res.releaseConnection(); - } - - // --------------------------------------------------------------- - // Utility methods used by tests above - // --------------------------------------------------------------- - @Override - public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; - } - - private MultipartOutput createAcquisitionInstance( - String accessionDate, - String acquisitionAuthorizer, - List acquisitionFundingSources, - List acqOwners, - List acquisitionSources) { - - AcquisitionsCommon acquisition = new AcquisitionsCommon(); - acquisition.setAccessionDate(accessionDate); - acquisition.setAcquisitionAuthorizer(acquisitionAuthorizer); - - // AcquisitionFunding-related authrefs fields are *not* currently - // enabled, as described in issue CSPACE-2818 - - /* + */ + + // In scalar repeatable fields + OwnerList ownersList = acquisition.getOwners(); + List owners = ownersList.getOwner(); + for (String refName : owners) { + Assert.assertTrue(ownersRefNames.contains(refName)); + } + + AcquisitionSourceList acquisitionSources = acquisition.getAcquisitionSources(); + List sources = acquisitionSources.getAcquisitionSource(); + for (String refName : sources) { + Assert.assertTrue(acquisitionSourcesRefNames.contains(refName)); + } + + // Get the auth refs and check them + ClientResponse res2 = + acquisitionClient.getAuthorityRefs(knownResourceId); + statusCode = res2.getStatus(); + + if(logger.isDebugEnabled()){ + logger.debug(testName + ".getAuthorityRefs: status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + AuthorityRefList list = res2.getEntity(); + + List items = list.getAuthorityRefItem(); + int numAuthRefsFound = items.size(); + if(logger.isDebugEnabled()){ + logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED + + " authority references, found " + numAuthRefsFound); + } + Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED, + "Did not find all expected authority references! " + + "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound); + + // Optionally output additional data about list members for debugging. + boolean iterateThroughList = true; + if(iterateThroughList && logger.isDebugEnabled()){ + int i = 0; + for(AuthorityRefList.AuthorityRefItem item : items){ + logger.debug(testName + ": list-item[" + i + "] Field:" + + item.getSourceField() + "= " + + item.getAuthDisplayName() + + item.getItemDisplayName()); + logger.debug(testName + ": list-item[" + i + "] refName=" + + item.getRefName()); + logger.debug(testName + ": list-item[" + i + "] URI=" + + item.getUri()); + i++; + } + } + } + + + // --------------------------------------------------------------- + // Cleanup of resources created during testing + // --------------------------------------------------------------- + + /** + * Deletes all resources created by tests, after all tests have been run. + * + * This cleanup method will always be run, even if one or more tests fail. + * For this reason, it attempts to remove all resources created + * at any point during testing, even if some of those resources + * may be expected to be deleted by certain tests. + */ + @AfterClass(alwaysRun=true) + public void cleanUp() { + String noTest = System.getProperty("noTestCleanup"); + if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { + if (logger.isDebugEnabled()) { + logger.debug("Skipping Cleanup phase ..."); + } + return; + } + if (logger.isDebugEnabled()) { + logger.debug("Cleaning up temporary resources created for testing ..."); + } + AcquisitionClient acquisitionClient = new AcquisitionClient(); + for (String resourceId : acquisitionIdsCreated) { + // Note: Any non-success responses are ignored and not reported. + ClientResponse res = acquisitionClient.delete(resourceId); + res.releaseConnection(); + } + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); + // Delete persons before PersonAuth + for (String resourceId : personIdsCreated) { + // Note: Any non-success responses are ignored and not reported. + ClientResponse res = personAuthClient.deleteItem(personAuthCSID, resourceId); + res.releaseConnection(); + } + // Note: Any non-success response is ignored and not reported. + ClientResponse res = personAuthClient.delete(personAuthCSID); + res.releaseConnection(); + } + + // --------------------------------------------------------------- + // Utility methods used by tests above + // --------------------------------------------------------------- + @Override + public String getServicePathComponent() { + return AcquisitionClient.SERVICE_PATH_COMPONENT; + } + + + @Override + protected String getServiceName() { + return AcquisitionClient.SERVICE_NAME; + } + + private PoxPayloadOut createAcquisitionInstance( + String accessionDate, + String acquisitionAuthorizer, + List acquisitionFundingSources, + List acqOwners, + List acquisitionSources) { + + AcquisitionsCommon acquisition = new AcquisitionsCommon(); + acquisition.setAccessionDate(accessionDate); + acquisition.setAcquisitionAuthorizer(acquisitionAuthorizer); + + // AcquisitionFunding-related authrefs fields are *not* currently + // enabled, as described in issue CSPACE-2818 + + /* AcquisitionFundingList acqFundingsList = new AcquisitionFundingList(); List acqFundings = acqFundingsList.getAcquisitionFunding(); int i = 0; @@ -400,33 +407,33 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { addtlAcqFunding.setAcquisitionFundingCurrency("USD"); acqFundings.add(addtlAcqFunding); acquisition.setAcquisitionFundingList(acqFundingsList); - */ - - OwnerList ownersList = new OwnerList(); - List owners = ownersList.getOwner(); - for (String owner: acqOwners) { - owners.add(owner); - } - acquisition.setOwners(ownersList); - - AcquisitionSourceList acqSourcesList = new AcquisitionSourceList(); - List acqSources = acqSourcesList.getAcquisitionSource(); - for (String acqSource: acquisitionSources) { - acqSources.add(acqSource); - } - acquisition.setAcquisitionSources(acqSourcesList); - - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); - AcquisitionClient acquisitionClient = new AcquisitionClient(); - commonPart.getHeaders().add("label", acquisitionClient.getCommonPartName()); - - if(logger.isDebugEnabled()){ - logger.debug("to be created, acquisition common"); - logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class)); - } - - return multipart; - } + */ + + OwnerList ownersList = new OwnerList(); + List owners = ownersList.getOwner(); + for (String owner: acqOwners) { + owners.add(owner); + } + acquisition.setOwners(ownersList); + + AcquisitionSourceList acqSourcesList = new AcquisitionSourceList(); + List acqSources = acqSourcesList.getAcquisitionSource(); + for (String acqSource: acquisitionSources) { + acqSources.add(acqSource); + } + acquisition.setAcquisitionSources(acqSourcesList); + + PoxPayloadOut multipart = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = + multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); + AcquisitionClient acquisitionClient = new AcquisitionClient(); + commonPart.setLabel(acquisitionClient.getCommonPartName()); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, acquisition common"); + logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class)); + } + + return multipart; + } } diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index 8213d966f..799678179 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -28,6 +28,10 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.client.AcquisitionClient; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.acquisition.AcquisitionsCommon; import org.collectionspace.services.acquisition.AcquisitionDateList; @@ -38,8 +42,6 @@ import org.collectionspace.services.acquisition.OwnerList; import org.jboss.resteasy.client.ClientResponse; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.testng.Assert; import org.testng.annotations.Test; @@ -64,6 +66,17 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { /** The known resource id. */ private String knownResourceId = null; + @Override + public String getServicePathComponent() { + return AcquisitionClient.SERVICE_PATH_COMPONENT; + } + + + @Override + protected String getServiceName() { + return AcquisitionClient.SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @@ -105,7 +118,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { String identifier = createIdentifier(); AcquisitionClient client = new AcquisitionClient(); - MultipartOutput multipart = createAcquisitionInstance(identifier); + PoxPayloadOut multipart = createAcquisitionInstance(identifier); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -302,7 +315,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { AcquisitionClient client = new AcquisitionClient(); // Submit the request to the service and store the response. - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -314,7 +327,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input, client.getCommonPartName(), AcquisitionsCommon.class); Assert.assertNotNull(acquisitionObject); @@ -355,7 +368,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); - ClientResponse res = client.read(NON_EXISTENT_ID); + ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -442,7 +455,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. AcquisitionClient client = new AcquisitionClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ logger.debug(testName + ": read status = " + res.getStatus()); } @@ -451,7 +464,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { if(logger.isDebugEnabled()){ logger.debug("got object to update with ID: " + knownResourceId); } - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input, client.getCommonPartName(), AcquisitionsCommon.class); @@ -464,9 +477,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class)); } // Submit the request to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); res = client.update(knownResourceId, output); int statusCode = res.getStatus(); @@ -479,7 +492,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); AcquisitionsCommon updatedAcquisition = (AcquisitionsCommon) extractPart(input, client.getCommonPartName(), AcquisitionsCommon.class); @@ -655,8 +668,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. AcquisitionClient client = new AcquisitionClient(); - MultipartOutput multipart = createAcquisitionInstance(NON_EXISTENT_ID); - ClientResponse res = + PoxPayloadOut multipart = createAcquisitionInstance(NON_EXISTENT_ID); + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); @@ -778,14 +791,6 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() - */ - @Override - public String getServicePathComponent() { - return new AcquisitionClient().getServicePathComponent(); - } - /** * Creates the acquisition instance. @@ -793,7 +798,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier * @return the multipart output */ - private MultipartOutput createAcquisitionInstance(String identifier) { + private PoxPayloadOut createAcquisitionInstance(String identifier) { AcquisitionsCommon acquisition = new AcquisitionsCommon(); acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-" + identifier); @@ -821,10 +826,10 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { owners.add("Second Owner-" + identifier); acquisition.setOwners(ownersList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(acquisition, + PoxPayloadOut multipart = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new AcquisitionClient().getCommonPartName()); + commonPart.setLabel(new AcquisitionClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, acquisition common"); @@ -846,16 +851,16 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { * @return * @throws Exception */ - private MultipartOutput createAcquisitionInstanceFromXml(String testName, String commonPartName, + private PoxPayloadOut createAcquisitionInstanceFromXml(String testName, String commonPartName, String commonPartFileName) throws Exception { AcquisitionsCommon acquisition = (AcquisitionsCommon) getObjectFromFile(AcquisitionsCommon.class, commonPartFileName); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(acquisition, + PoxPayloadOut multipart = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", commonPartName); + commonPart.setLabel(commonPartName); if (logger.isDebugEnabled()) { logger.debug(testName + " to be created, acquisitions common"); @@ -880,7 +885,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Perform setup. setupCreate(); - MultipartOutput multipart = null; + PoxPayloadOut multipart = null; AcquisitionClient client = new AcquisitionClient(); if (useJaxb) { @@ -914,17 +919,16 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { * @return * @throws Exception */ - private MultipartOutput createAcquisitionInstanceFromRawXml(String testName, String commonPartName, + private PoxPayloadOut createAcquisitionInstanceFromRawXml(String testName, String commonPartName, String commonPartFileName) throws Exception { - MultipartOutput multipart = new MultipartOutput(); + PoxPayloadOut multipart = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME); String stringObject = getXmlDocumentAsString(commonPartFileName); if (logger.isDebugEnabled()) { logger.debug(testName + " to be created, acquisition common " + "\n" + stringObject); } - OutputPart commonPart = multipart.addPart(stringObject, - MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", commonPartName); + PayloadOutputPart commonPart = multipart.addPart(stringObject, stringObject); + commonPart.setLabel(commonPartName); return multipart; @@ -942,7 +946,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); - ClientResponse res = client.read(csid); + ClientResponse res = client.read(csid); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -954,7 +958,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); if (logger.isDebugEnabled()) { logger.debug(testName + ": Reading Common part ..."); diff --git a/services/acquisition/jaxb/.classpath b/services/acquisition/jaxb/.classpath index 557f8a4e0..1674079c1 100644 --- a/services/acquisition/jaxb/.classpath +++ b/services/acquisition/jaxb/.classpath @@ -1,10 +1,31 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/acquisition/jaxb/.project b/services/acquisition/jaxb/.project index b563e0b30..8842031df 100644 --- a/services/acquisition/jaxb/.project +++ b/services/acquisition/jaxb/.project @@ -1,23 +1,19 @@ - - org.collectionspace.services.acquisition.jaxb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.acquisition.jaxb + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/acquisition/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/acquisition/jaxb/.settings/org.maven.ide.eclipse.prefs index 78f2eb42a..0c6fb5ca3 100644 --- a/services/acquisition/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/acquisition/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:12:07 PST 2010 +#Wed Jan 19 22:49:36 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/acquisition/service/.classpath b/services/acquisition/service/.classpath index 425cd1620..c4faa1f1c 100644 --- a/services/acquisition/service/.classpath +++ b/services/acquisition/service/.classpath @@ -1,10 +1,309 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/acquisition/service/.project b/services/acquisition/service/.project index 5aaad8bdf..e79adb713 100644 --- a/services/acquisition/service/.project +++ b/services/acquisition/service/.project @@ -1,26 +1,29 @@ - - org.collectionspace.services.acquisition.service - - - org.collectionspace.services.acquisition.jaxb - org.collectionspace.services.common - org.collectionspace.services.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.acquisition.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.acquisition.client + org.collectionspace.services.acquisition.jaxb + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/acquisition/service/pom.xml b/services/acquisition/service/pom.xml index 85bcc857d..0be07fb63 100644 --- a/services/acquisition/service/pom.xml +++ b/services/acquisition/service/pom.xml @@ -23,6 +23,11 @@ org.collectionspace.services.acquisition.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.acquisition.client + ${project.version} + diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java index e67b108d5..7337b6243 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java @@ -41,6 +41,11 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.client.AcquisitionClient; +import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; + import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.ServiceMessages; @@ -58,10 +63,9 @@ import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.CommonList; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.util.HttpResponseCodes; import org.nuxeo.ecm.core.api.DocumentModel; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,14 +75,12 @@ import org.slf4j.LoggerFactory; * Handles requests to the Acquisition service, orchestrates the retrieval * of relevant resources, and returns responses to the client. */ -@Path("/acquisitions") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Path(AcquisitionClient.SERVICE_PATH) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) public class AcquisitionResource extends AbstractMultiPartCollectionSpaceResourceImpl { - /** The service name. */ - final private String serviceName = "acquisitions"; /** The logger. */ final Logger logger = LoggerFactory.getLogger(AcquisitionResource.class); @@ -97,7 +99,7 @@ public class AcquisitionResource */ @Override public String getServiceName() { - return serviceName; + return AcquisitionClient.SERVICE_NAME; } @Override @@ -105,11 +107,11 @@ public class AcquisitionResource return AcquisitionsCommon.class; } - /* (non-Javadoc) + /* (non-Javadoc) //FIXME: REM - Please remove dead code. * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext) */ // @Override -// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { +// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { // DocumentHandler docHandler = ctx.getDocumentHandler(); // if (ctx.getInput() != null) { // Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), AcquisitionsCommon.class); @@ -123,7 +125,7 @@ public class AcquisitionResource * Instantiates a new acquisition resource. */ public AcquisitionResource() { - // do nothing + // Empty constructor. Note that all JAX-RS resource classes are singletons. } /** @@ -134,10 +136,10 @@ public class AcquisitionResource * @return the response */ @POST - public Response createAcquisition(MultipartInput input) { - + public Response createAcquisition(String xmlPayload) { try { - ServiceContext ctx = createServiceContext(input); + PoxPayloadIn input = new PoxPayloadIn(xmlPayload); + ServiceContext ctx = createServiceContext(input); DocumentHandler handler = createDocumentHandler(ctx); String csid = getRepositoryClient(ctx).create(ctx, handler); UriBuilder path = UriBuilder.fromResource(AcquisitionResource.class); @@ -169,7 +171,7 @@ public class AcquisitionResource */ @GET @Path("{csid}") - public MultipartOutput getAcquisition( + public byte[] getAcquisition( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getAcquisition with csid=" + csid); @@ -180,12 +182,12 @@ public class AcquisitionResource ServiceMessages.READ_FAILED + ServiceMessages.MISSING_CSID).type("text/plain").build(); throw new WebApplicationException(response); } - MultipartOutput result = null; + PoxPayloadOut result = null; try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csid, handler); - result = (MultipartOutput) ctx.getOutput(); + result = ctx.getOutput(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity( @@ -213,7 +215,7 @@ public class AcquisitionResource ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.getBytes(); } /** @@ -247,7 +249,7 @@ public class AcquisitionResource private CommonList getAcquisitionsList(MultivaluedMap queryParams) { CommonList commonList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); commonList = (CommonList) handler.getCommonPartList(); @@ -278,9 +280,9 @@ public class AcquisitionResource */ @PUT @Path("{csid}") - public MultipartOutput updateAcquisition( + public byte[] updateAcquisition( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlPayload) { if (logger.isDebugEnabled()) { logger.debug("updateAcquisition with csid=" + csid); } @@ -290,15 +292,13 @@ public class AcquisitionResource ServiceMessages.UPDATE_FAILED + ServiceMessages.MISSING_CSID).type("text/plain").build(); throw new WebApplicationException(response); } - if (logger.isDebugEnabled()) { - logger.debug("updateAcquisition with input: ", theUpdate); - } - MultipartOutput result = null; + PoxPayloadOut result = null; try { - ServiceContext ctx = createServiceContext(theUpdate); + PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload); + ServiceContext ctx = createServiceContext(theUpdate); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).update(ctx, csid, handler); - result = (MultipartOutput) ctx.getOutput(); + result = ctx.getOutput(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity( @@ -317,7 +317,7 @@ public class AcquisitionResource ServiceMessages.UPDATE_FAILED + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.getBytes(); } /** @@ -341,7 +341,7 @@ public class AcquisitionResource throw new WebApplicationException(response); } try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); getRepositoryClient(ctx).delete(ctx, csid); return Response.status(HttpResponseCodes.SC_OK).build(); } catch (UnauthorizedException ue) { @@ -390,11 +390,10 @@ public class AcquisitionResource * @return the acquisitions common list */ private CommonList searchAcquisitions( - MultivaluedMap queryParams, - String keywords) { + MultivaluedMap queryParams, String keywords) { CommonList commonList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); // perform a keyword search @@ -435,16 +434,15 @@ public class AcquisitionResource */ @GET @Path("{csid}/authorityrefs") - @Produces("application/xml") public AuthorityRefList getAuthorityRefs( @PathParam("csid") String csid, @Context UriInfo ui) { AuthorityRefList authRefList = null; try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentWrapper docWrapper = getRepositoryClient(ctx).getDoc(ctx, csid); - DocumentModelHandler handler = (DocumentModelHandler) createDocumentHandler(ctx); + DocumentModelHandler handler = (DocumentModelHandler) createDocumentHandler(ctx); List authRefFields = ((MultipartServiceContextImpl) ctx).getCommonPartPropertyValues( ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES); diff --git a/services/authentication/client/.classpath b/services/authentication/client/.classpath index 425cd1620..c1fdbc6d6 100644 --- a/services/authentication/client/.classpath +++ b/services/authentication/client/.classpath @@ -1,10 +1,250 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authentication/client/.project b/services/authentication/client/.project index 6a65606b3..e712cdee2 100644 --- a/services/authentication/client/.project +++ b/services/authentication/client/.project @@ -1,28 +1,21 @@ - - org.collectionspace.services.authentication.client - - - org.collectionspace.services.authentication.jaxb - org.collectionspace.services.client - org.collectionspace.services.collectionobject.client - org.collectionspace.services.collectionobject.jaxb - org.collectionspace.services.common - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.authentication.client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.authentication.jaxb + org.collectionspace.services.client + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/authentication/jaxb/.classpath b/services/authentication/jaxb/.classpath index 1707f3e6f..12fe49024 100644 --- a/services/authentication/jaxb/.classpath +++ b/services/authentication/jaxb/.classpath @@ -1,11 +1,66 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authentication/jaxb/.project b/services/authentication/jaxb/.project index aad9e2192..6623a6ead 100644 --- a/services/authentication/jaxb/.project +++ b/services/authentication/jaxb/.project @@ -1,23 +1,17 @@ - - org.collectionspace.services.authentication.jaxb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authentication.jaxb + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authentication/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/authentication/jaxb/.settings/org.maven.ide.eclipse.prefs index aa335bd29..223c9b5ad 100644 --- a/services/authentication/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/authentication/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:23:46 PST 2010 +#Wed Jan 19 22:49:16 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/authentication/pstore/.classpath b/services/authentication/pstore/.classpath index 1ca941f44..ca1391870 100644 --- a/services/authentication/pstore/.classpath +++ b/services/authentication/pstore/.classpath @@ -1,8 +1,65 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authentication/pstore/.project b/services/authentication/pstore/.project index f19b02240..efb9b30d8 100644 --- a/services/authentication/pstore/.project +++ b/services/authentication/pstore/.project @@ -1,24 +1,19 @@ - - org.collectionspace.services.authentication.pstore - - - org.collectionspace.services.authentication.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authentication.pstore + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.authentication.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authentication/service/.classpath b/services/authentication/service/.classpath index 425cd1620..517f72236 100644 --- a/services/authentication/service/.classpath +++ b/services/authentication/service/.classpath @@ -1,10 +1,41 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authentication/service/.project b/services/authentication/service/.project index 2b5bf8cae..883dbf6f9 100644 --- a/services/authentication/service/.project +++ b/services/authentication/service/.project @@ -1,23 +1,17 @@ - - org.collectionspace.services.authentication.service - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.authentication.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/authorization-mgt/client/.classpath b/services/authorization-mgt/client/.classpath index 425cd1620..d1ab1caa4 100644 --- a/services/authorization-mgt/client/.classpath +++ b/services/authorization-mgt/client/.classpath @@ -1,10 +1,282 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization-mgt/client/.project b/services/authorization-mgt/client/.project index a580aca14..42289ede7 100644 --- a/services/authorization-mgt/client/.project +++ b/services/authorization-mgt/client/.project @@ -1,23 +1,23 @@ - - org.collectionspace.services.authorization-mgt.client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization-mgt.client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.authentication.service + org.collectionspace.services.authorization.jaxb + org.collectionspace.services.authorization.service + org.collectionspace.services.client + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionClient.java b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionClient.java index 7cdf5e2c3..e7e0695b0 100644 --- a/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionClient.java +++ b/services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionClient.java @@ -43,7 +43,10 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * @version $Revision:$ */ public class PermissionClient extends AbstractServiceClientImpl { - + public static final String SERVICE_NAME = "authorization/permissions"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; /** * */ @@ -53,7 +56,7 @@ public class PermissionClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() */ public String getServicePathComponent() { - return "authorization/permissions"; + return SERVICE_PATH_COMPONENT; } /** @@ -135,4 +138,9 @@ public class PermissionClient extends AbstractServiceClientImpl { public ClientResponse delete(String csid) { return permissionProxy.delete(csid); } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } } 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 dd83a6fa6..cf1046ee0 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 @@ -46,6 +46,11 @@ public class PermissionRoleClient extends AbstractServiceClientImpl { /** The permission role proxy. */ private PermissionRoleProxy permissionRoleProxy; + @Override + public String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3497 + } + /* (non-Javadoc) * @see */ 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 e57ffa932..9802ca37e 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 @@ -43,12 +43,20 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * @version $Revision:$ */ public class RoleClient extends AbstractServiceClientImpl { - + public static final String SERVICE_NAME = "authorization/roles"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; /** * */ private RoleProxy roleProxy; + @Override + public String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498 } + } + /* (non-Javadoc) * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() */ 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 00bfe0958..a6a2356f7 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 @@ -47,6 +47,11 @@ public class RolePermissionClient extends AbstractServiceClientImpl { /** The role permission proxy. */ private RolePermissionProxy rolePermissionProxy; + @Override + public String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498 } + } + /* (non-Javadoc) * @see */ 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 eedd85321..6e60ccf78 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 @@ -93,6 +93,11 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { protected String getServicePathComponent() { return new PermissionRoleClient().getServicePathComponent(); } + + @Override + protected String getServiceName() { + return PermissionClient.SERVICE_NAME; //Since we're a sub-resource of permission service return its name? + } /** * Seed data. @@ -534,7 +539,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { * @throws Exception */ @Test(dependsOnMethods = {"create"}) - public void testSubmitRequest() throws Exception { + public void testSubmitRequest() throws Exception { //FIXME: REM - This is testing /permissions not /permissions/permroles // Expected status code: 200 OK final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java index 6957cf7b2..bdcd65f0b 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java @@ -62,16 +62,18 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { /** The known resource id. */ private String knownResourceId = null; private String knownResource = "accounts-test"; - /* - * This method is called only by the parent class, AbstractServiceTestImpl - */ + @Override + public String getServiceName() { + return PermissionClient.SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ @Override protected String getServicePathComponent() { - return new PermissionClient().getServicePathComponent(); + return PermissionClient.SERVICE_PATH_COMPONENT; } /* (non-Javadoc) @@ -642,7 +644,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { */ @Override @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, - dependsOnMethods = {"updateActions", "testSubmitRequest"}) + dependsOnMethods = {"update", "updateActions", "testSubmitRequest"}) public void delete(String testName) throws Exception { if (logger.isDebugEnabled()) { diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java index 38669abc6..73fe14f62 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java @@ -81,9 +81,6 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { /** The role values. */ private Hashtable roleValues = new Hashtable(); private Date now = new Date(); - /* - * This method is called only by the parent class, AbstractServiceTestImpl - */ /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() @@ -92,7 +89,12 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { protected String getServicePathComponent() { return new RolePermissionClient().getServicePathComponent(); } - + + @Override + public String getServiceName() { + return RoleClient.SERVICE_NAME; // RolePermission is a sub-resource of 'roles' resource. + } + private String getRoleName() { return TEST_ROLE_NAME + TEST_MARKER + now.toString(); } @@ -511,7 +513,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { * of the methods above. * @throws Exception */ - @Test(dependsOnMethods = {"create"}) + @Test(dependsOnMethods = {"create"}) //FIXME: REM - This is not a test of a submit to the permroles service, but to just authorization/roles public void testSubmitRequest() throws Exception { // Expected status code: 200 OK 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 443a4aacc..3683b5f8f 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 @@ -63,13 +63,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { private String verifyRoleName = "collections_manager_test"; // private List allResourceIdsCreated = new ArrayList(); - /* - * This method is called only by the parent class, AbstractServiceTestImpl - */ - - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() - */ + @Override + public String getServiceName() { + return RoleClient.SERVICE_NAME; + } + @Override protected String getServicePathComponent() { return new RoleClient().getServicePathComponent(); diff --git a/services/authorization-mgt/import/.classpath b/services/authorization-mgt/import/.classpath index 425cd1620..7f35f2720 100644 --- a/services/authorization-mgt/import/.classpath +++ b/services/authorization-mgt/import/.classpath @@ -1,10 +1,330 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization-mgt/import/.project b/services/authorization-mgt/import/.project index e8ddb56a1..bdc79064f 100644 --- a/services/authorization-mgt/import/.project +++ b/services/authorization-mgt/import/.project @@ -1,23 +1,26 @@ - - org.collectionspace.services.authorization-mgt.import - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization-mgt.import + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.authorization-mgt.service + org.collectionspace.services.authorization.jaxb + org.collectionspace.services.authorization.service + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authorization-mgt/service/.classpath b/services/authorization-mgt/service/.classpath index 425cd1620..82577d5a2 100644 --- a/services/authorization-mgt/service/.classpath +++ b/services/authorization-mgt/service/.classpath @@ -1,10 +1,343 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization-mgt/service/.project b/services/authorization-mgt/service/.project index e48099ed0..f02482ebd 100644 --- a/services/authorization-mgt/service/.project +++ b/services/authorization-mgt/service/.project @@ -1,23 +1,28 @@ - - org.collectionspace.services.authorization-mgt.service - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization-mgt.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.account.jaxb + org.collectionspace.services.account.service + org.collectionspace.services.authentication.jaxb + org.collectionspace.services.authorization.jaxb + org.collectionspace.services.authorization.service + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/RoleResource.java b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/RoleResource.java index 34b04dfa4..13393df66 100644 --- a/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/RoleResource.java +++ b/services/authorization-mgt/service/src/main/java/org/collectionspace/services/authorization/RoleResource.java @@ -62,7 +62,7 @@ import org.slf4j.LoggerFactory; /** * The Class RoleResource. */ -@Path("/authorization/roles") +@Path("/authorization/roles") //FIXME: REM - Replace string constant with RoleClient.SERVICE_PATH @Consumes("application/xml") @Produces("application/xml") public class RoleResource diff --git a/services/authorization/jaxb/.classpath b/services/authorization/jaxb/.classpath index d0883cb1b..f6f3fdf3e 100644 --- a/services/authorization/jaxb/.classpath +++ b/services/authorization/jaxb/.classpath @@ -1,9 +1,64 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization/jaxb/.project b/services/authorization/jaxb/.project index 677b488f8..25378271a 100644 --- a/services/authorization/jaxb/.project +++ b/services/authorization/jaxb/.project @@ -1,23 +1,17 @@ - - org.collectionspace.services.authorization.jaxb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization.jaxb + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs index bfcf7821d..944f24750 100644 --- a/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:13:37 PST 2010 +#Wed Jan 19 22:49:18 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/authorization/pstore/.classpath b/services/authorization/pstore/.classpath index 1ca941f44..97bfa7aca 100644 --- a/services/authorization/pstore/.classpath +++ b/services/authorization/pstore/.classpath @@ -1,8 +1,65 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization/pstore/.project b/services/authorization/pstore/.project index 6f4ff8683..bafe0582d 100644 --- a/services/authorization/pstore/.project +++ b/services/authorization/pstore/.project @@ -1,23 +1,19 @@ - - org.collectionspace.services.authorization.pstore - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization.pstore + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.authorization.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/authorization/service/.classpath b/services/authorization/service/.classpath index 425cd1620..3c7fb4921 100644 --- a/services/authorization/service/.classpath +++ b/services/authorization/service/.classpath @@ -1,10 +1,106 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/authorization/service/.project b/services/authorization/service/.project index 4d84665a6..e535fc3e9 100644 --- a/services/authorization/service/.project +++ b/services/authorization/service/.project @@ -1,24 +1,20 @@ - - org.collectionspace.services.authorization.service - - - org.collectionspace.services.authorization.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + org.collectionspace.services.authorization.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.authentication.service + org.collectionspace.services.authorization.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.classpath b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.classpath index 199bbbbdb..8ad8fad8e 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.classpath +++ b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.classpath @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.project b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.project index 6d3785ac4..e0d56f871 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.project +++ b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/.project @@ -1,23 +1,17 @@ - - org.collectionspace.services.collectionobject.3rdparty.nuxeo - CollectionObject Nuxeo document type - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.collectionobject.3rdparty.nuxeo + CollectionObject Nuxeo document type. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/collectionobject/client/.classpath b/services/collectionobject/client/.classpath index 425cd1620..27fc35a00 100644 --- a/services/collectionobject/client/.classpath +++ b/services/collectionobject/client/.classpath @@ -1,10 +1,314 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/collectionobject/client/.project b/services/collectionobject/client/.project index 918b0760e..e3b21d134 100644 --- a/services/collectionobject/client/.project +++ b/services/collectionobject/client/.project @@ -1,27 +1,30 @@ - - org.collectionspace.services.collectionobject.client - - - org.collectionspace.services.client - org.collectionspace.services.collectionobject.jaxb - org.collectionspace.services.common - org.collectionspace.services.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.collectionobject.client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.client + org.collectionspace.services.collectionobject.jaxb + org.collectionspace.services.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.organization.client + org.collectionspace.services.organization.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file 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 d26066d28..f9682b883 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 @@ -36,8 +36,8 @@ import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +//import org.jboss.resteasy.plugins.providers.multipart.PoxPayloadIn; +//import org.jboss.resteasy.plugins.providers.multipart.PoxPayloadOut; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.slf4j.Logger; @@ -47,16 +47,26 @@ import org.slf4j.Logger; * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 */ public class CollectionObjectClient extends AbstractServiceClientImpl { + public static final String SERVICE_NAME = "collectionobjects"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; /** The collection object proxy. */ private CollectionObjectProxy collectionObjectProxy; + @Override + public String getServiceName() { + return SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() */ @Override public String getServicePathComponent() { - return "collectionobjects"; + return SERVICE_PATH_COMPONENT; } /** @@ -127,10 +137,10 @@ public class CollectionObjectClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.CollectionObjectProxy#keywordSearch() * @return the client response< collectionobjects common list> */ - public ClientResponse keywordSearch(String keywords) { + public ClientResponse keywordSearch(String keywords) { return collectionObjectProxy.keywordSearch(keywords); - } + /** * Read. @@ -140,7 +150,7 @@ public class CollectionObjectClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.CollectionObjectProxy#keywordSearch() * @return the client response< multipart input> */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return collectionObjectProxy.read(csid); } @@ -166,8 +176,8 @@ public class CollectionObjectClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.CollectionObjectProxy#create() * @return the client response< response> */ - public ClientResponse create(MultipartOutput multipart) { - return collectionObjectProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return collectionObjectProxy.create(xmlPayload.getBytes()); } /** @@ -179,8 +189,9 @@ public class CollectionObjectClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.CollectionObjectProxy#update() * @return the client response< multipart input> */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return collectionObjectProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut multipart) { + String payload = multipart.toXML(); + return collectionObjectProxy.update(csid, payload.getBytes()); } /** @@ -195,4 +206,5 @@ public class CollectionObjectClient extends AbstractServiceClientImpl { public ClientResponse delete(String csid) { return collectionObjectProxy.delete(csid); } + } diff --git a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectFactory.java b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectFactory.java index 72e05c560..498546f6a 100644 --- a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectFactory.java +++ b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectFactory.java @@ -25,10 +25,10 @@ package org.collectionspace.services.client; import javax.ws.rs.core.MediaType; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; -import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,6 +39,8 @@ import org.slf4j.LoggerFactory; public class CollectionObjectFactory { static private final Logger logger = LoggerFactory.getLogger(CollectionObjectFactory.class); + final static String SERVICE_PATH_COMPONENT = "collectionobjects"; + /** * create account instance * @param screenName @@ -63,21 +65,24 @@ public class CollectionObjectFactory { * @param conh the conh * @return the multipart output */ - public static MultipartOutput createCollectionObjectInstance(String commonPartName, - CollectionobjectsCommon collectionObject, + public static PoxPayloadOut createCollectionObjectInstance(String commonPartName, + CollectionobjectsCommon collectionObjectCommon, String nhPartName, CollectionobjectsNaturalhistory conh) { - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(collectionObject, - MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", commonPartName); + PoxPayloadOut multipart = new PoxPayloadOut(getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(commonPartName); if (conh != null) { - OutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE); - nhPart.getHeaders().add("label", nhPartName); + PayloadOutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE); + nhPart.setLabel(nhPartName); } return multipart; } + public static String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } } diff --git a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectProxy.java b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectProxy.java index 426313c3d..743cddabb 100644 --- a/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectProxy.java +++ b/services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectProxy.java @@ -48,16 +48,13 @@ import org.collectionspace.services.collectionobject.CollectionobjectsCommonList import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; - /** * @version $Revision:$ * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 */ -@Path("/collectionobjects/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Path(CollectionObjectClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) public interface CollectionObjectProxy extends CollectionSpaceProxy { /** @@ -70,7 +67,7 @@ public interface CollectionObjectProxy extends CollectionSpaceProxy { ClientResponse readList(); // /** -// * Read list. +// * Read list. //FIXME: REM - Remove this dead code please. // * // * @param pageSize the page size // * @param pageNumber the page number @@ -110,11 +107,11 @@ public interface CollectionObjectProxy extends CollectionSpaceProxy { /** * Creates the. * - * @param multipart the multipart + * @param payload the payload * @return the client response */ @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(byte[] payload); //(R)ead /** @@ -125,11 +122,12 @@ public interface CollectionObjectProxy extends CollectionSpaceProxy { */ @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); @GET @Produces({"application/xml"}) @Path("/{csid}/picture") + @Deprecated //FIXME: REM - Remove this method and the corresponding client, and resource as well. ClientResponse createPicture(@PathParam("csid") String csid); // List Authority references @@ -155,7 +153,7 @@ public interface CollectionObjectProxy extends CollectionSpaceProxy { */ @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, byte[] payload); //(D)elete /** diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java index c9b44ee6e..679a39bd6 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java @@ -36,8 +36,11 @@ import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.client.OrgAuthorityClientUtils; +import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.collectionobject.AssocEventOrganizationList; import org.collectionspace.services.collectionobject.AssocEventPersonList; @@ -53,8 +56,6 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -72,6 +73,16 @@ import org.slf4j.LoggerFactory; */ public class CollectionObjectAuthRefsTest extends BaseServiceTest { + @Override + protected CollectionSpaceClient getClientInstance() { + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + + @Override + protected String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + /** The logger. */ private final String CLASS_NAME = CollectionObjectAuthRefsTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); @@ -137,14 +148,6 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { /** The number of authority references expected. */ private final int NUM_AUTH_REFS_EXPECTED = 7; - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() - */ - @Override - protected CollectionSpaceClient getClientInstance() { - throw new UnsupportedOperationException(); //method not supported (or needed) in this test class - } - /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) */ @@ -181,7 +184,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { // Create an object record payload, containing // authority reference values in a number of its fields String identifier = createIdentifier(); - MultipartOutput multipart = + PoxPayloadOut multipart = createCollectionObjectInstance( "Obj Title", "ObjNum" + "-" + identifier, @@ -236,7 +239,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { private void createPersonAuthority(String displayName, String shortIdentifier) { testSetup(STATUS_CREATED, ServiceRequestType.CREATE); PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, shortIdentifier, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); int statusCode = res.getStatus(); @@ -262,7 +265,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { personInfo.put(PersonJAXBSchema.SUR_NAME, surName); personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortIdentifier); PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - MultipartOutput multipart = + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, personAuthRefName, personInfo, personAuthClient.getItemCommonPartName()); ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); @@ -330,7 +333,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { private void createOrgAuthority(String displayName, String shortIdentifier) { testSetup(STATUS_CREATED, ServiceRequestType.CREATE); OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); - MultipartOutput multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, shortIdentifier, orgAuthClient.getCommonPartName()); ClientResponse res = orgAuthClient.create(multipart); int statusCode = res.getStatus(); @@ -356,7 +359,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace); orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier); OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrganizationInstance( orgAuthRefName, orgInfo, orgAuthClient.getItemCommonPartName()); ClientResponse res = orgAuthClient.createItem(orgAuthCSID, multipart); @@ -415,7 +418,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { // Submit the request to the service and store the response. CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); - ClientResponse res = collectionObjectClient.read(knownResourceId); + ClientResponse res = collectionObjectClient.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -427,7 +430,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input, collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class); Assert.assertNotNull(collectionObject); @@ -553,7 +556,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { * @param inscriber the inscriber * @return the multipart output */ - private MultipartOutput createCollectionObjectInstance( + private PoxPayloadOut createCollectionObjectInstance( String title, String objNum, String contentOrganization, @@ -617,10 +620,10 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { fieldCollectors.add(fieldCollector); collectionObject.setFieldCollectors(FieldCollectorList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = + PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new CollectionObjectClient().getCommonPartName()); + commonPart.setLabel(new CollectionObjectClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, collectionObject common"); diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java index 261a967a0..6ef7bdc2d 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java @@ -29,13 +29,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.BriefDescriptionList; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; -import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -53,6 +53,17 @@ import org.testng.annotations.Test; */ public class CollectionObjectSearchTest extends BaseServiceTest { + @Override + protected String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + + @Override + protected String getServicePathComponent() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + /** The logger. */ private final String CLASS_NAME = CollectionObjectSearchTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); @@ -87,13 +98,13 @@ public class CollectionObjectSearchTest extends BaseServiceTest { /* Use this to keep track of resources to delete */ private List allResourceIdsCreated = new ArrayList(); - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() - */ - @Override - protected String getServicePathComponent() { - return new CollectionObjectClient().getServicePathComponent(); - } +// /* (non-Javadoc) +// * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() +// */ +// @Override +// protected String getServicePathComponent() { +// return new CollectionObjectClient().getServicePathComponent(); //FIXME: REM = Remove all refs to this method. +// } /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -438,7 +449,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest { testSetup(STATUS_CREATED, ServiceRequestType.CREATE); CollectionObjectClient client = new CollectionObjectClient(); for (long i = 0; i < numToCreate; i++) { - MultipartOutput multipart = + PoxPayloadOut multipart = createCollectionObjectInstance(i, keywords, keywordsInSameField); ClientResponse res = client.create(multipart); try { @@ -455,7 +466,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest { } } - private MultipartOutput createCollectionObjectInstance(long i, List keywords, + private PoxPayloadOut createCollectionObjectInstance(long i, List keywords, boolean keywordsInSameField) { CollectionobjectsCommon collectionObject = new CollectionobjectsCommon(); collectionObject.setObjectNumber(createIdentifier()); @@ -471,10 +482,10 @@ public class CollectionObjectSearchTest extends BaseServiceTest { Assert.fail("List of keywords must have exactly one or two members."); } } - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(collectionObject, + PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new CollectionObjectClient().getCommonPartName()); + commonPart.setLabel(new CollectionObjectClient().getCommonPartName()); return multipart; } @@ -541,5 +552,4 @@ public class CollectionObjectSearchTest extends BaseServiceTest { public static String getSystemTimeIdentifier() { return Long.toString(System.currentTimeMillis()); } - } diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 19e596db0..6175bb650 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -7,7 +7,7 @@ * http://wiki.collectionspace.org * * Copyright © 2009 Regents of the University of California - * + *\ * Licensed under the Educational Community License (ECL), Version 2.0. * You may not use this file except in compliance with this License. * @@ -30,6 +30,10 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.CollectionObjectFactory; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadInputPart; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.BriefDescriptionList; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory; @@ -47,8 +51,6 @@ import org.collectionspace.services.collectionobject.TitleGroupList; import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.testng.Assert; import org.testng.annotations.Test; @@ -78,13 +80,18 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { private final String UTF8_DATA_SAMPLE = "Audiorecording album cover signed by Lech " + "Wa" + '\u0142' + '\u0119' + "sa"; - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() - */ - @Override - protected String getServicePathComponent() { - return new CollectionObjectClient().getServicePathComponent(); - } +// /* (non-Javadoc) +// * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() +// */ +// @Override +// protected String getServicePathComponent() { +// return new CollectionObjectClient().getServicePathComponent(); +// } + + @Override + protected String getServiceName() { + return CollectionObjectClient.SERVICE_NAME; + } /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() @@ -125,7 +132,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); String identifier = createIdentifier(); - MultipartOutput multipart = + PoxPayloadOut multipart = createCollectionObjectInstance(client.getCommonPartName(), identifier); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -535,7 +542,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); - MultipartOutput multipart = + PoxPayloadOut multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -601,7 +608,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -613,19 +620,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": Reading Common part ..."); - } - CollectionobjectsCommon collectionObject = - (CollectionobjectsCommon) extractPart(input, - client.getCommonPartName(), CollectionobjectsCommon.class); - Assert.assertNotNull(collectionObject); + // Extract the common part. + CollectionobjectsCommon collectionobjectCommon = extractCommonPartValue(testName, res); // Verify the number and contents of values in repeatable fields, // as created in the instance record used for testing. - DimensionList dimensionList = collectionObject.getDimensions(); + DimensionList dimensionList = collectionobjectCommon.getDimensions(); Assert.assertNotNull(dimensionList); List dimensionsGroups = dimensionList.getDimensionGroup(); Assert.assertNotNull(dimensionsGroups); @@ -636,9 +636,10 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug(testName + ": Reading Natural History part ..."); } - CollectionobjectsNaturalhistory conh = - (CollectionobjectsNaturalhistory) extractPart(input, - getNHPartName(), CollectionobjectsNaturalhistory.class); + + // Currently checking only that the natural history part is non-null; + // can add specific field-level checks as warranted. + Object conh = extractPartValue(testName, res, getNHPartName()); Assert.assertNotNull(conh); } @@ -659,7 +660,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); - ClientResponse res = client.read(NON_EXISTENT_ID); + ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -743,27 +744,20 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } - // Perform setup. - setupUpdate(); // Read an existing resource that will be updated. - ClientResponse res = updateRetrieve(testName, knownResourceId); + ClientResponse res = updateRetrieve(testName, knownResourceId); // Extract its common part. - CollectionObjectClient client = new CollectionObjectClient(); - MultipartInput input = (MultipartInput) res.getEntity(); - CollectionobjectsCommon collectionObject = - (CollectionobjectsCommon) extractPart(input, - client.getCommonPartName(), CollectionobjectsCommon.class); - Assert.assertNotNull(collectionObject); + CollectionobjectsCommon collectionObjectCommon = extractCommonPartValue(testName, res); // Change the content of one or more fields in the common part. - collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber()); + collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber()); // Change the object name in the first value instance in the // object name repeatable group. - ObjectNameList objNameList = collectionObject.getObjectNameList(); + ObjectNameList objNameList = collectionObjectCommon.getObjectNameList(); List objNameGroups = objNameList.getObjectNameGroup(); Assert.assertNotNull(objNameGroups); Assert.assertTrue(objNameGroups.size() >= 1); @@ -771,11 +765,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(objectName, OBJECT_NAME_VALUE); String updatedObjectName = "updated-" + objectName; objNameGroups.get(0).setObjectName(updatedObjectName); - collectionObject.setObjectNameList(objNameList); + collectionObjectCommon.setObjectNameList(objNameList); // Replace the existing value instances in the dimensions repeatable group // with entirely new value instances, also changing the number of such instances. - DimensionList dimensionList = collectionObject.getDimensions(); + DimensionList dimensionList = collectionObjectCommon.getDimensions(); Assert.assertNotNull(dimensionList); List dimensionGroups = dimensionList.getDimensionGroup(); Assert.assertNotNull(dimensionGroups); @@ -789,33 +783,24 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { int updatedDimensionGroupSize = dimensionGroups.size(); Assert.assertTrue(updatedDimensionGroupSize >= 1); Assert.assertTrue(updatedDimensionGroupSize != originalDimensionGroupSize); - collectionObject.setDimensions(dimensionList); + collectionObjectCommon.setDimensions(dimensionList); if (logger.isDebugEnabled()) { logger.debug("sparse update that will be sent in update request:"); - logger.debug(objectAsXmlString(collectionObject, + logger.debug(objectAsXmlString(collectionObjectCommon, CollectionobjectsCommon.class)); } - // Send the changed resource to be updated. - res = updateSend(testName, knownResourceId, collectionObject); - 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(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Send the changed resource to be updated and read the updated resource + // from the response. + res = updateSend(testName, knownResourceId, collectionObjectCommon); - // Read the response and verify that the resource was correctly updated. - input = (MultipartInput) res.getEntity(); - CollectionobjectsCommon updatedCollectionObject = - (CollectionobjectsCommon) extractPart(input, - client.getCommonPartName(), CollectionobjectsCommon.class); - Assert.assertNotNull(updatedCollectionObject); + // Extract its common part. + CollectionobjectsCommon updatedCollectionobjectCommon = extractCommonPartValue(testName, res); - objNameList = collectionObject.getObjectNameList(); + // Read the updated common part and verify that the resource was correctly updated. + objNameList = updatedCollectionobjectCommon.getObjectNameList(); + Assert.assertNotNull(objNameList); objNameGroups = objNameList.getObjectNameGroup(); Assert.assertNotNull(objNameGroups); Assert.assertTrue(objNameGroups.size() >= 1); @@ -823,7 +808,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { objNameGroups.get(0).getObjectName(), "Data in updated object did not match submitted data."); - dimensionList = collectionObject.getDimensions(); + dimensionList = updatedCollectionobjectCommon.getDimensions(); Assert.assertNotNull(dimensionList); dimensionGroups = dimensionList.getDimensionGroup(); Assert.assertNotNull(dimensionGroups); @@ -841,16 +826,21 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @param id the id * @return the client response */ - private ClientResponse updateRetrieve(String testName, String id) { - final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + private ClientResponse updateRetrieve(String testName, String id) { + setupRead(); CollectionObjectClient client = new CollectionObjectClient(); - ClientResponse res = client.read(id); + ClientResponse 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("read in updateRetrieve for " + testName + " status = " + res.getStatus()); + logger.debug(testName + ": read status = " + statusCode); } - Assert.assertEquals(res.getStatus(), EXPECTED_STATUS); - if (logger.isDebugEnabled()) { - logger.debug("got object to updateRetrieve for " + testName + " with ID: " + id); + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if(logger.isDebugEnabled()){ + logger.debug("got object to update with ID: " + knownResourceId); } return res; } @@ -863,13 +853,23 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @param collectionObject the collection object * @return the client response */ - private ClientResponse updateSend(String testName, String id, - CollectionobjectsCommon collectionObject) { - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); + private ClientResponse updateSend(String testName, String id, + CollectionobjectsCommon collectionObjectCommon) { + setupUpdate(); + PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE); CollectionObjectClient client = new CollectionObjectClient(); - commonPart.getHeaders().add("label", client.getCommonPartName()); - ClientResponse res = client.update(knownResourceId, output); + commonPart.setLabel(client.getCommonPartName()); + ClientResponse res = client.update(knownResourceId, output); + int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); return res; } @@ -1019,11 +1019,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updateCollectionObject(), below. CollectionObjectClient client = new CollectionObjectClient(); - MultipartOutput multipart = - createCollectionObjectInstance(client.getCommonPartName(), - NON_EXISTENT_ID); - ClientResponse res = - client.update(NON_EXISTENT_ID, multipart); + PoxPayloadOut multipart = + createCollectionObjectInstance(client.getCommonPartName(), NON_EXISTENT_ID); + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -1057,35 +1055,31 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } - // Perform setup. - setupUpdate(); - if (logger.isDebugEnabled()) { - logger.debug(testName + " got object to update with ID: " + knownResourceId); - } // Read an existing record for updating. - ClientResponse res = updateRetrieve(testName, knownResourceId); + ClientResponse res = updateRetrieve(testName, knownResourceId); - CollectionObjectClient client = new CollectionObjectClient(); - MultipartInput input = (MultipartInput) res.getEntity(); - CollectionobjectsCommon collectionObject = - (CollectionobjectsCommon) extractPart(input, - client.getCommonPartName(), CollectionobjectsCommon.class); - Assert.assertNotNull(collectionObject); + // Extract its common part. + CollectionobjectsCommon collectionObjectCommon = extractCommonPartValue(testName, res); - // Update with invalid content, by setting a value to the - // empty String, in a field that requires a non-empty value, + // Update the common part with invalid content, by setting a value to + // the empty String, in a field that requires a non-empty value, // as enforced by the service's validation routine(s). - collectionObject.setObjectNumber(""); + collectionObjectCommon.setObjectNumber(""); if (logger.isDebugEnabled()) { logger.debug(testName + " updated object"); - logger.debug(objectAsXmlString(collectionObject, + logger.debug(objectAsXmlString(collectionObjectCommon, CollectionobjectsCommon.class)); } // Submit the request to the service and store the response. - res = updateSend(testName, knownResourceId, collectionObject); + setupUpdate(); + PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE); + CollectionObjectClient client = new CollectionObjectClient(); + commonPart.setLabel(client.getCommonPartName()); + res = client.update(knownResourceId, output); int statusCode = res.getStatus(); // Read the response and verify that the update attempt failed. @@ -1208,7 +1202,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier * @return the multipart output */ - private MultipartOutput createCollectionObjectInstance(String commonPartName, + private PoxPayloadOut createCollectionObjectInstance(String commonPartName, String identifier) { return createCollectionObjectInstance(commonPartName, "objectNumber-" + identifier, @@ -1223,7 +1217,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @param objectName the object name * @return the multipart output */ - private MultipartOutput createCollectionObjectInstance(String commonPartName, + private PoxPayloadOut createCollectionObjectInstance(String commonPartName, String objectNumber, String objectName) { CollectionobjectsCommon collectionObject = new CollectionobjectsCommon(); @@ -1313,7 +1307,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { conh.setNhInt(999); conh.setNhLong(9999); - MultipartOutput multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh); + PoxPayloadOut multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh); return multipart; } @@ -1325,10 +1319,10 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @param conh the conh * @return the multipart output */ - private MultipartOutput createCollectionObjectInstance(String commonPartName, + private PoxPayloadOut createCollectionObjectInstance(String commonPartName, CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) { - MultipartOutput multipart = CollectionObjectFactory.createCollectionObjectInstance( + PoxPayloadOut multipart = CollectionObjectFactory.createCollectionObjectInstance( commonPartName, collectionObject, getNHPartName(), conh); if (logger.isDebugEnabled()) { logger.debug("to be created, collectionobject common"); @@ -1355,16 +1349,17 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @return * @throws Exception */ - private MultipartOutput createCollectionObjectInstanceFromXml(String testName, String commonPartName, + private PoxPayloadOut createCollectionObjectInstanceFromXml(String testName, String commonPartName, String commonPartFileName) throws Exception { CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) getObjectFromFile(CollectionobjectsCommon.class, commonPartFileName); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(collectionObject, + PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", commonPartName); + CollectionObjectClient client = new CollectionObjectClient(); + commonPart.setLabel(client.getCommonPartName()); if (logger.isDebugEnabled()) { logger.debug(testName + " to be created, collectionobject common"); @@ -1383,20 +1378,18 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @return * @throws Exception */ - private MultipartOutput createCollectionObjectInstanceFromRawXml(String testName, String commonPartName, + private PoxPayloadOut createCollectionObjectInstanceFromRawXml(String testName, String commonPartName, String commonPartFileName) throws Exception { - MultipartOutput multipart = new MultipartOutput(); + PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); String stringObject = getXmlDocumentAsString(commonPartFileName); if (logger.isDebugEnabled()) { logger.debug(testName + " to be created, collectionobject common " + "\n" + stringObject); } - OutputPart commonPart = multipart.addPart(stringObject, - MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", commonPartName); + PayloadOutputPart commonPart = multipart.addPart(commonPartName, stringObject); +// commonPart.setLabel(commonPartName); return multipart; - } /** @@ -1422,7 +1415,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Perform setup. setupCreate(); - MultipartOutput multipart = null; + PoxPayloadOut multipart = null; CollectionObjectClient client = new CollectionObjectClient(); if (useJaxb) { @@ -1458,7 +1451,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); - ClientResponse res = client.read(csid); + ClientResponse res = client.read(csid); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -1470,16 +1463,57 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - - if (logger.isDebugEnabled()) { - logger.debug(testName + ": Reading Common part ..."); - } - CollectionobjectsCommon collectionObject = - (CollectionobjectsCommon) extractPart(input, - client.getCommonPartName(), CollectionobjectsCommon.class); + // Extract the common part. + CollectionobjectsCommon collectionObject = extractCommonPartValue(testName, res); Assert.assertNotNull(collectionObject); return collectionObject; } + + private CollectionobjectsCommon extractCommonPartValue(String testName, ClientResponse res) + throws Exception { + CollectionObjectClient client = new CollectionObjectClient(); + PayloadInputPart payloadInputPart = extractPart(testName, res, client.getCommonPartName()); + Object obj = null; + if (payloadInputPart != null) { + obj = payloadInputPart.getBody(); + } + Assert.assertNotNull(obj, + testName + ": body of " + client.getCommonPartName() + " part was unexpectedly null."); + CollectionobjectsCommon collectionobjectCommon = (CollectionobjectsCommon) obj; + Assert.assertNotNull(collectionobjectCommon, + testName + ": " + client.getCommonPartName() + " part was unexpectedly null."); + return collectionobjectCommon; + } + + private Object extractPartValue(String testName, ClientResponse res, String partLabel) + throws Exception { + Object obj = null; + PayloadInputPart payloadInputPart = extractPart(testName, res, partLabel); + if (payloadInputPart != null) { + obj = payloadInputPart.getElementBody(); + } + Assert.assertNotNull(obj, + testName + ": value of part " + partLabel + " was unexpectedly null."); + return obj; + } + + private PayloadInputPart extractPart(String testName, ClientResponse res, String partLabel) + throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testName + ": Reading part " + partLabel + " ..."); + } + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(partLabel); + Assert.assertNotNull(payloadInputPart, + testName + ": part " + partLabel + " was unexpectedly null."); + return payloadInputPart; + } + + @Override + protected String getServicePathComponent() { + // TODO Auto-generated method stub + return CollectionObjectClient.SERVICE_PATH_COMPONENT; + } + } diff --git a/services/collectionobject/client/src/test/resources/test-data/cspace-2779-utf-8-create.xml b/services/collectionobject/client/src/test/resources/test-data/cspace-2779-utf-8-create.xml index 4cf35bf80..44f2f7dc4 100644 --- a/services/collectionobject/client/src/test/resources/test-data/cspace-2779-utf-8-create.xml +++ b/services/collectionobject/client/src/test/resources/test-data/cspace-2779-utf-8-create.xml @@ -7,9 +7,7 @@ --> + xmlns:ns2="http://collectionspace.org/services/collectionobject"> 2 Katowice Spodek Live '94 by the band Perfect Audiorecording album cover signed by Lech Wałęsa diff --git a/services/collectionobject/jaxb/.classpath b/services/collectionobject/jaxb/.classpath index 7251ed120..1674079c1 100644 --- a/services/collectionobject/jaxb/.classpath +++ b/services/collectionobject/jaxb/.classpath @@ -1,10 +1,31 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/collectionobject/jaxb/.project b/services/collectionobject/jaxb/.project index 6079d9391..7cefb9075 100644 --- a/services/collectionobject/jaxb/.project +++ b/services/collectionobject/jaxb/.project @@ -1,24 +1,19 @@ - - org.collectionspace.services.collectionobject.jaxb - - - org.collectionspace.services.jaxb - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.collectionobject.jaxb + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/collectionobject/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/collectionobject/jaxb/.settings/org.maven.ide.eclipse.prefs index 783150162..dbd51f384 100644 --- a/services/collectionobject/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/collectionobject/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 09:52:52 PST 2010 +#Wed Jan 19 22:49:41 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/collectionobject/sample/sample/src/main/java/org/collectionspace/services/collectionobject/client/sample/Sample.java b/services/collectionobject/sample/sample/src/main/java/org/collectionspace/services/collectionobject/client/sample/Sample.java index 9611ee611..88fe963c1 100644 --- a/services/collectionobject/sample/sample/src/main/java/org/collectionspace/services/collectionobject/client/sample/Sample.java +++ b/services/collectionobject/sample/sample/src/main/java/org/collectionspace/services/collectionobject/client/sample/Sample.java @@ -34,16 +34,16 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import org.collectionspace.services.client.CollectionObjectClient; +import org.collectionspace.services.client.PayloadInputPart; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; import org.collectionspace.services.collectionobject.ResponsibleDepartmentList; import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; -import org.jboss.resteasy.plugins.providers.multipart.InputPart; -import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,7 +72,7 @@ public class Sample { public String createCollectionObject() { // Create a CollectionObject record to submit to the service. - MultipartOutput multipart = createCollectionObjectInstance(); + PoxPayloadOut multipart = createCollectionObjectInstance(); // Submit a 'create' request to the service, sending the new // CollectionObject record to be created, and store the response. @@ -97,7 +97,7 @@ public class Sample { // Read // --------------------------------------------------------------- - public MultipartInput readCollectionObject(String resourceId) throws Exception { + public PoxPayloadIn readCollectionObject(String resourceId) throws Exception { if (resourceId == null || resourceId.trim().isEmpty()) { throw new IllegalArgumentException( @@ -107,7 +107,7 @@ public class Sample { // Submit the read ("get") request to the service and store the response. // The resourceId is a unique identifier for the CollectionObject // record we're reading. - ClientResponse res = client.read(resourceId); + ClientResponse res = client.read(resourceId); // Get the status code from the response and check it against // the expected status code. @@ -119,7 +119,7 @@ public class Sample { } // Get the entity body of the response from the service. - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); return input; @@ -197,7 +197,7 @@ public class Sample { // Utility methods // --------------------------------------------------------------- - private MultipartOutput createCollectionObjectInstance() { + private PoxPayloadOut createCollectionObjectInstance() { // Create the Common part of a CollectionObject and add data to its fields. @@ -216,10 +216,10 @@ public class Sample { collectionObject.getBriefDescriptions().getBriefDescription().add("Papier mache bird mask with horns, " + "painted red with black and yellow spots. " + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns)."); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(collectionObject, + PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", getCommonPartName()); + commonPart.setLabel(getCommonPartName()); if (logger.isInfoEnabled()) { logger.info("CollectionObject Common part to be created:"); @@ -239,8 +239,8 @@ public class Sample { conh.setNhInt(999); conh.setNhLong(9999); - OutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE); - nhPart.getHeaders().add("label", getNHPartName()); + PayloadOutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE); + nhPart.setLabel(getNHPartName()); if (logger.isInfoEnabled()) { logger.info("CollectionObject Natural History part to be created:"); @@ -253,60 +253,18 @@ public class Sample { return multipart; } - private Object extractPart(MultipartInput input, String label, - Class clazz) throws Exception { - Object obj = null; - String partLabel = ""; - List parts = input.getParts(); - if (parts.size() == 0) { - logger.warn("No parts found in multipart body."); - } - if(logger.isInfoEnabled()){ - logger.info("Parts:"); - for(InputPart part : parts){ - partLabel = part.getHeaders().getFirst("label"); - logger.info("part = " + partLabel); - } - } - boolean partLabelMatched = false; - for(InputPart part : parts){ - partLabel = part.getHeaders().getFirst("label"); - if(label.equalsIgnoreCase(partLabel)){ - partLabelMatched = true; - if(logger.isInfoEnabled()){ - logger.info("found part" + partLabel); - } - String partStr = part.getBodyAsString(); - if (partStr == null || partStr.trim().isEmpty()) { - logger.warn("Part '" + label + "' in multipart body is empty."); - } else { - if (logger.isInfoEnabled()){ - logger.info("extracted part as str=\n" + partStr); - } - obj = part.getBody(clazz, null); - if(logger.isInfoEnabled()){ - logger.info("extracted part as obj=\n", - objectAsXmlString(obj, clazz)); - } - } - break; - } - } - if (! partLabelMatched) { - logger.warn("Could not find part '" + label + "' in multipart body."); - // Handle a potential condition where getBodyAsString() or getBody(), - // above, do *not* throw an IOException, but getBody() nonetheless - // retrieves a null object. - // - // This *may* be effectively unreachable, but is here as a precaution. - } else if (obj == null) { - logger.warn("Could not extract part '" + label + - "' in multipart body as an object."); - } - return obj; - } + static Object extractPart(PoxPayloadIn input, String label, Class clazz) { + Object obj = null; + + PayloadInputPart payloadInputPart = input.getPart(label); + if (payloadInputPart != null) { + obj = payloadInputPart.getBody(); + } + + return obj; + } - public void displayCollectionObject(MultipartInput input) + public void displayCollectionObject(PoxPayloadIn input) throws Exception { if (input == null) { @@ -412,7 +370,7 @@ public class Sample { } logger.info("Reading the new CollectionObject record ..."); - MultipartInput corecord = sample.readCollectionObject(newRecordId); + PoxPayloadIn corecord = sample.readCollectionObject(newRecordId); sample.displayCollectionObject(corecord); logger.info("Deleting the new CollectionObject record ..."); diff --git a/services/collectionobject/service/.classpath b/services/collectionobject/service/.classpath index 08bf61feb..d7e70f81c 100644 --- a/services/collectionobject/service/.classpath +++ b/services/collectionobject/service/.classpath @@ -1,11 +1,324 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/collectionobject/service/.project b/services/collectionobject/service/.project index 97999ab26..321ab691e 100644 --- a/services/collectionobject/service/.project +++ b/services/collectionobject/service/.project @@ -1,26 +1,35 @@ - - org.collectionspace.services.collectionobject.service - - - org.collectionspace.services.collectionobject.jaxb - org.collectionspace.services.jaxb - org.collectionspace.services.common - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + org.collectionspace.services.collectionobject.service + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.client + org.collectionspace.services.collectionobject.client + org.collectionspace.services.collectionobject.jaxb + org.collectionspace.services.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.intake.client + org.collectionspace.services.intake.jaxb + org.collectionspace.services.intake.service + org.collectionspace.services.jaxb + org.collectionspace.services.organization.client + org.collectionspace.services.organization.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb + org.collectionspace.services.relation.service + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/services/collectionobject/service/pom.xml b/services/collectionobject/service/pom.xml index 6401cf952..f73679981 100644 --- a/services/collectionobject/service/pom.xml +++ b/services/collectionobject/service/pom.xml @@ -27,11 +27,21 @@ org.collectionspace.services.common ${project.version} + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + org.collectionspace.services org.collectionspace.services.collectionobject.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.collectionobject.client + ${project.version} + org.collectionspace.services org.collectionspace.services.intake.jaxb diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index 3377d479a..d3dc89a6d 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -25,9 +25,10 @@ */ package org.collectionspace.services.collectionobject; -import java.io.InputStream; +import java.io.InputStream; //FIXME: REM - Please remove unneeded imports import java.io.File; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -47,7 +48,10 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.MultivaluedMap; -import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils; +import org.collectionspace.services.client.CollectionObjectClient; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +//import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils; //FIXME: REM - Please remove all unneeded imports import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.authorityref.AuthorityRefList; @@ -78,30 +82,24 @@ import org.collectionspace.services.relation.RelationshipType; import org.collectionspace.services.common.profile.Profiler; import org.collectionspace.services.common.FileUtils; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.util.HttpResponseCodes; //FIXME: There should be no direct dependency on Nuxeo in our resource classes. import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.nuxeo.ecm.core.api.ClientException; +//import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +//import org.nuxeo.ecm.core.api.ClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class CollectionObjectResource. */ -@Path("/collectionobjects") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Path(CollectionObjectClient.SERVICE_PATH_COMPONENT) +@Consumes("application/xml") +@Produces("application/xml") public class CollectionObjectResource extends AbstractMultiPartCollectionSpaceResourceImpl { - - /** The Constant serviceName. */ - static final public String serviceName = "collectionobjects"; /** The logger. */ final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class); @@ -121,7 +119,7 @@ public class CollectionObjectResource */ @Override public String getServiceName() { - return serviceName; + return CollectionObjectClient.SERVICE_PATH_COMPONENT; } /* (non-Javadoc) @@ -136,7 +134,7 @@ public class CollectionObjectResource * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext) */ // @Override -// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { +// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { // DocumentHandler docHandler = ctx.getDocumentHandler(); // if (ctx.getInput() != null) { // Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), @@ -156,9 +154,11 @@ public class CollectionObjectResource * @return the response */ @POST - public Response createCollectionObject(MultipartInput input) { + public Response createCollectionObject(@Context HttpServletRequest req, + String xmlPayload) { try { - ServiceContext ctx = createServiceContext(input); // + PoxPayloadIn input = new PoxPayloadIn(xmlPayload); + ServiceContext ctx = createServiceContext(input); DocumentHandler handler = createDocumentHandler(ctx); String csid = getRepositoryClient(ctx).create(ctx, handler); UriBuilder path = UriBuilder.fromResource(CollectionObjectResource.class); @@ -192,7 +192,7 @@ public class CollectionObjectResource */ @GET @Path("{csid}") - public MultipartOutput getCollectionObject( + public byte[] getCollectionObject( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getCollectionObject with csid=" + csid); @@ -204,12 +204,12 @@ public class CollectionObjectResource "text/plain").build(); throw new WebApplicationException(response); } - MultipartOutput result = null; + PoxPayloadOut result = null; try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csid, handler); - result = (MultipartOutput) ctx.getOutput(); + result = ctx.getOutput(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build(); @@ -237,7 +237,8 @@ public class CollectionObjectResource "text/plain").build(); throw new WebApplicationException(response); } - return result; + + return result.getBytes(); } /** @@ -274,7 +275,7 @@ public class CollectionObjectResource profiler.start(); try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); collectionObjectList = (CollectionobjectsCommonList) handler.getCommonPartList(); @@ -299,15 +300,15 @@ public class CollectionObjectResource * Update collection object. * * @param csid the csid - * @param theUpdate the the update + * @param xmlText an XML representation of the data to be used in the update * - * @return the multipart output + * @return an XML representation of the updated object */ @PUT @Path("{csid}") - public MultipartOutput updateCollectionObject( + public String updateCollectionObject( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlText) { if (logger.isDebugEnabled()) { logger.debug("updateCollectionObject with csid=" + csid); } @@ -318,12 +319,13 @@ public class CollectionObjectResource "text/plain").build(); throw new WebApplicationException(response); } - MultipartOutput result = null; + PoxPayloadOut result = null; try { - ServiceContext ctx = createServiceContext(theUpdate); + PoxPayloadIn update = new PoxPayloadIn(xmlText); + ServiceContext ctx = createServiceContext(update); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).update(ctx, csid, handler); - result = (MultipartOutput) ctx.getOutput(); + result = ctx.getOutput(); } catch (BadRequestException bre) { Response response = Response.status( Response.Status.BAD_REQUEST).entity("Update failed reason " + bre.getErrorReason()).type("text/plain").build(); @@ -334,7 +336,7 @@ public class CollectionObjectResource throw new WebApplicationException(response); } catch (DocumentNotFoundException dnfe) { if (logger.isDebugEnabled()) { - logger.debug("caugth exception in updateCollectionObject", dnfe); + logger.debug("Caught exception in updateCollectionObject", dnfe); } Response response = Response.status(Response.Status.NOT_FOUND).entity( "Update failed on CollectionObject csid=" + csid).type( @@ -345,7 +347,7 @@ public class CollectionObjectResource Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.toXML(); } /** @@ -370,7 +372,7 @@ public class CollectionObjectResource throw new WebApplicationException(response); } try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); getRepositoryClient(ctx).delete(ctx, csid); return Response.status(HttpResponseCodes.SC_OK).build(); } catch (UnauthorizedException ue) { @@ -393,6 +395,8 @@ public class CollectionObjectResource } + // FIXME AR: should the method below be deprecated? + /** * Gets the intakes common list. * @@ -467,11 +471,11 @@ public class CollectionObjectResource AuthorityRefList authRefList = null; try { MultivaluedMap queryParams = ui.getQueryParameters(); - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentWrapper docWrapper = getRepositoryClient(ctx).getDoc(ctx, csid); - DocumentModelHandler docHandler = - (DocumentModelHandler)createDocumentHandler(ctx); + DocumentModelHandler docHandler = + (DocumentModelHandler)createDocumentHandler(ctx); List authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues( ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES); @@ -516,7 +520,7 @@ public class CollectionObjectResource } /** - * This method is deprecated. Use kwSearchCollectionObjects() method instead. + * This method is deprecated. Use SearchCollectionObjects() method instead. * Keywords search collection objects. * @param ui * @@ -527,6 +531,7 @@ public class CollectionObjectResource @GET @Path("/search") @Produces("application/xml") + @Deprecated public CollectionobjectsCommonList keywordsSearchCollectionObjects(@Context UriInfo ui, @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { MultivaluedMap queryParams = ui.getQueryParameters(); @@ -547,7 +552,7 @@ public class CollectionObjectResource try { Profiler profiler = new Profiler("searchCollectionObjects():", 1); profiler.start(); - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); // perform a keyword search diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectValidatorHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectValidatorHandler.java index 8d6db72cd..6d241bc2b 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectValidatorHandler.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectValidatorHandler.java @@ -49,15 +49,14 @@ */ package org.collectionspace.services.collectionobject.nuxeo; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; //import org.collectionspace.services.common.context.MultipartServiceContext; //import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.InvalidDocumentException; import org.collectionspace.services.common.document.ValidatorHandlerImpl; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +64,7 @@ import org.slf4j.LoggerFactory; * * @author */ -public class CollectionObjectValidatorHandler extends ValidatorHandlerImpl { +public class CollectionObjectValidatorHandler extends ValidatorHandlerImpl { final Logger logger = LoggerFactory.getLogger(CollectionObjectValidatorHandler.class); -- 2.47.3