From 3ce68c554b318c342cd7ca0452d28e7d92b501ca Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Tue, 21 May 2024 19:08:01 -0600 Subject: [PATCH] DRYD-1330: Add NAGPRA Claim (#409) --- services/JaxRsServiceProvider/pom.xml | 7 + .../CollectionSpaceJaxRsApplication.java | 2 + .../db/postgresql/load_id_generators.sql | 36 ++ services/nagpraclaim/build.xml | 106 ++++ services/nagpraclaim/client/pom.xml | 82 +++ .../services/client/NagpraClaimClient.java | 52 ++ .../services/client/NagpraClaimProxy.java | 27 + .../client/test/NagpraClaimServiceTest.java | 502 ++++++++++++++++++ services/nagpraclaim/jaxb/pom.xml | 33 ++ .../services/NagpraclaimJAXBSchema.java | 17 + .../NagpraclaimListItemJAXBSchema.java | 20 + .../main/resources/nagpraclaims_common.xsd | 176 ++++++ services/nagpraclaim/pom.xml | 58 ++ services/nagpraclaim/service/pom.xml | 93 ++++ .../nagpraclaim/NagpraClaimResource.java | 54 ++ .../nuxeo/NagpraClaimConstants.java | 33 ++ .../NagpraClaimDocumentModelHandler.java | 29 + .../nuxeo/NagpraClaimValidatorHandler.java | 67 +++ services/pom.xml | 1 + 19 files changed, 1395 insertions(+) create mode 100644 services/nagpraclaim/build.xml create mode 100644 services/nagpraclaim/client/pom.xml create mode 100644 services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimClient.java create mode 100644 services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimProxy.java create mode 100644 services/nagpraclaim/client/src/test/java/org/collectionspace/services/client/test/NagpraClaimServiceTest.java create mode 100644 services/nagpraclaim/jaxb/pom.xml create mode 100644 services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimJAXBSchema.java create mode 100644 services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimListItemJAXBSchema.java create mode 100644 services/nagpraclaim/jaxb/src/main/resources/nagpraclaims_common.xsd create mode 100644 services/nagpraclaim/pom.xml create mode 100644 services/nagpraclaim/service/pom.xml create mode 100644 services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/NagpraClaimResource.java create mode 100644 services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimConstants.java create mode 100644 services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimDocumentModelHandler.java create mode 100644 services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimValidatorHandler.java diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index a219239ab..097ee35c3 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -234,11 +234,18 @@ org.collectionspace.services.uoc.service ${project.version} + org.collectionspace.services org.collectionspace.services.claim.service ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim.service + ${project.version} + org.collectionspace.services org.collectionspace.services.exhibition.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 7020511c7..e8242770b 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 @@ -37,6 +37,7 @@ import org.collectionspace.services.intake.IntakeResource; import org.collectionspace.services.index.IndexResource; import org.collectionspace.services.loanin.LoaninResource; import org.collectionspace.services.loanout.LoanoutResource; +import org.collectionspace.services.nagpraclaim.NagpraClaimResource; import org.collectionspace.services.transport.TransportResource; import org.collectionspace.services.uoc.UocResource; import org.collectionspace.services.valuationcontrol.ValuationcontrolResource; @@ -160,6 +161,7 @@ public class CollectionSpaceJaxRsApplication extends Application addResourceToMapAndSingletons(new PropagationResource()); addResourceToMapAndSingletons(new PottagResource()); addResourceToMapAndSingletons(new ClaimResource()); + addResourceToMapAndSingletons(new NagpraClaimResource()); addResourceToMapAndSingletons(new ReportResource()); addResourceToMapAndSingletons(new PublicItemResource()); addResourceToMapAndSingletons(new TransportResource()); diff --git a/services/common/src/main/resources/db/postgresql/load_id_generators.sql b/services/common/src/main/resources/db/postgresql/load_id_generators.sql index 390049e53..1c957c50a 100644 --- a/services/common/src/main/resources/db/postgresql/load_id_generators.sql +++ b/services/common/src/main/resources/db/postgresql/load_id_generators.sql @@ -1126,3 +1126,39 @@ INSERT INTO id_generators SELECT csid FROM id_generators ); + +-- NAGPRA_CLAIM_REFERENCE_NUMBER + +INSERT INTO id_generators + (csid, displayname, description, priority, last_generated_id, id_generator_state) + SELECT + 'c4045ef4-a934-4a2e-8f92-edbf4069b64b', + 'NAGPRA Claim Reference Number', + 'Identifies a nagpra claim.', + '9', + '', +' + + + NCL + NCL + + + + + + . + . + + + 6 + 1 + -1 + + +' + WHERE 'c4045ef4-a934-4a2e-8f92-edbf4069b64b' NOT IN + ( + SELECT csid + FROM id_generators + ); diff --git a/services/nagpraclaim/build.xml b/services/nagpraclaim/build.xml new file mode 100644 index 000000000..b799eed44 --- /dev/null +++ b/services/nagpraclaim/build.xml @@ -0,0 +1,106 @@ + + + nagpraclaim service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/nagpraclaim/client/pom.xml b/services/nagpraclaim/client/pom.xml new file mode 100644 index 000000000..917610337 --- /dev/null +++ b/services/nagpraclaim/client/pom.xml @@ -0,0 +1,82 @@ + + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim + ${revision} + + + 4.0.0 + org.collectionspace.services.nagpraclaim.client + services.nagpraclaim.client + + + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + true + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common + true + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.person.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-nagpraclaim-client + + \ No newline at end of file diff --git a/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimClient.java b/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimClient.java new file mode 100644 index 000000000..90237b2bf --- /dev/null +++ b/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimClient.java @@ -0,0 +1,52 @@ +/* + * 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.nagpraclaim.NagpraclaimsCommon; + +/** + * NagpraclaimClient.java + */ +public class NagpraClaimClient extends AbstractCommonListPoxServiceClientImpl { + + public static final String SERVICE_NAME = "nagpraclaims"; + 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 NagpraClaimClient() throws Exception { + super(); + } + + public NagpraClaimClient(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 NagpraClaimProxy.class; + } +} diff --git a/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimProxy.java b/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimProxy.java new file mode 100644 index 000000000..77706ffdb --- /dev/null +++ b/services/nagpraclaim/client/src/main/java/org/collectionspace/services/client/NagpraClaimProxy.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; + +/** + * NagpraClaimProxy.java + */ +@Path(NagpraClaimClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface NagpraClaimProxy extends CollectionSpaceCommonListPoxProxy {} diff --git a/services/nagpraclaim/client/src/test/java/org/collectionspace/services/client/test/NagpraClaimServiceTest.java b/services/nagpraclaim/client/src/test/java/org/collectionspace/services/client/test/NagpraClaimServiceTest.java new file mode 100644 index 000000000..6885ec420 --- /dev/null +++ b/services/nagpraclaim/client/src/test/java/org/collectionspace/services/client/test/NagpraClaimServiceTest.java @@ -0,0 +1,502 @@ +/* + * 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.NagpraClaimClient; +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.jaxb.AbstractCommonList; +import org.collectionspace.services.nagpraclaim.NagpraclaimsCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; + +public class NagpraClaimServiceTest extends AbstractPoxServiceTestImpl { + + private final Logger logger = LoggerFactory.getLogger(NagpraClaimServiceTest.class); + + /** The service path component. */ + final String SERVICE_NAME = "nagpraclaims"; + + final String SERVICE_PATH_COMPONENT = "nagpraclaims"; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() throws Exception { + return new NagpraClaimClient(); + } + + @Override + protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception { + return new NagpraClaimClient(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. + NagpraClaimClient client = new NagpraClaimClient(); + String identifier = createIdentifier(); + PoxPayloadOut multipart = createNagpraClaimInstance(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. + NagpraClaimClient client = new NagpraClaimClient(); + 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()); + NagpraclaimsCommon common = null; + if (payloadInputPart != null) { + common = (NagpraclaimsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(common); + } + + // 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. + NagpraClaimClient client = new NagpraClaimClient(); + 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; + NagpraClaimClient client = new NagpraClaimClient(); + 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. + NagpraClaimClient client = new NagpraClaimClient(); + 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()); + NagpraclaimsCommon common = null; + if (payloadInputPart != null) { + common = (NagpraclaimsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(common); + + // Update the content of this resource. + common.setClaimNumber("updated-" + common.getClaimNumber()); + + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(common, NagpraclaimsCommon.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(), common); + 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()); + NagpraclaimsCommon updatedNagpraClaimCommon = null; + if (payloadInputPart != null) { + updatedNagpraClaimCommon = (NagpraclaimsCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(updatedNagpraClaimCommon); + + // Check selected fields in the updated common part. + Assert.assertEquals( + updatedNagpraClaimCommon.getClaimNumber(), + common.getClaimNumber(), + "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. + NagpraClaimClient client = new NagpraClaimClient(); + PoxPayloadOut multipart = createNagpraClaimInstance(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. + NagpraClaimClient client = new NagpraClaimClient(); + 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. + NagpraClaimClient client = new NagpraClaimClient(); + 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_PATH_COMPONENT; + } + + @Override + protected PoxPayloadOut createInstance(String identifier) throws Exception { + return createNagpraClaimInstance(identifier); + } + + /** + * Creates the nagpraclaim instance. + * + * @param claimNumber the exhibition number + * @return the multipart output + * @throws Exception + */ + private PoxPayloadOut createNagpraClaimInstance(String claimNumber) throws Exception { + NagpraclaimsCommon common = new NagpraclaimsCommon(); + common.setClaimNumber(claimNumber); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = multipart.addPart(new NagpraClaimClient().getCommonPartName(), common); + + logger.debug("to be created, nagpraclaim common"); + logger.debug(objectAsXmlString(common, NagpraclaimsCommon.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 createNagpraClaimInstance(identifier); + } + + @Override + protected NagpraclaimsCommon updateInstance(NagpraclaimsCommon commonPartObject) { + // TODO Auto-generated method stub + return null; + } + + @Override + protected void compareUpdatedInstances(NagpraclaimsCommon original, NagpraclaimsCommon updated) { + // TODO Auto-generated method stub + } +} diff --git a/services/nagpraclaim/jaxb/pom.xml b/services/nagpraclaim/jaxb/pom.xml new file mode 100644 index 000000000..ccd152164 --- /dev/null +++ b/services/nagpraclaim/jaxb/pom.xml @@ -0,0 +1,33 @@ + + + + org.collectionspace.services.nagpraclaim + org.collectionspace.services + ${revision} + + + 4.0.0 + org.collectionspace.services.nagpraclaim.jaxb + services.nagpraclaim.jaxb + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + + + collectionspace-services-nagpraclaim-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + \ No newline at end of file diff --git a/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimJAXBSchema.java b/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimJAXBSchema.java new file mode 100644 index 000000000..62aea882b --- /dev/null +++ b/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimJAXBSchema.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 NagpraclaimJAXBSchema {} diff --git a/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimListItemJAXBSchema.java b/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimListItemJAXBSchema.java new file mode 100644 index 000000000..d07581719 --- /dev/null +++ b/services/nagpraclaim/jaxb/src/main/java/org/collectionspace/services/NagpraclaimListItemJAXBSchema.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 NagpraclaimListItemJAXBSchema { + String CSID = "csid"; + String URI = "url"; +} diff --git a/services/nagpraclaim/jaxb/src/main/resources/nagpraclaims_common.xsd b/services/nagpraclaim/jaxb/src/main/resources/nagpraclaims_common.xsd new file mode 100644 index 000000000..c47644ec0 --- /dev/null +++ b/services/nagpraclaim/jaxb/src/main/resources/nagpraclaims_common.xsd @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/nagpraclaim/pom.xml b/services/nagpraclaim/pom.xml new file mode 100644 index 000000000..5978236a8 --- /dev/null +++ b/services/nagpraclaim/pom.xml @@ -0,0 +1,58 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + ${revision} + + + 4.0.0 + org.collectionspace.services.nagpraclaim + services.nagpraclaim + 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/nagpraclaim/service/pom.xml b/services/nagpraclaim/service/pom.xml new file mode 100644 index 000000000..2b14c4fb9 --- /dev/null +++ b/services/nagpraclaim/service/pom.xml @@ -0,0 +1,93 @@ + + + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim + ${revision} + + + 4.0.0 + org.collectionspace.services.nagpraclaim.service + services.nagpraclaim.service + jar + + + + org.collectionspace.services + org.collectionspace.services.common + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagpraclaim.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.collectionobject.jaxb + ${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-nagpraclaim + + \ No newline at end of file diff --git a/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/NagpraClaimResource.java b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/NagpraClaimResource.java new file mode 100644 index 000000000..18d9e6f3d --- /dev/null +++ b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/NagpraClaimResource.java @@ -0,0 +1,54 @@ +/* + * 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.nagpraclaim; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import org.collectionspace.services.client.NagpraClaimClient; +import org.collectionspace.services.common.NuxeoBasedResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Path(NagpraClaimClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") +public class NagpraClaimResource extends NuxeoBasedResource { + + final Logger logger = LoggerFactory.getLogger(NagpraClaimResource.class); + + @Override + protected String getVersionString() { + final String lastChangeRevision = "$LastChangedRevision$"; + return lastChangeRevision; + } + + @Override + public String getServiceName() { + return NagpraClaimClient.SERVICE_NAME; + } + + @Override + public Class getCommonPartClass() { + return NagpraclaimsCommon.class; + } +} diff --git a/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimConstants.java b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimConstants.java new file mode 100644 index 000000000..0e181785d --- /dev/null +++ b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimConstants.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.nagpraclaim.nuxeo; + +/** + * NagpraclaimConstants specifies constants for the Nagpraclaim service + * + */ +public class NagpraClaimConstants { + + public static final String NUXEO_DOCTYPE = "Nagpraclaim"; + public static final String NUXEO_SCHEMA_NAME = "nagpraclaim"; + public static final String NUXEO_DC_TITLE = "CollectionSpace-Nagpraclaim"; +} diff --git a/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimDocumentModelHandler.java b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimDocumentModelHandler.java new file mode 100644 index 000000000..4f28d73f9 --- /dev/null +++ b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimDocumentModelHandler.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.nagpraclaim.nuxeo; + +import org.collectionspace.services.nagpraclaim.NagpraclaimsCommon; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; + +/** NagpraClaimDocumentModelHandler + */ +public class NagpraClaimDocumentModelHandler extends NuxeoDocumentModelHandler {} diff --git a/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimValidatorHandler.java b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimValidatorHandler.java new file mode 100644 index 000000000..f76b28867 --- /dev/null +++ b/services/nagpraclaim/service/src/main/java/org/collectionspace/services/nagpraclaim/nuxeo/NagpraClaimValidatorHandler.java @@ -0,0 +1,67 @@ +/* + * 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.nagpraclaim.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.nagpraclaim.NagpraclaimsCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Validation handler for NagpraClaim. Checks for the common part and claimNumber on create. + */ +public class NagpraClaimValidatorHandler extends ValidatorHandlerImpl { + + private static final String COMMON_PART_MISSING = "Validation exception: nagpraclaims_common part is missing"; + private static final String CLAIM_NUMBER_MISSING = + "Validation exception: The nagpra claim field \"claimNumber\" cannot be empty or missing"; + + private final Logger logger = LoggerFactory.getLogger(NagpraClaimValidatorHandler.class); + + @Override + protected Class getCommonPartClass() { + return NagpraclaimsCommon.class; + } + + @Override + protected void handleCreate() throws InvalidDocumentException { + final NagpraclaimsCommon claim = (NagpraclaimsCommon) getCommonPart(); + if (claim == null) { + logger.error(COMMON_PART_MISSING); + throw new InvalidDocumentException(COMMON_PART_MISSING); + } + + final String claimNumber = claim.getClaimNumber(); + if (claimNumber == null || claimNumber.isEmpty()) { + logger.error(CLAIM_NUMBER_MISSING); + throw new InvalidDocumentException(CLAIM_NUMBER_MISSING); + } + } + + @Override + protected void handleGet() {} + + @Override + protected void handleGetAll() {} + + @Override + protected void handleUpdate() {} + + @Override + protected void handleDelete() {} +} diff --git a/services/pom.xml b/services/pom.xml index f080fdd9d..5bdead9ee 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -98,6 +98,7 @@ publicitem iterationreport chronology + nagpraclaim IntegrationTests PerformanceTests security -- 2.47.3