From 8f2d1795ef1a99105beccc05e6de8008c2855803 Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Tue, 11 Jun 2024 12:35:13 -0600 Subject: [PATCH] DRYD-1333: Summary Documentation (#411) --- services/JaxRsServiceProvider/pom.xml | 16 +- .../CollectionSpaceJaxRsApplication.java | 2 + .../db/postgresql/load_id_generators.sql | 36 ++ services/nagpra-jaxb/pom.xml | 36 ++ .../src/main/resources/nagpra_common.xsd | 159 ++++++ services/pom.xml | 3 +- services/summarydocumentation/build.xml | 106 ++++ services/summarydocumentation/client/pom.xml | 57 ++ .../client/SummaryDocumentationClient.java | 53 ++ .../client/SummaryDocumentationProxy.java | 27 + .../test/SummaryDocumentationServiceTest.java | 500 ++++++++++++++++++ services/summarydocumentation/jaxb/pom.xml | 38 ++ .../SummaryDocumentationJAXBSchema.java | 17 + ...ummaryDocumentationListItemJAXBSchema.java | 20 + .../summarydocumentations_common.xsd | 63 +++ services/summarydocumentation/pom.xml | 58 ++ services/summarydocumentation/service/pom.xml | 88 +++ .../SummaryDocumentationResource.java | 49 ++ .../nuxeo/SummaryDocumentationConstants.java | 33 ++ ...maryDocumentationDocumentModelHandler.java | 29 + .../SummaryDocumentationValidatorHandler.java | 65 +++ 21 files changed, 1449 insertions(+), 6 deletions(-) create mode 100644 services/nagpra-jaxb/pom.xml create mode 100644 services/nagpra-jaxb/src/main/resources/nagpra_common.xsd create mode 100644 services/summarydocumentation/build.xml create mode 100644 services/summarydocumentation/client/pom.xml create mode 100644 services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationClient.java create mode 100644 services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationProxy.java create mode 100644 services/summarydocumentation/client/src/test/java/org/collectionspace/services/client/test/SummaryDocumentationServiceTest.java create mode 100644 services/summarydocumentation/jaxb/pom.xml create mode 100644 services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationJAXBSchema.java create mode 100644 services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationListItemJAXBSchema.java create mode 100644 services/summarydocumentation/jaxb/src/main/resources/summarydocumentations_common.xsd create mode 100644 services/summarydocumentation/pom.xml create mode 100644 services/summarydocumentation/service/pom.xml create mode 100644 services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/SummaryDocumentationResource.java create mode 100644 services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationConstants.java create mode 100644 services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationDocumentModelHandler.java create mode 100644 services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationValidatorHandler.java diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index a9fadb207..816943bd7 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -431,11 +431,17 @@ org.collectionspace.services.dutyofcare.service ${project.version} - - org.collectionspace.services - org.collectionspace.services.nagprainventory.service - ${project.version} - + + org.collectionspace.services + org.collectionspace.services.nagprainventory.service + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation.service + ${project.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/pom.xml b/services/pom.xml index d6c28b176..ea84d9677 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -44,6 +44,7 @@ hyperjaxb common structureddate + nagpra-jaxb systeminfo authority authorization-mgt @@ -100,6 +101,7 @@ chronology nagpraclaim nagprainventory + summarydocumentation IntegrationTests PerformanceTests security @@ -112,7 +114,6 @@ org.testng testng - test org.slf4j diff --git a/services/summarydocumentation/build.xml b/services/summarydocumentation/build.xml new file mode 100644 index 000000000..c636f169f --- /dev/null +++ b/services/summarydocumentation/build.xml @@ -0,0 +1,106 @@ + + + summarydocumentation service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/summarydocumentation/client/pom.xml b/services/summarydocumentation/client/pom.xml new file mode 100644 index 000000000..ed8367425 --- /dev/null +++ b/services/summarydocumentation/client/pom.xml @@ -0,0 +1,57 @@ + + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation + ${revision} + + + 4.0.0 + org.collectionspace.services.summarydocumentation.client + services.summarydocumentation.client + + + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation.jaxb + ${project.version} + + + + + org.testng + testng + + + org.jboss.resteasy + resteasy-jaxrs + + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + + + collectionspace-services-summarydocumentation-client + + \ No newline at end of file diff --git a/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationClient.java b/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationClient.java new file mode 100644 index 000000000..3ef55e455 --- /dev/null +++ b/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationClient.java @@ -0,0 +1,53 @@ +/* + * 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 + * + * 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.summarydocumentation.SummaryDocumentationsCommon; + +/** + * SummarydocumentationClient.java + */ +public class SummaryDocumentationClient + extends AbstractCommonListPoxServiceClientImpl { + + public static final String SERVICE_NAME = "summarydocumentations"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; + + public SummaryDocumentationClient() throws Exception { + super(); + } + + public SummaryDocumentationClient(String clientPropertiesFilename) throws Exception { + super(clientPropertiesFilename); + } + + @Override + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override + public Class getProxyClass() { + return SummaryDocumentationProxy.class; + } +} diff --git a/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationProxy.java b/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationProxy.java new file mode 100644 index 000000000..7675585ae --- /dev/null +++ b/services/summarydocumentation/client/src/main/java/org/collectionspace/services/client/SummaryDocumentationProxy.java @@ -0,0 +1,27 @@ +/* + * 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 + * + * 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 javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +/** + * SummarydocumentationProxy.java + */ +@Path(SummaryDocumentationClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface SummaryDocumentationProxy extends CollectionSpaceCommonListPoxProxy {} diff --git a/services/summarydocumentation/client/src/test/java/org/collectionspace/services/client/test/SummaryDocumentationServiceTest.java b/services/summarydocumentation/client/src/test/java/org/collectionspace/services/client/test/SummaryDocumentationServiceTest.java new file mode 100644 index 000000000..f0f45c40b --- /dev/null +++ b/services/summarydocumentation/client/src/test/java/org/collectionspace/services/client/test/SummaryDocumentationServiceTest.java @@ -0,0 +1,500 @@ +/* + * 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 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 javax.ws.rs.core.Response; +import org.collectionspace.services.client.AbstractCommonListUtils; +import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.PayloadInputPart; +import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.client.SummaryDocumentationClient; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.summarydocumentation.SummaryDocumentationsCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; + +public class SummaryDocumentationServiceTest + extends AbstractPoxServiceTestImpl { + + private final Logger logger = LoggerFactory.getLogger(SummaryDocumentationServiceTest.class); + + final String SERVICE_NAME = "summarydocumentations"; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() throws Exception { + return new SummaryDocumentationClient(); + } + + @Override + protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception { + return new SummaryDocumentationClient(clientPropertiesFilename); + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) + */ + @Override + protected AbstractCommonList getCommonList(Response response) { + return response.readEntity(AbstractCommonList.class); + } + + // --------------------------------------------------------------- + // CRUD tests : CREATE tests + // --------------------------------------------------------------- + + // Success outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String) + */ + @Override + public void create(String testName) throws Exception { + // Perform setup, such as initializing the type of service request + // (e.g. CREATE, DELETE), its valid and expected status codes, and + // its associated HTTP method name (e.g. POST, DELETE). + setupCreate(); + + // Submit the request to the service and store the response. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + String identifier = createIdentifier(); + PoxPayloadOut multipart = createSummaryDocumentationInstance(identifier); + String newID = null; + Response res = client.create(multipart); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + // + // Specifically: + // Does it fall within the set of valid status codes? + // Does it exactly match the expected status code? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + newID = extractId(res); + } finally { + if (res != null) { + res.close(); + } + } + + // Store the ID returned from the first resource created + // for additional tests below. + if (knownResourceId == null) { + knownResourceId = newID; + logger.debug(testName + ": knownResourceId=" + knownResourceId); + } + + // Store the IDs from every resource created by tests, + // so they can be deleted after tests have been run. + allResourceIdsCreated.add(newID); + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) + */ + @Override + public void createList(String testName) throws Exception { + for (int i = 0; i < 3; i++) { + create(testName); + } + } + + // --------------------------------------------------------------- + // CRUD tests : READ tests + // --------------------------------------------------------------- + + // Success outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String) + */ + @Override + public void read(String testName) throws Exception { + // Perform setup. + setupRead(); + + // Submit the request to the service and store the response. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.read(knownResourceId); + PoxPayloadIn input; + try { + assertStatusCode(res, testName); + input = new PoxPayloadIn(res.readEntity(String.class)); + } finally { + if (res != null) { + res.close(); + } + } + + // Get the common part of the response and verify that it is not null. + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + SummaryDocumentationsCommon summaryDocumentation = null; + if (payloadInputPart != null) { + summaryDocumentation = (SummaryDocumentationsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(summaryDocumentation); + } + + // Failure outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String) + */ + @Override + public void readNonExistent(String testName) throws Exception { + // Perform setup. + setupReadNonExistent(); + + // Submit the request to the service and store the response. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.read(NON_EXISTENT_ID); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + if (res != null) { + res.close(); + } + } + } + + // --------------------------------------------------------------- + // CRUD tests : READ_LIST tests + // --------------------------------------------------------------- + + // Success outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String) + */ + @Override + public void readList(String testName) throws Exception { + // Perform setup. + setupReadList(); + + // Submit the request to the service and store the response. + AbstractCommonList list; + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.readList(); + assertStatusCode(res, testName); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + + list = res.readEntity(getCommonListType()); + } finally { + res.close(); + } + + // Optionally output additional data about list members for debugging. + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); + } + + // Failure outcomes + // None at present. + + // --------------------------------------------------------------- + // CRUD tests : UPDATE tests + // --------------------------------------------------------------- + + // Success outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String) + */ + @Override + public void update(String testName) throws Exception { + // Perform setup. + setupRead(); + + // Retrieve the contents of a resource to update. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.read(knownResourceId); + PoxPayloadIn input; + try { + assertStatusCode(res, testName); + input = new PoxPayloadIn(res.readEntity(String.class)); + logger.debug("got object to update with ID: " + knownResourceId); + } finally { + if (res != null) { + res.close(); + } + } + + // Extract the common part from the response. + PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); + SummaryDocumentationsCommon summaryDocumentation = null; + if (payloadInputPart != null) { + summaryDocumentation = (SummaryDocumentationsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(summaryDocumentation); + + // Update the content of this resource. + summaryDocumentation.setDocumentationNumber("updated-" + summaryDocumentation.getDocumentationNumber()); + + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(summaryDocumentation, SummaryDocumentationsCommon.class)); + + setupUpdate(); + + // Submit the updated common part in an update request to the service + // and store the response. + PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), summaryDocumentation); + res = client.update(knownResourceId, output); + try { + assertStatusCode(res, testName); + int statusCode = res.getStatus(); + // Check the status code of the response: does it match the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + input = new PoxPayloadIn(res.readEntity(String.class)); + } finally { + if (res != null) { + res.close(); + } + } + + // Extract the updated common part from the response. + payloadInputPart = input.getPart(client.getCommonPartName()); + SummaryDocumentationsCommon updatedSummaryDocumentationCommon = null; + if (payloadInputPart != null) { + updatedSummaryDocumentationCommon = (SummaryDocumentationsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(updatedSummaryDocumentationCommon); + + // Check selected fields in the updated common part. + Assert.assertEquals( + updatedSummaryDocumentationCommon.getDocumentationNumber(), + summaryDocumentation.getDocumentationNumber(), + "Data in updated object did not match submitted data."); + } + + @Override + public void updateNonExistent(String testName) throws Exception { + // Perform setup. + setupUpdateNonExistent(); + + // Submit the request to the service and store the response. + // Note: The ID used in this 'create' call may be arbitrary. + // The only relevant ID may be the one used in update(), below. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + PoxPayloadOut multipart = createSummaryDocumentationInstance(NON_EXISTENT_ID); + Response res = client.update(NON_EXISTENT_ID, multipart); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + if (res != null) { + res.close(); + } + } + } + + // --------------------------------------------------------------- + // CRUD tests : DELETE tests + // --------------------------------------------------------------- + + // Success outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String) + */ + @Override + public void delete(String testName) throws Exception { + // Perform setup. + setupDelete(); + + // Submit the request to the service and store the response. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.delete(knownResourceId); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + if (res != null) { + res.close(); + } + } + } + + // Failure outcomes + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String) + */ + @Override + public void deleteNonExistent(String testName) throws Exception { + // Perform setup. + setupDeleteNonExistent(); + + // Submit the request to the service and store the response. + SummaryDocumentationClient client = new SummaryDocumentationClient(); + Response res = client.delete(NON_EXISTENT_ID); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug(testName + ": status = " + statusCode); + Assert.assertTrue( + testRequestType.isValidStatusCode(statusCode), + invalidStatusCodeMessage(testRequestType, statusCode)); + Assert.assertEquals(statusCode, testExpectedStatusCode); + } finally { + if (res != null) { + res.close(); + } + } + } + + // --------------------------------------------------------------- + // Utility tests : tests of code used in tests above + // --------------------------------------------------------------- + + /** + * Tests the code for manually submitting data that is used by several + * of the methods above. + */ + public void testSubmitRequest() { + + // Expected status code: 200 OK + final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + + // Submit the request to the service and store the response. + String method = ServiceRequestType.READ.httpMethodName(); + String url = getResourceURL(knownResourceId); + int statusCode = submitRequest(method, url); + + // Check the status code of the response: does it match + // the expected response(s)? + logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); + Assert.assertEquals(statusCode, EXPECTED_STATUS); + } + + // --------------------------------------------------------------- + // Utility methods used by tests above + // --------------------------------------------------------------- + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() + */ + @Override + public String getServicePathComponent() { + return SERVICE_NAME; + } + + @Override + protected PoxPayloadOut createInstance(String identifier) throws Exception { + return createSummaryDocumentationInstance(identifier); + } + + /** + * Creates the summarydocumentation instance. + * + * @param summaryDocumentationNumber the documentation number + * @return the multipart output + * @throws Exception + */ + private PoxPayloadOut createSummaryDocumentationInstance(String summaryDocumentationNumber) throws Exception { + SummaryDocumentationsCommon summaryDocumentation = new SummaryDocumentationsCommon(); + summaryDocumentation.setDocumentationNumber(summaryDocumentationNumber); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(new SummaryDocumentationClient().getCommonPartName(), summaryDocumentation); + + logger.debug("to be created, summarydocumentations_common"); + logger.debug(objectAsXmlString(summaryDocumentation, SummaryDocumentationsCommon.class)); + + return multipart; + } + + @Override + public void CRUDTests(String testName) { + // TODO Auto-generated method stub + } + + @Override + protected PoxPayloadOut createInstance(String commonPartName, String identifier) throws Exception { + return createSummaryDocumentationInstance(identifier); + } + + @Override + protected SummaryDocumentationsCommon updateInstance(SummaryDocumentationsCommon commonPartObject) { + // TODO Auto-generated method stub + return null; + } + + @Override + protected void compareUpdatedInstances(SummaryDocumentationsCommon original, SummaryDocumentationsCommon updated) { + // TODO Auto-generated method stub + } +} diff --git a/services/summarydocumentation/jaxb/pom.xml b/services/summarydocumentation/jaxb/pom.xml new file mode 100644 index 000000000..1e27981d8 --- /dev/null +++ b/services/summarydocumentation/jaxb/pom.xml @@ -0,0 +1,38 @@ + + + + org.collectionspace.services.summarydocumentation + org.collectionspace.services + ${revision} + + + 4.0.0 + org.collectionspace.services.summarydocumentation.jaxb + services.summarydocumentation.jaxb + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagpra-jaxb + ${project.version} + + + + + collectionspace-services-summarydocumentation-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + \ No newline at end of file diff --git a/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationJAXBSchema.java b/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationJAXBSchema.java new file mode 100644 index 000000000..50b52f48a --- /dev/null +++ b/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationJAXBSchema.java @@ -0,0 +1,17 @@ +/* + * 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 + * + * 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; + +public interface SummaryDocumentationJAXBSchema {} diff --git a/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationListItemJAXBSchema.java b/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationListItemJAXBSchema.java new file mode 100644 index 000000000..93d919843 --- /dev/null +++ b/services/summarydocumentation/jaxb/src/main/java/org/collectionspace/services/SummaryDocumentationListItemJAXBSchema.java @@ -0,0 +1,20 @@ +/* + * 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 + * + * 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; + +public interface SummaryDocumentationListItemJAXBSchema { + String CSID = "csid"; + String URI = "url"; +} diff --git a/services/summarydocumentation/jaxb/src/main/resources/summarydocumentations_common.xsd b/services/summarydocumentation/jaxb/src/main/resources/summarydocumentations_common.xsd new file mode 100644 index 000000000..0855f2e30 --- /dev/null +++ b/services/summarydocumentation/jaxb/src/main/resources/summarydocumentations_common.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/summarydocumentation/pom.xml b/services/summarydocumentation/pom.xml new file mode 100644 index 000000000..11bb5cef4 --- /dev/null +++ b/services/summarydocumentation/pom.xml @@ -0,0 +1,58 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + ${revision} + + + 4.0.0 + org.collectionspace.services.summarydocumentation + services.summarydocumentation + pom + + + + 2.30.0 + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + src/main/java/**/*.java + src/test/java/**/*.java + + + + + true + 4 + + + + + + + + + + + + + + jaxb + service + client + + + \ No newline at end of file diff --git a/services/summarydocumentation/service/pom.xml b/services/summarydocumentation/service/pom.xml new file mode 100644 index 000000000..e5c5083f1 --- /dev/null +++ b/services/summarydocumentation/service/pom.xml @@ -0,0 +1,88 @@ + + + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation + ${revision} + + + 4.0.0 + org.collectionspace.services.summarydocumentation.service + services.summarydocumentation.service + jar + + + + org.collectionspace.services + org.collectionspace.services.common + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.summarydocumentation.client + ${project.version} + + + + + junit + junit + test + + + org.testng + testng + + + + + javax.security + jaas + 1.0.01 + 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-summarydocumentation + + diff --git a/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/SummaryDocumentationResource.java b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/SummaryDocumentationResource.java new file mode 100644 index 000000000..a3a864819 --- /dev/null +++ b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/SummaryDocumentationResource.java @@ -0,0 +1,49 @@ +/* + * 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 + * + * 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.summarydocumentation; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import org.collectionspace.services.client.SummaryDocumentationClient; +import org.collectionspace.services.common.NuxeoBasedResource; + +@Path(SummaryDocumentationClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") +public class SummaryDocumentationResource extends NuxeoBasedResource { + + @Override + protected String getVersionString() { + return "$LastChangedRevision$"; + } + + @Override + public String getServiceName() { + return SummaryDocumentationClient.SERVICE_NAME; + } + + @Override + public Class getCommonPartClass() { + return SummaryDocumentationsCommon.class; + } +} diff --git a/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationConstants.java b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationConstants.java new file mode 100644 index 000000000..7f690bc77 --- /dev/null +++ b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationConstants.java @@ -0,0 +1,33 @@ +/* + * 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 + * + * 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.summarydocumentation.nuxeo; + +/** + * SummarydocumentationConstants specifies constants for the Summarydocumentation service + * + */ +public class SummaryDocumentationConstants { + + public static final String NUXEO_DOCTYPE = "Summarydocumentation"; + public static final String NUXEO_SCHEMA_NAME = "summarydocumentation"; + public static final String NUXEO_DC_TITLE = "CollectionSpace-Summarydocumentation"; +} diff --git a/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationDocumentModelHandler.java b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationDocumentModelHandler.java new file mode 100644 index 000000000..dda6eccb1 --- /dev/null +++ b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationDocumentModelHandler.java @@ -0,0 +1,29 @@ +/* + * 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 + * + * 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.summarydocumentation.nuxeo; + +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.summarydocumentation.SummaryDocumentationsCommon; + +/** SummarydocumentationDocumentModelHandler + */ +public class SummaryDocumentationDocumentModelHandler extends NuxeoDocumentModelHandler {} diff --git a/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationValidatorHandler.java b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationValidatorHandler.java new file mode 100644 index 000000000..53f6012c8 --- /dev/null +++ b/services/summarydocumentation/service/src/main/java/org/collectionspace/services/summarydocumentation/nuxeo/SummaryDocumentationValidatorHandler.java @@ -0,0 +1,65 @@ +/* + * 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 + * + * 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.summarydocumentation.nuxeo; + +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.document.InvalidDocumentException; +import org.collectionspace.services.common.document.ValidatorHandlerImpl; +import org.collectionspace.services.summarydocumentation.SummaryDocumentationsCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SummaryDocumentationValidatorHandler extends ValidatorHandlerImpl { + + private static final String COMMON_PART_MISSING = + "Validation exception: summarydocumentations_common part is missing"; + private static final String DOCUMENTATION_NUMBER_MISSING = + "Validation exception: The summary documentation field \"documentationNumber\" cannot be empty or missing"; + + private final Logger logger = LoggerFactory.getLogger(SummaryDocumentationValidatorHandler.class); + + @Override + protected Class getCommonPartClass() { + return SummaryDocumentationsCommon.class; + } + + @Override + protected void handleCreate() throws InvalidDocumentException { + final SummaryDocumentationsCommon summary = (SummaryDocumentationsCommon) getCommonPart(); + if (summary == null) { + logger.error(COMMON_PART_MISSING); + throw new InvalidDocumentException(COMMON_PART_MISSING); + } + + final String documentationNumber = summary.getDocumentationNumber(); + if (documentationNumber == null || documentationNumber.isEmpty()) { + logger.error(DOCUMENTATION_NUMBER_MISSING); + throw new InvalidDocumentException(DOCUMENTATION_NUMBER_MISSING); + } + } + + @Override + protected void handleGet() {} + + @Override + protected void handleGetAll() {} + + @Override + protected void handleUpdate() {} + + @Override + protected void handleDelete() {} +} -- 2.47.3