From: Patrick Schmitz Date: Thu, 13 Oct 2011 00:35:15 +0000 (+0000) Subject: CSPACE-3178 Modified authorityItem create and update to accept refNames in place... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=a28b12c9a2caacf9e69c39623728fe377f6fae24;p=tmp%2Fjakarta-migration.git CSPACE-3178 Modified authorityItem create and update to accept refNames in place of csids for children and parent identifiers in relations. Extensive cleanup related to relations, and to refName handling. Fixed bugs in handling of relations payloads. Many tests cleaned up to properly handle refNames. Lots of cleanup related to build dependencies among authority packages. Restructured authority project to properly separate jaxb and services classes (to resolve dependency cycles). --- diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java index d71772c40..c4eb6f383 100755 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java @@ -140,10 +140,10 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString(); ClientResponse resultResponse = relationClient.readList( collectionObjectCsid, - CollectionobjectsCommon.class.getSimpleName(), + null, //CollectionobjectsCommon.class.getSimpleName(), predicate, intakeCsid, - IntakesCommon.class.getSimpleName()); + null ); //IntakesCommon.class.getSimpleName()); RelationsCommonList relationList = null; try { Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -270,10 +270,10 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { for (String collectionObjectCsid : collectionObjectIDList) { ClientResponse resultResponse = relationClient.readList( intakeCsid, - IntakesCommon.class.getSimpleName(), //subject + null, //IntakesCommon.class.getSimpleName(), //subject predicate, collectionObjectCsid, - CollectionobjectsCommon.class.getSimpleName()); //object + null); //CollectionobjectsCommon.class.getSimpleName()); //object try { Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode()); diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/2-item.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/2-item.xml index 2432caa2f..17a5fc4d6 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/2-item.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/2-item.xml @@ -2,7 +2,7 @@ ${shortIdentifier} - urn:cspace:org.collectionspace.demo:locationauthority:name(${authShortIdentifier}):location:name(${shortIdentifier}) + Approved true false diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations_CSID.xml old mode 100755 new mode 100644 similarity index 68% rename from services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations.xml rename to services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations_CSID.xml index 0477ff257..cf1b8ecdd --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/3-locations_w_relations_CSID.xml @@ -1,9 +1,9 @@ - ${inAuthority} + ${name} false true @@ -17,60 +17,60 @@ hasBroader ${itemCSID} - Locationitem + ${parentCSID} - ${parentUri} - Locationitem + hasBroader ${childCSID} - ${childUri} + ${itemCSID} - Locationitem + hasBroader - ${child2Uri} ${child2CSID} + ${itemCSID} - Locationitem + hasBroader - ${child3Uri} ${child3CSID} + ${itemCSID} - Locationitem + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/5-locations_w_relations_RefNames.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/5-locations_w_relations_RefNames.xml new file mode 100644 index 000000000..f86783b25 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/hierarchy/5-locations_w_relations_RefNames.xml @@ -0,0 +1,53 @@ + + + + ${shortIdentifier} + ${name} + false + + + + + hasBroader + + ${itemCSID} + + + urn:cspace:core.collectionspace.org:locationauthorities:name(CSPACE3739LocationAuthority):item:name(Aisle3)'Aisle 3' + + + + hasBroader + + urn:cspace:core.collectionspace.org:locationauthorities:name(CSPACE3739LocationAuthority):item:name(Shelf1)'Shelf 1' + + + ${itemCSID} + + + + hasBroader + + urn:cspace:core.collectionspace.org:locationauthorities:name(CSPACE3739LocationAuthority):item:name(Shelf2)'Shelf 2' + + + ${itemCSID} + + + + hasBroader + + urn:cspace:core.collectionspace.org:locationauthorities:name(CSPACE3739LocationAuthority):item:name(Shelf3)'Shelf 3' + + + ${itemCSID} + + + + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/location-hierarchy.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/location-hierarchy.xml index c09c83336..fa2bc51ea 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/location-hierarchy.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/location/location-hierarchy.xml @@ -61,24 +61,30 @@ Aisle 3 + + + POST + /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority)/items/ + location/hierarchy/3-locations_w_relations_CSID.xml + + Cabinet 1 + ${LocationParent.CSID} + ${LocationChild1.CSID} + ${LocationChild2.CSID} + ${LocationChild3.CSID} + + POST /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority)/items/ - location/hierarchy/3-locations_w_relations.xml + location/hierarchy/5-locations_w_relations_RefNames.xml - ${LocationAuth1.CSID} - CSPACE3739LocationAuthority - Cabinet1 - Cabinet 1 - ${LocationParent.CSID} - /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority-setting-error-parent)/items/${LocationParent.CSID} + Cabinet1a + Cabinet 1a ${LocationChild1.CSID} - /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority)/items/${LocationChild1.CSID} ${LocationChild2.CSID} - /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority)/items/${LocationChild2.CSID} ${LocationChild3.CSID} - /cspace-services/locationauthorities/urn:cspace:name(CSPACE3739LocationAuthority)/items/${LocationChild3.CSID} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml index cec5f0029..fd72e30e7 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/person/person.xml @@ -20,6 +20,7 @@ ${PersonAuth1.CSID} CSPACE3739PersonAuthority + johnWayneActor1 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml index 65a1660e1..e78cd5c63 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml @@ -42,7 +42,9 @@ - + diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 56a458613..5ec81e874 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -52,7 +52,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.service ${project.version} diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java index d99eaff77..60e293345 100644 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java @@ -96,14 +96,12 @@ public class CollectionSpaceJaxRsApplication extends Application singletons.add(new RoleResource()); singletons.add(new PermissionResource()); - singletons.add(new VocabularyResource()); - singletons.add(new PersonAuthorityResource()); - singletons.add(new OrgAuthorityResource()); - singletons.add(new LocationAuthorityResource()); - singletons.add(new TaxonomyAuthorityResource()); - - singletons.add(new AcquisitionResource()); - + addResourceToMapAndSingletons(new VocabularyResource()); + addResourceToMapAndSingletons(new PersonAuthorityResource()); + addResourceToMapAndSingletons(new OrgAuthorityResource()); + addResourceToMapAndSingletons(new LocationAuthorityResource()); + addResourceToMapAndSingletons(new TaxonomyAuthorityResource()); + addResourceToMapAndSingletons(new AcquisitionResource()); addResourceToMapAndSingletons(new ContactResource()); addResourceToMapAndSingletons(new CollectionObjectResource()); addResourceToMapAndSingletons(new GroupResource()); diff --git a/services/acquisition/client/pom.xml b/services/acquisition/client/pom.xml index c5cfe67d2..03532b092 100644 --- a/services/acquisition/client/pom.xml +++ b/services/acquisition/client/pom.xml @@ -29,7 +29,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/authority/jaxb/pom.xml b/services/authority/jaxb/pom.xml new file mode 100644 index 000000000..557655e72 --- /dev/null +++ b/services/authority/jaxb/pom.xml @@ -0,0 +1,49 @@ + + + + org.collectionspace.services.authority + org.collectionspace.services + 1.12-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.authority.jaxb + services.authority.jaxb + + + + com.sun.xml.bind + jaxb-impl + + + org.jvnet.jaxb2-commons + property-listener-injector + + + org.jvnet.jaxb2_commons + runtime + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + + + + diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java rename to services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java rename to services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java rename to services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java rename to services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java diff --git a/services/authority/pom.xml b/services/authority/pom.xml index 8d4d98cbd..eb504088b 100644 --- a/services/authority/pom.xml +++ b/services/authority/pom.xml @@ -12,272 +12,11 @@ org.collectionspace.services org.collectionspace.services.authority services.authority - jar + pom - - - - org.collectionspace.services - org.collectionspace.services.common-api - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.common - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authentication.jaxb - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authentication.service - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authorization.jaxb - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authorization.service - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.relation.service - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.relation.client - ${project.version} - - - - - - - org.slf4j - slf4j-api - provided - - - org.slf4j - slf4j-log4j12 - provided - - - log4j - log4j - 1.2.14 - provided - - - org.apache.commons - commons-jexl - 2.0.1 - - - commons-codec - commons-codec - 1.4 - - - - - javax.servlet - servlet-api - 2.5 - provided - - - - javax.security - jaas - 1.0.01 - provided - - - javax.security - jacc - 1.0 - provided - - - - mysql - mysql-connector-java - - - postgresql - postgresql - - - javax.persistence - persistence-api - - - - com.sun.xml.bind - jaxb-impl - - - org.jvnet.jaxb2-commons - property-listener-injector - - - org.jvnet.jaxb2_commons - runtime - - - - - org.jboss.resteasy - jaxrs-api - - - org.jboss.resteasy - resteasy-jaxrs - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - - - org.jboss.resteasy - resteasy-multipart-provider - - - - org.hibernate - hibernate-entitymanager - - - - jboss - jbosssx - 4.2.3.GA - provided - - - jboss - jboss-remoting - 2.2.2.SP8 - provided - - - - org.nuxeo.ecm.platform - nuxeo-platform-mimetype-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-core - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-filemanager-api - ${nuxeo.platform.version} - - - org.nuxeo.common - nuxeo-common - ${nuxeo.core.version} - provided - - - org.nuxeo.runtime - nuxeo-runtime - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-api - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-client - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-query - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-schema - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-storage-sql - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-io - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-facade - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-io - ${nuxeo.core.version} - - - org.nuxeo.runtime - nuxeo-runtime-osgi - ${nuxeo.core.version} - - - org.osgi - org.osgi.core - 4.1.0 - - + + jaxb + service + diff --git a/services/authority/service/pom.xml b/services/authority/service/pom.xml new file mode 100644 index 000000000..481e36956 --- /dev/null +++ b/services/authority/service/pom.xml @@ -0,0 +1,288 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + 1.12-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.authority.service + services.authority + jar + + + + + org.collectionspace.services + org.collectionspace.services.common-api + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authentication.jaxb + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authentication.service + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authorization.jaxb + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authorization.service + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.relation.service + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.relation.client + ${project.version} + + + + + + + org.slf4j + slf4j-api + provided + + + org.slf4j + slf4j-log4j12 + provided + + + log4j + log4j + 1.2.14 + provided + + + org.apache.commons + commons-jexl + 2.0.1 + + + commons-codec + commons-codec + 1.4 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + javax.security + jaas + 1.0.01 + provided + + + javax.security + jacc + 1.0 + provided + + + + mysql + mysql-connector-java + + + postgresql + postgresql + + + javax.persistence + persistence-api + + + + com.sun.xml.bind + jaxb-impl + + + org.jvnet.jaxb2-commons + property-listener-injector + + + org.jvnet.jaxb2_commons + runtime + + + + + org.jboss.resteasy + jaxrs-api + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + + org.hibernate + hibernate-entitymanager + + + + jboss + jbosssx + 4.2.3.GA + provided + + + jboss + jboss-remoting + 2.2.2.SP8 + provided + + + + org.nuxeo.ecm.platform + nuxeo-platform-mimetype-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-filemanager-api + ${nuxeo.platform.version} + + + org.nuxeo.common + nuxeo-common + ${nuxeo.core.version} + provided + + + org.nuxeo.runtime + nuxeo-runtime + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-api + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-client + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-query + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-schema + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-storage-sql + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-io + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-facade + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-io + ${nuxeo.core.version} + + + org.nuxeo.runtime + nuxeo-runtime-osgi + ${nuxeo.core.version} + + + org.osgi + org.osgi.core + 4.1.0 + + + + diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java similarity index 96% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 0b3c219e0..96d887e65 100644 --- a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -30,6 +30,7 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.XmlTools; @@ -287,6 +288,31 @@ public abstract class AuthorityResource return itemcsid; } + /* + * Generally, callers will first call RefName.AuthorityItem.parse with a refName, and then + * use the returned item.inAuthority.resource and a resourceMap to get a service-specific + * Resource. They then call this method on that resource. + */ + @Override + public DocumentModel getDocModelForAuthorityItem(RefName.AuthorityItem item) + throws Exception, DocumentNotFoundException { + if(item == null) { + return null; + } + String whereClause = buildWhereForAuthByName(item.getParentShortIdentifier()); + // Ensure we have the right context. + ServiceContext ctx = createServiceContext(item.inAuthority.resource); + + String parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause); + + String itemWhereClause = buildWhereForAuthItemByName(item.getShortIdentifier(), parentcsid); + ctx = createServiceContext(getItemServiceName()); + DocumentWrapper docWrapper = getRepositoryClient(ctx).findDoc(ctx, itemWhereClause); + DocumentModel docModel = docWrapper.getWrappedObject(); + return docModel; + } + + @POST public Response createAuthority(String xmlPayload) { try { @@ -461,10 +487,12 @@ public abstract class AuthorityResource *************************************************************************/ @POST @Path("{csid}/items") - public Response createAuthorityItem(@Context UriInfo ui, @PathParam("csid") String specifier, String xmlPayload) { + public Response createAuthorityItem(@Context ResourceMap resourceMap, @Context UriInfo ui, + @PathParam("csid") String specifier, String xmlPayload) { try { PoxPayloadIn input = new PoxPayloadIn(xmlPayload); ServiceContext ctx = createServiceContext(getItemServiceName(), input); + ctx.setResourceMap(resourceMap); ctx.setUriInfo(ui); //Laramie // Note: must have the parentShortId, to do the create. @@ -761,6 +789,7 @@ public abstract class AuthorityResource @PUT @Path("{csid}/items/{itemcsid}") public byte[] updateAuthorityItem( + @Context ResourceMap resourceMap, @Context UriInfo ui, @PathParam("csid") String parentspecifier, @PathParam("itemcsid") String itemspecifier, @@ -773,6 +802,7 @@ public abstract class AuthorityResource String parentcsid = lookupParentCSID(parentspecifier, "updateAuthorityItem(parent)", "UPDATE_ITEM", null); ServiceContext ctx = createServiceContext(getItemServiceName(), theUpdate); + ctx.setResourceMap(resourceMap); String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx); // We omit the parentShortId, only needed when doing a create... diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/Hierarchy.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/Hierarchy.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/Hierarchy.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/Hierarchy.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java similarity index 100% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityIdentifierUtils.java diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java similarity index 84% rename from services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java rename to services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index a20f7de0e..29dbd50c2 100644 --- a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -125,7 +125,9 @@ public abstract class AuthorityItemDocumentModelHandler public void handleCreate(DocumentWrapper wrapDoc) throws Exception { // first fill all the parts of the document super.handleCreate(wrapDoc); + // Ensure we have required fields set properly handleInAuthority(wrapDoc.getWrappedObject()); + handleComputedDisplayNames(wrapDoc.getWrappedObject()); String displayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); @@ -133,9 +135,8 @@ public abstract class AuthorityItemDocumentModelHandler logger.warn("Creating Authority Item with no displayName!"); } // CSPACE-3178: - // Uncomment once debugged and App layer is read to integrate - // Experimenting with these uncommented now ... handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName); + // refName includes displayName, so we force a correct value here. updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase()); } @@ -441,6 +442,7 @@ public abstract class AuthorityItemDocumentModelHandler public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { super.fillAllParts(wrapDoc, action); + /* ServiceContext ctx = getServiceContext(); PoxPayloadIn input = (PoxPayloadIn) ctx.getInput(); DocumentModel documentModel = (wrapDoc.getWrappedObject()); @@ -451,16 +453,43 @@ public abstract class AuthorityItemDocumentModelHandler PayloadOutputPart payloadOutputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMON_LIST_NAME, relationsCommonList); ctx.setProperty(RelationClient.SERVICE_COMMON_LIST_NAME, payloadOutputPart); + */ + } + + public void completeCreate(DocumentWrapper wrapDoc) throws Exception { + super.completeCreate(wrapDoc); + handleRelationsPayload(wrapDoc, false); } public void completeUpdate(DocumentWrapper wrapDoc) throws Exception { super.completeUpdate(wrapDoc); - //now we add part for relations list - ServiceContext ctx = getServiceContext(); - PayloadOutputPart foo = (PayloadOutputPart) ctx.getProperty(RelationClient.SERVICE_COMMON_LIST_NAME); - ((PoxPayloadOut) ctx.getOutput()).addPart(foo); + handleRelationsPayload(wrapDoc, true); handleItemRefNameReferenceUpdate(); } + + // Note that we must do this after we have completed the Update, so that the repository has the + // info for the item itself. The relations code must call into the repo to get info for each end. + // This could be optimized to pass in the parent docModel, since it will often be one end. + // Nevertheless, we should complete the item save before we do work on the relations, especially + // since a save on Create might fail, and we would not want to create relations for something + // that may not be created... + private void handleRelationsPayload(DocumentWrapper wrapDoc, boolean fUpdate) throws Exception { + ServiceContext ctx = getServiceContext(); + PoxPayloadIn input = (PoxPayloadIn) ctx.getInput(); + DocumentModel documentModel = (wrapDoc.getWrappedObject()); + String itemCsid = documentModel.getName(); + + //Updates relations part + RelationsCommonList relationsCommonList = updateRelations(itemCsid, input, wrapDoc, fUpdate); + + PayloadOutputPart payloadOutputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMON_LIST_NAME, relationsCommonList); + ctx.setProperty(RelationClient.SERVICE_COMMON_LIST_NAME, payloadOutputPart); + + //now we add part for relations list + //ServiceContext ctx = getServiceContext(); + //PayloadOutputPart foo = (PayloadOutputPart) ctx.getProperty(RelationClient.SERVICE_COMMON_LIST_NAME); + ((PoxPayloadOut) ctx.getOutput()).addPart(payloadOutputPart); + } /** updateRelations strategy: @@ -478,53 +507,69 @@ public abstract class AuthorityItemDocumentModelHandler child-b parent-d child-c parent-a */ - public RelationsCommonList updateRelations(String itemCSID, PoxPayloadIn input, DocumentWrapper wrapDoc) + private RelationsCommonList updateRelations( + String itemCSID, PoxPayloadIn input, DocumentWrapper wrapDoc, boolean fUpdate) throws Exception { + if(logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID); + } PayloadInputPart part = input.getPart(RelationClient.SERVICE_COMMON_LIST_NAME); //input.getPart("relations_common"); if (part == null) { return null; //nothing to do--they didn't send a list of relations. } RelationsCommonList relationsCommonListBody = (RelationsCommonList) part.getBody(); + List inboundList = relationsCommonListBody.getRelationListItem(); + List actionList = newList(); + List childList = null; + List parentList = null; + DocumentModel docModel = wrapDoc.getWrappedObject(); ServiceContext ctx = getServiceContext(); - UriInfo uriInfo = ctx.getUriInfo(); - MultivaluedMap queryParams = uriInfo.getQueryParameters(); - - //Run getList() once as sent to get childListOuter: - String predicate = RelationshipType.HAS_BROADER.value(); - queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); - queryParams.putSingle(IRelationsManager.SUBJECT_QP, null); - queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null); - queryParams.putSingle(IRelationsManager.OBJECT_QP, itemCSID); - queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null); - RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo()); //magically knows all query params because they are in the context. - - //Now run getList() again, leaving predicate, swapping subject and object, to get parentListOuter. - queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); - queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemCSID); - queryParams.putSingle(IRelationsManager.OBJECT_QP, null); - RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo()); + //Do magic replacement of ${itemCSID} and fix URI's. + fixupInboundListItems(ctx, inboundList, docModel, itemCSID); String HAS_BROADER = RelationshipType.HAS_BROADER.value(); + UriInfo uriInfo = ctx.getUriInfo(); + MultivaluedMap queryParams = uriInfo.getQueryParameters(); - List inboundList = relationsCommonListBody.getRelationListItem(); - List actionList = newList(); - List childList = childListOuter.getRelationListItem(); - List parentList = parentListOuter.getRelationListItem(); - - if (parentList.size() > 1) { - throw new Exception("Too many parents for object: " + itemCSID + " list: " + dumpList(parentList, "parentList")); + if(fUpdate) { + //Run getList() once as sent to get childListOuter: + String predicate = RelationshipType.HAS_BROADER.value(); + queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); + queryParams.putSingle(IRelationsManager.SUBJECT_QP, null); + queryParams.putSingle(IRelationsManager.SUBJECT_TYPE_QP, null); + queryParams.putSingle(IRelationsManager.OBJECT_QP, itemCSID); + queryParams.putSingle(IRelationsManager.OBJECT_TYPE_QP, null); + RelationsCommonList childListOuter = (new RelationResource()).getList(ctx.getUriInfo()); //magically knows all query params because they are in the context. + + //Now run getList() again, leaving predicate, swapping subject and object, to get parentListOuter. + queryParams.putSingle(IRelationsManager.PREDICATE_QP, predicate); + queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemCSID); + queryParams.putSingle(IRelationsManager.OBJECT_QP, null); + RelationsCommonList parentListOuter = (new RelationResource()).getList(ctx.getUriInfo()); + + + childList = childListOuter.getRelationListItem(); + parentList = parentListOuter.getRelationListItem(); + + if (parentList.size() > 1) { + throw new Exception("Too many parents for object: " + itemCSID + " list: " + dumpList(parentList, "parentList")); + } + + if(logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" got existing relations."); + } } - DocumentModel docModel = wrapDoc.getWrappedObject(); - - //Do magic replacement of ${itemCSID} and fix URI's. - fixupInboundListItems(ctx, inboundList, docModel, itemCSID); for (RelationsCommonList.RelationListItem inboundItem : inboundList) { - if (inboundItem.getObject().getCsid().equals(itemCSID) && inboundItem.getPredicate().equals(HAS_BROADER)) { + // Note that the relations may specify the other (non-item) bit with a refName, not a CSID, + // and so the CSID for those may be null + if (itemCSID.equals(inboundItem.getObject().getCsid()) + && inboundItem.getPredicate().equals(HAS_BROADER)) { //then this is an item that says we have a child. That child is inboundItem - RelationsCommonList.RelationListItem childItem = findInList(childList, inboundItem); + RelationsCommonList.RelationListItem childItem = + (childList==null)?null:findInList(childList, inboundItem); if (childItem != null) { removeFromList(childList, childItem); //exists, just take it off delete list } else { @@ -532,9 +577,11 @@ public abstract class AuthorityItemDocumentModelHandler } ensureChildHasNoOtherParents(ctx, queryParams, inboundItem.getSubject().getCsid()); - } else if (inboundItem.getSubject().getCsid().equals(itemCSID) && inboundItem.getPredicate().equals(HAS_BROADER)) { + } else if (itemCSID.equals(inboundItem.getSubject().getCsid()) + && inboundItem.getPredicate().equals(HAS_BROADER)) { //then this is an item that says we have a parent. inboundItem is that parent. - RelationsCommonList.RelationListItem parentItem = findInList(parentList, inboundItem); + RelationsCommonList.RelationListItem parentItem = + (parentList==null)?null:findInList(parentList, inboundItem); if (parentItem != null) { removeFromList(parentList, parentItem); //exists, just take it off delete list } else { @@ -545,12 +592,27 @@ public abstract class AuthorityItemDocumentModelHandler //not dealing with: hasNarrower or any other predicate. } } - String dump = dumpLists(itemCSID, parentList, childList, actionList); - //System.out.println("====dump====="+CR+dump); - logger.info("~~~~~~~~~~~~~~~~~~~~~~dump~~~~~~~~~~~~~~~~~~~~~~~~" + CR + dump); - deleteRelations(parentList, ctx, "parentList"); //todo: there are items appearing on both lists....april 20. - deleteRelations(childList, ctx, "childList"); + if(logger.isTraceEnabled()) { + String dump = dumpLists(itemCSID, parentList, childList, actionList); + //System.out.println("====dump====="+CR+dump); + logger.trace("~~~~~~~~~~~~~~~~~~~~~~dump~~~~~~~~~~~~~~~~~~~~~~~~" + CR + dump); + } + if(fUpdate) { + if(logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" deleting " + +parentList.size()+" existing parents and "+childList.size()+" existing children."); + } + deleteRelations(parentList, ctx, "parentList"); //todo: there are items appearing on both lists....april 20. + deleteRelations(childList, ctx, "childList"); + } + if(logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" adding " + +actionList.size()+" new parents and children."); + } createRelations(actionList, ctx); + if(logger.isTraceEnabled()) { + logger.trace("AuthItemDocHndler.updateRelations for: "+itemCSID+" done."); + } //We return all elements on the inbound list, since we have just worked to make them exist in the system // and be non-redundant, etc. That list came from relationsCommonListBody, so it is still attached to it, just pass that back. return relationsCommonListBody; @@ -615,42 +677,41 @@ public abstract class AuthorityItemDocumentModelHandler RelationsDocListItem inboundItemObject = inboundItem.getObject(); RelationsDocListItem inboundItemSubject = inboundItem.getSubject(); - if (inboundItemObject.getCsid().equalsIgnoreCase(CommonAPI.AuthorityItemCSID_REPLACE)) { + if (CommonAPI.AuthorityItemCSID_REPLACE.equalsIgnoreCase(inboundItemObject.getCsid())) { inboundItem.setObjectCsid(itemCSID); inboundItemObject.setCsid(itemCSID); - inboundItemObject.setUri(getUri(docModel)); + //inboundItemObject.setUri(getUri(docModel)); } else { + /* String objectCsid = inboundItemObject.getCsid(); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, objectCsid); //null if not found. DocumentWrapper wrapper = new DocumentWrapperImpl(itemDocModel); String uri = this.getRepositoryClient(ctx).getDocURI(wrapper); inboundItemObject.setUri(uri); //CSPACE-4037 + */ } - uriPointsToSameAuthority(thisURI, inboundItemObject.getUri()); //CSPACE-4042 + //uriPointsToSameAuthority(thisURI, inboundItemObject.getUri()); //CSPACE-4042 - if (inboundItemSubject.getCsid().equalsIgnoreCase(CommonAPI.AuthorityItemCSID_REPLACE)) { + if (CommonAPI.AuthorityItemCSID_REPLACE.equalsIgnoreCase(inboundItemSubject.getCsid())) { inboundItem.setSubjectCsid(itemCSID); inboundItemSubject.setCsid(itemCSID); - inboundItemSubject.setUri(getUri(docModel)); + //inboundItemSubject.setUri(getUri(docModel)); } else { + /* String subjectCsid = inboundItemSubject.getCsid(); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, subjectCsid); //null if not found. DocumentWrapper wrapper = new DocumentWrapperImpl(itemDocModel); String uri = this.getRepositoryClient(ctx).getDocURI(wrapper); inboundItemSubject.setUri(uri); //CSPACE-4037 + */ } - uriPointsToSameAuthority(thisURI, inboundItemSubject.getUri()); //CSPACE-4042 + //uriPointsToSameAuthority(thisURI, inboundItemSubject.getUri()); //CSPACE-4042 } } - public RepositoryClient getRepositoryClient(ServiceContext ctx) { - RepositoryClient repositoryClient = RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName()); - return repositoryClient; - } - // this method calls the RelationResource to have it create the relations and persist them. - private void createRelations(List inboundList, ServiceContext ctx) { + private void createRelations(List inboundList, ServiceContext ctx) throws Exception { for (RelationsCommonList.RelationListItem item : inboundList) { RelationsCommon rc = new RelationsCommon(); //rc.setCsid(item.getCsid()); @@ -658,6 +719,8 @@ public abstract class AuthorityItemDocumentModelHandler RelationsDocListItem itemSubject = item.getSubject(); RelationsDocListItem itemObject = item.getObject(); + // Set at least one of CSID and refName for Subject and Object + // Either value might be null for for each of Subject and Object String subjectCsid = itemSubject.getCsid(); rc.setSubjectCsid(subjectCsid); rc.setDocumentId1(subjectCsid); // populate legacy field for backward compatibility @@ -673,21 +736,27 @@ public abstract class AuthorityItemDocumentModelHandler //RelationshipType foo = (RelationshipType.valueOf(item.getPredicate())) ; //rc.setPredicate(foo); //this must be one of the type found in the enum in services/jaxb/src/main/resources/relations_common.xsd + // This is superfluous, since it will be fetched by the Relations Create logic. rc.setSubjectDocumentType(itemSubject.getDocumentType()); rc.setObjectDocumentType(itemObject.getDocumentType()); // populate legacy fields for backward compatibility rc.setDocumentType1(itemSubject.getDocumentType()); rc.setDocumentType2(itemObject.getDocumentType()); + // This is superfluous, since it will be fetched by the Relations Create logic. rc.setSubjectUri(itemSubject.getUri()); rc.setObjectUri(itemObject.getUri()); + // May not have the info here. Only really require CSID or refName. + // Rest is handled in the Relation create mechanism + //uriPointsToSameAuthority(itemSubject.getUri(), itemObject.getUri()); PoxPayloadOut payloadOut = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart outputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMONPART_NAME, rc); payloadOut.addPart(outputPart); //System.out.println("\r\n==== TO CREATE: "+rc.getDocumentId1()+"==>"+rc.getPredicate()+"==>"+rc.getDocumentId2()); RelationResource relationResource = new RelationResource(); - Object res = relationResource.create(ctx.getUriInfo(), payloadOut.toXML()); //NOTE ui recycled from above to pass in unknown query params. + Object res = relationResource.create(ctx.getResourceMap(), + ctx.getUriInfo(), payloadOut.toXML()); //NOTE ui recycled from above to pass in unknown query params. } } diff --git a/services/batch/client/pom.xml b/services/batch/client/pom.xml index 633a706f6..a751d5397 100644 --- a/services/batch/client/pom.xml +++ b/services/batch/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java index 8df63cddb..fcaa5e616 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java @@ -135,7 +135,7 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable { // First, create the Loanout // We fetch the resource class by service name ResourceBase resource = resourceMap.get( LoanoutClient.SERVICE_NAME); - Response response = resource.create(null, loanoutPayload); + Response response = resource.create(resourceMap, null, loanoutPayload); if(response.getStatus() != CREATED_STATUS) { completionStatus = STATUS_ERROR; errorInfo = new InvocationError(INT_ERROR_STATUS, @@ -161,7 +161,7 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable { + ""+RELATION_PREDICATE_DISP+"" + ""; ResourceBase resource = resourceMap.get(RelationClient.SERVICE_NAME); - Response response = resource.create(null, relationPayload); + Response response = resource.create(resourceMap, null, relationPayload); if(response.getStatus() != CREATED_STATUS) { completionStatus = STATUS_ERROR; errorInfo = new InvocationError(INT_ERROR_STATUS, diff --git a/services/blob/client/pom.xml b/services/blob/client/pom.xml index 7d78e24a3..1459035aa 100644 --- a/services/blob/client/pom.xml +++ b/services/blob/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java index 9126c7835..645c5976f 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java @@ -28,6 +28,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.FileUtils; import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.blob.BlobInput; import org.collectionspace.services.common.blob.BlobUtil; @@ -207,7 +208,9 @@ public class BlobResource extends ResourceBase { @POST @Override - public Response create(@Context UriInfo ui, + public Response create( + @Context ResourceMap resourceMap, + @Context UriInfo ui, String xmlPayload) { Response response = null; MultivaluedMap queryParams = ui.getQueryParameters(); @@ -220,7 +223,7 @@ public class BlobResource extends ResourceBase { blobInput.createBlobFile(blobUri); response = this.create(null, ctx); } else { - response = super.create(ui, xmlPayload); + response = super.create(resourceMap, ui, xmlPayload); } } catch (Exception e) { throw bigReThrow(e, ServiceMessages.CREATE_FAILED); diff --git a/services/collectionobject/client/pom.xml b/services/collectionobject/client/pom.xml index 0b0351263..7249f02bd 100644 --- a/services/collectionobject/client/pom.xml +++ b/services/collectionobject/client/pom.xml @@ -37,7 +37,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 4dc221e38..3d348503a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -26,6 +26,7 @@ package org.collectionspace.services.common; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.context.MultipartServiceContextImpl; import org.collectionspace.services.common.context.ServiceBindingUtils; @@ -78,13 +79,15 @@ public abstract class ResourceBase //======================= CREATE ==================================================== + @POST - public Response create(@Context UriInfo ui, + public Response create(@Context ResourceMap resourceMap, @Context UriInfo ui, String xmlPayload) { try { PoxPayloadIn input = new PoxPayloadIn(xmlPayload); //System.out.println("\r\n\r\n==============================\r\nxmlPayload:\r\n"+xmlPayload); ServiceContext ctx = createServiceContext(input); + ctx.setResourceMap(resourceMap); return create(input, ctx); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.CREATE_FAILED); @@ -116,12 +119,13 @@ public abstract class ResourceBase //======================= UPDATE ==================================================== @PUT @Path("{csid}") - public byte[] update(@PathParam("csid") String csid, String xmlPayload) { + public byte[] update(@Context ResourceMap resourceMap, @PathParam("csid") String csid, String xmlPayload) { PoxPayloadOut result = null; ensureCSID(csid, UPDATE); try { PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload); ServiceContext ctx = createServiceContext(theUpdate); + ctx.setResourceMap(resourceMap); result = update(csid, theUpdate, ctx); //==> CALL implementation method, which subclasses may override. } catch (Exception e) { throw bigReThrow(e, ServiceMessages.UPDATE_FAILED, csid); @@ -336,4 +340,35 @@ public abstract class ResourceBase } return authRefList; } + + //======================== UTILITY : getDocModelForRefName ======================================== + /* + * ResourceBase create and update calls will set the resourceMap into the service context + * for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get + * the map, and pass it in. + */ + public static DocumentModel getDocModelForRefName(String refName, ResourceMap resourceMap) + throws Exception, DocumentNotFoundException { + // TODO - we need to generalize the idea of a refName to more than Authorities and Items. + RefName.AuthorityItem item = RefName.AuthorityItem.parse(refName); + if(item == null) { + return null; + } + ResourceBase resource = resourceMap.get(item.inAuthority.resource); + return resource.getDocModelForAuthorityItem(item); + } + + // THis is ugly, but prevents us parsing the refName twice. Once we make refName a little more + // general, and less Authority(Item) specific, this will look better. + public DocumentModel getDocModelForAuthorityItem(RefName.AuthorityItem item) + throws Exception, DocumentNotFoundException { + logger.warn("Default (ResourceBase) getDocModelForAuthorityItem called - should not happen!"); + return null; + } + + public DocumentModel getDocModelForRefName(String refName) + throws Exception, DocumentNotFoundException { + return getDocModelForAuthorityItem(RefName.AuthorityItem.parse(refName)); + } + } diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java index be3df4641..1c5f5c422 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java @@ -27,6 +27,7 @@ import java.lang.reflect.Constructor; import javax.ws.rs.core.MultivaluedMap; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.security.UnauthorizedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +52,8 @@ public class RemoteServiceContextImpl /** The target of the HTTP request **/ JaxRsContext jaxRsContext; + ResourceMap resourceMap = null; + @Override public void setJaxRsContext(JaxRsContext theJaxRsContext) { this.jaxRsContext = theJaxRsContext; @@ -138,6 +141,22 @@ public class RemoteServiceContextImpl this.output = output; } + /** + * @return the map of service names to resource classes. + */ + public ResourceMap getResourceMap() { + return resourceMap; + } + + /** + * @param map the map of service names to resource instances. + */ + public void setResourceMap(ResourceMap map) { + this.resourceMap = map; + } + + + /* (non-Javadoc) * @see org.collectionspace.services.common.context.RemoteServiceContext#getLocalContext(java.lang.String) */ diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java index ccfdb588c..193167e1c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java @@ -30,6 +30,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; import org.collectionspace.services.common.ClientType; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.ValidatorHandler; import org.collectionspace.services.common.query.QueryContext; @@ -44,6 +45,12 @@ import org.collectionspace.services.common.service.ServiceBindingType; * between various components of the service framework while processing * a service request. */ +/** + * @author pschmitz + * + * @param + * @param + */ public interface ServiceContext { /** @@ -169,7 +176,7 @@ public interface ServiceContext { * @return the input */ public IT getInput(); - + /** * setInput is used to set request input before starting to * process input data @@ -189,6 +196,16 @@ public interface ServiceContext { */ public void setOutput(OT output); + /** + * @return the map of service names to resource classes. + */ + public ResourceMap getResourceMap(); + + /** + * @param map the map of service names to resource instances. + */ + public void setResourceMap(ResourceMap map); + /** * getPartsMetadata returns metadata for object parts used by the service * @return diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java index e8d9366f9..2ce34ae91 100755 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java @@ -32,10 +32,13 @@ import java.util.List; import org.collectionspace.services.common.ReflectionMapper; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.repository.RepositoryClient; +import org.collectionspace.services.common.repository.RepositoryClientFactory; import org.collectionspace.services.common.service.ListResultField; import org.collectionspace.services.common.service.DocHandlerParams; import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.datetime.DateTimeFormatUtils; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentWrapper; @@ -89,6 +92,7 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl } + public RepositoryClient getRepositoryClient(ServiceContext ctx) { + RepositoryClient repositoryClient = RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName()); + return repositoryClient; + } + /** * getRepositorySession returns Nuxeo Repository Session * @return diff --git a/services/contact/service/pom.xml b/services/contact/service/pom.xml index 74c236d2c..49a787eff 100644 --- a/services/contact/service/pom.xml +++ b/services/contact/service/pom.xml @@ -15,7 +15,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.service true ${project.version} diff --git a/services/group/client/pom.xml b/services/group/client/pom.xml index 20904c25d..6d0fa2bbc 100644 --- a/services/group/client/pom.xml +++ b/services/group/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/intake/client/pom.xml b/services/intake/client/pom.xml index 9ccff5661..55e9c2b60 100644 --- a/services/intake/client/pom.xml +++ b/services/intake/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} 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 dfc3ca4f3..51b062e45 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 @@ -74,7 +74,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { private List intakeIdsCreated = new ArrayList(); private List orgIdsCreated = new ArrayList(); private String orgAuthCSID = null; - private String orgAuthRefName = null; + //private String orgAuthRefName = null; private String currentOwnerOrgCSID = null; private String currentOwnerRefName = null; private String depositorRefName = null; @@ -173,8 +173,8 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { */ protected void createOrgRefs(){ OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); - orgAuthRefName = - OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null); + //orgAuthRefName = + // OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null); PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( ORGANIZATION_AUTHORITY_NAME, ORGANIZATION_AUTHORITY_NAME, orgAuthClient.getCommonPartName()); ClientResponse res = orgAuthClient.create(multipart); @@ -218,7 +218,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { orgInfo.put(OrganizationJAXBSchema.SHORT_NAME, shortName); orgInfo.put(OrganizationJAXBSchema.LONG_NAME, longName); PoxPayloadOut multipart = - OrgAuthorityClientUtils.createOrganizationInstance(orgAuthRefName, + OrgAuthorityClientUtils.createOrganizationInstance(null, //orgAuthRefName, orgInfo, orgAuthClient.getItemCommonPartName()); ClientResponse res = orgAuthClient.createItem(orgAuthCSID, multipart); int statusCode = res.getStatus(); diff --git a/services/loanin/client/pom.xml b/services/loanin/client/pom.xml index 5aea39c89..503295fa7 100644 --- a/services/loanin/client/pom.xml +++ b/services/loanin/client/pom.xml @@ -52,6 +52,11 @@ org.collectionspace.services.person.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + org.testng diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java index cd761fc1b..f6e2dcf3c 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.PersonJAXBSchema; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.LoaninClient; import org.collectionspace.services.client.PersonAuthorityClient; diff --git a/services/loanin/pom.xml b/services/loanin/pom.xml index 6da96f378..467a27507 100644 --- a/services/loanin/pom.xml +++ b/services/loanin/pom.xml @@ -14,12 +14,6 @@ pom - - org.collectionspace.services - org.collectionspace.services.authority - true - ${project.version} - diff --git a/services/loanout/client/pom.xml b/services/loanout/client/pom.xml index e482002e2..5e27b9008 100644 --- a/services/loanout/client/pom.xml +++ b/services/loanout/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/location/client/pom.xml b/services/location/client/pom.xml index 0c140143a..627b746fd 100644 --- a/services/location/client/pom.xml +++ b/services/location/client/pom.xml @@ -40,6 +40,11 @@ org.collectionspace.services.location.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + org.collectionspace.services org.collectionspace.services.client diff --git a/services/location/jaxb/pom.xml b/services/location/jaxb/pom.xml index 80341e13b..639cc224b 100644 --- a/services/location/jaxb/pom.xml +++ b/services/location/jaxb/pom.xml @@ -36,6 +36,12 @@ org.collectionspace.services.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + diff --git a/services/location/pom.xml b/services/location/pom.xml index c9a34a6e4..32b502480 100644 --- a/services/location/pom.xml +++ b/services/location/pom.xml @@ -13,12 +13,6 @@ pom - - org.collectionspace.services - org.collectionspace.services.authority - true - ${project.version} - diff --git a/services/location/service/pom.xml b/services/location/service/pom.xml index 50f662244..19deb675a 100644 --- a/services/location/service/pom.xml +++ b/services/location/service/pom.xml @@ -37,6 +37,11 @@ org.collectionspace.services.location.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.service + ${project.version} + org.collectionspace.services org.collectionspace.services.contact.service diff --git a/services/media/client/pom.xml b/services/media/client/pom.xml index 66e64af21..bc2a854c1 100644 --- a/services/media/client/pom.xml +++ b/services/media/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/movement/client/pom.xml b/services/movement/client/pom.xml index 1cf2a5c27..0d39ad2b8 100644 --- a/services/movement/client/pom.xml +++ b/services/movement/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/note/client/pom.xml b/services/note/client/pom.xml index 4ffd7ca00..67ef18d83 100644 --- a/services/note/client/pom.xml +++ b/services/note/client/pom.xml @@ -24,12 +24,6 @@ slf4j-log4j12 - - org.collectionspace.services - org.collectionspace.services.authority - true - ${project.version} - org.collectionspace.services org.collectionspace.services.note.jaxb diff --git a/services/objectexit/client/pom.xml b/services/objectexit/client/pom.xml index ad0dca9cc..9df823f6b 100644 --- a/services/objectexit/client/pom.xml +++ b/services/objectexit/client/pom.xml @@ -28,7 +28,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/organization/client/pom.xml b/services/organization/client/pom.xml index 369fad5f5..7d1b314c6 100644 --- a/services/organization/client/pom.xml +++ b/services/organization/client/pom.xml @@ -26,11 +26,6 @@ provided - - org.collectionspace.services - org.collectionspace.services.authority - ${project.version} - org.collectionspace.services org.collectionspace.services.organization.jaxb 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 80b5c9886..e8f8f3587 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 @@ -143,8 +143,8 @@ public class OrgAuthorityClientUtils { OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon(); orgAuthority.setDisplayName(displayName); orgAuthority.setShortIdentifier(shortIdentifier); - String refName = createOrgAuthRefName(shortIdentifier, displayName); - orgAuthority.setRefName(refName); + //String refName = createOrgAuthRefName(shortIdentifier, displayName); + //orgAuthority.setRefName(refName); orgAuthority.setVocabType("OrgAuthority"); PoxPayloadOut multipart = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE); @@ -258,8 +258,8 @@ public class OrgAuthorityClientUtils { if((value = (String)orgInfo.get(OrganizationJAXBSchema.SHORT_DISPLAY_NAME))!=null) organization.setShortDisplayName(value); - String refName = createOrganizationRefName(orgAuthRefName, shortId, value); - organization.setRefName(refName); + //String refName = createOrganizationRefName(orgAuthRefName, shortId, value); + //organization.setRefName(refName); if (mainBodyList != null) { organization.setMainBodyGroupList(mainBodyList); @@ -359,6 +359,7 @@ public class OrgAuthorityClientUtils { * @param displaySuffix displayName to be appended, if non-null * @return the string */ + /* public static String createOrgAuthRefName(String shortId, String displaySuffix) { String refName = "urn:cspace:org.collectionspace.demo:orgauthority:name(" +shortId+")"; @@ -366,6 +367,7 @@ public class OrgAuthorityClientUtils { refName += "'"+displaySuffix+"'"; return refName; } + */ /** * Creates the organization ref name. @@ -375,6 +377,7 @@ public class OrgAuthorityClientUtils { * @param displaySuffix displayName to be appended, if non-null * @return the string */ + /* public static String createOrganizationRefName( String orgAuthRefName, String shortId, String displaySuffix) { String refName = orgAuthRefName+":organization:name("+shortId+")"; @@ -382,6 +385,7 @@ public class OrgAuthorityClientUtils { refName += "'"+displaySuffix+"'"; return refName; } + */ /** * Produces a default displayName from the basic name and foundingPlace fields. 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 4e2f722c4..ef155886b 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 @@ -155,7 +155,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); String shortId = createIdentifier(); String displayName = "TestOrgAuth-" + shortId; - String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); + //String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, shortId, orgAuthClient.getCommonPartName()); @@ -181,7 +181,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { // so they can be deleted after tests have been run. String newId = extractId(res); if (knownResourceId == null){ - setKnownResource( newId, baseRefName ); + setKnownResource( newId, null ); //baseRefName ); } allResourceIdsCreated.add(newId); } finally { @@ -252,17 +252,17 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { res.releaseConnection(); } - String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); + //String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); // Create temporary Person resources, and their corresponding refNames // by which they can be identified. - String csid = createPerson("Charlie", "Orgcontact", "charlieOrgcontact", authRefName); + String csid = createPerson("Charlie", "Orgcontact", "charlieOrgcontact", null ); // authRefName); personIdsCreated.add(csid); organizationContactPersonRefName1 = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); // Create temporary Person resources, and their corresponding refNames // by which they can be identified. - csid = createPerson("Chelsie", "Contact", "chelsieContact", authRefName); + csid = createPerson("Chelsie", "Contact", "chelsieContact", null ); // authRefName); personIdsCreated.add(csid); organizationContactPersonRefName2 = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); } 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 8529b975f..160e08da1 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 @@ -146,7 +146,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: OrgAuthorityClient client = new OrgAuthorityClient(); String shortId = createIdentifier(); String displayName = "displayName-" + shortId; - String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); + //String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null); PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, shortId, client.getCommonPartName()); @@ -176,7 +176,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: // Store the ID returned from the first resource created // for additional tests below. if (knownResourceId == null) { - setKnownResource(newID, shortId, baseRefName); + setKnownResource(newID, shortId, null ); //baseRefName); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } diff --git a/services/organization/jaxb/pom.xml b/services/organization/jaxb/pom.xml index 4f3a92044..4da8fc09c 100644 --- a/services/organization/jaxb/pom.xml +++ b/services/organization/jaxb/pom.xml @@ -14,12 +14,6 @@ services.organization.jaxb - - org.collectionspace.services - org.collectionspace.services.authority - true - ${project.version} - org.collectionspace.services org.collectionspace.services.common @@ -42,6 +36,11 @@ org.collectionspace.services.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + diff --git a/services/organization/pom.xml b/services/organization/pom.xml index 4506840ca..5acef8dc3 100644 --- a/services/organization/pom.xml +++ b/services/organization/pom.xml @@ -13,12 +13,14 @@ pom + diff --git a/services/organization/service/pom.xml b/services/organization/service/pom.xml index 46d9ab20a..55924d0e9 100644 --- a/services/organization/service/pom.xml +++ b/services/organization/service/pom.xml @@ -24,7 +24,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.service true ${project.version} diff --git a/services/person/client/pom.xml b/services/person/client/pom.xml index f3247e59b..8942b0473 100644 --- a/services/person/client/pom.xml +++ b/services/person/client/pom.xml @@ -29,6 +29,11 @@ org.collectionspace.services.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + org.collectionspace.services org.collectionspace.services.common diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java index b7613f673..267c8ac99 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -140,8 +140,8 @@ public class PersonAuthorityClientUtils { PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon(); personAuthority.setDisplayName(displayName); personAuthority.setShortIdentifier(shortIdentifier); - String refName = createPersonAuthRefName(shortIdentifier, displayName); - personAuthority.setRefName(refName); + //String refName = createPersonAuthRefName(shortIdentifier, displayName); + //personAuthority.setRefName(refName); personAuthority.setVocabType("PersonAuthority"); PoxPayloadOut multipart = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE); @@ -170,7 +170,7 @@ public class PersonAuthorityClientUtils { String headerLabel){ final Map> EMPTY_PERSON_REPEATABLES_INFO = new HashMap>(); - return createPersonInstance(inAuthority, personAuthRefName, personInfo, + return createPersonInstance(inAuthority, null /*personAuthRefName*/, personInfo, EMPTY_PERSON_REPEATABLES_INFO, headerLabel); } @@ -226,8 +226,8 @@ public class PersonAuthorityClientUtils { throw new IllegalArgumentException("shortDisplayName cannot be null when shortDisplayComputed is 'false'"); } - String refName = createPersonRefName(personAuthRefName, shortId, displayName); - person.setRefName(refName); + //String refName = createPersonRefName(personAuthRefName, shortId, displayName); + //person.setRefName(refName); String value; List values = null; @@ -352,10 +352,10 @@ public class PersonAuthorityClientUtils { if(logger.isDebugEnabled()){ logger.debug("Import: Create Item: \"" + displayName - +"\" in personAuthorityulary: \"" + personAuthorityRefName +"\""); + +"\" in personAuthorityulary: \"" + vcsid +"\""); } PoxPayloadOut multipart = - createPersonInstance(vcsid, personAuthorityRefName, + createPersonInstance(vcsid, null /*personAuthorityRefName*/, personMap, personRepeatablesMap, client.getItemCommonPartName()); String result = null; @@ -365,12 +365,12 @@ public class PersonAuthorityClientUtils { if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { throw new RuntimeException("Could not create Item: \""+personMap.get(PersonJAXBSchema.SHORT_IDENTIFIER) - +"\" in personAuthority: \"" + personAuthorityRefName + +"\" in personAuthority: \"" + vcsid //personAuthorityRefName +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); } if(statusCode != EXPECTED_STATUS_CODE) { throw new RuntimeException("Unexpected Status when creating Item: \""+personMap.get(PersonJAXBSchema.SHORT_IDENTIFIER) - +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode); + +"\" in personAuthority: \"" + vcsid /*personAuthorityRefName*/ +"\", Status:"+ statusCode); } result = extractId(res); @@ -388,6 +388,7 @@ public class PersonAuthorityClientUtils { * @param displaySuffix displayName to be appended, if non-null * @return the string */ + /* public static String createPersonAuthRefName(String shortId, String displaySuffix) { String refName = "urn:cspace:org.collectionspace.demo:personauthority:name(" +shortId+")"; @@ -395,6 +396,7 @@ public class PersonAuthorityClientUtils { refName += "'"+displaySuffix+"'"; return refName; } + */ /** * Creates the person ref name. @@ -404,6 +406,7 @@ public class PersonAuthorityClientUtils { * @param displaySuffix displayName to be appended, if non-null * @return the string */ + /* public static String createPersonRefName( String personAuthRefName, String shortId, String displaySuffix) { String refName = personAuthRefName+":person:name("+shortId+")"; @@ -411,6 +414,7 @@ public class PersonAuthorityClientUtils { refName += "'"+displaySuffix+"'"; return refName; } + */ /** * Extract id. diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java index c6f38395f..662e3018c 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java @@ -123,7 +123,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { private String knownResourceId = null; /** The known resource ref name. */ - private String knownResourceRefName = null; + //private String knownResourceRefName = null; /** The known item resource id. */ private String knownItemResourceId = null; @@ -210,7 +210,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { Assert.fail("Could not create new Authority for search tests.", e); } try { - createItemsInAuthorityForPartialTermMatch(knownResourceId, knownResourceRefName); + createItemsInAuthorityForPartialTermMatch(knownResourceId, null ); //knownResourceRefName); } catch (Exception e) { Assert.fail("Could not create new item in Authority for search tests.", e); } @@ -594,7 +594,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { PersonAuthorityClient client = new PersonAuthorityClient(); String shortId = createIdentifier(); String displayName = "displayName-" + shortId; - String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); + //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, shortId, client.getCommonPartName()); @@ -617,12 +617,12 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { } // Store the refname from the first resource created // for additional tests below. - knownResourceRefName = baseRefName; + //knownResourceRefName = baseRefName; // Store the ID returned from the first resource created // for additional tests below. if (knownResourceId == null){ knownResourceId = newID; - knownResourceRefName = baseRefName; + //knownResourceRefName = baseRefName; } // Store the IDs from every resource created by tests, @@ -666,7 +666,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { styles.add(TEST_KWD_UTF8_STYLE); partialTermRepeatablesMap.put(PersonJAXBSchema.SCHOOLS_OR_STYLES, styles); - createItem(testName, authorityCsid, authRefName, client, + createItem(testName, authorityCsid, null /*authRefName*/, client, partialTermPersonMap, partialTermRepeatablesMap); // // Adjust the property map for the QUOTE item @@ -676,7 +676,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { partialTermPersonMap.put(PersonJAXBSchema.SUR_NAME, TEST_PARTIAL_TERM_SUR_NAME_QUOTE); partialTermPersonMap.put(PersonJAXBSchema.BIO_NOTE, TEST_KWD_BIO_NOTE_DBL_QUOTES); - createItem(testName, authorityCsid, authRefName, client, + createItem(testName, authorityCsid, null /*authRefName*/, client, partialTermPersonMap, partialTermRepeatablesMap); } @@ -688,7 +688,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { Map partialTermPersonMap, Map> partialTermRepeatablesMap) throws Exception { PoxPayloadOut multipart = - PersonAuthorityClientUtils.createPersonInstance(authorityCsid, authRefName, + PersonAuthorityClientUtils.createPersonInstance(authorityCsid, null, //authRefName, partialTermPersonMap, partialTermRepeatablesMap, client.getItemCommonPartName() ); String newID = null; diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java index e960c8581..1ef98d121 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java @@ -59,7 +59,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { // final String SERVICE_PATH_COMPONENT = "personauthorities"; // final String ITEM_SERVICE_PATH_COMPONENT = "items"; private String authId = null; - private String authRefName = null; + //private String authRefName = null; private List allItemIdsCreated = new ArrayList(); private String[] firstNames = { "Ann","Anne","Anno", @@ -155,7 +155,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { PersonAuthorityClient client = new PersonAuthorityClient(); String shortId = "perfTestPersons"; String displayName = "Perf Test Person Auth"; - String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); + //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, shortId, client.getCommonPartName()); @@ -176,7 +176,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { } // Store the refname from the first resource created // for additional tests below. - authRefName = baseRefName; + //authRefName = baseRefName; // Store the ID returned from the first resource created // for additional tests below. authId = newID; @@ -211,7 +211,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { personMap.put(PersonJAXBSchema.SUR_NAME, lastName); Map> personRepeatablesMap = new HashMap>(); PoxPayloadOut multipart = - PersonAuthorityClientUtils.createPersonInstance(authId, authRefName, + PersonAuthorityClientUtils.createPersonInstance(authId, null, //authRefName, personMap, personRepeatablesMap, client.getItemCommonPartName() ); String newID = null; diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index a3ea09e71..3802681c0 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -98,7 +98,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM // Hold some values for a recently created item to verify upon read. private String knownResourceId = null; private String knownResourceShortIdentifer = null; - private String knownResourceRefName = null; + //private String knownResourceRefName = null; private String knownItemResourceId = null; private String knownItemResourceShortIdentifer = null; // The resource ID of an item resource used for partial term matching tests. @@ -118,7 +118,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM String refName) { knownResourceId = id; knownResourceShortIdentifer = shortIdentifer; - knownResourceRefName = refName; + //knownResourceRefName = refName; } protected void setKnownItemResource(String id, String shortIdentifer) { @@ -158,7 +158,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM PersonAuthorityClient client = new PersonAuthorityClient(); String shortId = createIdentifier(); String displayName = "displayName-" + shortId; - String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); + //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null); PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, shortId, client.getCommonPartName()); @@ -187,7 +187,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM } // Save values for additional tests if (knownResourceId == null) { - setKnownResource(newID, shortId, baseRefName); + setKnownResource(newID, shortId, null ); //baseRefName); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } @@ -232,7 +232,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM logger.debug(testBanner(testName, CLASS_NAME)); } setupCreate(); - String newID = createItemInAuthority(knownResourceId, knownResourceRefName); + String newID = createItemInAuthority(knownResourceId, null ); //knownResourceRefName); } /** @@ -307,7 +307,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM johnWayneGroups.add("Scottish"); johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups); - return createItemInAuthority(vcsid, authRefName, shortId, johnWayneMap, johnWayneRepeatablesMap); + return createItemInAuthority(vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneRepeatablesMap); } @@ -332,7 +332,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM PersonAuthorityClient client = new PersonAuthorityClient(); PoxPayloadOut multipart = - PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, itemFieldProperties, + PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties, itemRepeatableFieldProperties, client.getItemCommonPartName()); String newID = null; @@ -633,7 +633,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM final Map NULL_REPEATABLE_FIELD_PROPERTIES = null; PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(knownResourceId, - knownResourceRefName, fieldProperties, + null /*knownResourceRefName*/, fieldProperties, NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName()); // Send the request and receive a response @@ -1921,7 +1921,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM Map> nonexRepeatablesMap = new HashMap>(); PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID, - PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null), + null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null), nonexMap, nonexRepeatablesMap, client.getItemCommonPartName()); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); diff --git a/services/person/client/src/test/resources/log4j.properties b/services/person/client/src/test/resources/log4j.properties index 1a5d8cfb5..4519e9992 100644 --- a/services/person/client/src/test/resources/log4j.properties +++ b/services/person/client/src/test/resources/log4j.properties @@ -19,7 +19,7 @@ log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n #packages -log4j.logger.org.collectionspace=INFO +log4j.logger.org.collectionspace=DEBUG log4j.logger.org.apache=INFO log4j.logger.httpclient=INFO log4j.logger.org.jboss.resteasy=INFO diff --git a/services/person/jaxb/pom.xml b/services/person/jaxb/pom.xml index 7c3a70686..ecae74458 100644 --- a/services/person/jaxb/pom.xml +++ b/services/person/jaxb/pom.xml @@ -36,6 +36,12 @@ org.collectionspace.services.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + diff --git a/services/person/pom.xml b/services/person/pom.xml index 00ddab8b9..ee3dee389 100644 --- a/services/person/pom.xml +++ b/services/person/pom.xml @@ -13,12 +13,14 @@ pom + diff --git a/services/person/service/pom.xml b/services/person/service/pom.xml index 76e3233db..d2c37e1f1 100644 --- a/services/person/service/pom.xml +++ b/services/person/service/pom.xml @@ -27,6 +27,11 @@ org.collectionspace.services.common ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.service + ${project.version} + org.collectionspace.services org.collectionspace.services.person.jaxb diff --git a/services/relation/client/pom.xml b/services/relation/client/pom.xml index e5ceb19bc..65c6744f6 100644 --- a/services/relation/client/pom.xml +++ b/services/relation/client/pom.xml @@ -36,6 +36,17 @@ org.collectionspace.services.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.person.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + org.collectionspace.services org.collectionspace.services.common diff --git a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java index 26ecb6bf0..8b220a874 100644 --- a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java +++ b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java @@ -22,13 +22,20 @@ */ package org.collectionspace.services.client.test; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.PayloadInputPart; 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.client.RelationClient; @@ -56,7 +63,16 @@ public class RelationServiceTest extends AbstractServiceTestImpl { /** The logger. */ private final String CLASS_NAME = RelationServiceTest.class.getName(); + private final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + private List personIdsCreated = new ArrayList(); + private String samSubjectPersonCSID = null; + private String oliveObjectPersonCSID = null; + private String samSubjectRefName = null; + private String oliveObjectRefName = null; + private String personAuthCSID = null; + private String personShortId = PERSON_AUTHORITY_NAME; + /** The SERVICE path component. */ final String SERVICE_PATH_COMPONENT = "relations"; @@ -99,6 +115,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). setupCreate(); + createPersonRefs(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -132,6 +149,58 @@ public class RelationServiceTest extends AbstractServiceTestImpl { // so they can be deleted after tests have been run. allResourceIdsCreated.add(extractId(res)); } + + /** + * Creates the person refs. + */ + protected void createPersonRefs() { + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); + ClientResponse res = personAuthClient.create(multipart); + int statusCode = res.getStatus(); + + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, STATUS_CREATED); + personAuthCSID = extractId(res); + + String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); + + String csid = createPerson("Sam", "Subject", "samSubject", authRefName); + Assert.assertNotNull(csid); + samSubjectPersonCSID = csid; + samSubjectRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); + Assert.assertNotNull(samSubjectRefName); + personIdsCreated.add(csid); + + csid = createPerson("Olive", "Object", "oliveObject", authRefName); + Assert.assertNotNull(csid); + oliveObjectRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); + oliveObjectPersonCSID = csid; + Assert.assertNotNull(oliveObjectRefName); + personIdsCreated.add(csid); + } + + protected String createPerson(String firstName, String surName, String shortId, String authRefName) { + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); + Map personInfo = new HashMap(); + personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); + personInfo.put(PersonJAXBSchema.SUR_NAME, surName); + personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); + PoxPayloadOut multipart = + PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, + authRefName, personInfo, personAuthClient.getItemCommonPartName()); + ClientResponse res = personAuthClient.createItem(personAuthCSID, multipart); + int statusCode = res.getStatus(); + + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, STATUS_CREATED); + return extractId(res); + } + + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) @@ -857,10 +926,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { * @param identifier the identifier */ private void fillRelation(RelationsCommon relationCommon, String identifier) { - fillRelation(relationCommon, "Subject-" + identifier, - "SubjectType-" + identifier + "-type", - "Object-" + identifier, - "ObjectType-" + identifier + "-type", + fillRelation(relationCommon, samSubjectPersonCSID, null, oliveObjectPersonCSID, null, RelationshipType.COLLECTIONOBJECT_INTAKE.toString(), RelationshipType.COLLECTIONOBJECT_INTAKE + ".displayName"); } diff --git a/services/relation/service/pom.xml b/services/relation/service/pom.xml index e271c8040..651c43952 100644 --- a/services/relation/service/pom.xml +++ b/services/relation/service/pom.xml @@ -36,6 +36,26 @@ 5.6 + + org.collectionspace.services + org.collectionspace.services.person.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.organization.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.location.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.taxonomy.client + ${project.version} + diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index 0e988e172..5aceb9a87 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -23,14 +23,19 @@ */ package org.collectionspace.services.relation.nuxeo; +import java.util.HashMap; import java.util.Iterator; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; +import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.context.ServiceBindingUtils; +import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.InvalidDocumentException; import org.collectionspace.services.common.relation.RelationJAXBSchema; import org.collectionspace.services.common.relation.nuxeo.RelationConstants; @@ -43,10 +48,17 @@ import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationsCommonList.RelationListItem; +// HACK HACK HACK +import org.collectionspace.services.client.PersonAuthorityClient; +import org.collectionspace.services.client.OrgAuthorityClient; +import org.collectionspace.services.client.LocationAuthorityClient; +import org.collectionspace.services.client.TaxonomyAuthorityClient; + import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.relation.RelationsDocListItem; +import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.model.PropertyException; @@ -77,28 +89,26 @@ public class RelationDocumentModelHandler @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { + // Merge in the data from the payload + super.handleCreate(wrapDoc); - // Obtain document models for the subject and object of the relation. + // Obtain document models for the subject and object of the relation, so that + // we ensure we have value docType, URI info. If the docModels support refNames, + // we will also set those. + // Note that this introduces another caching problem... DocumentModel relationDocModel = wrapDoc.getWrappedObject(); ServiceContext ctx = getServiceContext(); - DocumentModel subjectDocModel = getSubjectDocModel(relationDocModel, ctx); - DocumentModel objectDocModel = getObjectDocModel(relationDocModel, ctx); + DocumentModel subjectDocModel = getSubjectOrObjectDocModel(relationDocModel, ctx, SUBJ_DOC_MODEL); + DocumentModel objectDocModel = getSubjectOrObjectDocModel(relationDocModel, ctx, OBJ_DOC_MODEL); // Use values from the subject and object document models to populate the // relevant fields of the relation's own document model. if (subjectDocModel != null) { - relationDocModel = populateSubjectValues(relationDocModel, subjectDocModel); + populateSubjectOrObjectValues(relationDocModel, subjectDocModel, ctx, SUBJ_DOC_MODEL); } if (objectDocModel != null) { - relationDocModel = populateObjectValues(relationDocModel, objectDocModel); + populateSubjectOrObjectValues(relationDocModel, objectDocModel, ctx, OBJ_DOC_MODEL); } - - // FIXME: Verify the following: - // Do we call this method here, only after we've updated the relationDocModel? - // Has the wrapDoc instance itself been updated, in the process of updating the relationDocModel, - // or do we need to pass the updated relationDocModel back into that instance? - super.handleCreate(wrapDoc); - } @Override @@ -199,6 +209,8 @@ public class RelationDocumentModelHandler String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_URI); subject.setUri(subjectUri); + String subjectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_REFNAME); + subject.setRefName(subjectRefName); relationListItem.setSubject(subject); String objectCsid = relationListItem.getObjectCsid(); @@ -207,6 +219,8 @@ public class RelationDocumentModelHandler String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_URI); object.setUri(objectUri); + String objectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_REFNAME); + object.setRefName(objectRefName); relationListItem.setObject(object); return relationListItem; @@ -293,62 +307,25 @@ public class RelationDocumentModelHandler return "/" + RelationConstants.NUXEO_SCHEMA_ROOT_ELEMENT + "/" + prop; } - /** - * Obtains the subject resource and uses its values to populate - * subject-related fields in the relation resource. - */ - private DocumentModel getSubjectDocModel(DocumentModel relationDocModel, ServiceContext ctx) throws Exception { - // Get the document model for the subject of the relation. - DocumentModel subjectDocModel = null; - String subjectCsid = ""; - String subjectRefName = ""; - // FIXME: Currently assumes that the object CSID is valid if present - // in the incoming payload. - try { - subjectCsid = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_CSID); - // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record: - if (Tools.isBlank(subjectCsid)) { - subjectCsid = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_1); - } - } catch (PropertyException pe) { - // Per CSPACE-4468, ignore any property exception here. - // (See parallel comment below in getObjectDocModel.) - } - if (Tools.notBlank(subjectCsid)) { - // FIXME: Call a utility routine here that uses the CSID to retrieve the subject record's docModel. - // The following is a placeholder: - subjectDocModel = getDocModelFromCsid(subjectCsid); - } - if (Tools.isBlank(subjectCsid)) { - try { - subjectRefName = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_REFNAME); - // FIXME: Call a utility routine here - for which the method below is currently a - // placeholder - that uses the refName to retrieve the subject record's docModel. - subjectDocModel = getDocModelFromRefname(subjectRefName); - } catch (Exception e) { - throw new InvalidDocumentException( - "Relation record must contain a CSID or refName to identify the subject of the relation.", e); - } - } - return subjectDocModel; - } - - /** - * Obtains the object resource and uses its values to populate - * object-related fields in the relation resource. - */ - private DocumentModel getObjectDocModel(DocumentModel relationDocModel, ServiceContext ctx) throws Exception { + private final boolean SUBJ_DOC_MODEL = true; + private final boolean OBJ_DOC_MODEL = false; + + private DocumentModel getSubjectOrObjectDocModel( + DocumentModel relationDocModel, ServiceContext ctx, boolean fSubject) throws Exception { // Get the document model for the object of the relation. - String objectCsid = ""; - String objectRefName = ""; - DocumentModel objectDocModel = null; + String commonPartLabel = ctx.getCommonPartLabel(); + String csid = ""; + String refName = ""; + DocumentModel docModel = null; // FIXME: Currently assumes that the object CSID is valid if present // in the incoming payload. try { - objectCsid = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_CSID); + csid = (String) relationDocModel.getProperty(commonPartLabel, + (fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID)); // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record: - if (Tools.isBlank(objectCsid)) { - objectCsid = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_2); + if (Tools.isBlank(csid)) { + csid = (String) relationDocModel.getProperty(commonPartLabel, + (fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2)); } } catch (PropertyException pe) { // Per CSPACE-4468, ignore any property exception here. @@ -356,40 +333,88 @@ public class RelationDocumentModelHandler // can now be null (missing), because a refName value can be // provided as an alternate identifier. } - if (Tools.isBlank(objectCsid)) { + if (Tools.notBlank(csid)) { + DocumentWrapper docWrapper = getRepositoryClient(ctx).getDocFromCsid(ctx, csid); + docModel = docWrapper.getWrappedObject(); + } else { // if (Tools.isBlank(objectCsid)) { try { - objectRefName = (String) relationDocModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_REFNAME); - // FIXME: Call a utility routine here - for which the method below is currently a - // placeholder - that uses the refName to retrieve the object record's docModel. - objectDocModel = getDocModelFromRefname(objectRefName); + refName = (String) relationDocModel.getProperty(commonPartLabel, + (fSubject?RelationJAXBSchema.SUBJECT_REFNAME:RelationJAXBSchema.OBJECT_REFNAME)); + docModel = ResourceBase.getDocModelForRefName(refName, ctx.getResourceMap()); } catch (Exception e) { throw new InvalidDocumentException( "Relation record must have a CSID or refName to identify the object of the relation.", e); } } - return objectDocModel; + if(docModel==null) { + throw new DocumentNotFoundException("Relation.getSubjectOrObjectDocModel could not find doc with CSID: " + +csid+" and/or refName: "+refName ); + } + return docModel; } - - // CSPACE-4468 placeholder methods: - // FIXME: Placeholder method. - private DocumentModel getDocModelFromCsid(String csid) { - return null; - } + private void populateSubjectOrObjectValues( + DocumentModel relationDocModel, + DocumentModel subjectOrObjectDocModel, + ServiceContext ctx, + boolean fSubject ) { + HashMap properties = new HashMap(); - // FIXME: Placeholder method. - // Patrick is providing a working replacement for this method, in a framework class. - private DocumentModel getDocModelFromRefname(String csid) { - return null; - } + try { + String doctype = (String) subjectOrObjectDocModel.getType(); + properties.put((fSubject?RelationJAXBSchema.SUBJECT_DOCTYPE:RelationJAXBSchema.OBJECT_DOCTYPE), + doctype); + // FIXME: Remove the line below when legacy fields are removed from the Relation record: + properties.put((fSubject?RelationJAXBSchema.DOCUMENT_TYPE_1:RelationJAXBSchema.DOCUMENT_TYPE_2), + doctype); + + String csid = (String) subjectOrObjectDocModel.getName(); + properties.put((fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID), + csid); + // FIXME: Remove the two lines immediately below when legacy fields are removed from the Relation record: + properties.put((fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2), + csid); + + String uri = (String) subjectOrObjectDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, + COLLECTIONSPACE_CORE_URI); + properties.put((fSubject?RelationJAXBSchema.SUBJECT_URI:RelationJAXBSchema.OBJECT_URI), + uri); + + String common_schema = getCommonSchemaNameForDocType(doctype); + + if(common_schema!=null) { + String refname = (String)subjectOrObjectDocModel.getProperty(common_schema, + RefName.REFNAME ); + properties.put((fSubject?RelationJAXBSchema.SUBJECT_REFNAME:RelationJAXBSchema.OBJECT_REFNAME), + refname); + } + } catch (ClientException ce) { + throw new RuntimeException( + "populateSubjectOrObjectValues: Problem fetching field " + ce.getLocalizedMessage()); + } - // FIXME: Placeholder method. - private DocumentModel populateSubjectValues(DocumentModel relationDocModel, DocumentModel objectDocModel) { - throw new UnsupportedOperationException("Not yet implemented"); + // FIXME: Call below is based solely on Nuxeo API docs; have not yet verified that it correctly updates existing + // property values in the target document model. + try { + relationDocModel.setProperties(ctx.getCommonPartLabel(), properties); + } catch (ClientException ce) { + throw new RuntimeException( + "populateSubjectValues: Problem setting fields " + ce.getLocalizedMessage()); + } } - - // FIXME: Placeholder method. - private DocumentModel populateObjectValues(DocumentModel relationDocModel, DocumentModel objectDocModel) { - throw new UnsupportedOperationException("Not yet implemented"); + + private String getCommonSchemaNameForDocType(String docType) { + String common_schema = null; + if("Person".equals(docType)) + common_schema = PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; + else if("Organization".equals(docType)) + common_schema = OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; + else if("Locationitem".equals(docType)) + common_schema = LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; + else if("Taxon".equals(docType)) + common_schema = TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; + //else leave it null. + return common_schema; } + } diff --git a/services/report/service/pom.xml b/services/report/service/pom.xml index f41265c6b..ab8702d24 100644 --- a/services/report/service/pom.xml +++ b/services/report/service/pom.xml @@ -16,7 +16,7 @@ org.collectionspace.services - org.collectionspace.services.authority + org.collectionspace.services.authority.jaxb true ${project.version} diff --git a/services/taxonomy/client/pom.xml b/services/taxonomy/client/pom.xml index cc9601b5a..771993f9c 100644 --- a/services/taxonomy/client/pom.xml +++ b/services/taxonomy/client/pom.xml @@ -40,6 +40,11 @@ org.collectionspace.services.taxonomy.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + org.collectionspace.services org.collectionspace.services.client diff --git a/services/taxonomy/jaxb/pom.xml b/services/taxonomy/jaxb/pom.xml index adaa1a42c..9072d0751 100644 --- a/services/taxonomy/jaxb/pom.xml +++ b/services/taxonomy/jaxb/pom.xml @@ -36,6 +36,11 @@ org.collectionspace.services.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + diff --git a/services/taxonomy/pom.xml b/services/taxonomy/pom.xml index 0b692e58c..2885bccc5 100644 --- a/services/taxonomy/pom.xml +++ b/services/taxonomy/pom.xml @@ -13,12 +13,14 @@ pom + diff --git a/services/taxonomy/service/pom.xml b/services/taxonomy/service/pom.xml index b9f5727da..cd7cfd6f0 100644 --- a/services/taxonomy/service/pom.xml +++ b/services/taxonomy/service/pom.xml @@ -39,7 +39,7 @@ org.collectionspace.services - org.collectionspace.services.contact.service + org.collectionspace.services.authority.service ${project.version} diff --git a/services/vocabulary/client/pom.xml b/services/vocabulary/client/pom.xml index f1e46c184..cc5dca721 100644 --- a/services/vocabulary/client/pom.xml +++ b/services/vocabulary/client/pom.xml @@ -30,6 +30,11 @@ org.collectionspace.services.vocabulary.jaxb ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + org.collectionspace.services org.collectionspace.services.client diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java index 38b8efe1d..5e62c178c 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java @@ -26,8 +26,8 @@ public class VocabularyClientUtils { VocabulariesCommon vocabulary = new VocabulariesCommon(); vocabulary.setDisplayName(displayName); vocabulary.setShortIdentifier(shortIdentifier); - String refName = createVocabularyRefName(shortIdentifier, displayName); - vocabulary.setRefName(refName); + //String refName = createVocabularyRefName(shortIdentifier, displayName); + //vocabulary.setRefName(refName); vocabulary.setVocabType("enum"); PoxPayloadOut multipart = new PoxPayloadOut(VocabularyClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(vocabulary, MediaType.APPLICATION_XML_TYPE); @@ -50,8 +50,8 @@ public class VocabularyClientUtils { String displayName = vocabItemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME); vocabularyItem.setShortIdentifier(shortId); vocabularyItem.setDisplayName(displayName); - String refName = createVocabularyItemRefName(vocabularyRefName, shortId, displayName); - vocabularyItem.setRefName(refName); + //String refName = createVocabularyItemRefName(vocabularyRefName, shortId, displayName); + //vocabularyItem.setRefName(refName); PoxPayloadOut multipart = new PoxPayloadOut(VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(vocabularyItem, MediaType.APPLICATION_XML_TYPE); @@ -76,7 +76,7 @@ public class VocabularyClientUtils { logger.debug("Import: Create Item: \""+itemMap.get(AuthorityItemJAXBSchema.SHORT_IDENTIFIER) +"\" in personAuthority: \"" + vcsid +"\""); } - PoxPayloadOut multipart = createVocabularyItemInstance(vocabularyRefName, + PoxPayloadOut multipart = createVocabularyItemInstance(null, //vocabularyRefName, itemMap, client.getCommonPartItemName()); ClientResponse res = client.createItem(vcsid, multipart); @@ -84,12 +84,12 @@ public class VocabularyClientUtils { if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { throw new RuntimeException("Could not create Item: \"" + itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME) - + "\" in personAuthority: \"" + vocabularyRefName + + "\" in personAuthority: \"" + vcsid //vocabularyRefName + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); } if(statusCode != EXPECTED_STATUS_CODE) { throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME) - + "\" in personAuthority: \"" + vocabularyRefName + "\", Status:" + statusCode); + + "\" in personAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode); } return extractId(res); @@ -126,6 +126,7 @@ public class VocabularyClientUtils { return id; } + /* public static String createVocabularyRefName(String shortIdentifier, String displaySuffix) { String refName = "urn:cspace:org.collectionspace.demo:vocabulary:name(" + shortIdentifier + ")"; @@ -141,5 +142,6 @@ public class VocabularyClientUtils { refName += "'" + displaySuffix + "'"; return refName; } + */ } diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index fb103e585..79819f5be 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -66,8 +66,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { final String SERVICE_ITEM_PAYLOAD_NAME = VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME; private String knownResourceId = null; private String knownResourceShortIdentifer = null; - private String knownResourceRefName = null; - private String knownResourceFullRefName = null; + //private String knownResourceRefName = null; + //private String knownResourceFullRefName = null; private String knownItemResourceId = null; private int nItemsToCreateInList = 5; // private List allResourceIdsCreated = new ArrayList(); @@ -78,8 +78,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { String refName, String fullRefName) { knownResourceId = id; knownResourceShortIdentifer = shortIdentifer; - knownResourceRefName = refName; - knownResourceFullRefName = fullRefName; + //knownResourceRefName = refName; + //knownResourceFullRefName = fullRefName; } /* (non-Javadoc) @@ -140,9 +140,9 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Store the ID returned from the first resource created // for additional tests below. if (knownResourceId == null) { - setKnownResource(extractId(res), identifier, - VocabularyClientUtils.createVocabularyRefName(identifier, null), - VocabularyClientUtils.createVocabularyRefName(identifier, displayName)); + setKnownResource(extractId(res), identifier, null, null ); + //VocabularyClientUtils.createVocabularyRefName(identifier, null), + //VocabularyClientUtils.createVocabularyRefName(identifier, displayName)); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } @@ -180,7 +180,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId); itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId); String newID = VocabularyClientUtils.createItemInVocabulary(knownResourceId, - knownResourceRefName, itemInfo, client); + null /*knownResourceRefName*/, itemInfo, client); // Store the ID returned from the first item resource created // for additional tests below. @@ -272,7 +272,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, "Bad Item Short Id!"); itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "Bad Item!"); PoxPayloadOut multipart = - VocabularyClientUtils.createVocabularyItemInstance(knownResourceRefName, + VocabularyClientUtils.createVocabularyItemInstance(null, //knownResourceRefName, itemInfo, client.getCommonPartItemName()); ClientResponse res = client.createItem(knownResourceId, multipart); @@ -280,12 +280,12 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { if (!REQUEST_TYPE.isValidStatusCode(statusCode)) { throw new RuntimeException("Could not create Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME) - + "\" in personAuthority: \"" + knownResourceRefName + + "\" in personAuthority: \"" + knownResourceId //knownResourceRefName + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); } if (statusCode != EXPECTED_STATUS_CODE) { throw new RuntimeException("Unexpected Status when creating Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME) - + "\" in personAuthority: \"" + knownResourceRefName + "\", Status:" + statusCode); + + "\" in personAuthority: \"" + knownResourceId /*knownResourceRefName*/ + "\", Status:" + statusCode); } } @@ -410,7 +410,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { client.getCommonPartName(), VocabulariesCommon.class); Assert.assertNotNull(vocabulary); - Assert.assertEquals(vocabulary.getRefName(), knownResourceFullRefName); + //Assert.assertEquals(vocabulary.getRefName(), knownResourceFullRefName); } /** @@ -1079,7 +1079,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-nonex"); PoxPayloadOut multipart = VocabularyClientUtils.createVocabularyItemInstance( - VocabularyClientUtils.createVocabularyRefName(NON_EXISTENT_ID, null), + null, //VocabularyClientUtils.createVocabularyRefName(NON_EXISTENT_ID, null), itemInfo, client.getCommonPartItemName()); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); diff --git a/services/vocabulary/pom.xml b/services/vocabulary/pom.xml index 3b79d7d62..642852793 100644 --- a/services/vocabulary/pom.xml +++ b/services/vocabulary/pom.xml @@ -15,12 +15,14 @@ pom + diff --git a/services/vocabulary/service/pom.xml b/services/vocabulary/service/pom.xml index 745f6c3bf..9940c99b7 100644 --- a/services/vocabulary/service/pom.xml +++ b/services/vocabulary/service/pom.xml @@ -27,6 +27,11 @@ org.collectionspace.services.common ${project.version} + + org.collectionspace.services + org.collectionspace.services.authority.service + ${project.version} + org.collectionspace.services org.collectionspace.services.vocabulary.jaxb diff --git a/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java b/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java index ea93390e6..b0ec10880 100644 --- a/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java +++ b/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java @@ -25,6 +25,7 @@ package org.collectionspace.services.workflow; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -72,7 +73,7 @@ public class WorkflowResource extends ResourceBase { @Override @POST - public Response create(@Context UriInfo ui, String xmlPayload) { + public Response create(@Context ResourceMap resourceMap, @Context UriInfo ui, String xmlPayload) { Response response = Response.status(Response.Status.BAD_REQUEST) .entity(ServiceMessages.POST_UNSUPPORTED).type("text/plain").build(); return response;