From f142ab08cbb82455d82b7a6beb74ed1eb6cea085 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 16 Feb 2011 00:23:41 +0000 Subject: [PATCH] CSPACE-3574: Merging Plain Old XML payload work into trunk. --- .../nuxeo-platform-cs-intake/.classpath | 12 +- .../nuxeo-platform-cs-intake/.project | 12 +- services/intake/client/.classpath | 320 ++++++++++++++++- services/intake/client/.project | 17 +- .../services/client/IntakeClient.java | 39 ++- .../services/client/IntakeProxy.java | 19 +- .../client/test/IntakeAuthRefsTest.java | 34 +- .../client/test/IntakeServiceTest.java | 125 ++++--- .../test/OrganizationAuthRefDocsTest.java | 25 +- .../client/test/PersonAuthRefDocsTest.java | 25 +- services/intake/jaxb/.classpath | 37 +- services/intake/jaxb/.project | 10 +- .../.settings/org.maven.ide.eclipse.prefs | 8 +- services/intake/service/.classpath | 323 +++++++++++++++++- services/intake/service/.project | 20 +- services/intake/service/pom.xml | 10 + .../services/intake/IntakeResource.java | 70 ++-- .../intake/nuxeo/IntakeValidatorHandler.java | 4 +- 18 files changed, 908 insertions(+), 202 deletions(-) diff --git a/services/intake/3rdparty/nuxeo-platform-cs-intake/.classpath b/services/intake/3rdparty/nuxeo-platform-cs-intake/.classpath index 199bbbbdb..6fd3b8551 100644 --- a/services/intake/3rdparty/nuxeo-platform-cs-intake/.classpath +++ b/services/intake/3rdparty/nuxeo-platform-cs-intake/.classpath @@ -1,8 +1,8 @@ - - - - - + + - + + + + \ No newline at end of file diff --git a/services/intake/3rdparty/nuxeo-platform-cs-intake/.project b/services/intake/3rdparty/nuxeo-platform-cs-intake/.project index 51588d70e..da817907e 100644 --- a/services/intake/3rdparty/nuxeo-platform-cs-intake/.project +++ b/services/intake/3rdparty/nuxeo-platform-cs-intake/.project @@ -1,23 +1,17 @@ - org.collectionspace.services.intake.3rdparty.nuxeo - Intake Nuxeo Document Type - - + Intake 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/intake/client/.classpath b/services/intake/client/.classpath index 425cd1620..dca20c1df 100644 --- a/services/intake/client/.classpath +++ b/services/intake/client/.classpath @@ -1,10 +1,314 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/intake/client/.project b/services/intake/client/.project index 420e96184..4716f7560 100644 --- a/services/intake/client/.project +++ b/services/intake/client/.project @@ -1,27 +1,30 @@ - org.collectionspace.services.intake.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.intake.jaxb org.collectionspace.services.jaxb + org.collectionspace.services.organization.client + org.collectionspace.services.organization.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java index 92c67ca16..7c902a9d8 100644 --- a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java +++ b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java @@ -26,7 +26,7 @@ */ package org.collectionspace.services.client; -import javax.ws.rs.PathParam; +//import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; @@ -37,8 +37,8 @@ import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +//import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; +//import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.spi.ResteasyProviderFactory; /** @@ -48,17 +48,22 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 */ public class IntakeClient extends AbstractServiceClientImpl { - - /* (non-Javadoc) - * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() - */ + public static final String SERVICE_NAME = "intakes"; + 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; + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override public String getServicePathComponent() { - return "intakes"; + return SERVICE_PATH_COMPONENT; } - /** - * - */ -// private static final IntakeClient instance = new IntakeClient(); + /** * */ @@ -125,7 +130,7 @@ public class IntakeClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.IntakeProxy#getIntake(java.lang.String) */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return intakeProxy.read(csid); } @@ -134,8 +139,8 @@ public class IntakeClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.IntakeProxy#createIntake(org.collectionspace.hello.Intake) */ - public ClientResponse create(MultipartOutput multipart) { - return intakeProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return intakeProxy.create(xmlPayload.getBytes()); } /** @@ -144,8 +149,8 @@ public class IntakeClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.IntakeProxy#updateIntake(java.lang.Long, org.collectionspace.hello.Intake) */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return intakeProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut xmlPayload) { + return intakeProxy.update(csid, xmlPayload.getBytes()); } diff --git a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java index 21c8760c7..4b68ebdd5 100644 --- a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java +++ b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java @@ -38,20 +38,19 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.intake.IntakesCommonList; -import org.collectionspace.services.person.PersonsCommonList; +//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; +//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("/intakes/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) +@Path(IntakeClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) public interface IntakeProxy extends CollectionSpaceProxy { - /** * Read list. * @@ -69,7 +68,7 @@ public interface IntakeProxy extends CollectionSpaceProxy { * @return the client response */ @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(byte[] payload); //(R)ead /** @@ -80,7 +79,7 @@ public interface IntakeProxy extends CollectionSpaceProxy { */ @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); //(U)pdate /** @@ -92,7 +91,7 @@ public interface IntakeProxy extends CollectionSpaceProxy { */ @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, byte[] payload); //(D)elete /** diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java index c705daf41..eb826ced6 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java @@ -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.IntakeClient; +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.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; @@ -43,9 +46,9 @@ 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.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; @@ -66,7 +69,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - final String SERVICE_PATH_COMPONENT = "intakes"; + final String SERVICE_PATH_COMPONENT = IntakeClient.SERVICE_PATH_COMPONENT;//"intakes"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; private List intakeIdsCreated = new ArrayList(); @@ -79,6 +82,11 @@ public class IntakeAuthRefsTest extends BaseServiceTest { private String valuerRefName = null; private final int NUM_AUTH_REFS_EXPECTED = 5; + @Override + protected String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @@ -116,7 +124,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { // Submit the request to the service and store the response. IntakeClient intakeClient = new IntakeClient(); - MultipartOutput multipart = createIntakeInstance( + PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, "entryDate-" + identifier, currentOwnerRefName, @@ -157,7 +165,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { protected void createPersonRefs(){ PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - 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(); @@ -196,7 +204,7 @@ public class IntakeAuthRefsTest 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); @@ -221,7 +229,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { // Submit the request to the service and store the response. IntakeClient intakeClient = new IntakeClient(); - ClientResponse res = intakeClient.read(knownResourceId); + ClientResponse res = intakeClient.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -233,7 +241,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); IntakesCommon intake = (IntakesCommon) extractPart(input, intakeClient.getCommonPartName(), IntakesCommon.class); Assert.assertNotNull(intake); @@ -328,7 +336,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { return SERVICE_PATH_COMPONENT; } - private MultipartOutput createIntakeInstance(String entryNumber, + private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String currentOwner, String depositor, @@ -352,10 +360,10 @@ public class IntakeAuthRefsTest extends BaseServiceTest { insurers.add(insurer); intake.setInsurers(insurerList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); + commonPart.setLabel(new IntakeClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, intake common"); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index f53896fec..33432c500 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -28,6 +28,10 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IntakeClient; +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.intake.EntryMethodList; import org.collectionspace.services.intake.FieldCollectionEventNameList; import org.collectionspace.services.intake.CurrentLocationGroup; @@ -37,9 +41,9 @@ import org.collectionspace.services.intake.IntakesCommonList; 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.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; @@ -56,26 +60,23 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ public class IntakeServiceTest extends AbstractServiceTestImpl { - /** The logger. */ private final String CLASS_NAME = IntakeServiceTest.class.getName(); - private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - - // Instance variables specific to this test. - /** The service path component. */ - final String SERVICE_PATH_COMPONENT = "intakes"; + private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class); /** The known resource id. */ private String knownResourceId = null; - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() - */ @Override protected CollectionSpaceClient getClientInstance() { return new IntakeClient(); } + @Override + protected String getServiceName() { + return IntakeClient.SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) */ @@ -107,7 +108,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createIntakeInstance(identifier); + PoxPayloadOut multipart = createIntakeInstance(identifier); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -287,7 +288,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); - ClientResponse res = client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -299,24 +300,29 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); - IntakesCommon intake = (IntakesCommon) extractPart(input, - client.getCommonPartName(), IntakesCommon.class); - Assert.assertNotNull(intake); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + IntakesCommon intakeCommons = null; + if (payloadInputPart != null) { + intakeCommons = (IntakesCommon) payloadInputPart.getBody(); + } +// IntakesCommon intake = (IntakesCommon) extractPart(input, +// client.getCommonPartName(), IntakesCommon.class); + Assert.assertNotNull(intakeCommons); // Verify the number and contents of values in repeatable fields, // as created in the instance record used for testing. List entryMethods = - intake.getEntryMethods().getEntryMethod(); + intakeCommons.getEntryMethods().getEntryMethod(); Assert.assertTrue(entryMethods.size() > 0); Assert.assertNotNull(entryMethods.get(0)); List fieldCollectionEventNames = - intake.getFieldCollectionEventNames().getFieldCollectionEventName(); + intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName(); Assert.assertTrue(fieldCollectionEventNames.size() > 0); Assert.assertNotNull(fieldCollectionEventNames.get(0)); - CurrentLocationGroupList currentLocationGroupList = intake.getCurrentLocationGroupList(); + CurrentLocationGroupList currentLocationGroupList = intakeCommons.getCurrentLocationGroupList(); Assert.assertNotNull(currentLocationGroupList); List currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); Assert.assertNotNull(currentLocationGroups); @@ -324,6 +330,15 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0); Assert.assertNotNull(currentLocationGroup); Assert.assertNotNull(currentLocationGroup.getCurrentLocationNote()); + + // 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=" + intakeCommons.getEntryNote()); + } + Assert.assertEquals(intakeCommons.getEntryNote(), getUTF8DataFragment(), + "UTF-8 data retrieved '" + intakeCommons.getEntryNote() + + "' does not match expected data '" + getUTF8DataFragment()); } // Failure outcomes @@ -343,7 +358,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); - 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 @@ -430,8 +445,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. IntakeClient client = new IntakeClient(); - ClientResponse res = - client.read(knownResourceId); + ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ logger.debug(testName + ": read status = " + res.getStatus()); } @@ -440,20 +454,25 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { if(logger.isDebugEnabled()){ logger.debug("got object to update with ID: " + knownResourceId); } - MultipartInput input = (MultipartInput) res.getEntity(); - IntakesCommon intake = (IntakesCommon) extractPart(input, - client.getCommonPartName(), IntakesCommon.class); - Assert.assertNotNull(intake); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + IntakesCommon intakeCommons = null; + if (payloadInputPart != null) { + intakeCommons = (IntakesCommon) payloadInputPart.getBody(); + } +// IntakesCommon intake = (IntakesCommon) extractPart(input, +// client.getCommonPartName(), IntakesCommon.class); + Assert.assertNotNull(intakeCommons); // Update the content of this resource. - intake.setEntryNumber("updated-" + intake.getEntryNumber()); - intake.setEntryDate("updated-" + intake.getEntryDate()); + intakeCommons.setEntryNumber("updated-" + intakeCommons.getEntryNumber()); + intakeCommons.setEntryDate("updated-" + intakeCommons.getEntryDate()); if(logger.isDebugEnabled()){ logger.debug("to be updated object"); - logger.debug(objectAsXmlString(intake, IntakesCommon.class)); + logger.debug(objectAsXmlString(intakeCommons, IntakesCommon.class)); } - CurrentLocationGroupList currentLocationGroupList = intake.getCurrentLocationGroupList(); + CurrentLocationGroupList currentLocationGroupList = intakeCommons.getCurrentLocationGroupList(); Assert.assertNotNull(currentLocationGroupList); List currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); Assert.assertNotNull(currentLocationGroups); @@ -464,12 +483,12 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(currentLocationNote); String updatedCurrentLocationNote = "updated-" + currentLocationNote; currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote); - intake.setCurrentLocationGroupList(currentLocationGroupList); + intakeCommons.setCurrentLocationGroupList(currentLocationGroupList); // Submit the request to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = output.addPart(intakeCommons, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); res = client.update(knownResourceId, output); int statusCode = res.getStatus(); @@ -481,7 +500,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); IntakesCommon updatedIntake = (IntakesCommon) extractPart(input, client.getCommonPartName(), IntakesCommon.class); @@ -489,7 +508,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(updatedIntake); Assert.assertEquals(updatedIntake.getEntryDate(), - intake.getEntryDate(), + intakeCommons.getEntryDate(), "Data in updated object did not match submitted data."); currentLocationGroupList = updatedIntake.getCurrentLocationGroupList(); @@ -502,6 +521,17 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { currentLocationGroups.get(0).getCurrentLocationNote(), "Data in updated object did not match submitted data."); + if(logger.isDebugEnabled()){ + logger.debug("UTF-8 data sent=" + intakeCommons.getEntryNote() + "\n" + + "UTF-8 data received=" + updatedIntake.getEntryNote()); + } + Assert.assertTrue(updatedIntake.getEntryNote().contains(getUTF8DataFragment()), + "UTF-8 data retrieved '" + updatedIntake.getEntryNote() + + "' does not contain expected data '" + getUTF8DataFragment()); + Assert.assertEquals(updatedIntake.getEntryNote(), + intakeCommons.getEntryNote(), + "Data in updated object did not match submitted data."); + } // Failure outcomes @@ -638,8 +668,8 @@ public class IntakeServiceTest 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. IntakeClient client = new IntakeClient(); - MultipartOutput multipart = createIntakeInstance(NON_EXISTENT_ID); - ClientResponse res = + PoxPayloadOut multipart = createIntakeInstance(NON_EXISTENT_ID); + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); @@ -752,7 +782,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { */ @Override public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; + return IntakeClient.SERVICE_PATH_COMPONENT; } /** @@ -761,7 +791,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier * @return the multipart output */ - private MultipartOutput createIntakeInstance(String identifier) { + private PoxPayloadOut createIntakeInstance(String identifier) { return createIntakeInstance( "entryNumber-" + identifier, "entryDate-" + identifier, @@ -776,7 +806,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { * @param depositor the depositor * @return the multipart output */ - private MultipartOutput createIntakeInstance(String entryNumber, + private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String depositor) { IntakesCommon intake = new IntakesCommon(); @@ -807,10 +837,12 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { currentLocationGroups.add(currentLocationGroup); intake.setCurrentLocationGroupList(currentLocationGroupList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = + intake.setEntryNote(getUTF8DataFragment()); + + PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); + commonPart.setLabel(new IntakeClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, intake common"); @@ -819,4 +851,5 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { return multipart; } + } diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java index 1bd7ae13d..dfc3ca4f3 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java @@ -35,6 +35,8 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IntakeClient; import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.client.OrgAuthorityClientUtils; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; @@ -44,8 +46,8 @@ 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.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; @@ -81,6 +83,11 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { private String valuerRefName = null; private final int NUM_AUTH_REF_DOCS_EXPECTED = 1; + @Override + protected String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498 + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @@ -117,7 +124,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { createOrgRefs(); IntakeClient intakeClient = new IntakeClient(); - MultipartOutput multipart = createIntakeInstance( + PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, "entryDate-" + identifier, currentOwnerRefName, @@ -168,7 +175,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); orgAuthRefName = OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null); - MultipartOutput multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( ORGANIZATION_AUTHORITY_NAME, ORGANIZATION_AUTHORITY_NAME, orgAuthClient.getCommonPartName()); ClientResponse res = orgAuthClient.create(multipart); int statusCode = res.getStatus(); @@ -210,7 +217,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId); orgInfo.put(OrganizationJAXBSchema.SHORT_NAME, shortName); orgInfo.put(OrganizationJAXBSchema.LONG_NAME, longName); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrganizationInstance(orgAuthRefName, orgInfo, orgAuthClient.getItemCommonPartName()); ClientResponse res = orgAuthClient.createItem(orgAuthCSID, multipart); @@ -323,7 +330,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { return SERVICE_PATH_COMPONENT; } - private MultipartOutput createIntakeInstance(String entryNumber, + private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String currentOwner, String depositor, @@ -347,10 +354,10 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { insurers.add(insurer); intake.setInsurers(insurerList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); + commonPart.setLabel(new IntakeClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, intake common"); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java index 5c7b636c0..8d99147c6 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java @@ -33,8 +33,10 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IntakeClient; +import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.intake.ConditionCheckerOrAssessorList; import org.collectionspace.services.intake.IntakesCommon; @@ -44,8 +46,8 @@ 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.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; @@ -83,6 +85,11 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { private String valuerShortId = null; private final int NUM_AUTH_REF_DOCS_EXPECTED = 1; + @Override + public String getServiceName() { + throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498 + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @@ -119,7 +126,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { createPersonRefs(); IntakeClient intakeClient = new IntakeClient(); - MultipartOutput multipart = createIntakeInstance( + PoxPayloadOut multipart = createIntakeInstance( "entryNumber-" + identifier, "entryDate-" + identifier, currentOwnerRefName, @@ -167,7 +174,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { */ protected void createPersonRefs() { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); - 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(); @@ -223,7 +230,7 @@ public class PersonAuthRefDocsTest 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); @@ -437,7 +444,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { return SERVICE_PATH_COMPONENT; } - private MultipartOutput createIntakeInstance(String entryNumber, + private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String currentOwner, String depositor, @@ -461,10 +468,10 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { insurers.add(insurer); intake.setInsurers(insurerList); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); + commonPart.setLabel(new IntakeClient().getCommonPartName()); if (logger.isDebugEnabled()) { logger.debug("to be created, intake common"); diff --git a/services/intake/jaxb/.classpath b/services/intake/jaxb/.classpath index 557f8a4e0..981c9add6 100644 --- a/services/intake/jaxb/.classpath +++ b/services/intake/jaxb/.classpath @@ -1,10 +1,31 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/intake/jaxb/.project b/services/intake/jaxb/.project index 1f242033c..c5c217bfb 100644 --- a/services/intake/jaxb/.project +++ b/services/intake/jaxb/.project @@ -1,23 +1,19 @@ - org.collectionspace.services.intake.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/intake/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/intake/jaxb/.settings/org.maven.ide.eclipse.prefs index 2a011636e..dbd51f384 100644 --- a/services/intake/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/intake/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 09:57:38 PST 2010 +#Wed Jan 19 22:49:41 PST 2011 activeProfiles= eclipse.preferences.version=1 -fullBuildGoals=process-classes +fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true -resourceFilterGoals=process-classes -skipCompilerPlugin=false +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true version=1 diff --git a/services/intake/service/.classpath b/services/intake/service/.classpath index 425cd1620..4c8d17405 100644 --- a/services/intake/service/.classpath +++ b/services/intake/service/.classpath @@ -1,10 +1,317 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/intake/service/.project b/services/intake/service/.project index 328b53b0e..8e2245957 100644 --- a/services/intake/service/.project +++ b/services/intake/service/.project @@ -1,26 +1,32 @@ - org.collectionspace.services.intake.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.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.hyperjaxb + org.collectionspace.services.intake.client org.collectionspace.services.intake.jaxb org.collectionspace.services.jaxb + org.collectionspace.services.organization.client + org.collectionspace.services.organization.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/intake/service/pom.xml b/services/intake/service/pom.xml index 1eca45bb7..827c0c4cf 100644 --- a/services/intake/service/pom.xml +++ b/services/intake/service/pom.xml @@ -19,11 +19,21 @@ org.collectionspace.services.common ${project.version} + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + org.collectionspace.services org.collectionspace.services.intake.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.intake.client + ${project.version} + org.collectionspace.services org.collectionspace.services.collectionobject.jaxb diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java index 18a0a43cd..33526c666 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java @@ -42,6 +42,9 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; //import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; +import org.collectionspace.services.client.IntakeClient; +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; @@ -58,11 +61,11 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.IQueryManager; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.security.UnauthorizedException; -import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; +//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.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; @@ -71,14 +74,11 @@ import org.slf4j.LoggerFactory; /** * The Class IntakeResource. */ -@Path("/intakes") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Path(IntakeClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") public class IntakeResource extends AbstractMultiPartCollectionSpaceResourceImpl { - - /** The Constant serviceName. */ - private final static String serviceName = "intakes"; /** The logger. */ final Logger logger = LoggerFactory.getLogger(IntakeResource.class); @@ -108,7 +108,7 @@ public class IntakeResource extends */ @Override public String getServiceName() { - return serviceName; + return IntakeClient.SERVICE_NAME; } /* (non-Javadoc) @@ -123,7 +123,7 @@ public class IntakeResource extends * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext) */ // @Override -// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { +// public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { // DocumentHandler docHandler = ctx.getDocumentHandler(); // if (ctx.getInput() != null) { // Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), IntakesCommon.class); @@ -142,9 +142,10 @@ public class IntakeResource extends * @return the response */ @POST - public Response createIntake(MultipartInput input) { + public Response createIntake(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); //intakeObject.setCsid(csid); @@ -175,7 +176,7 @@ public class IntakeResource extends */ @GET @Path("{csid}") - public MultipartOutput getIntake( + public byte[] getIntake( @PathParam("csid") String csid) { if (logger.isDebugEnabled()) { logger.debug("getIntake with csid=" + csid); @@ -187,12 +188,12 @@ public class IntakeResource 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(); @@ -219,7 +220,8 @@ public class IntakeResource extends "text/plain").build(); throw new WebApplicationException(response); } - return result; + + return result.getBytes(); } /** @@ -254,7 +256,7 @@ public class IntakeResource extends private IntakesCommonList getIntakeList(MultivaluedMap queryParams) { IntakesCommonList intakeObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); intakeObjectList = (IntakesCommonList) handler.getCommonPartList(); @@ -290,11 +292,11 @@ public class IntakeResource extends 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); @@ -324,7 +326,7 @@ public class IntakeResource extends public IntakesCommonList getIntakeList(List csidList) { IntakesCommonList intakeObjectList = new IntakesCommonList(); try { - ServiceContext ctx = createServiceContext(); + ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csidList, handler); intakeObjectList = (IntakesCommonList) handler.getCommonPartList(); @@ -353,9 +355,9 @@ public class IntakeResource extends */ @PUT @Path("{csid}") - public MultipartOutput updateIntake( + public byte[] updateIntake( @PathParam("csid") String csid, - MultipartInput theUpdate) { + String xmlText) { if (logger.isDebugEnabled()) { logger.debug("updateIntake with csid=" + csid); } @@ -366,19 +368,20 @@ public class IntakeResource 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(); throw new WebApplicationException(response); } catch (DocumentNotFoundException dnfe) { if (logger.isDebugEnabled()) { - logger.debug("caugth exception in updateIntake", dnfe); + logger.debug("Caught exception in updateIntake", dnfe); } Response response = Response.status(Response.Status.NOT_FOUND).entity( "Update failed on Intake csid=" + csid).type( @@ -389,7 +392,8 @@ public class IntakeResource extends Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build(); throw new WebApplicationException(response); } - return result; + + return result.getBytes(); } /** @@ -414,7 +418,7 @@ public class IntakeResource 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) { @@ -465,7 +469,7 @@ public class IntakeResource extends String keywords) { IntakesCommonList intakesObjectList; try { - ServiceContext ctx = createServiceContext(queryParams); + ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); // perform a keyword search diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeValidatorHandler.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeValidatorHandler.java index d03640444..fffe25e93 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeValidatorHandler.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeValidatorHandler.java @@ -1,5 +1,7 @@ package org.collectionspace.services.intake.nuxeo; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.document.InvalidDocumentException; import org.collectionspace.services.common.document.ValidatorHandlerImpl; import org.collectionspace.services.intake.IntakesCommon; @@ -10,7 +12,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class IntakeValidatorHandler extends ValidatorHandlerImpl { +public class IntakeValidatorHandler extends ValidatorHandlerImpl { /** The logger. */ private final Logger logger = LoggerFactory.getLogger(IntakeValidatorHandler.class); -- 2.47.3