From 9b3d8a1e8f41bc2cf64f1662b27dab60c431fd93 Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Fri, 16 Mar 2012 17:31:52 -0700 Subject: [PATCH] CSPACE-2403 - Adding initial support for a basic concept authority --- .../concept/conceptauthorities_materials.xml | 11 + .../xmlreplay/concept/concepts-wood.xml | 9 + services/JaxRsServiceProvider/pom.xml | 5 + .../CollectionSpaceJaxRsApplication.java | 2 + .../tenants/tenant-bindings-proto.xml | 140 ++++++ services/concept/3rdparty/build.xml | 131 +++++ .../nuxeo-platform-cs-concept/build.xml | 145 ++++++ .../nuxeo-platform-cs-concept/pom.xml | 37 ++ .../src/main/resources/META-INF/MANIFEST.MF | 23 + .../resources/OSGI-INF/core-types-contrib.xml | 25 + .../OSGI-INF/deployment-fragment.xml | 10 + .../resources/OSGI-INF/ecm-types-contrib.xml | 53 ++ .../resources/OSGI-INF/layouts-contrib.xml | 184 +++++++ .../resources/OSGI-INF/life-cycle-contrib.xml | 12 + .../schemas/conceptauthorities_common.xsd | 34 ++ .../resources/schemas/concepts_common.xsd | 152 ++++++ services/concept/3rdparty/pom.xml | 23 + services/concept/build.xml | 132 +++++ services/concept/client/pom.xml | 93 ++++ .../client/ConceptAuthorityClient.java | 81 ++++ .../client/ConceptAuthorityClientUtils.java | 149 ++++++ .../client/ConceptAuthorityProxy.java | 16 + .../test/ConceptAuthorityServiceTest.java | 455 ++++++++++++++++++ .../src/test/resources/log4j.properties | 23 + services/concept/installer/build.xml | 61 +++ services/concept/jaxb/pom.xml | 46 ++ .../services/ConceptJAXBSchema.java | 41 ++ .../src/main/resources/concept_common.xsd | 159 ++++++ .../resources/conceptauthority_common.xsd | 49 ++ services/concept/pom.xml | 35 ++ services/concept/service/pom.xml | 134 ++++++ .../concept/ConceptAuthorityResource.java | 69 +++ .../nuxeo/ConceptAuthorityConstants.java | 35 ++ .../ConceptAuthorityDocumentModelHandler.java | 57 +++ .../concept/nuxeo/ConceptConstants.java | 35 ++ .../nuxeo/ConceptDocumentModelHandler.java | 66 +++ .../nuxeo/ConceptValidatorHandler.java | 94 ++++ .../test/LocationAuthorityServiceTest.java | 17 - services/pom.xml | 1 + services/relation/service/pom.xml | 5 + .../nuxeo/RelationDocumentModelHandler.java | 3 + 41 files changed, 2835 insertions(+), 17 deletions(-) create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/conceptauthorities_materials.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/concepts-wood.xml create mode 100644 services/concept/3rdparty/build.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/build.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/pom.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/META-INF/MANIFEST.MF create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/core-types-contrib.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/deployment-fragment.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/ecm-types-contrib.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/layouts-contrib.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/life-cycle-contrib.xml create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/conceptauthorities_common.xsd create mode 100644 services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/concepts_common.xsd create mode 100644 services/concept/3rdparty/pom.xml create mode 100644 services/concept/build.xml create mode 100644 services/concept/client/pom.xml create mode 100644 services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClient.java create mode 100644 services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClientUtils.java create mode 100644 services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityProxy.java create mode 100644 services/concept/client/src/test/java/org/collectionspace/services/client/test/ConceptAuthorityServiceTest.java create mode 100644 services/concept/client/src/test/resources/log4j.properties create mode 100644 services/concept/installer/build.xml create mode 100644 services/concept/jaxb/pom.xml create mode 100644 services/concept/jaxb/src/main/java/org/collectionspace/services/ConceptJAXBSchema.java create mode 100644 services/concept/jaxb/src/main/resources/concept_common.xsd create mode 100644 services/concept/jaxb/src/main/resources/conceptauthority_common.xsd create mode 100644 services/concept/pom.xml create mode 100644 services/concept/service/pom.xml create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/ConceptAuthorityResource.java create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityConstants.java create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptConstants.java create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java create mode 100644 services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptValidatorHandler.java diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/conceptauthorities_materials.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/conceptauthorities_materials.xml new file mode 100644 index 000000000..f95f1f788 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/conceptauthorities_materials.xml @@ -0,0 +1,11 @@ + + + + conceptMaterials + Materials + ConceptAuthority + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/concepts-wood.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/concepts-wood.xml new file mode 100644 index 000000000..ce834c2c6 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/concept/concepts-wood.xml @@ -0,0 +1,9 @@ + + + + wood + Wood + false + + + diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 9600cb342..e857fcf36 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -172,6 +172,11 @@ org.collectionspace.services.location.service ${project.version} + + org.collectionspace.services + org.collectionspace.services.concept.service + ${project.version} + org.collectionspace.services org.collectionspace.services.taxonomy.service 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 e09dd3c2e..9c9a92937 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 @@ -36,6 +36,7 @@ import org.collectionspace.services.objectexit.ObjectExitResource; import org.collectionspace.services.batch.BatchResource; import org.collectionspace.services.imports.ImportsResource; import org.collectionspace.services.location.LocationAuthorityResource; +import org.collectionspace.services.concept.ConceptAuthorityResource; import org.collectionspace.services.taxonomy.TaxonomyAuthorityResource; import org.collectionspace.services.movement.MovementResource; import org.collectionspace.services.relation.RelationResource; @@ -104,6 +105,7 @@ public class CollectionSpaceJaxRsApplication extends Application addResourceToMapAndSingletons(new PersonAuthorityResource()); addResourceToMapAndSingletons(new OrgAuthorityResource()); addResourceToMapAndSingletons(new LocationAuthorityResource()); + addResourceToMapAndSingletons(new ConceptAuthorityResource()); addResourceToMapAndSingletons(new TaxonomyAuthorityResource()); addResourceToMapAndSingletons(new AcquisitionResource()); addResourceToMapAndSingletons(new ContactResource()); diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index 869675c0f..587c0a7f2 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -2320,6 +2320,146 @@ + + + /conceptauthorities/*/workflow/ + /conceptauthorities/*/items/*/workflow/ + + + default-domain + org.collectionspace.services.concept.nuxeo.ConceptAuthorityDocumentModelHandler + + + + + displayName + displayName + + + refName + refName + + + shortIdentifier + shortIdentifier + + + vocabType + vocabType + + + + + + org.collectionspace.services.common.init.AddIndices + + + conceptauthorities_common + displayname + + + conceptauthorities_common + shortidentifier + + + + + + + + + + + + + + + + + + + + + + + + + + default-domain + org.collectionspace.services.concept.nuxeo.ConceptDocumentModelHandler + + + + + + + + org.collectionspace.services.concept.nuxeo.ConceptValidatorHandler + + org.collectionspace.services.common.init.AddIndices + + + concepts_common + inauthority + + + concepts_common + displayname + + + concepts_common + shortidentifier + + + + + + objectNameProperty + displayName + + + objectNumberProperty + shortIdentifier + + + + + + + + + + + + + termRef + conceptType + + + termRef + termStatus + + + + + + + + + + + + + + + /acquisitions/*/workflow/ diff --git a/services/concept/3rdparty/build.xml b/services/concept/3rdparty/build.xml new file mode 100644 index 000000000..13dafa507 --- /dev/null +++ b/services/concept/3rdparty/build.xml @@ -0,0 +1,131 @@ + + + + concept service 3rdparty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/build.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/build.xml new file mode 100644 index 000000000..bf2c817cb --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/build.xml @@ -0,0 +1,145 @@ + + + + concept nuxeo document type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/pom.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/pom.xml new file mode 100644 index 000000000..c18c7a968 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/pom.xml @@ -0,0 +1,37 @@ + + + org.collectionspace.services + org.collectionspace.services.concept.3rdparty + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.concept.3rdparty.nuxeo + services.concept.3rdparty.nuxeo + jar + + Concept Nuxeo Document Type + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + src/main/resources/META-INF/MANIFEST.MF + + ${eclipseVersion} + 2 + + + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/META-INF/MANIFEST.MF b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..a35cbe250 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 1 +Bundle-Name: NuxeoCS +Bundle-SymbolicName: org.collectionspace.concept;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Vendor: Nuxeo +Require-Bundle: org.nuxeo.runtime, + org.nuxeo.ecm.core.api, + org.nuxeo.ecm.core, + org.nuxeo.ecm.core.api, + org.nuxeo.ecm.platform.types.api, + org.nuxeo.ecm.platform.versioning.api, + org.nuxeo.ecm.platform.ui, + org.nuxeo.ecm.platform.forms.layout.client, + org.nuxeo.ecm.platform.ws, + org.collectionspace.collectionspace_core +Provide-Package: org.collectionspace.concept +Nuxeo-Component: OSGI-INF/core-types-contrib.xml, + OSGI-INF/life-cycle-contrib.xml, + OSGI-INF/ecm-types-contrib.xml, + OSGI-INF/layouts-contrib.xml + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/core-types-contrib.xml new file mode 100644 index 000000000..687ff79b3 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/core-types-contrib.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/deployment-fragment.xml new file mode 100644 index 000000000..270abbd5f --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/deployment-fragment.xml @@ -0,0 +1,10 @@ + + + + + + ${bundle.fileName} + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/ecm-types-contrib.xml new file mode 100644 index 000000000..2bbb814d0 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/ecm-types-contrib.xml @@ -0,0 +1,53 @@ + + + + + + + view_documents + + + heading + csconceptauthority + + + + + + Conceptauthority + + + + + + Conceptauthority + + + + + + + + + view_documents + + + heading + concept + + + + + + Concept + + + + + + Concept + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/layouts-contrib.xml new file mode 100644 index 000000000..1145b1e10 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + + displayName + shortIdentifier + refName + vocabType + + + + + + + true + + displayName + + + dataInputText + + + + + + + + true + + shortIdentifier + + + dataInputText + + + + + + + + true + + refName + + + dataInputText + + + + + + + + true + + vocabType + + + dataInputText + + + + + + + + + + + + + inAuthority + shortIdentifier + refName + displayName + displayNameComputed + conceptType + status + + + + + + + true + + inAuthority + + + dataInputText + + + + + + + + true + + shortIdentifier + + + dataInputText + + + + + + + + true + + refName + + + dataInputText + + + + + + + + true + + displayName + + + dataInputText + + + + + + + + + true + + displayNameComputed + + + dataInputText + + + + + + + + true + + conceptType + + + dataInputText + + + + + + + + true + + status + + + dataInputText + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/life-cycle-contrib.xml b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/life-cycle-contrib.xml new file mode 100644 index 000000000..c842e5fde --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/OSGI-INF/life-cycle-contrib.xml @@ -0,0 +1,12 @@ + + + + + + default + default + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/conceptauthorities_common.xsd b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/conceptauthorities_common.xsd new file mode 100644 index 000000000..8628182a0 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/conceptauthorities_common.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/concepts_common.xsd b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/concepts_common.xsd new file mode 100644 index 000000000..0e2380469 --- /dev/null +++ b/services/concept/3rdparty/nuxeo-platform-cs-concept/src/main/resources/schemas/concepts_common.xsd @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/3rdparty/pom.xml b/services/concept/3rdparty/pom.xml new file mode 100644 index 000000000..b7ebd99fe --- /dev/null +++ b/services/concept/3rdparty/pom.xml @@ -0,0 +1,23 @@ + + + + org.collectionspace.services + org.collectionspace.services.concept + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.concept.3rdparty + services.concept.3rdparty + pom + + 3rd party build for concept service + + + + nuxeo-platform-cs-concept + + diff --git a/services/concept/build.xml b/services/concept/build.xml new file mode 100644 index 000000000..d8c445a00 --- /dev/null +++ b/services/concept/build.xml @@ -0,0 +1,132 @@ + + + + Concept Authority service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/client/pom.xml b/services/concept/client/pom.xml new file mode 100644 index 000000000..54db67c14 --- /dev/null +++ b/services/concept/client/pom.xml @@ -0,0 +1,93 @@ + + + + org.collectionspace.services + org.collectionspace.services.concept + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services.concept.client + services.concept.client + + + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common + true + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.concept.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.contact.client + ${project.version} + + + + org.testng + testng + + + org.jboss.resteasy + resteasy-jaxrs + + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + commons-httpclient + commons-httpclient + + + + + collectionspace-services-concept-client + + + + + diff --git a/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClient.java b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClient.java new file mode 100644 index 000000000..6428c508b --- /dev/null +++ b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClient.java @@ -0,0 +1,81 @@ +/** + * ConceptAuthorityClient.java + * + * {Purpose of This Class} + * + * {Other Notes Relating to This Class (Optional)} + * + * $LastChangedBy: $ + * $LastChangedRevision: $ + * $LastChangedDate: $ + * + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright © 2009 {Contributing Institution} + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + */ +package org.collectionspace.services.client; + +import org.collectionspace.services.concept.ConceptsCommon; + +/** + * The Class ConceptAuthorityClient. + */ +public class ConceptAuthorityClient extends AuthorityClientImpl { + public static final String SERVICE_NAME = "conceptauthorities"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; + // + // Subitem constants + // + public static final String SERVICE_ITEM_NAME = "concepts"; + public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME; + // + // Payload Part/Schema part names + // + public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + + @Override + public String getItemCommonPartName() { + return getCommonPartName(SERVICE_ITEM_NAME); + } + + @Override + public Class getProxyClass() { + return ConceptAuthorityProxy.class; + } + + @Override + public String getInAuthority(ConceptsCommon item) { + return item.getInAuthority(); + } + + @Override + public void setInAuthority(ConceptsCommon item, String inAuthorityCsid) { + item.setInAuthority(inAuthorityCsid); + } +} diff --git a/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClientUtils.java b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClientUtils.java new file mode 100644 index 000000000..f817b2db5 --- /dev/null +++ b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityClientUtils.java @@ -0,0 +1,149 @@ +package org.collectionspace.services.client; + +import java.io.File; +import java.util.ArrayList; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +import org.apache.commons.io.FileUtils; +import org.collectionspace.services.client.test.ServiceRequestType; +import org.collectionspace.services.concept.ConceptauthoritiesCommon; +import org.dom4j.DocumentException; +import org.jboss.resteasy.client.ClientResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConceptAuthorityClientUtils { + private static final Logger logger = + LoggerFactory.getLogger(ConceptAuthorityClientUtils.class); + + /** + * Creates a new Concept Authority + * @param displayName The displayName used in UI, etc. + * @param refName The proper refName for this authority + * @param headerLabel The common part label + * @return The PoxPayloadOut payload for the create call + */ + public static PoxPayloadOut createConceptAuthorityInstance( + String displayName, String shortIdentifier, String headerLabel ) { + ConceptauthoritiesCommon conceptAuthority = new ConceptauthoritiesCommon(); + conceptAuthority.setDisplayName(displayName); + conceptAuthority.setShortIdentifier(shortIdentifier); + conceptAuthority.setVocabType("ConceptAuthority"); //FIXME: REM - Should this really be hard-coded? + PoxPayloadOut multipart = new PoxPayloadOut(ConceptAuthorityClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = multipart.addPart(conceptAuthority, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(headerLabel); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, conceptAuthority common ", + conceptAuthority, ConceptauthoritiesCommon.class); + } + + return multipart; + } + + /** + * @param commonPartXML the XML payload for the common part. + * @param headerLabel The common part label + * @return The PoxPayloadOut payload for the create call + * @throws DocumentException + */ + public static PoxPayloadOut createConceptInstance( + String commonPartXML, String headerLabel) throws DocumentException { + PoxPayloadOut multipart = new PoxPayloadOut(ConceptAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + /* + PayloadOutputPart commonPart = multipart.addPart(commonPartXML, + MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(headerLabel); + */ + PayloadOutputPart commonPart = multipart.addPart( + ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME, + commonPartXML); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, concept common ", commonPart.asXML()); + } + + return multipart; + } + + public static String createItemInAuthority(String vcsid, + String commonPartXML, + ConceptAuthorityClient client ) throws DocumentException { + // Expected status code: 201 Created + int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); + // Type of service request being tested + ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; + + PoxPayloadOut multipart = + createConceptInstance(commonPartXML, client.getItemCommonPartName()); + String newID = null; + ClientResponse res = client.createItem(vcsid, multipart); + try { + int statusCode = res.getStatus(); + + if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { + throw new RuntimeException("Could not create Item: \""+commonPartXML + +"\" in conceptAuthority: \"" + vcsid + +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + } + if(statusCode != EXPECTED_STATUS_CODE) { + throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML + +"\" in conceptAuthority: \"" + vcsid +"\", Status:"+ statusCode); + } + newID = extractId(res); + } finally { + res.releaseConnection(); + } + + return newID; + } + + /** + * Creates the from xml file. + * + * @param fileName the file name + * @return new CSID as string + * @throws Exception the exception + */ + private String createItemInAuthorityFromXmlFile(String vcsid, String commonPartFileName, + ConceptAuthorityClient client) throws Exception { + byte[] b = FileUtils.readFileToByteArray(new File(commonPartFileName)); + String commonPartXML = new String(b); + return createItemInAuthority(vcsid, commonPartXML, client ); + } + + public static String extractId(ClientResponse res) { + MultivaluedMap mvm = res.getMetadata(); + String uri = (String) ((ArrayList) mvm.get("Location")).get(0); + if(logger.isDebugEnabled()){ + logger.debug("extractId:uri=" + uri); + } + String[] segments = uri.split("/"); + String id = segments[segments.length - 1]; + if(logger.isDebugEnabled()){ + logger.debug("id=" + id); + } + return id; + } + + /** + * Returns an error message indicating that the status code returned by a + * specific call to a service does not fall within a set of valid status + * codes for that service. + * + * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). + * + * @param statusCode The invalid status code that was returned in the response, + * from submitting that type of request to the service. + * + * @return An error message. + */ + public static String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) { + return "Status code '" + statusCode + "' in response is NOT within the expected set: " + + requestType.validStatusCodesAsString(); + } + +} diff --git a/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityProxy.java b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityProxy.java new file mode 100644 index 000000000..dfcdf1bb6 --- /dev/null +++ b/services/concept/client/src/main/java/org/collectionspace/services/client/ConceptAuthorityProxy.java @@ -0,0 +1,16 @@ +package org.collectionspace.services.client; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +/** + * @version $Revision:$ + * ILT = Item list type + * LT = List type + */ +@Path(ConceptAuthorityClient.SERVICE_PATH + "/") +@Produces("application/xml") +@Consumes("application/xml") +public interface ConceptAuthorityProxy extends AuthorityProxy { +} diff --git a/services/concept/client/src/test/java/org/collectionspace/services/client/test/ConceptAuthorityServiceTest.java b/services/concept/client/src/test/java/org/collectionspace/services/client/test/ConceptAuthorityServiceTest.java new file mode 100644 index 000000000..72962d01d --- /dev/null +++ b/services/concept/client/src/test/java/org/collectionspace/services/client/test/ConceptAuthorityServiceTest.java @@ -0,0 +1,455 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright (c)) 2009 Regents of the University of California + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.client.test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.collectionspace.services.ConceptJAXBSchema; +import org.collectionspace.services.client.AbstractCommonListUtils; +import org.collectionspace.services.client.AuthorityClient; +import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; +import org.collectionspace.services.client.ConceptAuthorityClient; +import org.collectionspace.services.client.ConceptAuthorityClientUtils; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.concept.ConceptauthoritiesCommon; +import org.collectionspace.services.concept.ConceptsCommon; +import org.dom4j.DocumentException; + +import org.jboss.resteasy.client.ClientResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +/** + * ConceptAuthorityServiceTest, carries out tests against a + * deployed and running ConceptAuthority Service. + * + * $LastChangedRevision: 753 $ + * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $ + */ +public class ConceptAuthorityServiceTest extends AbstractAuthorityServiceTest { + + /** The logger. */ + private final String CLASS_NAME = ConceptAuthorityServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(ConceptAuthorityServiceTest.class); + private final String REFNAME = "refName"; + private final String DISPLAYNAME = "displayName"; + private final static String CURRENT_DATE_UTC = + GregorianCalendarDateTimeUtils.currentDateUTC(); + + @Override + public String getServicePathComponent() { + return ConceptAuthorityClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return ConceptAuthorityClient.SERVICE_NAME; + } + + public String getItemServicePathComponent() { + return AuthorityClient.ITEMS; + } + + // Instance variables specific to this test. + + final String TEST_NAME = "Concept 1"; + final String TEST_SHORTID = "concept1"; + final String TEST_SCOPE_NOTE = "Covers quite a bit"; + // TODO Make status type be a controlled vocab term. + final String TEST_STATUS = "Approved"; + + private String knownConceptTypeRefName = null; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() { + return new ConceptAuthorityClient(); + } + + /** + * Creates the item in authority. + * + * @param vcsid the vcsid + * @param authRefName the auth ref name + * @return the string + */ + @Override + protected String createItemInAuthority(String authorityId) { + + final String testName = "createItemInAuthority("+authorityId+")"; + if(logger.isDebugEnabled()){ + logger.debug(testName); + } + + // Submit the request to the service and store the response. + ConceptAuthorityClient client = new ConceptAuthorityClient(); + + String commonPartXML = createCommonPartXMLForItem(TEST_SHORTID, TEST_NAME); + + String newID = null; + try { + newID = ConceptAuthorityClientUtils.createItemInAuthority(authorityId, + commonPartXML, client ); + } catch( DocumentException de ) { + logger.error("Problem creating item from XML: "+de.getLocalizedMessage()); + logger.debug("commonPartXML: "+commonPartXML); + return null; + } + + // Store the ID returned from the first item resource created + // for additional tests below. + if (knownItemResourceId == null){ + setKnownItemResource(newID, TEST_SHORTID); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": knownItemResourceId=" + newID); + } + } + + // Store the IDs from any item resources created + // by tests, along with the IDs of their parents, so these items + // can be deleted after all tests have been run. + allResourceItemIdsCreated.put(newID, authorityId); + + return newID; + } + + /** + * Read item list. + */ + @Test(dataProvider = "testName", groups = {"readList"}, + dependsOnMethods = {"readList"}) + public void readItemList(String testName) { + readItemList(knownAuthorityWithItems, null); + } + + /** + * Read item list by authority name. + */ + @Test(dataProvider = "testName", groups = {"readList"}, + dependsOnMethods = {"readItemList"}) + public void readItemListByAuthorityName(String testName) { + readItemList(null, READITEMS_SHORT_IDENTIFIER); + } + + /** + * Read item list. + * + * @param vcsid the vcsid + * @param name the name + */ + private void readItemList(String vcsid, String shortId) { + + String testName = "readItemList"; + + // Perform setup. + setupReadList(); + + // Submit the request to the service and store the response. + ConceptAuthorityClient client = new ConceptAuthorityClient(); + ClientResponse res = null; + if(vcsid!= null) { + res = client.readItemList(vcsid, null, null); + } else if(shortId!= null) { + res = client.readItemListForNamedAuthority(shortId, null, null); + } else { + Assert.fail("readItemList passed null csid and name!"); + } + AbstractCommonList list = null; + try { + assertStatusCode(res, testName); + list = res.getEntity(); + } finally { + res.releaseConnection(); + } + List items = + list.getListItem(); + int nItemsReturned = items.size(); + // There will be 'nItemsToCreateInList' + // items created by the createItemList test, + // all associated with the same parent resource. + int nExpectedItems = nItemsToCreateInList; + if(logger.isDebugEnabled()){ + logger.debug(testName + ": Expected " + + nExpectedItems +" items; got: "+nItemsReturned); + } + Assert.assertEquals(nItemsReturned, nExpectedItems); + + for (AbstractCommonList.ListItem item : items) { + String value = + AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME); + Assert.assertTrue((null != value), "Item refName is null!"); + value = + AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME); + Assert.assertTrue((null != value), "Item displayName is null!"); + } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); + } + } + + @Override + public void delete(String testName) throws Exception { + // Do nothing. See localDelete(). This ensure proper test order. + } + + @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"}) + public void localDelete(String testName) throws Exception { + super.delete(testName); + } + + @Override + public void deleteItem(String testName) throws Exception { + // Do nothing. We need to wait until after the test "localDelete" gets run. When it does, + // its dependencies will get run first and then we can call the base class' delete method. + } + + @Test(dataProvider = "testName", groups = {"delete"}, + dependsOnMethods = {"readItem", "updateItem"}) + public void localDeleteItem(String testName) throws Exception { + super.deleteItem(testName); + } + + + + // --------------------------------------------------------------- + // Cleanup of resources created during testing + // --------------------------------------------------------------- + + /** + * Deletes all resources created by tests, after all tests have been run. + * + * This cleanup method will always be run, even if one or more tests fail. + * For this reason, it attempts to remove all resources created + * at any point during testing, even if some of those resources + * may be expected to be deleted by certain tests. + */ + + @AfterClass(alwaysRun=true) + public void cleanUp() { + String noTest = System.getProperty("noTestCleanup"); + if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { + if (logger.isDebugEnabled()) { + logger.debug("Skipping Cleanup phase ..."); + } + return; + } + if (logger.isDebugEnabled()) { + logger.debug("Cleaning up temporary resources created for testing ..."); + } + String parentResourceId; + String itemResourceId; + // Clean up contact resources. + ConceptAuthorityClient client = new ConceptAuthorityClient(); + parentResourceId = knownResourceId; + // Clean up item resources. + for (Map.Entry entry : allResourceItemIdsCreated.entrySet()) { + itemResourceId = entry.getKey(); + parentResourceId = entry.getValue(); + // Note: Any non-success responses from the delete operation + // below are ignored and not reported. + client.deleteItem(parentResourceId, itemResourceId).releaseConnection(); + } + // Clean up parent resources. + for (String resourceId : allResourceIdsCreated) { + // Note: Any non-success responses from the delete operation + // below are ignored and not reported. + client.delete(resourceId).releaseConnection(); + } + } + + // --------------------------------------------------------------- + // Utility methods used by tests above + // --------------------------------------------------------------- + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() + */ + + /** + * Returns the root URL for the item service. + * + * This URL consists of a base URL for all services, followed by + * a path component for the owning parent, followed by the + * path component for the items. + * + * @param parentResourceIdentifier An identifier (such as a UUID) for the + * parent authority resource of the relevant item resource. + * + * @return The root URL for the item service. + */ + protected String getItemServiceRootURL(String parentResourceIdentifier) { + return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent(); + } + + /** + * Returns the URL of a specific item resource managed by a service, and + * designated by an identifier (such as a universally unique ID, or UUID). + * + * @param parentResourceIdentifier An identifier (such as a UUID) for the + * parent authority resource of the relevant item resource. + * + * @param itemResourceIdentifier An identifier (such as a UUID) for an + * item resource. + * + * @return The URL of a specific item resource managed by a service. + */ + protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) { + return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier; + } + + @Override + public void authorityTests(String testName) { + // TODO Auto-generated method stub + + } + + // + // Concept specific overrides + // + + @Override + protected PoxPayloadOut createInstance(String commonPartName, + String identifier) { + ConceptAuthorityClient client = new ConceptAuthorityClient(); + String shortId = identifier; + String displayName = "displayName-" + shortId; + // String baseRefName = ConceptAuthorityClientUtils.createConceptAuthRefName(shortId, null); + PoxPayloadOut multipart = + ConceptAuthorityClientUtils.createConceptAuthorityInstance( + displayName, shortId, commonPartName); + return multipart; + } + + + private String createCommonPartXMLForItem(String shortId, String name ) { + + String commonPartXML = + "" + + " "+shortId+""+ + " "+name+""+ + " false"+ + " Imagined"+ + /* + " "+ + " "+ + " Another term"+ + " alternate"+ + " My Imagination"+ + " "+ + " "+ + */ + ""; + return commonPartXML; + } + + @Override + protected PoxPayloadOut createNonExistenceInstance(String commonPartName, String identifier) { + String displayName = "displayName-NON_EXISTENT_ID"; + PoxPayloadOut result = ConceptAuthorityClientUtils.createConceptAuthorityInstance( + displayName, "nonEx", commonPartName); + return result; + } + + @Override + protected ConceptauthoritiesCommon updateInstance(ConceptauthoritiesCommon conceptauthoritiesCommon) { + ConceptauthoritiesCommon result = new ConceptauthoritiesCommon(); + + result.setDisplayName("updated-" + conceptauthoritiesCommon.getDisplayName()); + result.setVocabType("updated-" + conceptauthoritiesCommon.getVocabType()); + + return result; + } + + @Override + protected void compareUpdatedInstances(ConceptauthoritiesCommon original, + ConceptauthoritiesCommon updated) throws Exception { + Assert.assertEquals(updated.getDisplayName(), + original.getDisplayName(), + "Display name in updated object did not match submitted data."); + } + + protected void compareReadInstances(ConceptauthoritiesCommon original, + ConceptauthoritiesCommon fromRead) throws Exception { + Assert.assertNotNull(fromRead.getDisplayName()); + Assert.assertNotNull(fromRead.getShortIdentifier()); + Assert.assertNotNull(fromRead.getRefName()); + } + + @Override + protected ConceptsCommon updateItemInstance(ConceptsCommon conceptsCommon) { + ConceptsCommon result = new ConceptsCommon(); + + result.setTermStatus("updated-" + conceptsCommon.getTermStatus()); + result.setDisplayName("updated-" + conceptsCommon.getDisplayName()); + + return result; + } + + @Override + protected void compareUpdatedItemInstances(ConceptsCommon original, + ConceptsCommon updated) throws Exception { + Assert.assertEquals(updated.getTermStatus(), original.getTermStatus(), + "Data in updated Concept did not match submitted data."); + Assert.assertEquals(updated.getDisplayName(), original.getDisplayName(), + "Data in updated Concept did not match submitted data."); + } + + @Override + protected void verifyReadItemInstance(ConceptsCommon item) + throws Exception { + // TODO Auto-generated method stub + + } + + + @Override + protected PoxPayloadOut createNonExistenceItemInstance( + String commonPartName, String identifier) { + + String commonPartXML = createCommonPartXMLForItem("nonExShortId", "nonExItem"); + + try { + PoxPayloadOut result = + ConceptAuthorityClientUtils.createConceptInstance( + commonPartXML, commonPartName); + return result; + } catch( DocumentException de ) { + logger.error("Problem creating item from XML: "+de.getLocalizedMessage()); + logger.debug("commonPartXML: "+commonPartXML); + } + return null; + } + +} diff --git a/services/concept/client/src/test/resources/log4j.properties b/services/concept/client/src/test/resources/log4j.properties new file mode 100644 index 000000000..148a3e865 --- /dev/null +++ b/services/concept/client/src/test/resources/log4j.properties @@ -0,0 +1,23 @@ +log4j.rootLogger=debug, stdout, R + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n + +log4j.appender.R=org.apache.log4j.RollingFileAppender +log4j.appender.R.File=target/test-client.log + +log4j.appender.R.MaxFileSize=100KB +# Keep one backup file +log4j.appender.R.MaxBackupIndex=1 + +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=DEBUG +log4j.logger.org.apache=INFO +log4j.logger.httpclient=INFO +log4j.logger.org.jboss.resteasy=INFO diff --git a/services/concept/installer/build.xml b/services/concept/installer/build.xml new file mode 100644 index 000000000..9dd64631c --- /dev/null +++ b/services/concept/installer/build.xml @@ -0,0 +1,61 @@ + + + + concept service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/jaxb/pom.xml b/services/concept/jaxb/pom.xml new file mode 100644 index 000000000..a1232d5cd --- /dev/null +++ b/services/concept/jaxb/pom.xml @@ -0,0 +1,46 @@ + + + + org.collectionspace.services + org.collectionspace.services.concept + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.concept.jaxb + services.concept.jaxb + + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + + + + + collectionspace-services-concept-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + + diff --git a/services/concept/jaxb/src/main/java/org/collectionspace/services/ConceptJAXBSchema.java b/services/concept/jaxb/src/main/java/org/collectionspace/services/ConceptJAXBSchema.java new file mode 100644 index 000000000..3bb44db74 --- /dev/null +++ b/services/concept/jaxb/src/main/java/org/collectionspace/services/ConceptJAXBSchema.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.collectionspace.services; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; + +/** + * @author pschmitz + * + */ +public interface ConceptJAXBSchema extends AuthorityItemJAXBSchema { + final static String CONCEPTS_COMMON = "concepts_common"; + final static String CONCEPT_TYPE = "conceptType"; + final static String CONCEPT_SCOPE_NOTE = "scopeNote"; + final static String CONCEPT_SCOPE_NOTE_SOURCE = "scopeNoteSource"; + final static String CONCEPT_SCOPE_NOTE_SOURCE_DETAIL = "scopeNoteSourceDetail"; + final static String CONCEPT_REMARKS = "remarks"; + final static String CONCEPT_DISPLAY_TERM_FLAG = "displayTermFlag"; + + final static String CONCEPT_TERM_GROUP_LIST = "conceptTermGroupList"; + final static String CONCEPT_CITATION_GROUP_LIST = "citationGroupList"; + final static String CONCEPT_ADDL_TERM_SOURCE_GROUP_LIST = "additionalTermSourceGroupList"; + + final static String CONCEPT_TERM_GROUP_TERM = "term"; + final static String CONCEPT_TERM_GROUP_TERM_TYPE = "termType"; + final static String CONCEPT_TERM_GROUP_TERM_QUALIFIER = "termQualifier"; + final static String CONCEPT_TERM_GROUP_TERM_LANGUAGE = "termLanguage"; + final static String CONCEPT_TERM_GROUP_HISTORICAL_FLAG = "historicalFlag"; + final static String CONCEPT_TERM_GROUP_SOURCE = "source"; + final static String CONCEPT_TERM_GROUP_SOURCE_DETAIL = "sourceDetail"; + final static String CONCEPT_TERM_GROUP_SOURCE_UID = "sourceUID"; + final static String CONCEPT_TERM_GROUP_TERM_DATE = "termDate"; + + final static String CONCEPT_CITATION_GROUP_SOURCE = "source"; + final static String CONCEPT_CITATION_GROUP_SOURCE_DETAIL = "sourceDetail"; + + final static String CONCEPT_ADDL_TERM_SOURCE_GROUP_SOURCE = "source"; + final static String CONCEPT_ADDL_TERM_SOURCE_GROUP_DETAIL = "sourceDetail"; + final static String CONCEPT_ADDL_TERM_SOURCE_GROUP_UID = "sourceUID"; +} + diff --git a/services/concept/jaxb/src/main/resources/concept_common.xsd b/services/concept/jaxb/src/main/resources/concept_common.xsd new file mode 100644 index 000000000..fcb4149c4 --- /dev/null +++ b/services/concept/jaxb/src/main/resources/concept_common.xsd @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/jaxb/src/main/resources/conceptauthority_common.xsd b/services/concept/jaxb/src/main/resources/conceptauthority_common.xsd new file mode 100644 index 000000000..2cc040422 --- /dev/null +++ b/services/concept/jaxb/src/main/resources/conceptauthority_common.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/concept/pom.xml b/services/concept/pom.xml new file mode 100644 index 000000000..77234fb25 --- /dev/null +++ b/services/concept/pom.xml @@ -0,0 +1,35 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.concept + services.concept + pom + + + + + + jaxb + service + 3rdparty + client + + + + + samples + + + + + + + + diff --git a/services/concept/service/pom.xml b/services/concept/service/pom.xml new file mode 100644 index 000000000..85709c633 --- /dev/null +++ b/services/concept/service/pom.xml @@ -0,0 +1,134 @@ + + + + org.collectionspace.services + org.collectionspace.services.concept + 2.2-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.concept.service + services.concept.service + jar + + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.concept.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.concept.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.service + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.contact.service + ${project.version} + + + + junit + junit + 4.1 + test + + + org.testng + testng + 5.6 + + + + + commons-beanutils + commons-beanutils + 1.6.1 + + + + commons-logging + commons-logging + 1.1 + + + + + + javax.security + jaas + 1.0.01 + provided + + + + dom4j + dom4j + 1.6.1 + provided + + + + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + + + + org.nuxeo.ecm.core + nuxeo-core-api + + + jboss-remoting + jboss + + + + + + + + collectionspace-services-concept + + + + + diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/ConceptAuthorityResource.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/ConceptAuthorityResource.java new file mode 100644 index 000000000..b2c7afe1b --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/ConceptAuthorityResource.java @@ -0,0 +1,69 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept; + +import org.collectionspace.services.client.ConceptAuthorityClient; +import org.collectionspace.services.common.vocabulary.AuthorityResource; +import org.collectionspace.services.concept.nuxeo.ConceptDocumentModelHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path(ConceptAuthorityClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") +public class ConceptAuthorityResource + extends AuthorityResource { + + private final static String conceptAuthorityServiceName = "conceptauthorities"; + private final static String CONCEPTAUTHORITIES_COMMON = "conceptauthorities_common"; + + private final static String conceptServiceName = "concepts"; + private final static String CONCEPTS_COMMON = "concepts_common"; + + final Logger logger = LoggerFactory.getLogger(ConceptAuthorityResource.class); + + public ConceptAuthorityResource() { + super(ConceptauthoritiesCommon.class, ConceptAuthorityResource.class, + CONCEPTAUTHORITIES_COMMON, CONCEPTS_COMMON); + } + + @Override + public String getServiceName() { + return conceptAuthorityServiceName; + } + + public String getItemServiceName() { + return conceptServiceName; + } + + @Override + public Class getCommonPartClass() { + return ConceptauthoritiesCommon.class; + } +} diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityConstants.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityConstants.java new file mode 100644 index 000000000..7178d9d46 --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityConstants.java @@ -0,0 +1,35 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept.nuxeo; + +/** + * ConceptAuthorityConstants processes CollectionObject document + * + */ +public class ConceptAuthorityConstants { + + public final static String NUXEO_DOCTYPE = "ConceptAuthority"; + public final static String NUXEO_SCHEMA_NAME = "conceptauthority"; + public final static String NUXEO_DC_TITLE = "CollectionSpace-ConceptAuthority"; +} diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java new file mode 100644 index 000000000..5b971bd96 --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java @@ -0,0 +1,57 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept.nuxeo; + +import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; +import org.collectionspace.services.concept.ConceptauthoritiesCommon; + +/** + * ConceptAuthorityDocumentModelHandler + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class ConceptAuthorityDocumentModelHandler + extends AuthorityDocumentModelHandler { + + /** + * Common part schema label + */ + private static final String COMMON_PART_LABEL = "conceptauthorities_common"; + + public ConceptAuthorityDocumentModelHandler() { + super(COMMON_PART_LABEL); + } + + /** + * getQProperty converts the given property to qualified schema property + * @param prop + * @return + */ + @Override + public String getQProperty(String prop) { + return ConceptAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop; + } +} + diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptConstants.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptConstants.java new file mode 100644 index 000000000..6995b8f65 --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptConstants.java @@ -0,0 +1,35 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept.nuxeo; + +/** + * ConceptConstants processes CollectionObject document + * + */ +public class ConceptConstants { + + public final static String NUXEO_DOCTYPE = "Concept"; + public final static String NUXEO_SCHEMA_NAME = "concept"; + public final static String NUXEO_DC_TITLE = "CollectionSpace-Concept"; +} diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java new file mode 100644 index 000000000..b67e02b27 --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java @@ -0,0 +1,66 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept.nuxeo; + +import org.collectionspace.services.client.ConceptAuthorityClient; +import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; +import org.collectionspace.services.concept.ConceptsCommon; + +/** + * ConceptDocumentModelHandler + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +/** + * @author pschmitz + * + */ +public class ConceptDocumentModelHandler + extends AuthorityItemDocumentModelHandler { + + public ConceptDocumentModelHandler() { + super(ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + } + + @Override + public String getAuthorityServicePath(){ + return ConceptAuthorityClient.SERVICE_PATH_COMPONENT; // CSPACE-3932 + } + + /** + * Note that Concept has no displayName computation support. + */ + + /** + * getQProperty converts the given property to qualified schema property + * @param prop + * @return + */ + @Override + public String getQProperty(String prop) { + return ConceptConstants.NUXEO_SCHEMA_NAME + ":" + prop; + } +} + diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptValidatorHandler.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptValidatorHandler.java new file mode 100644 index 000000000..5fbe9699c --- /dev/null +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptValidatorHandler.java @@ -0,0 +1,94 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.concept.nuxeo; + +import java.util.regex.Pattern; + +import org.collectionspace.services.concept.ConceptsCommon; +import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.common.document.DocumentHandler.Action; +import org.collectionspace.services.common.document.InvalidDocumentException; +import org.collectionspace.services.common.document.ValidatorHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * ConceptValidatorHandler + * + * Validates data supplied when attempting to create and/or update Concept records. + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class ConceptValidatorHandler implements ValidatorHandler { + + final Logger logger = LoggerFactory.getLogger(ConceptValidatorHandler.class); + private static final Pattern shortIdBadPattern = Pattern.compile("[\\W]"); //.matcher(input).matches() + + @Override + public void validate(Action action, ServiceContext ctx) + throws InvalidDocumentException { + if (logger.isDebugEnabled()) { + logger.debug("validate() action=" + action.name()); + } + try { + MultipartServiceContext mctx = (MultipartServiceContext) ctx; + ConceptsCommon concept = (ConceptsCommon) mctx.getInputPart(mctx.getCommonPartLabel(), + ConceptsCommon.class); + String msg = ""; + boolean invalid = false; + + // Validation occurring on both creates and updates + String displayName = concept.getDisplayName(); + if (!concept.isDisplayNameComputed() && ((displayName == null) || displayName.trim().isEmpty())) { + invalid = true; + msg += "displayName must be non-null and non-blank if displayNameComputed is false"; + } + + // Validation specific to creates or updates + if (action.equals(Action.CREATE)) { + String shortId = concept.getShortIdentifier(); + // Per CSPACE-2215, shortIdentifier values that are null (missing) + // oe the empty string are now legally accepted in create payloads. + // In either of those cases, a short identifier will be synthesized from + // a display name or supplied in another manner. + if ((shortId != null) && (shortIdBadPattern.matcher(shortId).find())) { + invalid = true; + msg += "shortIdentifier must only contain standard word characters"; + } + } else if (action.equals(Action.UPDATE)) { + } + + if (invalid) { + logger.error(msg); + throw new InvalidDocumentException(msg); + } + } catch (InvalidDocumentException ide) { + throw ide; + } catch (Exception e) { + throw new InvalidDocumentException(e); + } + } +} diff --git a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java index a72e48426..9ff14e513 100644 --- a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java +++ b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java @@ -82,15 +82,6 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTestbatch imports location + concept taxonomy movement report diff --git a/services/relation/service/pom.xml b/services/relation/service/pom.xml index 083b707cf..5910603ae 100644 --- a/services/relation/service/pom.xml +++ b/services/relation/service/pom.xml @@ -55,6 +55,11 @@ org.collectionspace.services.taxonomy.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.concept.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 2c394b3a3..9a5c0a667 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 @@ -53,6 +53,7 @@ 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.client.ConceptAuthorityClient; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -407,6 +408,8 @@ public class RelationDocumentModelHandler common_schema = LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; else if(docType.startsWith("Taxon")) common_schema = TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; + else if(docType.startsWith("Conceptitem")) + common_schema = ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME; //else leave it null. } return common_schema; -- 2.47.3