From 72cc0c490e401b2a68013d29bdb68ba3c179a0ce Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 16 Feb 2011 00:06:49 +0000 Subject: [PATCH] CSPACE-3574: Merging Plain Old XML payload work into trunk. --- .../nuxeo-platform-cs-note/.classpath | 12 +- .../3rdparty/nuxeo-platform-cs-note/.project | 4 +- services/note/client/.project | 6 +- services/note/client/pom.xml | 13 + .../services/client/NoteClient.java | 57 ++-- .../services/client/NoteClientUtils.java | 36 +- .../services/client/NoteProxy.java | 12 +- .../services/client/test/NoteServiceTest.java | 106 +++--- services/note/jaxb/.classpath | 39 ++- services/note/jaxb/.project | 8 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/note/service/.classpath | 309 +++++++++++++++++- services/note/service/.project | 9 +- .../services/note/NoteResource.java | 41 +-- 14 files changed, 504 insertions(+), 156 deletions(-) diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/.classpath b/services/note/3rdparty/nuxeo-platform-cs-note/.classpath index 199bbbbdb..6fd3b8551 100644 --- a/services/note/3rdparty/nuxeo-platform-cs-note/.classpath +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.classpath @@ -1,8 +1,8 @@ - - - - - + + - + + + + \ No newline at end of file diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/.project b/services/note/3rdparty/nuxeo-platform-cs-note/.project index 65504f9a5..5dbb76fb8 100644 --- a/services/note/3rdparty/nuxeo-platform-cs-note/.project +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.project @@ -1,6 +1,6 @@ org.collectionspace.services.note.3rdparty.nuxeo - Note Nuxeo Document Type + note Nuxeo Document Type. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. @@ -14,4 +14,4 @@ org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/note/client/.project b/services/note/client/.project index 7dc76b048..3660ba30e 100644 --- a/services/note/client/.project +++ b/services/note/client/.project @@ -1,9 +1,9 @@ org.collectionspace.services.note.client - + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - org.collectionspace.services.common org.collectionspace.services.client + org.collectionspace.services.jaxb org.collectionspace.services.note.jaxb @@ -18,4 +18,4 @@ org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/note/client/pom.xml b/services/note/client/pom.xml index 4885629a8..c91e3d5c1 100644 --- a/services/note/client/pom.xml +++ b/services/note/client/pom.xml @@ -34,7 +34,20 @@ org.collectionspace.services.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.common + true + ${project.version} + + + + dom4j + dom4j + 1.6.1 + provided + org.testng testng diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java index 39e69729c..6e026b4ae 100644 --- a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java @@ -24,8 +24,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; /** @@ -37,22 +35,9 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; public class NoteClient extends AbstractServiceClientImpl { - /* (non-Javadoc) - * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() - */ - public String getServicePathComponent() { - return "notes"; - } - - /** - * - */ -// private static final NoteClient instance = new NoteClient(); - - /** - * - */ private NoteProxy noteProxy; + public static final String SERVICE_NAME = "notes"; + public static final String SERVICE_PATH_COMPONENT = "notes"; /** * @@ -65,6 +50,19 @@ public class NoteClient extends AbstractServiceClientImpl { setProxy(); } + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() + */ + @Override + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + @Override public CollectionSpaceProxy getProxy() { return this.noteProxy; @@ -83,15 +81,6 @@ public class NoteClient extends AbstractServiceClientImpl { } } - /** - * FIXME Comment this - * - * @return - */ -// public static NoteClient getInstance() { -// return instance; -// } - /** * @return * @see org.collectionspace.services.client.Note#getNote() @@ -106,27 +95,30 @@ public class NoteClient extends AbstractServiceClientImpl { * @see org.collectionspace.services.client.Note#getNote(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return noteProxy.read(csid); } /** + * @param multipart * @param note * @return * @see org.collectionspace.services.client.Note#createNote(org.collectionspace.services.Note) */ - public ClientResponse create(MultipartOutput multipart) { - return noteProxy.create(multipart); + public ClientResponse create(PoxPayloadOut multipart) { + String payload = multipart.toXML(); + return noteProxy.create(payload); } /** * @param csid - * @param note + * @param multipart * @return * @see org.collectionspace.services.client.Note#updateNote(java.lang.Long, org.collectionspace.services.Note) */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return noteProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut multipart) { + String payload = multipart.toXML(); + return noteProxy.update(csid, payload); } @@ -135,6 +127,7 @@ public class NoteClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.Note#deleteNote(java.lang.Long) */ + @Override public ClientResponse delete(String csid) { return noteProxy.delete(csid); } diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java index 6422f8b29..8d08dd452 100644 --- a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java @@ -2,10 +2,7 @@ package org.collectionspace.services.client; import javax.ws.rs.core.MediaType; -import org.collectionspace.services.client.NoteClient; import org.collectionspace.services.note.NotesCommon; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; -import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,7 +12,9 @@ public class NoteClientUtils { private static final Logger logger = LoggerFactory.getLogger(NoteClientUtils.class); - public static MultipartOutput createNoteInstance( + private static final String SERVICE_PATH_COMPONENT = "notes"; + + public static PoxPayloadOut createNoteInstance ( String owner, String identifier, String headerLabel) { return createNoteInstance( owner, @@ -26,21 +25,21 @@ public class NoteClientUtils { headerLabel); } - public static MultipartOutput createNoteInstance( + public static PoxPayloadOut createNoteInstance( String owner, boolean isPrimary, int order, String content, String author, String date, String headerLabel) { - NotesCommon note = new NotesCommon(); - note.setOwner(owner); - note.setIsPrimary(isPrimary); - note.setOrder(order); - note.setContent(content); - note.setAuthor(author); - note.setDate(date); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(note, MediaType.APPLICATION_XML_TYPE); - NoteClient client = new NoteClient(); - commonPart.getHeaders().add("label", headerLabel); + NotesCommon noteCommon = new NotesCommon(); + noteCommon.setOwner(owner); + noteCommon.setIsPrimary(isPrimary); + noteCommon.setOrder(order); + noteCommon.setContent(content); + noteCommon.setAuthor(author); + noteCommon.setDate(date); + + PoxPayloadOut multipart = new PoxPayloadOut(getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(noteCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new NoteClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, note common"); @@ -50,5 +49,8 @@ public class NoteClientUtils { return multipart; } + public static String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } } diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java index 6d05d6800..b5788776a 100644 --- a/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java @@ -12,15 +12,13 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.note.NotesCommonList; 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("/notes/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Produces({"application/xml;charset=UTF-8"}) +@Consumes({"application/xml"}) public interface NoteProxy extends CollectionSpaceProxy { @GET @@ -29,17 +27,17 @@ public interface NoteProxy extends CollectionSpaceProxy { //(C)reate @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(String 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, String payload); //(D)elete @DELETE diff --git a/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java index 427bf6fab..0c47c7f8f 100644 --- a/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java +++ b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java @@ -24,21 +24,23 @@ package org.collectionspace.services.client.test; import java.util.ArrayList; import java.util.List; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.NoteClient; import org.collectionspace.services.client.NoteClientUtils; +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.note.NotesCommon; import org.collectionspace.services.note.NotesCommonList; import org.collectionspace.services.jaxb.AbstractCommonList; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.jboss.resteasy.client.ClientResponse; +import org.dom4j.DocumentException; -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; @@ -58,8 +60,10 @@ public class NoteServiceTest extends AbstractServiceTestImpl { private final String CLASS_NAME = NoteServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + private final String SERVICE_PATH_COMPONENT = "notes"; + private final String SERVICE_NAME = "notes"; + // Instance variables specific to this test. - final String SERVICE_PATH_COMPONENT = "notes"; private String knownResourceId = null; /* (non-Javadoc) @@ -98,7 +102,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. NoteClient client = new NoteClient(); String identifier = createIdentifier(); - MultipartOutput multipart = + PoxPayloadOut multipart = NoteClientUtils.createNoteInstance("owner"+identifier, identifier, client.getCommonPartName()); ClientResponse res = client.create(multipart); @@ -177,7 +181,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. NoteClient client = new NoteClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -189,10 +193,14 @@ public class NoteServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - NotesCommon note = (NotesCommon) extractPart(input, - client.getCommonPartName(), NotesCommon.class); - Assert.assertNotNull(note); + // 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()); + NotesCommon noteCommon = null; + if (payloadInputPart != null) { + noteCommon = (NotesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(noteCommon); } // Failure outcomes @@ -209,7 +217,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. NoteClient client = new NoteClient(); - 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 @@ -290,36 +298,41 @@ public class NoteServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. NoteClient client = new NoteClient(); - 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(); - NotesCommon note = (NotesCommon) extractPart(input, - client.getCommonPartName(), NotesCommon.class); - Assert.assertNotNull(note); - - // Update the content of this resource, both the subitem, and the content - note.setContent("updated-" + note.getContent()); - note.setOrder(note.getOrder()+10); + + // 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()); + NotesCommon noteCommon = null; + if (payloadInputPart != null) { + noteCommon = (NotesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(noteCommon); + + // Update the common part, both the subitem, and the content + noteCommon.setContent("updated-" + noteCommon.getContent()); + noteCommon.setOrder(noteCommon.getOrder()+10); if(logger.isDebugEnabled()){ logger.debug("to be updated object"); - logger.debug(objectAsXmlString(note, NotesCommon.class)); + logger.debug(objectAsXmlString(noteCommon, NotesCommon.class)); } - // Submit the request to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(note, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + // Submit the common part in an update request to the service + // and store the response. + PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = output.addPart(noteCommon, 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); } @@ -327,16 +340,18 @@ public class NoteServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Extract the updated common part from the response. + payloadInputPart = input.getPart(client.getCommonPartName()); + NotesCommon updatedNoteCommon = null; + if (payloadInputPart != null) { + updatedNoteCommon = (NotesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(updatedNoteCommon); - input = (MultipartInput) res.getEntity(); - NotesCommon updatedNote = - (NotesCommon) extractPart(input, - client.getCommonPartName(), NotesCommon.class); - Assert.assertNotNull(updatedNote); - - Assert.assertEquals(updatedNote.getContent(), note.getContent(), + // Check selected fields in the updated common part. + Assert.assertEquals(updatedNoteCommon.getContent(), noteCommon.getContent(), "Data in updated object did not match submitted data."); - Assert.assertEquals(updatedNote.getOrder(), note.getOrder(), + Assert.assertEquals(updatedNoteCommon.getOrder(), noteCommon.getOrder(), "Data in updated object (subitem) did not match submitted data."); } @@ -377,10 +392,10 @@ public class NoteServiceTest 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. NoteClient client = new NoteClient(); - MultipartOutput multipart = - NoteClientUtils.createNoteInstance(NON_EXISTENT_ID, NON_EXISTENT_ID, client.getCommonPartName()); - ClientResponse res = - client.update(NON_EXISTENT_ID, multipart); + PoxPayloadOut multipart = + NoteClientUtils.createNoteInstance( + NON_EXISTENT_ID, NON_EXISTENT_ID, client.getCommonPartName()); + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -453,6 +468,12 @@ public class NoteServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility tests : tests of code used in tests above // --------------------------------------------------------------- + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + /** * Tests the code for manually submitting data that is used by several * of the methods above. @@ -485,4 +506,5 @@ public class NoteServiceTest extends AbstractServiceTestImpl { public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } + } diff --git a/services/note/jaxb/.classpath b/services/note/jaxb/.classpath index 1707f3e6f..0d593e17f 100644 --- a/services/note/jaxb/.classpath +++ b/services/note/jaxb/.classpath @@ -1,11 +1,32 @@ - - - - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/note/jaxb/.project b/services/note/jaxb/.project index 3148d1189..cca579f76 100644 --- a/services/note/jaxb/.project +++ b/services/note/jaxb/.project @@ -1,7 +1,9 @@ org.collectionspace.services.note.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 @@ -14,4 +16,4 @@ org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs index 841e128b1..51e142d70 100644 --- a/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:05:00 PST 2010 +#Wed Jan 19 22:49:31 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/note/service/.classpath b/services/note/service/.classpath index 425cd1620..a68042212 100644 --- a/services/note/service/.classpath +++ b/services/note/service/.classpath @@ -1,10 +1,303 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/note/service/.project b/services/note/service/.project index e58ed0c27..3403c1ac8 100644 --- a/services/note/service/.project +++ b/services/note/service/.project @@ -1,10 +1,13 @@ org.collectionspace.services.note.service - + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - org.collectionspace.services.note.jaxb + org.collectionspace.services.3rdparty.nuxeo.quote-api + org.collectionspace.services.client org.collectionspace.services.common + org.collectionspace.services.hyperjaxb org.collectionspace.services.jaxb + org.collectionspace.services.note.jaxb @@ -18,4 +21,4 @@ org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature - + \ No newline at end of file diff --git a/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java b/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java index 08752b218..63894b026 100644 --- a/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java +++ b/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java @@ -38,6 +38,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; @@ -45,9 +47,6 @@ import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentHandler; - -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.util.HttpResponseCodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,8 +55,8 @@ import org.slf4j.LoggerFactory; * The Class NoteResource. */ @Path("/notes") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Consumes("application/xml") +@Produces("application/xml;charset=UTF-8") public class NoteResource extends AbstractMultiPartCollectionSpaceResourceImpl { @@ -112,9 +111,10 @@ public class NoteResource extends * @return the response */ @POST - public Response createNote(MultipartInput input) { + public Response createNote(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); UriBuilder path = UriBuilder.fromResource(NoteResource.class); @@ -140,7 +140,7 @@ public class NoteResource extends */ @GET @Path("{csid}") - public MultipartOutput getNote( + public String getNote( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getNote with csid=" + csid); @@ -152,12 +152,12 @@ public class NoteResource extends "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 (DocumentNotFoundException dnfe) { if (logger.isDebugEnabled()) { logger.debug("getNote", dnfe); @@ -180,7 +180,7 @@ public class NoteResource extends "text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.toXML(); } /** @@ -196,7 +196,7 @@ public class NoteResource extends MultivaluedMap queryParams = ui.getQueryParameters(); NotesCommonList noteObjectList = new NotesCommonList(); try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); noteObjectList = (NotesCommonList) handler.getCommonPartList(); @@ -221,9 +221,9 @@ public class NoteResource extends */ @PUT @Path("{csid}") - public MultipartOutput updateNote( + public String updateNote( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlText) { if (logger.isDebugEnabled()) { logger.debug("updateNote with csid=" + csid); } @@ -234,12 +234,13 @@ public class NoteResource extends "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 (DocumentNotFoundException dnfe) { if (logger.isDebugEnabled()) { logger.debug("Caught exception in updateNote", dnfe); @@ -253,7 +254,7 @@ public class NoteResource extends Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.toXML(); } /** @@ -278,7 +279,7 @@ public class NoteResource extends throw new WebApplicationException(response); } try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); getRepositoryClient(ctx).delete(ctx, csid); return Response.status(HttpResponseCodes.SC_OK).build(); } catch (DocumentNotFoundException dnfe) { -- 2.47.3