From 3165413ef8e57fb1c2c1af1261d917d5cc771608 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 16 Feb 2011 00:11:08 +0000 Subject: [PATCH] CSPACE-3574: Merging Plain Old XML payload work into trunk. --- .../nuxeo-platform-cs-media/.classpath | 12 +- .../3rdparty/nuxeo-platform-cs-media/.project | 12 +- services/media/client/.classpath | 318 ++++++++++++++++- services/media/client/.project | 19 +- .../services/client/MediaClient.java | 41 +-- .../services/client/MediaProxy.java | 12 +- .../client/test/MediaAuthRefsTest.java | 42 ++- .../client/test/MediaServiceTest.java | 53 +-- services/media/jaxb/.classpath | 37 +- services/media/jaxb/.project | 10 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/media/service/.classpath | 323 +++++++++++++++++- services/media/service/.project | 23 +- services/media/service/pom.xml | 5 + .../services/media/MediaResource.java | 49 +-- .../nuxeo-platform-cs-movement/.classpath | 12 +- .../nuxeo-platform-cs-movement/.project | 12 +- services/movement/client/.classpath | 318 ++++++++++++++++- services/movement/client/.project | 19 +- .../services/client/MovementClient.java | 59 ++-- .../services/client/MovementProxy.java | 13 +- .../client/test/MovementAuthRefsTest.java | 60 ++-- .../client/test/MovementServiceTest.java | 196 ++++++----- .../client/test/MovementSortByTest.java | 54 +-- services/movement/jaxb/.classpath | 37 +- services/movement/jaxb/.project | 10 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/movement/service/.classpath | 314 ++++++++++++++++- services/movement/service/.project | 16 +- .../services/movement/MovementResource.java | 48 +-- 30 files changed, 1734 insertions(+), 406 deletions(-) diff --git a/services/media/3rdparty/nuxeo-platform-cs-media/.classpath b/services/media/3rdparty/nuxeo-platform-cs-media/.classpath index 199bbbbdb..6fd3b8551 100644 --- a/services/media/3rdparty/nuxeo-platform-cs-media/.classpath +++ b/services/media/3rdparty/nuxeo-platform-cs-media/.classpath @@ -1,8 +1,8 @@ - - - - - + + - + + + + \ No newline at end of file diff --git a/services/media/3rdparty/nuxeo-platform-cs-media/.project b/services/media/3rdparty/nuxeo-platform-cs-media/.project index 4e940726b..8b023b3ab 100644 --- a/services/media/3rdparty/nuxeo-platform-cs-media/.project +++ b/services/media/3rdparty/nuxeo-platform-cs-media/.project @@ -1,23 +1,17 @@ - org.collectionspace.services.media.3rdparty.nuxeo - - - + Media 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.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/media/client/.classpath b/services/media/client/.classpath index 425cd1620..fac02f372 100644 --- a/services/media/client/.classpath +++ b/services/media/client/.classpath @@ -1,10 +1,312 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/media/client/.project b/services/media/client/.project index 21e912c43..b1282c8a7 100644 --- a/services/media/client/.project +++ b/services/media/client/.project @@ -1,23 +1,28 @@ - org.collectionspace.services.media.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.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.media.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.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/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java b/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java index be915210a..436fde70a 100644 --- a/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java +++ b/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java @@ -38,17 +38,21 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * */ public class MediaClient extends AbstractServiceClientImpl { - - /* (non-Javadoc) - * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() - */ + public static final String SERVICE_NAME = "media"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override public String getServicePathComponent() { - return "media"; //Laramie20100824 was medias, but label was a mismatch. + return SERVICE_PATH_COMPONENT; } - /** - * - */ -// private static final MediaClient instance = new MediaClient(); + /** * */ @@ -83,15 +87,6 @@ public class MediaClient extends AbstractServiceClientImpl { } } - /** - * FIXME Comment this - * - * @return - */ -// public static MediaClient getInstance() { -// return instance; -// } - /** * @return * @see org.collectionspace.services.client.MediaProxy#getMedia() @@ -115,7 +110,7 @@ public class MediaClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.MediaProxy#getMedia(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return mediaProxy.read(csid); } @@ -124,8 +119,8 @@ public class MediaClient extends AbstractServiceClientImpl { * @return * */ - public ClientResponse create(MultipartOutput multipart) { - return mediaProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return mediaProxy.create(xmlPayload.getBytes()); } /** @@ -133,8 +128,8 @@ public class MediaClient extends AbstractServiceClientImpl { * @param media * @return */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return mediaProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut xmlPayload) { + return mediaProxy.update(csid, xmlPayload.getBytes()); } diff --git a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java index 2c0291724..8c2534ab9 100644 --- a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java +++ b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java @@ -19,24 +19,24 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; /** * @version $Revision: 2108 $ */ -@Path("/media/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Path(MediaClient.SERVICE_PATH + "/") +@Produces({"application/xml", "multipart/mixed"}) +@Consumes({"application/xml", "multipart/mixed"}) public interface MediaProxy extends CollectionSpaceProxy { //(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); //(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/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java index 76768956e..201bc7204 100644 --- a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java +++ b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java @@ -33,8 +33,11 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.MediaClient; +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.media.MediaCommon; @@ -57,10 +60,8 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class MediaAuthRefsTest extends BaseServiceTest { - private final String CLASS_NAME = MediaAuthRefsTest.class.getName(); - private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - final String SERVICE_PATH_COMPONENT = "media"; + private final Logger logger = LoggerFactory.getLogger(MediaAuthRefsTest.class); final String PERSON_AUTHORITY_NAME = "MediaPersonAuth"; private String knownResourceId = null; private List mediaIdsCreated = new ArrayList(); @@ -69,6 +70,16 @@ public class MediaAuthRefsTest extends BaseServiceTest { private String depositorRefName = null; private String title = null; + @Override + public String getServicePathComponent() { + return MediaClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return MediaClient.SERVICE_NAME; + } + @Override protected CollectionSpaceClient getClientInstance() { throw new UnsupportedOperationException(); //method not supported (or needed) in this test class @@ -79,20 +90,15 @@ public class MediaAuthRefsTest extends BaseServiceTest { throw new UnsupportedOperationException(); //method not supported (or needed) in this test class } - @Override - public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; - } - - private MultipartOutput createMediaInstance(String depositorRefName, String title) { + private PoxPayloadOut createMediaInstance(String depositorRefName, String title) { this.title = title; this.depositorRefName = depositorRefName; MediaCommon media = new MediaCommon(); media.setTitle(title); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new MediaClient().getCommonPartName()); + PoxPayloadOut multipart = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new MediaClient().getCommonPartName()); logger.debug("to be created, media common: " + objectAsXmlString(media, MediaCommon.class)); return multipart; } @@ -106,7 +112,7 @@ public class MediaAuthRefsTest extends BaseServiceTest { // Create a new Loans In resource. One or more fields in this resource will be PersonAuthority // references, and will refer to Person resources by their refNames. MediaClient mediaClient = new MediaClient(); - MultipartOutput multipart = createMediaInstance(depositorRefName, "media.title-" + identifier); + PoxPayloadOut multipart = createMediaInstance(depositorRefName, "media.title-" + identifier); ClientResponse res = mediaClient.create(multipart); assertStatusCode(res, testName); if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below. @@ -118,7 +124,8 @@ public class MediaAuthRefsTest extends BaseServiceTest { protected void createPersonRefs() { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified. - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); assertStatusCode(res, "createPersonRefs (not a surefire test)"); personAuthCSID = extractId(res); @@ -141,7 +148,8 @@ public class MediaAuthRefsTest extends BaseServiceTest { personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName()); + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance( + personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName()); ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); assertStatusCode(res, "createPerson (not a surefire test)"); return extractId(res); @@ -159,9 +167,9 @@ public class MediaAuthRefsTest extends BaseServiceTest { logger.debug(testBanner(testName, CLASS_NAME)); testSetup(STATUS_OK, ServiceRequestType.READ); MediaClient mediaClient = new MediaClient(); - ClientResponse res = mediaClient.read(knownResourceId); + ClientResponse res = mediaClient.read(knownResourceId); assertStatusCode(res, testName); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); MediaCommon media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class); Assert.assertNotNull(media); logger.debug(objectAsXmlString(media, MediaCommon.class)); diff --git a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java index e90092e6e..aef19334f 100644 --- a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java +++ b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java @@ -27,7 +27,11 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.MediaClient; +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.media.MediaCommon; @@ -51,9 +55,18 @@ public class MediaServiceTest extends AbstractServiceTestImpl { private final String CLASS_NAME = MediaServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - final String SERVICE_PATH_COMPONENT = "media"; private String knownResourceId = null; + @Override + public String getServicePathComponent() { + return MediaClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return MediaClient.SERVICE_NAME; + } + @Override protected CollectionSpaceClient getClientInstance() { return new MediaClient(); @@ -70,7 +83,7 @@ public class MediaServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupCreate(); MediaClient client = new MediaClient(); - MultipartOutput multipart = createMediaInstance(createIdentifier()); + PoxPayloadOut multipart = createMediaInstance(createIdentifier()); ClientResponse res = client.create(multipart); assertStatusCode(res, testName); if (knownResourceId == null) { @@ -95,9 +108,9 @@ public class MediaServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupRead(); MediaClient client = new MediaClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); assertStatusCode(res, testName); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); MediaCommon media = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class); Assert.assertNotNull(media); } @@ -129,21 +142,21 @@ public class MediaServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupUpdate(); MediaClient client = new MediaClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); assertStatusCode(res, testName); logger.debug("got object to update with ID: " + knownResourceId); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity());; MediaCommon media = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class); Assert.assertNotNull(media); media.setTitle("updated-" + media.getTitle()); logger.debug("Object to be updated:"+objectAsXmlString(media, MediaCommon.class)); - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(media, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(media, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); res = client.update(knownResourceId, output); assertStatusCode(res, testName); - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); MediaCommon updatedMedia = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class); Assert.assertNotNull(updatedMedia); } @@ -157,8 +170,8 @@ public class MediaServiceTest 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. MediaClient client = new MediaClient(); - MultipartOutput multipart = createMediaInstance(NON_EXISTENT_ID); - ClientResponse res = client.update(NON_EXISTENT_ID, multipart); + PoxPayloadOut multipart = createMediaInstance(NON_EXISTENT_ID); + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); assertStatusCode(res, testName); } @@ -183,7 +196,7 @@ public class MediaServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupReadNonExistent(); MediaClient client = new MediaClient(); - ClientResponse res = client.read(NON_EXISTENT_ID); + ClientResponse res = client.read(NON_EXISTENT_ID); assertStatusCode(res, testName); } @@ -242,19 +255,13 @@ public class MediaServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- - - @Override - public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; - } - - private MultipartOutput createMediaInstance(String title) { + private PoxPayloadOut createMediaInstance(String title) { String identifier = "media.title-" + title; MediaCommon media = new MediaCommon(); media.setTitle(identifier); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new MediaClient().getCommonPartName()); + PoxPayloadOut multipart = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new MediaClient().getCommonPartName()); if (logger.isDebugEnabled()) { logger.debug("to be created, media common"); diff --git a/services/media/jaxb/.classpath b/services/media/jaxb/.classpath index 557f8a4e0..981c9add6 100644 --- a/services/media/jaxb/.classpath +++ b/services/media/jaxb/.classpath @@ -1,10 +1,31 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/media/jaxb/.project b/services/media/jaxb/.project index 42974242f..f340a5806 100644 --- a/services/media/jaxb/.project +++ b/services/media/jaxb/.project @@ -1,23 +1,19 @@ - org.collectionspace.services.media.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.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/media/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/media/jaxb/.settings/org.maven.ide.eclipse.prefs index 678086497..bd49bfd74 100644 --- a/services/media/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/media/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:06:22 PST 2010 +#Wed Jan 19 22:49:44 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/media/service/.classpath b/services/media/service/.classpath index 425cd1620..be462d3c8 100644 --- a/services/media/service/.classpath +++ b/services/media/service/.classpath @@ -1,10 +1,317 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/media/service/.project b/services/media/service/.project index b76607a81..c807a19e3 100644 --- a/services/media/service/.project +++ b/services/media/service/.project @@ -1,23 +1,32 @@ - org.collectionspace.services.media.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.blob.client + org.collectionspace.services.blob.service + 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.media.client + org.collectionspace.services.media.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.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/media/service/pom.xml b/services/media/service/pom.xml index 271b552a8..97de9ad1a 100644 --- a/services/media/service/pom.xml +++ b/services/media/service/pom.xml @@ -34,6 +34,11 @@ org.collectionspace.services.media.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.media.client + ${project.version} + org.collectionspace.services org.collectionspace.services.collectionobject.jaxb diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java index 9cc3e6e06..3774bea95 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java @@ -23,6 +23,9 @@ */ package org.collectionspace.services.media; +import org.collectionspace.services.client.MediaClient; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ResourceBase; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ServiceMain; @@ -38,6 +41,8 @@ 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.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; @@ -55,17 +60,19 @@ import javax.ws.rs.core.Response; import java.io.InputStream; import java.util.List; -@Path("/media") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Path(MediaClient.SERVICE_PATH) +@Produces({"application/xml", "multipart/mixed"}) +@Consumes({"application/xml", "multipart/mixed"}) public class MediaResource extends ResourceBase { + final Logger logger = LoggerFactory.getLogger(MediaResource.class); @Override public String getServiceName(){ - return "media"; + return MediaClient.SERVICE_NAME; } private BlobResource blobResource = new BlobResource(); + BlobResource getBlobResource() { return blobResource; } @@ -75,7 +82,7 @@ public class MediaResource extends ResourceBase { // */ // private BlobInput blobInput = new BlobInput(); // -// public BlobInput getBlobInput(ServiceContext ctx) { +// public BlobInput getBlobInput(ServiceContext ctx) { // // // // Publish the blobInput to the current context on every get. Even though // // it might already be published. @@ -87,7 +94,7 @@ public class MediaResource extends ResourceBase { private String getBlobCsid(String mediaCsid) throws Exception { String result = null; - ServiceContext mediaContext = createServiceContext(); + ServiceContext mediaContext = createServiceContext(); BlobInput blobInput = BlobUtil.getBlobInput(mediaContext); blobInput.setSchemaRequested(true); get(mediaCsid, mediaContext); //this call sets the blobInput.blobCsid field for us @@ -95,9 +102,8 @@ public class MediaResource extends ResourceBase { ensureCSID(result, READ); return result; - } + } - //FIXME retrieve client type from configuration final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); @@ -119,20 +125,20 @@ public class MediaResource extends ResourceBase { public Response createBlob(@Context HttpServletRequest req, @QueryParam("blobUri") String blobUri, @PathParam("csid") String csid) { - MultipartInput input = null; + PoxPayloadIn input = null; Response response = null; try { // // First, create the blob // - ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME, input); + ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME, input); BlobInput blobInput = BlobUtil.getBlobInput(blobContext); blobInput.createBlobFile(req, blobUri); response = this.create(input, blobContext); // // Next, update the Media record to be linked to the blob // - ServiceContext mediaContext = createServiceContext(); + ServiceContext mediaContext = createServiceContext(); BlobUtil.setBlobInput(mediaContext, blobInput); //and put the blobInput into the Media context this.update(csid, input, mediaContext); @@ -145,18 +151,18 @@ public class MediaResource extends ResourceBase { @GET @Path("{csid}/blob") - public MultipartOutput getBlobInfo(@PathParam("csid") String csid) { - MultipartOutput result = null; + public byte[] getBlobInfo(@PathParam("csid") String csid) { + PoxPayloadOut result = null; try { String blobCsid = this.getBlobCsid(csid); - ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); + ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); result = this.get(blobCsid, blobContext); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.READ_FAILED, csid); } - return result; + return result.getBytes(); } @GET @@ -198,20 +204,21 @@ public class MediaResource extends ResourceBase { @GET @Path("{csid}/blob/derivatives/{derivativeTerm}") - public MultipartOutput getDerivative(@PathParam("csid") String csid, + public byte[] getDerivative(@PathParam("csid") String csid, @PathParam("derivativeTerm") String derivativeTerm) { - MultipartOutput result = null; + PoxPayloadOut result = null; try { ensureCSID(csid, READ); String blobCsid = this.getBlobCsid(csid); - ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); - result = getBlobResource().getDerivative(blobCsid, derivativeTerm); + ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); + String xmlPayload = getBlobResource().getDerivative(blobCsid, derivativeTerm); + result = new PoxPayloadOut(xmlPayload.getBytes()); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.READ_FAILED, csid); } - return result; + return result.getBytes(); } @GET @@ -224,7 +231,7 @@ public class MediaResource extends ResourceBase { try { ensureCSID(csid, READ); String blobCsid = this.getBlobCsid(csid); - ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); + ServiceContext blobContext = createServiceContext(BlobUtil.BLOB_RESOURCE_NAME); result = getBlobResource().getDerivatives(blobCsid); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.READ_FAILED, csid); diff --git a/services/movement/3rdparty/nuxeo-platform-cs-movement/.classpath b/services/movement/3rdparty/nuxeo-platform-cs-movement/.classpath index 199bbbbdb..6fd3b8551 100644 --- a/services/movement/3rdparty/nuxeo-platform-cs-movement/.classpath +++ b/services/movement/3rdparty/nuxeo-platform-cs-movement/.classpath @@ -1,8 +1,8 @@ - - - - - + + - + + + + \ No newline at end of file diff --git a/services/movement/3rdparty/nuxeo-platform-cs-movement/.project b/services/movement/3rdparty/nuxeo-platform-cs-movement/.project index 1dd0e5960..3b05b57bf 100644 --- a/services/movement/3rdparty/nuxeo-platform-cs-movement/.project +++ b/services/movement/3rdparty/nuxeo-platform-cs-movement/.project @@ -1,23 +1,17 @@ - org.collectionspace.services.movement.3rdparty.nuxeo - - - + Movement 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.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/movement/client/.classpath b/services/movement/client/.classpath index 425cd1620..3905887fc 100644 --- a/services/movement/client/.classpath +++ b/services/movement/client/.classpath @@ -1,10 +1,312 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/movement/client/.project b/services/movement/client/.project index c38b04b90..2c306d690 100644 --- a/services/movement/client/.project +++ b/services/movement/client/.project @@ -1,23 +1,28 @@ - org.collectionspace.services.movement.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.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.movement.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.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/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java index df554cc5c..89d2ee506 100644 --- a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java +++ b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java @@ -26,8 +26,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; /** @@ -38,23 +36,13 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * */ public class MovementClient extends AbstractServiceClientImpl { + public static final String SERVICE_NAME = "movements"; + 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.AbstractServiceClientImpl#getServicePathComponent() - */ - @Override - public String getServicePathComponent() { - return "movements"; - } - /** - * - */ -// private static final MovementClient instance = new MovementClient(); - /** - * - */ private MovementProxy movementProxy; - /** * * Default constructor for MovementClient class. @@ -66,6 +54,19 @@ public class MovementClient extends AbstractServiceClientImpl { setProxy(); } + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() + */ + @Override + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + @Override public CollectionSpaceProxy getProxy() { return this.movementProxy; @@ -85,15 +86,6 @@ public class MovementClient extends AbstractServiceClientImpl { } } - /** - * FIXME Comment this - * - * @return - */ -// public static MovementClient getInstance() { -// return instance; -// } - /** * @return * @see org.collectionspace.services.client.MovementProxy#readList() @@ -136,27 +128,27 @@ public class MovementClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.MovementProxy#getMovement(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return movementProxy.read(csid); } /** - * @param movement + * @param multipart * @return * @see org.collectionspace.services.client.MovementProxy#createMovement(org.collectionspace.hello.Movement) */ - public ClientResponse create(MultipartOutput multipart) { - return movementProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return movementProxy.create(xmlPayload.getBytes()); } /** * @param csid - * @param movement + * @param multipart * @return * @see org.collectionspace.services.client.MovementProxy#updateMovement(java.lang.Long, org.collectionspace.hello.Movement) */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return movementProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut xmlPayload) { + return movementProxy.update(csid, xmlPayload.getBytes()); } @@ -165,6 +157,7 @@ public class MovementClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.MovementProxy#deleteMovement(java.lang.Long) */ + @Override public ClientResponse delete(String csid) { return movementProxy.delete(csid); } diff --git a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java index 19ac2b65e..d4b90f0b2 100644 --- a/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java +++ b/services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java @@ -39,8 +39,7 @@ import org.collectionspace.services.common.query.IQueryManager; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.movement.MovementsCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; + /** * MovementProxy.java @@ -49,23 +48,23 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; * $LastChangedDate$ */ @Path("/movements/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Produces("application/xml") +@Consumes("application/xml") public interface MovementProxy extends CollectionSpaceProxy { //(C)reate @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(byte[] payload); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, byte[] payload); //(D)elete @DELETE diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java index 2079f7ebf..351b69a4b 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java @@ -35,6 +35,10 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.MovementClient; import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; +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.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -42,9 +46,6 @@ import org.collectionspace.services.movement.MovementsCommon; 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; import org.testng.annotations.Test; @@ -63,9 +64,10 @@ public class MovementAuthRefsTest extends BaseServiceTest { private final String CLASS_NAME = MovementAuthRefsTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + final String SERVICE_NAME = "movements"; + final String SERVICE_PATH_COMPONENT = "movements"; // Instance variables specific to this test. - final String SERVICE_PATH_COMPONENT = "movements"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; private List movementIdsCreated = new ArrayList(); @@ -118,7 +120,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { // One or more fields in this resource will be PersonAuthority // references, and will refer to Person resources by their refNames. MovementClient movementClient = new MovementClient(); - MultipartOutput multipart = createMovementInstance( + PoxPayloadOut multipart = createMovementInstance( "movementReferenceNumber-" + identifier, GregorianCalendarDateTimeUtils.timestampUTC(), movementContactRefName); @@ -157,7 +159,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding // refName by which it can be identified. - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); int statusCode = res.getStatus(); @@ -182,7 +184,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); - MultipartOutput multipart = + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName()); ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); @@ -207,7 +209,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient movementClient = new MovementClient(); - ClientResponse res = movementClient.read(knownResourceId); + ClientResponse res = movementClient.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -219,16 +221,20 @@ public class MovementAuthRefsTest extends BaseServiceTest { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - MovementsCommon movement = (MovementsCommon) extractPart(input, - movementClient.getCommonPartName(), MovementsCommon.class); - Assert.assertNotNull(movement); + // Extract and return the common part of the record. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(movementClient.getCommonPartName()); + MovementsCommon movementCommon = null; + if (payloadInputPart != null) { + movementCommon = (MovementsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(movementCommon); if(logger.isDebugEnabled()){ - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } // Check a couple of fields // FIXME - Assert.assertEquals(movement.getMovementContact(), movementContactRefName); + Assert.assertEquals(movementCommon.getMovementContact(), movementContactRefName); // Get the auth refs and check them ClientResponse res2 = @@ -318,26 +324,32 @@ public class MovementAuthRefsTest extends BaseServiceTest { // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- + + @Override + protected String getServiceName() { + return SERVICE_NAME; + } + @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } - private MultipartOutput createMovementInstance(String movementReferenceNumber, + private PoxPayloadOut createMovementInstance(String movementReferenceNumber, String locationDate, String movementContact) { - MovementsCommon movement = new MovementsCommon(); - movement.setMovementReferenceNumber(movementReferenceNumber); - movement.setLocationDate(locationDate); - movement.setMovementContact(movementContact); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(movement, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new MovementClient().getCommonPartName()); + MovementsCommon movementCommon = new MovementsCommon(); + movementCommon.setMovementReferenceNumber(movementReferenceNumber); + movementCommon.setLocationDate(locationDate); + movementCommon.setMovementContact(movementContact); + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new MovementClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, movement common"); - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } return multipart; diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java index 729af0e51..181f4f2b7 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java @@ -41,9 +41,10 @@ import org.collectionspace.services.movement.MovementMethodsList; 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.collectionspace.services.client.PayloadInputPart; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.testng.Assert; import org.testng.annotations.Test; @@ -63,13 +64,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { private final String CLASS_NAME = MovementServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - // Instance variables specific to this test. - /** The service path component. */ + final String SERVICE_NAME = "movements"; final String SERVICE_PATH_COMPONENT = "movements"; - - /** The known resource id. */ - private String knownResourceId = null; + // Instance variables specific to this test. + private String knownResourceId = null; private final static String TIMESTAMP_UTC = GregorianCalendarDateTimeUtils.timestampUTC(); /* (non-Javadoc) @@ -111,7 +110,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createMovementInstance(identifier); + PoxPayloadOut multipart = createMovementInstance(identifier); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -291,7 +290,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -303,19 +302,35 @@ public class MovementServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - MovementsCommon movement = (MovementsCommon) extractPart(input, - client.getCommonPartName(), MovementsCommon.class); - Assert.assertNotNull(movement); + // Get the common part of the response and verify that it is not null. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + MovementsCommon movementCommon = null; + if (payloadInputPart != null) { + movementCommon = (MovementsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(movementCommon); + + // Check selected fields. - // Check the values of one or more date/time fields + // Check the values of one or more date/time fields. if (logger.isDebugEnabled()) { - logger.debug("locationDate=" + movement.getLocationDate()); + logger.debug("locationDate=" + movementCommon.getLocationDate()); logger.debug("TIMESTAMP_UTC=" + TIMESTAMP_UTC); } - Assert.assertTrue(movement.getLocationDate().equals(TIMESTAMP_UTC)); - Assert.assertTrue(movement.getPlannedRemovalDate().equals(TIMESTAMP_UTC)); - Assert.assertNull(movement.getRemovalDate()); + Assert.assertTrue(movementCommon.getLocationDate().equals(TIMESTAMP_UTC)); + Assert.assertTrue(movementCommon.getPlannedRemovalDate().equals(TIMESTAMP_UTC)); + Assert.assertNull(movementCommon.getRemovalDate()); + + // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters. + if(logger.isDebugEnabled()){ + logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n" + + "UTF-8 data received=" + movementCommon.getMovementNote()); + } + Assert.assertEquals(movementCommon.getMovementNote(), getUTF8DataFragment(), + "UTF-8 data retrieved '" + movementCommon.getMovementNote() + + "' does not match expected data '" + getUTF8DataFragment()); + } // Failure outcomes @@ -335,7 +350,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - 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 @@ -424,43 +439,46 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. MovementClient client = new MovementClient(); - ClientResponse res = - client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); - if(logger.isDebugEnabled()){ logger.debug("got object to update with ID: " + knownResourceId); } - MultipartInput input = (MultipartInput) res.getEntity(); - MovementsCommon movement = (MovementsCommon) extractPart(input, - client.getCommonPartName(), MovementsCommon.class); - Assert.assertNotNull(movement); - // Update the content of this resource. - movement.setMovementReferenceNumber("updated-" + movement.getMovementReferenceNumber()); - movement.setMovementNote("updated movement note-" + movement.getMovementNote()); - movement.setNormalLocation(""); // Test deletion of existing string value + // Extract the common part from the response. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + MovementsCommon movementCommon = null; + if (payloadInputPart != null) { + movementCommon = (MovementsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(movementCommon); + + // Update its content. + movementCommon.setMovementReferenceNumber("updated-" + movementCommon.getMovementReferenceNumber()); + movementCommon.setMovementNote("updated movement note-" + movementCommon.getMovementNote()); + movementCommon.setNormalLocation(""); // Test deletion of existing string value String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC(); - movement.setPlannedRemovalDate(""); // Test deletion of existing date or date/time value - movement.setRemovalDate(currentTimestamp); + movementCommon.setPlannedRemovalDate(""); // Test deletion of existing date or date/time value + movementCommon.setRemovalDate(currentTimestamp); if(logger.isDebugEnabled()){ logger.debug("to be updated object"); - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } // Submit the request to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(movement, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); - + PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = output.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); res = client.update(knownResourceId, output); - int statusCode = res.getStatus(); + // Check the status code of the response: does it match the expected response(s)? + int statusCode = res.getStatus(); if(logger.isDebugEnabled()){ logger.debug(testName + ": status = " + statusCode); } @@ -468,34 +486,48 @@ public class MovementServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - input = (MultipartInput) res.getEntity(); - MovementsCommon updatedMovement = - (MovementsCommon) extractPart(input, - client.getCommonPartName(), MovementsCommon.class); - Assert.assertNotNull(updatedMovement); - + // Extract the updated common part from the response. + input = new PoxPayloadIn(res.getEntity()); + payloadInputPart = input.getPart(client.getCommonPartName()); + MovementsCommon updatedMovementCommon = null; + if (payloadInputPart != null) { + updatedMovementCommon = (MovementsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(movementCommon); if(logger.isDebugEnabled()){ logger.debug("updated object"); - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(updatedMovementCommon, MovementsCommon.class)); } - Assert.assertEquals(updatedMovement.getNormalLocation(), - movement.getNormalLocation(), "Data in updated object did not match submitted data."); + // Check selected fields in the updated common part. + Assert.assertEquals(updatedMovementCommon.getNormalLocation(), + movementCommon.getNormalLocation(), "Data in updated object did not match submitted data."); if(logger.isDebugEnabled()){ - logger.debug("Normal location after update=|" + updatedMovement.getNormalLocation() + "|"); + logger.debug("Normal location after update=|" + updatedMovementCommon.getNormalLocation() + "|"); } - Assert.assertEquals(updatedMovement.getMovementReferenceNumber(), - movement.getMovementReferenceNumber(), + Assert.assertEquals(updatedMovementCommon.getMovementReferenceNumber(), + movementCommon.getMovementReferenceNumber(), "Data in updated object did not match submitted data."); - Assert.assertEquals(updatedMovement.getMovementNote(), - movement.getMovementNote(), + Assert.assertEquals(updatedMovementCommon.getMovementNote(), + movementCommon.getMovementNote(), "Data in updated object did not match submitted data."); - Assert.assertNull(updatedMovement.getPlannedRemovalDate()); - Assert.assertEquals(updatedMovement.getRemovalDate(), - movement.getRemovalDate(), + Assert.assertNull(updatedMovementCommon.getPlannedRemovalDate()); + Assert.assertEquals(updatedMovementCommon.getRemovalDate(), + movementCommon.getRemovalDate(), "Data in updated object did not match submitted data."); + if(logger.isDebugEnabled()){ + logger.debug("UTF-8 data sent=" + movementCommon.getMovementNote() + "\n" + + "UTF-8 data received=" + updatedMovementCommon.getMovementNote()); + } + Assert.assertTrue(updatedMovementCommon.getMovementNote().contains(getUTF8DataFragment()), + "UTF-8 data retrieved '" + updatedMovementCommon.getMovementNote() + + "' does not contain expected data '" + getUTF8DataFragment()); + Assert.assertEquals(updatedMovementCommon.getMovementNote(), + movementCommon.getMovementNote(), + "Data in updated object did not match submitted data."); + } // Failure outcomes @@ -632,9 +664,8 @@ public class MovementServiceTest 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. MovementClient client = new MovementClient(); - MultipartOutput multipart = createMovementInstance(NON_EXISTENT_ID); - ClientResponse res = - client.update(NON_EXISTENT_ID, multipart); + PoxPayloadOut multipart = createMovementInstance(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 @@ -746,6 +777,12 @@ public class MovementServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- + + @Override + protected String getServiceName() { + return SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ @@ -760,7 +797,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier * @return the multipart output */ - private MultipartOutput createMovementInstance(String identifier) { + private PoxPayloadOut createMovementInstance(String identifier) { return createInstance("movementReferenceNumber-" + identifier); } @@ -771,16 +808,16 @@ public class MovementServiceTest extends AbstractServiceTestImpl { * @return Multipart output suitable for use as a payload * in a create or update request. */ - private MultipartOutput createInstance(String movementReferenceNumber) { - MovementsCommon movement = new MovementsCommon(); + private PoxPayloadOut createInstance(String movementReferenceNumber) { + MovementsCommon movementCommon = new MovementsCommon(); // FIXME: Values of currentLocation, normalLocation, // and movementContact should be refNames. - movement.setCurrentLocation("currentLocation value"); - movement.setCurrentLocationFitness("currentLocationFitness value"); - movement.setCurrentLocationNote("currentLocationNote value"); - movement.setLocationDate(TIMESTAMP_UTC); - movement.setNormalLocation("normalLocation value"); - movement.setMovementContact("movementContact value"); + movementCommon.setCurrentLocation("currentLocation value"); + movementCommon.setCurrentLocationFitness("currentLocationFitness value"); + movementCommon.setCurrentLocationNote("currentLocationNote value"); + movementCommon.setLocationDate(TIMESTAMP_UTC); + movementCommon.setNormalLocation("normalLocation value"); + movementCommon.setMovementContact("movementContact value"); MovementMethodsList movementMethodsList = new MovementMethodsList(); List methods = movementMethodsList.getMovementMethod(); // @TODO Use properly formatted refNames for representative movement @@ -788,20 +825,21 @@ public class MovementServiceTest extends AbstractServiceTestImpl { String identifier = createIdentifier(); methods.add("First Movement Method-" + identifier); methods.add("Second Movement Method-" + identifier); - movement.setMovementMethods(movementMethodsList); - movement.setMovementNote("movementNote value"); - movement.setMovementReferenceNumber(movementReferenceNumber); - movement.setPlannedRemovalDate(TIMESTAMP_UTC); - movement.setRemovalDate(""); // Test empty date value - movement.setReasonForMove("reasonForMove value"); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(movement, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new MovementClient().getCommonPartName()); + movementCommon.setMovementMethods(movementMethodsList); + movementCommon.setMovementNote(getUTF8DataFragment()); + movementCommon.setMovementReferenceNumber(movementReferenceNumber); + movementCommon.setPlannedRemovalDate(TIMESTAMP_UTC); + movementCommon.setRemovalDate(""); // Test empty date value + movementCommon.setReasonForMove("reasonForMove value"); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new MovementClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, movement common"); - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } return multipart; diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java index e72a25fb5..cb2836c02 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java @@ -33,14 +33,15 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.MovementJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.MovementClient; +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.movement.MovementsCommon; import org.collectionspace.services.movement.MovementsCommonList; 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; @@ -61,6 +62,7 @@ public class MovementSortByTest extends BaseServiceTest { private final String CLASS_NAME = MovementSortByTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + final String SERVICE_NAME = "movements"; // Instance variables specific to this test. private final String DELIMITER_SCHEMA_AND_FIELD = ":"; @@ -593,6 +595,11 @@ public class MovementSortByTest extends BaseServiceTest { // Utility methods used by tests above // --------------------------------------------------------------- + @Override + protected String getServiceName() { + return SERVICE_NAME; + } + @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; @@ -627,7 +634,7 @@ public class MovementSortByTest extends BaseServiceTest { */ @DataProvider(name = "unsortedValues") public Object[][] unsortedValues() { - // Add a test record-specific string so we have the option of + // FIXME: ADR Add a test record-specific string so we have the option of // constraining tests to only test records, in list or search results. final String TEST_RECORD_SPECIFIC_STRING = CLASS_NAME + " " + TEST_SPECIFIC_KEYWORD; return new Object[][]{ @@ -669,9 +676,9 @@ public class MovementSortByTest extends BaseServiceTest { testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. - MovementClient client = new MovementClient(); - MultipartOutput multipart = createMovementInstance(createIdentifier(), + PoxPayloadOut multipart = createMovementInstance(createIdentifier(), movementNote, locationDate); + MovementClient client = new MovementClient(); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -700,7 +707,7 @@ public class MovementSortByTest extends BaseServiceTest { // Submit the request to the service and store the response. MovementClient client = new MovementClient(); - ClientResponse res = client.read(csid); + ClientResponse res = client.read(csid); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -713,29 +720,32 @@ public class MovementSortByTest extends BaseServiceTest { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Extract and return the common part of the record. - MultipartInput input = (MultipartInput) res.getEntity(); - MovementsCommon movement = (MovementsCommon) extractPart(input, - client.getCommonPartName(), MovementsCommon.class); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + MovementsCommon movementCommon = null; + if (payloadInputPart != null) { + movementCommon = (MovementsCommon) payloadInputPart.getBody(); + } - return movement; + return movementCommon; } - private MultipartOutput createMovementInstance( + private PoxPayloadOut createMovementInstance( String movementReferenceNumber, String movementNote, String locationDate) { - MovementsCommon movement = new MovementsCommon(); - movement.setMovementReferenceNumber(movementReferenceNumber); - movement.setMovementNote(movementNote); - movement.setLocationDate(locationDate); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(movement, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new MovementClient().getCommonPartName()); - + MovementsCommon movementCommon = new MovementsCommon(); + movementCommon.setMovementReferenceNumber(movementReferenceNumber); + movementCommon.setMovementNote(movementNote); + movementCommon.setLocationDate(locationDate); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new MovementClient().getCommonPartName()); if (logger.isDebugEnabled()) { logger.debug("to be created, movement common"); - logger.debug(objectAsXmlString(movement, MovementsCommon.class)); + logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } return multipart; diff --git a/services/movement/jaxb/.classpath b/services/movement/jaxb/.classpath index 557f8a4e0..981c9add6 100644 --- a/services/movement/jaxb/.classpath +++ b/services/movement/jaxb/.classpath @@ -1,10 +1,31 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/movement/jaxb/.project b/services/movement/jaxb/.project index 474a1e995..63db17199 100644 --- a/services/movement/jaxb/.project +++ b/services/movement/jaxb/.project @@ -1,23 +1,19 @@ - org.collectionspace.services.movement.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.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/movement/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/movement/jaxb/.settings/org.maven.ide.eclipse.prefs index 6d70a75d4..57e45eb37 100644 --- a/services/movement/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/movement/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:05:52 PST 2010 +#Wed Jan 19 22:49:46 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/movement/service/.classpath b/services/movement/service/.classpath index 425cd1620..d2d242f0e 100644 --- a/services/movement/service/.classpath +++ b/services/movement/service/.classpath @@ -1,10 +1,308 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/movement/service/.project b/services/movement/service/.project index fcd987dbf..2bba63e0c 100644 --- a/services/movement/service/.project +++ b/services/movement/service/.project @@ -1,23 +1,25 @@ - org.collectionspace.services.movement.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.jaxb + org.collectionspace.services.common + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.movement.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/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java b/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java index 93a8dbd1e..67759b3a7 100644 --- a/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java +++ b/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java @@ -41,6 +41,8 @@ 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.common.AbstractMultiPartCollectionSpaceResourceImpl; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ServiceMain; @@ -60,8 +62,6 @@ import org.collectionspace.services.movement.MovementsCommon; import org.collectionspace.services.movement.MovementsCommonList; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -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; @@ -77,8 +77,8 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ @Path("/movements") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Consumes("application/xml") +@Produces("application/xml") public class MovementResource extends AbstractMultiPartCollectionSpaceResourceImpl { /** The Constant serviceName. */ @@ -144,9 +144,10 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm * @return the response */ @POST - public Response createMovement(MultipartInput input) { + public Response createMovement(String xmlText) { try { - ServiceContext ctx = createServiceContext(input); + PoxPayloadIn input = new PoxPayloadIn(xmlText); + ServiceContext ctx = createServiceContext(input); DocumentHandler handler = createDocumentHandler(ctx); String csid = getRepositoryClient(ctx).create(ctx, handler); //movementObject.setCsid(csid); @@ -179,7 +180,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm */ @GET @Path("{csid}") - public MultipartOutput getMovement( + public byte[] getMovement( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getMovement with csid=" + csid); @@ -190,12 +191,12 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm 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( @@ -222,7 +223,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.getBytes(); } /** @@ -256,7 +257,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm private MovementsCommonList getMovementList(MultivaluedMap queryParams) { MovementsCommonList movementObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); movementObjectList = (MovementsCommonList) handler.getCommonPartList(); @@ -294,10 +295,10 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm AuthorityRefList authRefList = null; try { MultivaluedMap queryParams = ui.getQueryParameters(); - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); 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); @@ -330,7 +331,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm public MovementsCommonList getMovementList(List csidList) { MovementsCommonList movementObjectList = new MovementsCommonList(); try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csidList, handler); movementObjectList = (MovementsCommonList) handler.getCommonPartList(); @@ -361,9 +362,9 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm */ @PUT @Path("{csid}") - public MultipartOutput updateMovement( + public byte[] updateMovement( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlText) { if (logger.isDebugEnabled()) { logger.debug("updateMovement with csid=" + csid); } @@ -374,12 +375,13 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm "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 (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity( @@ -399,7 +401,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm ServiceMessages.UPDATE_FAILED + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.getBytes(); } /** @@ -424,7 +426,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm 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) { @@ -459,7 +461,7 @@ public class MovementResource extends AbstractMultiPartCollectionSpaceResourceIm String keywords) { MovementsCommonList movementsObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); // perform a keyword search -- 2.47.3