From: Richard Millet Date: Wed, 16 Feb 2011 00:01:16 +0000 (+0000) Subject: CSPACE-3574: Merging Plain Old XML payload work into trunk. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=d837f48b681a99344fd43f40e418f2260772e39a;p=tmp%2Fjakarta-migration.git CSPACE-3574: Merging Plain Old XML payload work into trunk. --- diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath b/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath index 425cd1620..3be05e087 100644 --- a/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath +++ b/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath @@ -1,10 +1,10 @@ - - - - - - - + + + + - + + + + \ No newline at end of file diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.project b/services/organization/3rdparty/nuxeo-platform-cs-organization/.project index 8f18e6d1f..c5a368a36 100644 --- a/services/organization/3rdparty/nuxeo-platform-cs-organization/.project +++ b/services/organization/3rdparty/nuxeo-platform-cs-organization/.project @@ -1,28 +1,20 @@ - org.collectionspace.services.organization.3rdparty.nuxeo - Organization Nuxeo Document Type - - + Organization 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.eclipse.pde.ds.core.builder - - 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/organization/client/.classpath b/services/organization/client/.classpath index 425cd1620..05737489f 100644 --- a/services/organization/client/.classpath +++ b/services/organization/client/.classpath @@ -1,10 +1,312 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/organization/client/.project b/services/organization/client/.project index 3b636e056..8bd26a5b7 100644 --- a/services/organization/client/.project +++ b/services/organization/client/.project @@ -1,26 +1,28 @@ - org.collectionspace.services.organization.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.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/organization/client/pom.xml b/services/organization/client/pom.xml index 1e3e76587..fbf25be33 100644 --- a/services/organization/client/pom.xml +++ b/services/organization/client/pom.xml @@ -45,6 +45,7 @@ org.collectionspace.services org.collectionspace.services.contact.client + ${project.version} diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java index d7ac2b525..111c54e59 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java @@ -39,21 +39,38 @@ import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.spi.ResteasyProviderFactory; /** * The Class OrgAuthorityClient. */ public class OrgAuthorityClient extends AbstractServiceClientImpl { - - /* (non-Javadoc) - * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent() - */ + public static final String SERVICE_NAME = "orgauthorities"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; + // + // Subitem constants + // + public static final String SERVICE_ITEM_NAME = "organizations"; + public static final String SERVICE_PATH_ITEMS_COMPONENT = "items"; //FIXME: REM - This should be defined in an AuthorityClient base class + public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME; + // + // Payload Part/Schema part names + // + public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override public String getServicePathComponent() { - return "orgauthorities"; + return SERVICE_PATH_COMPONENT; } /** @@ -62,12 +79,9 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @return the item common part name */ public String getItemCommonPartName() { - return getCommonPartName("organizations"); + return getCommonPartName(SERVICE_ITEM_NAME); } - /** The Constant instance. */ //FIXME: This is wrong. There should NOT be a static instance of the OrgAuthorityClient class -// private static final OrgAuthorityClient instance = new OrgAuthorityClient(); - /** The org authority proxy. */ private OrgAuthorityProxy orgAuthorityProxy; @@ -125,7 +139,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid the csid * @return the client response */ - public ClientResponse read(String csid) { + public ClientResponse read(String csid) { return orgAuthorityProxy.read(csid); } @@ -135,7 +149,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param name the name * @return the client response */ - public ClientResponse readByName(String name) { + public ClientResponse readByName(String name) { return orgAuthorityProxy.readByName(name); } @@ -145,8 +159,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse create(MultipartOutput multipart) { - return orgAuthorityProxy.create(multipart); + public ClientResponse create(PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.create(xmlPayload.getBytes()); } /** @@ -156,8 +170,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse update(String csid, MultipartOutput multipart) { - return orgAuthorityProxy.update(csid, multipart); + public ClientResponse update(String csid, PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.update(csid, xmlPayload.getBytes()); } @@ -236,7 +250,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid the csid * @return the client response */ - public ClientResponse readItem(String vcsid, String csid) { + public ClientResponse readItem(String vcsid, String csid) { return orgAuthorityProxy.readItem(vcsid, csid); } @@ -247,7 +261,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param shortId the shortIdentifier * @return the client response */ - public ClientResponse readNamedItem(String vcsid, String shortId) { + public ClientResponse readNamedItem(String vcsid, String shortId) { return orgAuthorityProxy.readNamedItem(vcsid, shortId); } @@ -258,7 +272,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid the csid * @return the client response */ - public ClientResponse readItemInNamedAuthority(String authShortId, String csid) { + public ClientResponse readItemInNamedAuthority(String authShortId, String csid) { return orgAuthorityProxy.readItemInNamedAuthority(authShortId, csid); } @@ -269,7 +283,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param itemShortId the shortIdentifier for the item * @return the client response */ - public ClientResponse readNamedItemInNamedAuthority(String authShortId, String itemShortId) { + public ClientResponse readNamedItemInNamedAuthority(String authShortId, String itemShortId) { return orgAuthorityProxy.readNamedItemInNamedAuthority(authShortId, itemShortId); } @@ -280,8 +294,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse createItem(String vcsid, MultipartOutput multipart) { - return orgAuthorityProxy.createItem(vcsid, multipart); + public ClientResponse createItem(String vcsid, PoxPayloadOut multipart) { + return orgAuthorityProxy.createItem(vcsid, multipart.getBytes()); } /** @@ -292,8 +306,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse updateItem(String vcsid, String csid, MultipartOutput multipart) { - return orgAuthorityProxy.updateItem(vcsid, csid, multipart); + public ClientResponse updateItem(String vcsid, String csid, PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.updateItem(vcsid, csid, xmlPayload.getBytes()); } @@ -323,8 +337,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @return the client response */ public ClientResponse createContact(String parentcsid, - String itemcsid, MultipartOutput multipart) { - return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart); + String itemcsid, PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.createContact(parentcsid, itemcsid, xmlPayload.getBytes()); } /** @@ -338,8 +352,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { public ClientResponse createContactForNamedItem( String parentcsid, String itemspecifier, - MultipartOutput multipart) { - return orgAuthorityProxy.createContactForNamedItem(parentcsid, itemspecifier, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.createContactForNamedItem(parentcsid, itemspecifier, xmlPayload.getBytes()); } /** * Creates the contact. @@ -352,8 +366,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { public ClientResponse createContactForItemInNamedAuthority( String parentspecifier, String itemcsid, - MultipartOutput multipart) { - return orgAuthorityProxy.createContactForItemInNamedAuthority(parentspecifier, itemcsid, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.createContactForItemInNamedAuthority(parentspecifier, itemcsid, xmlPayload.getBytes()); } /** * Creates the contact. @@ -366,8 +380,8 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { public ClientResponse createContactForNamedItemInNamedAuthority( String parentspecifier, String itemspecifier, - MultipartOutput multipart) { - return orgAuthorityProxy.createContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.createContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, xmlPayload.getBytes()); } /** @@ -378,7 +392,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid the csid * @return the client response */ - public ClientResponse readContact(String parentcsid, + public ClientResponse readContact(String parentcsid, String itemcsid, String csid) { return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid); } @@ -391,7 +405,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid * @return the client response */ - public ClientResponse readContactForNamedItem( + public ClientResponse readContactForNamedItem( String parentcsid, String itemspecifier, String csid){ @@ -406,7 +420,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid * @return the client response */ - public ClientResponse readContactInNamedAuthority( + public ClientResponse readContactInNamedAuthority( String parentspecifier, String itemcsid, String csid){ @@ -421,7 +435,7 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param csid * @return the client response */ - public ClientResponse readContactForNamedItemInNamedAuthority( + public ClientResponse readContactForNamedItemInNamedAuthority( String parentspecifier, String itemspecifier, String csid){ @@ -490,9 +504,9 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse updateContact(String parentcsid, - String itemcsid, String csid, MultipartOutput multipart) { - return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart); + public ClientResponse updateContact(String parentcsid, + String itemcsid, String csid, PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, xmlPayload.getBytes()); } /** @@ -504,12 +518,12 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse updateContactForNamedItem( + public ClientResponse updateContactForNamedItem( String parentcsid, String itemspecifier, String csid, - MultipartOutput multipart) { - return orgAuthorityProxy.updateContactForNamedItem(parentcsid, itemspecifier, csid, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.updateContactForNamedItem(parentcsid, itemspecifier, csid, xmlPayload.getBytes()); } /** @@ -521,12 +535,12 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse updateContactInNamedAuthority( + public ClientResponse updateContactInNamedAuthority( String parentspecifier, String itemcsid, String csid, - MultipartOutput multipart) { - return orgAuthorityProxy.updateContactInNamedAuthority(parentspecifier, itemcsid, csid, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.updateContactInNamedAuthority(parentspecifier, itemcsid, csid, xmlPayload.getBytes()); } /** @@ -538,12 +552,12 @@ public class OrgAuthorityClient extends AbstractServiceClientImpl { * @param multipart the multipart * @return the client response */ - public ClientResponse updateContactForNamedItemInNamedAuthority( + public ClientResponse updateContactForNamedItemInNamedAuthority( String parentspecifier, String itemspecifier, String csid, - MultipartOutput multipart) { - return orgAuthorityProxy.updateContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, csid, multipart); + PoxPayloadOut xmlPayload) { + return orgAuthorityProxy.updateContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, csid, xmlPayload.getBytes()); } diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java index 7c709609a..80b5c9886 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java @@ -49,8 +49,6 @@ import org.collectionspace.services.organization.SubBodyList; import org.collectionspace.services.person.PersonauthoritiesCommon; import org.collectionspace.services.person.PersonsCommon; 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +71,7 @@ public class OrgAuthorityClientUtils { public static String getAuthorityRefName(String csid, OrgAuthorityClient client){ if(client==null) client = new OrgAuthorityClient(); - ClientResponse res = client.read(csid); + ClientResponse res = client.read(csid); try { int statusCode = res.getStatus(); if(!READ_REQ.isValidStatusCode(statusCode) @@ -82,7 +80,7 @@ public class OrgAuthorityClientUtils { } //FIXME: remove the following try catch once Aron fixes signatures try { - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input, client.getCommonPartName(), OrgauthoritiesCommon.class); @@ -107,7 +105,7 @@ public class OrgAuthorityClientUtils { public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client){ if(client==null) client = new OrgAuthorityClient(); - ClientResponse res = client.readItem(inAuthority, csid); + ClientResponse res = client.readItem(inAuthority, csid); try { int statusCode = res.getStatus(); if(!READ_REQ.isValidStatusCode(statusCode) @@ -116,7 +114,7 @@ public class OrgAuthorityClientUtils { } //FIXME: remove the following try catch once Aron fixes signatures try { - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon org = (OrganizationsCommon) CollectionSpaceClientUtils.extractPart(input, client.getItemCommonPartName(), OrganizationsCommon.class); @@ -140,7 +138,7 @@ public class OrgAuthorityClientUtils { * @param headerLabel the header label * @return the multipart output */ - public static MultipartOutput createOrgAuthorityInstance( + public static PoxPayloadOut createOrgAuthorityInstance( String displayName, String shortIdentifier, String headerLabel ) { OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon(); orgAuthority.setDisplayName(displayName); @@ -148,9 +146,9 @@ public class OrgAuthorityClientUtils { String refName = createOrgAuthRefName(shortIdentifier, displayName); orgAuthority.setRefName(refName); orgAuthority.setVocabType("OrgAuthority"); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", headerLabel); + PoxPayloadOut multipart = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(headerLabel); if(logger.isDebugEnabled()){ logger.debug("to be created, orgAuthority common ", @@ -182,7 +180,7 @@ public class OrgAuthorityClientUtils { logger.debug("Import: Create Item: \""+displayName +"\" in orgAuthority: \"" + orgAuthorityRefName +"\""); } - MultipartOutput multipart = + PoxPayloadOut multipart = createOrganizationInstance(orgAuthorityRefName, orgInfo, orgRepeatablesInfo, mainBodyList, client.getItemCommonPartName()); @@ -217,7 +215,7 @@ public class OrgAuthorityClientUtils { * @param headerLabel the header label * @return the multipart output */ - public static MultipartOutput createOrganizationInstance( + public static PoxPayloadOut createOrganizationInstance( String orgAuthRefName, Map orgInfo, String headerLabel){ final Map> EMPTY_ORG_REPEATABLES_INFO = new HashMap>(); @@ -237,7 +235,7 @@ public class OrgAuthorityClientUtils { * @param headerLabel the header label * @return the multipart output */ - public static MultipartOutput createOrganizationInstance( + public static PoxPayloadOut createOrganizationInstance( String orgAuthRefName, Map orgInfo, Map> orgRepeatablesInfo, MainBodyGroupList mainBodyList, String headerLabel){ OrganizationsCommon organization = new OrganizationsCommon(); @@ -305,10 +303,10 @@ public class OrgAuthorityClientUtils { } if((value = (String)orgInfo.get(OrganizationJAXBSchema.TERM_STATUS))!=null) organization.setTermStatus(value); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(organization, + PoxPayloadOut multipart = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(organization, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", headerLabel); + commonPart.setLabel(headerLabel); if(logger.isDebugEnabled()){ logger.debug("to be created, organization common ", organization, OrganizationsCommon.class); diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java index d7d30b095..e84136e57 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java @@ -17,42 +17,39 @@ import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.contact.ContactsCommonList; import org.collectionspace.services.organization.OrgauthoritiesCommonList; import org.collectionspace.services.organization.OrganizationsCommonList; -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; /** * @version $Revision$ */ -@Path("/orgauthorities/") -@Produces({"multipart/mixed"}) -@Consumes({"multipart/mixed"}) -public interface OrgAuthorityProxy extends CollectionSpaceProxy { +@Path(OrgAuthorityClient.SERVICE_PATH + "/") +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface OrgAuthorityProxy extends CollectionSpaceProxy { //FIXME: REM - Most of the methods in this class and PersonAuthorityProxy are the same and should be moved to a base class // List OrgAuthorities @GET - @Produces({"application/xml"}) ClientResponse readList(); //(C)reate @POST - ClientResponse create(MultipartOutput multipart); + ClientResponse create(byte[] xmlPayload); //(R)ead @GET @Path("/{csid}") - ClientResponse read(@PathParam("csid") String csid); + ClientResponse read(@PathParam("csid") String csid); //(R)ead by name @GET @Path("/urn:cspace:name({name})") - ClientResponse readByName(@PathParam("name") String name); + ClientResponse readByName(@PathParam("name") String name); //(U)pdate @PUT @Path("/{csid}") - ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse update(@PathParam("csid") String csid, byte[] xmlPayload); //(D)elete @DELETE @@ -102,32 +99,32 @@ public interface OrgAuthorityProxy extends CollectionSpaceProxy { //(C)reate Item @POST @Path("/{vcsid}/items/") - ClientResponse createItem(@PathParam("vcsid") String vcsid, MultipartOutput multipart); + ClientResponse createItem(@PathParam("vcsid") String vcsid, byte[] xmlPayload); //(R)ead Item @GET @Path("/{vcsid}/items/{csid}") - ClientResponse readItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid); + ClientResponse readItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid); //(R)ead Named Item @GET @Path("/{vcsid}/items/urn:cspace:name({specifier})") - ClientResponse readNamedItem(@PathParam("vcsid") String vcsid, @PathParam("specifier") String specifier); + ClientResponse readNamedItem(@PathParam("vcsid") String vcsid, @PathParam("specifier") String specifier); //(R)ead Item In Named Authority @GET @Path("/urn:cspace:name({specifier})/items/{csid}") - ClientResponse readItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("csid") String csid); + ClientResponse readItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("csid") String csid); //(R)ead Named Item In Named Authority @GET @Path("/urn:cspace:name({specifier})/items/urn:cspace:name({itemspecifier})") - ClientResponse readNamedItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("itemspecifier") String itemspecifier); + ClientResponse readNamedItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("itemspecifier") String itemspecifier); //(U)pdate Item @PUT @Path("/{vcsid}/items/{csid}") - ClientResponse updateItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid, MultipartOutput multipart); + ClientResponse updateItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid, byte[] xmlPayload); //(D)elete Item @DELETE @@ -166,48 +163,48 @@ public interface OrgAuthorityProxy extends CollectionSpaceProxy { ClientResponse createContact( @PathParam("parentcsid") String parentcsid, @PathParam("itemcsid") String itemcsid, - MultipartOutput multipart); + byte[] xmlPayload); @POST @Path("/{parentcsid}/items/urn:cspace:name({itemspecifier})/contacts/") ClientResponse createContactForNamedItem( @PathParam("parentcsid") String parentcsid, @PathParam("itemspecifier") String itemspecifier, - MultipartOutput multipart); + byte[] xmlPayload); @POST @Path("/urn:cspace:name({parentspecifier})/items/{itemcsid}/contacts/") ClientResponse createContactForItemInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemcsid") String itemcsid, - MultipartOutput multipart); + byte[] xmlPayload); @POST @Path("/urn:cspace:name({parentspecifier})/items/urn:cspace:name({itemspecifier})/contacts/") ClientResponse createContactForNamedItemInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemspecifier") String itemspecifier, - MultipartOutput multipart); + byte[] xmlPayload); //(R)ead Contact @GET @Path("/{parentcsid}/items/{itemcsid}/contacts/{csid}") - ClientResponse readContact( + ClientResponse readContact( @PathParam("parentcsid") String parentcsid, @PathParam("itemcsid") String itemcsid, @PathParam("csid") String csid); @GET @Path("/{parentcsid}/items/urn:cspace:name({itemspecifier})/contacts/{csid}") - ClientResponse readContactForNamedItem( + ClientResponse readContactForNamedItem( @PathParam("parentcsid") String parentcsid, @PathParam("itemspecifier") String itemspecifier, @PathParam("csid") String csid); @GET @Path("/urn:cspace:name({parentspecifier})/items/{itemcsid}/contacts/{csid}") - ClientResponse readContactInNamedAuthority( + ClientResponse readContactInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemcsid") String itemcsid, @PathParam("csid") String csid); @GET @Path("/urn:cspace:name({parentspecifier})/items/urn:cspace:name({itemspecifier})/contacts/{csid}") - ClientResponse readContactForNamedItemInNamedAuthority( + ClientResponse readContactForNamedItemInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemspecifier") String itemspecifier, @PathParam("csid") String csid); @@ -215,32 +212,32 @@ public interface OrgAuthorityProxy extends CollectionSpaceProxy { //(U)pdate Contact @PUT @Path("/{parentcsid}/items/{itemcsid}/contacts/{csid}") - ClientResponse updateContact( + ClientResponse updateContact( @PathParam("parentcsid") String parentcsid, @PathParam("itemcsid") String itemcsid, @PathParam("csid") String csid, - MultipartOutput multipart); + byte[] xmlPayload); @PUT @Path("/{parentcsid}/items/urn:cspace:name({itemspecifier})/contacts/{csid}") - ClientResponse updateContactForNamedItem( + ClientResponse updateContactForNamedItem( @PathParam("parentcsid") String parentcsid, @PathParam("itemspecifier") String itemspecifier, @PathParam("csid") String csid, - MultipartOutput multipart); + byte[] xmlPayload); @PUT @Path("/urn:cspace:name({parentspecifier})/items/{itemcsid}/contacts/{csid}") - ClientResponse updateContactInNamedAuthority( + ClientResponse updateContactInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemcsid") String itemcsid, @PathParam("csid") String csid, - MultipartOutput multipart); + byte[] xmlPayload); @PUT @Path("/urn:cspace:name({parentspecifier})/items/urn:cspace:name({itemspecifier})/contacts/{csid}") - ClientResponse updateContactForNamedItemInNamedAuthority( + ClientResponse updateContactForNamedItemInNamedAuthority( @PathParam("parentspecifier") String parentspecifier, @PathParam("itemspecifier") String itemspecifier, @PathParam("csid") String csid, - MultipartOutput multipart); + byte[] xmlPayload); //(D)elete Contact @DELETE diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java index 9aae6506f..4e2f722c4 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java @@ -36,6 +36,8 @@ import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.client.OrgAuthorityClientUtils; import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.organization.MainBodyGroup; @@ -44,8 +46,6 @@ import org.collectionspace.services.organization.OrganizationsCommon; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; @@ -67,10 +67,18 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - final String SERVICE_PATH_COMPONENT = "orgauthorities"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; final String ORG_AUTHORITY_NAME = "TestOrgAuth"; + @Override + public String getServicePathComponent() { + return OrgAuthorityClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return OrgAuthorityClient.SERVICE_NAME; + } private String knownResourceId = null; private String knownResourceRefName = null; @@ -148,7 +156,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { String shortId = createIdentifier(); String displayName = "TestOrgAuth-" + shortId; String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, shortId, orgAuthClient.getCommonPartName()); @@ -230,7 +238,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding // refName by which it can be identified. - MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); @@ -274,7 +282,7 @@ public class OrgAuthorityAuthRefsTest 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()); @@ -315,7 +323,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { subBodyName + "-" + shortId); subBodyOrgMap.put(OrganizationJAXBSchema.LONG_NAME, subBodyName + " Long Name"); subBodyOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, subBodyName + " Founding Place"); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrganizationInstance( knownResourceRefName, subBodyOrgMap, orgAuthClient.getItemCommonPartName()); @@ -353,7 +361,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { // Submit the request to the service and store the response. OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = orgAuthClient.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -366,7 +374,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon organization = (OrganizationsCommon) extractPart(input, orgAuthClient.getItemCommonPartName(), OrganizationsCommon.class); Assert.assertNotNull(organization); @@ -478,15 +486,4 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { client.delete(resourceId).releaseConnection(); } } - - // --------------------------------------------------------------- - // Utility methods used by tests above - // --------------------------------------------------------------- - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() - */ - @Override - public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; - } } diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java index b4eabd96c..9eee82fd2 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java @@ -33,6 +33,9 @@ import org.collectionspace.services.OrganizationJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.ContactClientUtils; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; import org.collectionspace.services.client.OrgAuthorityClient; @@ -46,9 +49,7 @@ import org.collectionspace.services.organization.OrganizationsCommon; import org.collectionspace.services.organization.OrganizationsCommonList; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -62,21 +63,21 @@ import org.testng.annotations.Test; * $LastChangedRevision$ * $LastChangedDate$ */ -public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { +public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class! /** The logger. */ private final String CLASS_NAME = OrgAuthorityServiceTest.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 = "orgauthorities"; - - /** The item service path component. */ - final String ITEM_SERVICE_PATH_COMPONENT = "items"; - - /** The contact service path component. */ - final String CONTACT_SERVICE_PATH_COMPONENT = "contacts"; + @Override + public String getServicePathComponent() { + return OrgAuthorityClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return OrgAuthorityClient.SERVICE_NAME; + } /** The test organization shortname. */ private final String TEST_ORG_SHORTNAME = "Test Org"; @@ -159,8 +160,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { String shortId = createIdentifier(); String displayName = "displayName-" + shortId; String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); - MultipartOutput multipart = - OrgAuthorityClientUtils.createOrgAuthorityInstance( + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, shortId, client.getCommonPartName()); String newID = null; @@ -298,7 +298,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); String identifier = createIdentifier(); - MultipartOutput multipart = + PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid, itemcsid, identifier, new ContactClient().getCommonPartName()); @@ -537,7 +537,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if(CSID!=null) { res = client.read(CSID); } else if(shortId!=null) { @@ -558,7 +558,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); //FIXME: remove the following try catch once Aron fixes signatures try { - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input, new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class); Assert.assertNotNull(orgAuthority); @@ -633,7 +633,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if(authCSID!=null) { if(itemCSID!=null) { res = client.readItem(authCSID, itemCSID); @@ -666,7 +666,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Check whether we've received a organization. - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon organization = (OrganizationsCommon) extractPart(input, client.getItemCommonPartName(), OrganizationsCommon.class); Assert.assertNotNull(organization); @@ -708,8 +708,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - MultipartInput input = null; - ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); + PoxPayloadIn input = null; + ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { int statusCode = res.getStatus(); @@ -723,7 +723,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Check whether organization has expected displayName. - input = res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); } finally { res.releaseConnection(); } @@ -755,9 +755,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { updatedShortName, TEST_ORG_FOUNDING_PLACE); // Submit the updated resource to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getItemCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); res = client.updateItem(knownResourceId, knownItemResourceId, output); try { int statusCode = res.getStatus(); @@ -771,7 +771,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Retrieve the updated resource and verify that its contents exist. - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); } finally { res.releaseConnection(); } @@ -798,9 +798,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { organization.setDisplayName(expectedDisplayName); // Submit the updated resource to the service and store the response. - output = new MultipartOutput(); + output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getItemCommonPartName()); + commonPart.setLabel(client.getItemCommonPartName()); res = client.updateItem(knownResourceId, knownItemResourceId, output); try { int statusCode = res.getStatus(); @@ -814,7 +814,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Retrieve the updated resource and verify that its contents exist. - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); } finally { res.releaseConnection(); } @@ -852,7 +852,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); + ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { int statusCode = res.getStatus(); @@ -866,7 +866,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode()); // Check whether organization has expected displayName. - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon organization = (OrganizationsCommon) extractPart(input, client.getItemCommonPartName(), OrganizationsCommon.class); Assert.assertNotNull(organization); @@ -875,9 +875,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { organization.setDisplayName(null); // Submit the updated resource to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getItemCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); res.releaseConnection(); res = client.updateItem(knownResourceId, knownItemResourceId, output); statusCode = res.getStatus(); @@ -912,7 +912,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); try { @@ -928,7 +928,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Check whether we've received a contact. - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); ContactsCommon contact = (ContactsCommon) extractPart(input, new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); @@ -961,7 +961,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = client.read(NON_EXISTENT_ID); + ClientResponse res = client.read(NON_EXISTENT_ID); try { int statusCode = res.getStatus(); @@ -995,7 +995,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); + ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); try { int statusCode = res.getStatus(); @@ -1029,7 +1029,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID); try { int statusCode = res.getStatus(); @@ -1298,7 +1298,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = client.read(knownResourceId); try { if(logger.isDebugEnabled()){ @@ -1309,7 +1309,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { if(logger.isDebugEnabled()){ logger.debug("got OrgAuthority to update with ID: " + knownResourceId); } - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input, client.getCommonPartName(), OrgauthoritiesCommon.class); Assert.assertNotNull(orgAuthority); @@ -1323,9 +1323,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the updated resource to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); res.releaseConnection(); res = client.update(knownResourceId, output); int statusCode = res.getStatus(); @@ -1339,7 +1339,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Retrieve the updated resource and verify that its contents exist. - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); OrgauthoritiesCommon updatedOrgAuthority = (OrgauthoritiesCommon) extractPart(input, client.getCommonPartName(), OrgauthoritiesCommon.class); @@ -1372,7 +1372,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { if(logger.isDebugEnabled()){ @@ -1385,7 +1385,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { knownItemResourceId + " in OrgAuthority: " + knownResourceId ); } - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon organization = (OrganizationsCommon) extractPart(input, client.getItemCommonPartName(), OrganizationsCommon.class); Assert.assertNotNull(organization); @@ -1407,9 +1407,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the updated resource to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getItemCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); res.releaseConnection(); res = client.updateItem(knownResourceId, knownItemResourceId, output); int statusCode = res.getStatus(); @@ -1423,7 +1423,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Retrieve the updated resource and verify that its contents exist. - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); OrganizationsCommon updatedOrganization = (OrganizationsCommon) extractPart(input, client.getItemCommonPartName(), OrganizationsCommon.class); @@ -1458,7 +1458,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = + ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); try { if(logger.isDebugEnabled()){ @@ -1472,7 +1472,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { " in item: " + knownItemResourceId + " in parent: " + knownResourceId ); } - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); ContactsCommon contact = (ContactsCommon) extractPart(input, new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); @@ -1486,9 +1486,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the updated resource to the service and store the response. - MultipartOutput output = new MultipartOutput(); - OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", new ContactClient().getCommonPartName()); + PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(new ContactClient().getCommonPartName()); res.releaseConnection(); res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output); int statusCode = res.getStatus(); @@ -1502,7 +1502,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Retrieve the updated resource and verify that its contents exist. - input = (MultipartInput) res.getEntity(); + input = new PoxPayloadIn(res.getEntity()); ContactsCommon updatedContact = (ContactsCommon) extractPart(input, new ContactClient().getCommonPartName(), ContactsCommon.class); @@ -1648,10 +1648,10 @@ public class OrgAuthorityServiceTest 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. OrgAuthorityClient client = new OrgAuthorityClient(); - MultipartOutput multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( NON_EXISTENT_ID, NON_EXISTENT_ID, new OrgAuthorityClient().getCommonPartName()); - ClientResponse res = + ClientResponse res = client.update(NON_EXISTENT_ID, multipart); try { int statusCode = res.getStatus(); @@ -1692,11 +1692,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { Map nonexOrgMap = new HashMap(); nonexOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, "nonExistent"); nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent"); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrganizationInstance( knownResourceRefName, nonexOrgMap, client.getItemCommonPartName() ); - ClientResponse res = + ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); try { int statusCode = res.getStatus(); @@ -2097,18 +2097,13 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ - @Override - public String getServicePathComponent() { - return SERVICE_PATH_COMPONENT; - } - /** * Gets the item service path component. * * @return the item service path component */ public String getItemServicePathComponent() { - return ITEM_SERVICE_PATH_COMPONENT; + return OrgAuthorityClient.SERVICE_PATH_ITEMS_COMPONENT; } /** @@ -2117,7 +2112,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { * @return the contact service path component */ public String getContactServicePathComponent() { - return CONTACT_SERVICE_PATH_COMPONENT; + return ContactClient.SERVICE_PATH_COMPONENT; } /** diff --git a/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java b/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java index eda8264dd..0662d229b 100644 --- a/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java +++ b/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java @@ -36,9 +36,9 @@ import org.apache.log4j.BasicConfigurator; import org.collectionspace.services.OrganizationJAXBSchema; import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.client.OrgAuthorityClientUtils; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.test.ServiceRequestType; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,7 +70,7 @@ public class OrgAuthorityBaseImport { logger.debug("Import: Create orgAuthority: \"" + orgAuthorityShortId +"\""); } String baseOrgAuthRefName = OrgAuthorityClientUtils.createOrgAuthRefName(orgAuthorityShortId, null); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( orgAuthorityDisplayName, orgAuthorityShortId, client.getCommonPartName()); ClientResponse res = client.create(multipart); diff --git a/services/organization/jaxb/.classpath b/services/organization/jaxb/.classpath index fef07b28f..3de74d965 100644 --- a/services/organization/jaxb/.classpath +++ b/services/organization/jaxb/.classpath @@ -1,9 +1,300 @@ - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/organization/jaxb/.project b/services/organization/jaxb/.project index 4e8829944..0b2ae01ca 100644 --- a/services/organization/jaxb/.project +++ b/services/organization/jaxb/.project @@ -1,23 +1,23 @@ - org.collectionspace.services.organization.jaxb - + 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.hyperjaxb + 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/organization/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs index 5f53d8256..cee0b6ddb 100644 --- a/services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs +++ b/services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -1,9 +1,9 @@ -#Tue Dec 21 10:34:21 PST 2010 +#Wed Jan 19 22:49:38 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/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java b/services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java index 5331b522f..71119a652 100644 --- a/services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java +++ b/services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java @@ -43,8 +43,6 @@ import org.collectionspace.services.organization.OrgauthoritiesCommonList; import org.collectionspace.services.organization.OrganizationsCommon; import org.collectionspace.services.organization.OrganizationsCommonList; import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; @@ -92,7 +90,7 @@ public class Sample { logger.info("Import: Create orgAuthority: \"" + orgAuthName +"\""); String baseOrgAuthRefName = createOrgAuthRefName(orgAuthName); String fullOrgAuthRefName = baseOrgAuthRefName+"'"+orgAuthName+"'"; - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( orgAuthName, fullOrgAuthRefName, client.getCommonPartName()); @@ -135,7 +133,7 @@ public class Sample { logger.info("Import: Create Item: \""+shortName+ "\" in orgAuthority: \"" + orgAuthorityRefName +"\""); - MultipartOutput multipart = + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrganizationInstance( vcsid, refName, orgInfo, client.getItemCommonPartName() ); @@ -207,7 +205,7 @@ public class Sample { // Submit the request to the service and store the response. OrgauthoritiesCommon orgAuthority = null; try { - ClientResponse res = client.read(orgAuthId); + ClientResponse res = client.read(orgAuthId); int statusCode = res.getStatus(); if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { throw new RuntimeException("Could not read orgAuthority" @@ -217,7 +215,7 @@ public class Sample { throw new RuntimeException("Unexpected Status when reading " + "orgAuthority, Status:"+ statusCode); } - MultipartInput input = (MultipartInput) res.getEntity(); + PoxPayloadIn input = (PoxPayloadIn) res.getEntity(); orgAuthority = (OrgauthoritiesCommon) extractPart(input, client.getCommonPartName(), OrgauthoritiesCommon.class); } catch (Exception e) { @@ -377,7 +375,7 @@ public class Sample { return sb.toString(); } - private Object extractPart(MultipartInput input, String label, + private Object extractPart(PoxPayloadIn input, String label, Class clazz) throws Exception { Object obj = null; for(InputPart part : input.getParts()){ diff --git a/services/organization/service/.classpath b/services/organization/service/.classpath index 425cd1620..73c509836 100644 --- a/services/organization/service/.classpath +++ b/services/organization/service/.classpath @@ -1,10 +1,319 @@ - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/organization/service/.project b/services/organization/service/.project index d4caadcad..0739a4af5 100644 --- a/services/organization/service/.project +++ b/services/organization/service/.project @@ -1,26 +1,30 @@ - org.collectionspace.services.organization.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.common + org.collectionspace.services.contact.client + org.collectionspace.services.contact.jaxb + org.collectionspace.services.contact.service + org.collectionspace.services.hyperjaxb + org.collectionspace.services.jaxb + org.collectionspace.services.organization.client org.collectionspace.services.organization.jaxb - org.collectionspace.services.jaxb + org.collectionspace.services.person.client + org.collectionspace.services.person.jaxb org.eclipse.jdt.core.javabuilder - - org.maven.ide.eclipse.maven2Builder - - org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature - + \ No newline at end of file diff --git a/services/organization/service/pom.xml b/services/organization/service/pom.xml index 9477d3a33..5ba95bc64 100644 --- a/services/organization/service/pom.xml +++ b/services/organization/service/pom.xml @@ -32,6 +32,11 @@ org.collectionspace.services.organization.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.organization.client + ${project.version} + org.collectionspace.services org.collectionspace.services.contact.service diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java index a8da5723a..a417bf369 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java @@ -27,6 +27,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.contact.AuthorityResourceWithContacts; import org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler; import org.slf4j.Logger; @@ -35,9 +36,9 @@ import org.slf4j.LoggerFactory; /** * The Class OrgAuthorityResource. */ -@Path("/orgauthorities") -@Consumes("multipart/mixed") -@Produces("multipart/mixed") +@Path("/" + OrgAuthorityClient.SERVICE_PATH_COMPONENT) +@Consumes("application/xml") +@Produces("application/xml") public class OrgAuthorityResource extends AuthorityResourceWithContacts {