From: Richard Millet Date: Tue, 15 Feb 2011 23:51:49 +0000 (+0000) Subject: CSPACE-3574: Merging Plain Old XML payload work into trunk. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=a25d3e859851884e5ce5134ae2f4d49b56ee7b15;p=tmp%2Fjakarta-migration.git CSPACE-3574: Merging Plain Old XML payload work into trunk. --- diff --git a/services/report/3rdparty/nuxeo-platform-cs-report/.classpath b/services/report/3rdparty/nuxeo-platform-cs-report/.classpath index 199bbbbdb..0198489ba 100644 --- a/services/report/3rdparty/nuxeo-platform-cs-report/.classpath +++ b/services/report/3rdparty/nuxeo-platform-cs-report/.classpath @@ -1,8 +1,31 @@ - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/report/3rdparty/nuxeo-platform-cs-report/.project b/services/report/3rdparty/nuxeo-platform-cs-report/.project index 422da103e..9835178cf 100644 --- a/services/report/3rdparty/nuxeo-platform-cs-report/.project +++ b/services/report/3rdparty/nuxeo-platform-cs-report/.project @@ -1,23 +1,17 @@ - org.collectionspace.services.report.3rdparty.nuxeo - Report Nuxeo Document Type - - + Report Nuxeo Document Type. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/report/client/.classpath b/services/report/client/.classpath index 425cd1620..a9633ef61 100644 --- a/services/report/client/.classpath +++ b/services/report/client/.classpath @@ -1,10 +1,330 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/report/client/.project b/services/report/client/.project index 85fc9d063..f49dfdf77 100644 --- a/services/report/client/.project +++ b/services/report/client/.project @@ -1,27 +1,30 @@ - org.collectionspace.services.report.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.organization.client + org.collectionspace.services.organization.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb org.collectionspace.services.report.jaxb - org.collectionspace.services.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java index 042e1b44d..31e9fb3b6 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java @@ -26,7 +26,6 @@ */ package org.collectionspace.services.client; -import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; @@ -37,8 +36,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; /** @@ -49,20 +46,9 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; */ public class ReportClient extends AbstractServiceClientImpl { - /* (non-Javadoc) - * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() - */ - public String getServicePathComponent() { - return "reports"; - } - /** - * - */ -// private static final ReportClient instance = new ReportClient(); - /** - * - */ private ReportProxy reportProxy; + public static final String SERVICE_NAME = "reports"; + public static final String SERVICE_PATH_COMPONENT = "reports"; /** * @@ -75,6 +61,19 @@ public class ReportClient extends AbstractServiceClientImpl { setProxy(); } + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() + */ + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + + @Override public CollectionSpaceProxy getProxy() { return this.reportProxy; @@ -93,15 +92,6 @@ public class ReportClient extends AbstractServiceClientImpl { } } - /** - * FIXME Comment this - * - * @return - */ -// public static ReportClient getInstance() { -// return instance; -// } - /** * @return * @see org.collectionspace.services.client.ReportProxy#getReport() @@ -125,7 +115,7 @@ public class ReportClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.ReportProxy#getReport(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return reportProxy.read(csid); } @@ -134,8 +124,9 @@ public class ReportClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.ReportProxy#createReport(org.collectionspace.hello.Report) */ - public ClientResponse create(MultipartOutput multipart) { - return reportProxy.create(multipart); + public ClientResponse create(PoxPayloadOut multipart) { + String payload = multipart.toXML(); + return reportProxy.create(payload); } /** @@ -144,8 +135,9 @@ public class ReportClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.ReportProxy#updateReport(java.lang.Long, org.collectionspace.hello.Report) */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return reportProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut multipart) { + String payload = multipart.toXML(); + return reportProxy.update(csid, payload); } @@ -157,4 +149,6 @@ public class ReportClient extends AbstractServiceClientImpl { public ClientResponse delete(String csid) { return reportProxy.delete(csid); } + + } diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java index 4ba050b6f..2225743f4 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java @@ -40,16 +40,14 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.report.ReportsCommonList; import org.collectionspace.services.person.PersonsCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; /** * @version $Revision:$ * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 */ @Path("/reports/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Produces({"application/xml;charset=UTF-8"}) +@Consumes({"application/xml"}) public interface ReportProxy extends CollectionSpaceProxy { /** @@ -69,7 +67,7 @@ public interface ReportProxy extends CollectionSpaceProxy { * @return the client response */ @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(String payload); //(R)ead /** @@ -80,7 +78,7 @@ public interface ReportProxy extends CollectionSpaceProxy { */ @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); //(U)pdate /** @@ -92,7 +90,7 @@ public interface ReportProxy extends CollectionSpaceProxy { */ @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, String payload); //(D)elete /** diff --git a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java index 8500df16f..04fe3212c 100644 --- a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java +++ b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java @@ -27,15 +27,16 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadInputPart; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.ReportClient; import org.collectionspace.services.report.ReportsCommon; import org.collectionspace.services.report.ReportsCommonList; 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; import org.testng.annotations.Test; @@ -57,9 +58,11 @@ public class ReportServiceTest extends AbstractServiceTestImpl { private final String CLASS_NAME = ReportServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - // Instance variables specific to this test. - /** The service path component. */ + final String SERVICE_NAME = "reports"; final String SERVICE_PATH_COMPONENT = "reports"; + + // Instance variables specific to this test. + /** The known resource id. */ private String knownResourceId = null; @@ -103,17 +106,16 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. ReportClient client = new ReportClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createReportInstance(identifier); + PoxPayloadOut multipart = createReportInstance(identifier); ClientResponse res = client.create(multipart); - int statusCode = res.getStatus(); - // Check the status code of the response: does it match // the expected response(s)? // // Specifically: // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? + int statusCode = res.getStatus(); if(logger.isDebugEnabled()){ logger.debug(testName + ": status = " + statusCode); } @@ -194,11 +196,11 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. ReportClient client = new ReportClient(); - ClientResponse res = client.read(knownResourceId); - int statusCode = res.getStatus(); + ClientResponse res = client.read(knownResourceId); // 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); } @@ -206,10 +208,14 @@ public class ReportServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - ReportsCommon report = (ReportsCommon) extractPart(input, - client.getCommonPartName(), ReportsCommon.class); - Assert.assertNotNull(report); + // 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()); + ReportsCommon reportCommon = null; + if (payloadInputPart != null) { + reportCommon = (ReportsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(reportCommon); } // Failure outcomes @@ -229,7 +235,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. ReportClient client = new ReportClient(); - 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 @@ -316,37 +322,41 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. ReportClient client = new ReportClient(); - 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(); - ReportsCommon report = (ReportsCommon) extractPart(input, - client.getCommonPartName(), ReportsCommon.class); - Assert.assertNotNull(report); - - // Update the content of this resource. - // Update the content of this resource. - report.setName("updated-" + report.getName()); - report.setOutputMIME("updated-" + report.getOutputMIME()); + + // Extract the common part from the response. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + ReportsCommon reportCommon = null; + if (payloadInputPart != null) { + reportCommon = (ReportsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(reportCommon); + + // Update its content. + reportCommon.setName("updated-" + reportCommon.getName()); + reportCommon.setOutputMIME("updated-" + reportCommon.getOutputMIME()); if(logger.isDebugEnabled()){ logger.debug("to be updated object"); - logger.debug(objectAsXmlString(report, ReportsCommon.class)); + logger.debug(objectAsXmlString(reportCommon, ReportsCommon.class)); } - // Submit the request to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(report, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); - + + // Submit the updated common part in an update request to the service + // and store the response. + PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = output.addPart(reportCommon, 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); } @@ -354,15 +364,22 @@ public class ReportServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Extract the updated common part from the response. + input = new PoxPayloadIn(res.getEntity()); + payloadInputPart = input.getPart(client.getCommonPartName()); + ReportsCommon updatedReportCommon = null; + if (payloadInputPart != null) { + updatedReportCommon = (ReportsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(updatedReportCommon); + if(logger.isDebugEnabled()){ + logger.debug("updated object"); + logger.debug(objectAsXmlString(updatedReportCommon, ReportsCommon.class)); + } - input = (MultipartInput) res.getEntity(); - ReportsCommon updatedReport = - (ReportsCommon) extractPart(input, - client.getCommonPartName(), ReportsCommon.class); - Assert.assertNotNull(updatedReport); - - Assert.assertEquals(updatedReport.getName(), - report.getName(), + // Check selected fields in the updated common part. + Assert.assertEquals(updatedReportCommon.getName(), + reportCommon.getName(), "Data in updated object did not match submitted data."); } @@ -412,9 +429,8 @@ public class ReportServiceTest 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. ReportClient client = new ReportClient(); - MultipartOutput multipart = createReportInstance(NON_EXISTENT_ID); - ClientResponse res = - client.update(NON_EXISTENT_ID, multipart); + PoxPayloadOut multipart = createReportInstance(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 @@ -493,6 +509,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility tests : tests of code used in tests above // --------------------------------------------------------------- + /** * Tests the code for manually submitting data that is used by several * of the methods above. @@ -521,6 +538,13 @@ public class ReportServiceTest 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() */ @@ -535,7 +559,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier * @return the multipart output */ - private MultipartOutput createReportInstance(String identifier) { + private PoxPayloadOut createReportInstance(String identifier) { return createReportInstance( "name-" + identifier, "persAuthTermCountsTest.jasper", @@ -550,21 +574,23 @@ public class ReportServiceTest extends AbstractServiceTestImpl { * @param outputMIME the MIME type we will return for this report * @return the multipart output */ - private MultipartOutput createReportInstance(String name, + private PoxPayloadOut createReportInstance(String name, String filename, String outputMIME) { - ReportsCommon report = new ReportsCommon(); - report.setName(name); - report.setFilename(filename); - report.setOutputMIME(outputMIME); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = - multipart.addPart(report, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new ReportClient().getCommonPartName()); + ReportsCommon reportCommon = new ReportsCommon(); + reportCommon.setName(name); + reportCommon.setFilename(filename); + reportCommon.setOutputMIME(outputMIME); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new ReportClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, report common"); - logger.debug(objectAsXmlString(report, ReportsCommon.class)); + logger.debug(objectAsXmlString(reportCommon, ReportsCommon.class)); + logger.debug(multipart.toXML()); } return multipart; diff --git a/services/report/jaxb/.classpath b/services/report/jaxb/.classpath index 1707f3e6f..09611883c 100644 --- a/services/report/jaxb/.classpath +++ b/services/report/jaxb/.classpath @@ -1,11 +1,55 @@ - - - - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/report/jaxb/.project b/services/report/jaxb/.project index 31f83a2ff..488da827a 100644 --- a/services/report/jaxb/.project +++ b/services/report/jaxb/.project @@ -1,23 +1,19 @@ - org.collectionspace.services.report.jaxb - + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + org.collectionspace.services.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/report/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/report/jaxb/.settings/org.maven.ide.eclipse.prefs index f05489e16..86abf8e53 100644 --- a/services/report/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/report/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:03:32 PST 2010 +#Wed Jan 19 22:49:47 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/report/service/.classpath b/services/report/service/.classpath index 425cd1620..f0d1a70d1 100644 --- a/services/report/service/.classpath +++ b/services/report/service/.classpath @@ -1,10 +1,320 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/report/service/.project b/services/report/service/.project index 2d5155a4f..425e89938 100644 --- a/services/report/service/.project +++ b/services/report/service/.project @@ -1,26 +1,25 @@ - org.collectionspace.services.report.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.report.jaxb + org.collectionspace.services.hyperjaxb org.collectionspace.services.jaxb + org.collectionspace.services.report.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java index 25eb72a60..9a0b43ce6 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java @@ -56,6 +56,8 @@ import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import org.collectionspace.services.ReportJAXBSchema; +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; @@ -75,8 +77,6 @@ import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; 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; @@ -86,8 +86,8 @@ import org.slf4j.LoggerFactory; * The Class ReportResource. */ @Path("/reports") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Consumes("application/xml") +@Produces("application/xml;charset=UTF-8") public class ReportResource extends AbstractMultiPartCollectionSpaceResourceImpl { @@ -152,9 +152,10 @@ public class ReportResource extends * @return the response */ @POST - public Response createReport(MultipartInput input) { + public Response createReport(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(ReportResource.class); @@ -184,7 +185,7 @@ public class ReportResource extends */ @GET @Path("{csid}") - public MultipartOutput getReport( + public String getReport( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getReport with csid=" + csid); @@ -196,12 +197,12 @@ public class ReportResource 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 (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build(); @@ -228,7 +229,7 @@ public class ReportResource extends "text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.toXML(); } /** @@ -255,7 +256,7 @@ public class ReportResource extends throw new WebApplicationException(response); } try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentWrapper docWrapper = getRepositoryClient(ctx).getDoc(ctx, csid); DocumentModel docModel = docWrapper.getWrappedObject(); String reportFileName = (String)docModel.getPropertyValue(ReportJAXBSchema.FILENAME); @@ -384,7 +385,7 @@ public class ReportResource extends private ReportsCommonList getReportList(MultivaluedMap queryParams) { ReportsCommonList reportObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); reportObjectList = (ReportsCommonList) handler.getCommonPartList(); @@ -413,7 +414,7 @@ public class ReportResource extends public ReportsCommonList getReportList(List csidList) { ReportsCommonList reportObjectList = new ReportsCommonList(); try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csidList, handler); reportObjectList = (ReportsCommonList) handler.getCommonPartList(); @@ -443,9 +444,9 @@ public class ReportResource extends */ @PUT @Path("{csid}") - public MultipartOutput updateReport( + public String updateReport( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlText) { if (logger.isDebugEnabled()) { logger.debug("updateReport with csid=" + csid); } @@ -456,12 +457,13 @@ public class ReportResource 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 (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build(); @@ -479,7 +481,7 @@ public class ReportResource extends Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build(); throw new WebApplicationException(response); } - return result; + return result.toXML(); } /** @@ -504,7 +506,7 @@ public class ReportResource 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 (UnauthorizedException ue) { @@ -537,7 +539,7 @@ public class ReportResource extends String keywords) { ReportsCommonList reportsObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); // perform a keyword search