From: Michael Ritter Date: Wed, 5 Jun 2024 00:52:44 +0000 (-0600) Subject: DRYD-1331: NAGPRA Inventory (#410) X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=efc869a3d84368c3025c9da8bb144c10a0a2c16b;p=tmp%2Fjakarta-migration.git DRYD-1331: NAGPRA Inventory (#410) --- diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 097ee35c3..a9fadb207 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -431,11 +431,16 @@ org.collectionspace.services.dutyofcare.service ${project.version} - + + org.collectionspace.services + org.collectionspace.services.nagprainventory.service + ${project.version} + + commons-io commons-io 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 e8242770b..213a558a8 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 @@ -38,6 +38,7 @@ 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.nagprainventory.NagpraInventoryResource; import org.collectionspace.services.transport.TransportResource; import org.collectionspace.services.uoc.UocResource; import org.collectionspace.services.valuationcontrol.ValuationcontrolResource; @@ -167,6 +168,7 @@ public class CollectionSpaceJaxRsApplication extends Application addResourceToMapAndSingletons(new TransportResource()); addResourceToMapAndSingletons(new IterationreportResource()); addResourceToMapAndSingletons(new ChronologyAuthorityResource()); + addResourceToMapAndSingletons(new NagpraInventoryResource()); singletons.add(new IDResource()); 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 1c957c50a..7069851eb 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 @@ -1162,3 +1162,39 @@ INSERT INTO id_generators SELECT csid FROM id_generators ); + +-- NAGPRAINVENTORY_REFERENCE_NUMBER + +INSERT INTO id_generators + (csid, displayname, description, priority, last_generated_id, id_generator_state) + SELECT + '500b27f0-2ad9-42ab-af0b-3452a4ad5d29', + 'NAGPRA Inventory Report Reference Number', + 'Identifies a nagprainventory.', + '9', + '', +' + + + INV + INV + + + + + + . + . + + + 6 + 1 + -1 + + +' + WHERE '500b27f0-2ad9-42ab-af0b-3452a4ad5d29' NOT IN + ( + SELECT csid + FROM id_generators + ); diff --git a/services/nagprainventory/build.xml b/services/nagprainventory/build.xml new file mode 100644 index 000000000..353e525c1 --- /dev/null +++ b/services/nagprainventory/build.xml @@ -0,0 +1,106 @@ + + + nagprainventory service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/nagprainventory/client/pom.xml b/services/nagprainventory/client/pom.xml new file mode 100644 index 000000000..cb5308830 --- /dev/null +++ b/services/nagprainventory/client/pom.xml @@ -0,0 +1,61 @@ + + + + org.collectionspace.services + org.collectionspace.services.nagprainventory + ${revision} + + + 4.0.0 + org.collectionspace.services.nagprainventory.client + services.nagprainventory.client + + + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagprainventory.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 + + + commons-httpclient + commons-httpclient + + + + + collectionspace-services-nagprainventory-client + + \ No newline at end of file diff --git a/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryClient.java b/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryClient.java new file mode 100644 index 000000000..adcb965be --- /dev/null +++ b/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryClient.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.nagprainventory.NagpraInventoriesCommon; + +/** + * NagpraInventoryClient.java + */ +public class NagpraInventoryClient + extends AbstractCommonListPoxServiceClientImpl { + + public static final String SERVICE_NAME = "nagprainventories"; + 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 NagpraInventoryClient() throws Exception { + super(); + } + + public NagpraInventoryClient(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 NagpraInventoryProxy.class; + } +} diff --git a/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryProxy.java b/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryProxy.java new file mode 100644 index 000000000..816355657 --- /dev/null +++ b/services/nagprainventory/client/src/main/java/org/collectionspace/services/client/NagpraInventoryProxy.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; + +/** + * NagprainventoryProxy.java + */ +@Path(NagpraInventoryClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface NagpraInventoryProxy extends CollectionSpaceCommonListPoxProxy {} diff --git a/services/nagprainventory/client/src/test/java/org/collectionspace/services/client/test/NagpraInventoryServiceTest.java b/services/nagprainventory/client/src/test/java/org/collectionspace/services/client/test/NagpraInventoryServiceTest.java new file mode 100644 index 000000000..005274077 --- /dev/null +++ b/services/nagprainventory/client/src/test/java/org/collectionspace/services/client/test/NagpraInventoryServiceTest.java @@ -0,0 +1,504 @@ +/* + * 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.NagpraInventoryClient; +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.nagprainventory.NagpraInventoriesCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; + +public class NagpraInventoryServiceTest + extends AbstractPoxServiceTestImpl { + + private final Logger logger = LoggerFactory.getLogger(NagpraInventoryServiceTest.class); + + /** The service path component. */ + final String SERVICE_NAME = "nagprainventories"; + + final String SERVICE_PATH_COMPONENT = "nagprainventories"; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() throws Exception { + return new NagpraInventoryClient(); + } + + @Override + protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception { + return new NagpraInventoryClient(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. + NagpraInventoryClient client = new NagpraInventoryClient(); + String identifier = createIdentifier(); + PoxPayloadOut multipart = createNagpraInventoryInstance(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. + NagpraInventoryClient client = new NagpraInventoryClient(); + 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()); + NagpraInventoriesCommon nagprainventoryCommon = null; + if (payloadInputPart != null) { + nagprainventoryCommon = (NagpraInventoriesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(nagprainventoryCommon); + } + + // 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. + NagpraInventoryClient client = new NagpraInventoryClient(); + 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; + NagpraInventoryClient client = new NagpraInventoryClient(); + 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. + NagpraInventoryClient client = new NagpraInventoryClient(); + 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()); + NagpraInventoriesCommon nagprainventoryCommon = null; + if (payloadInputPart != null) { + nagprainventoryCommon = (NagpraInventoriesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(nagprainventoryCommon); + + // Update the content of this resource. + nagprainventoryCommon.setInventoryNumber("updated-" + nagprainventoryCommon.getInventoryNumber()); + + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(nagprainventoryCommon, NagpraInventoriesCommon.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(), nagprainventoryCommon); + 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()); + NagpraInventoriesCommon updatedNagpraInventoriesCommon = null; + if (payloadInputPart != null) { + updatedNagpraInventoriesCommon = (NagpraInventoriesCommon) payloadInputPart.getBody(); + } + Assert.assertNotNull(updatedNagpraInventoriesCommon); + + // Check selected fields in the updated common part. + Assert.assertEquals( + updatedNagpraInventoriesCommon.getInventoryNumber(), + nagprainventoryCommon.getInventoryNumber(), + "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. + NagpraInventoryClient client = new NagpraInventoryClient(); + PoxPayloadOut multipart = createNagpraInventoryInstance(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. + NagpraInventoryClient client = new NagpraInventoryClient(); + 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. + NagpraInventoryClient client = new NagpraInventoryClient(); + 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 createNagpraInventoryInstance(identifier); + } + + /** + * Creates the nagprainventory instance. + * + * @param nagprainventoryNumber the inventory number + * @return the multipart output + * @throws Exception + */ + private PoxPayloadOut createNagpraInventoryInstance(String nagprainventoryNumber) throws Exception { + NagpraInventoriesCommon nagprainventoryCommon = new NagpraInventoriesCommon(); + nagprainventoryCommon.setInventoryNumber(nagprainventoryNumber); + + PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); + PayloadOutputPart commonPart = + multipart.addPart(new NagpraInventoryClient().getCommonPartName(), nagprainventoryCommon); + + logger.debug("to be created, nagprainventory common"); + logger.debug(objectAsXmlString(nagprainventoryCommon, NagpraInventoriesCommon.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 createNagpraInventoryInstance(identifier); + } + + @Override + protected NagpraInventoriesCommon updateInstance(NagpraInventoriesCommon commonPartObject) { + // TODO Auto-generated method stub + return null; + } + + @Override + protected void compareUpdatedInstances(NagpraInventoriesCommon original, NagpraInventoriesCommon updated) { + // TODO Auto-generated method stub + } +} diff --git a/services/nagprainventory/jaxb/pom.xml b/services/nagprainventory/jaxb/pom.xml new file mode 100644 index 000000000..c8606bcbe --- /dev/null +++ b/services/nagprainventory/jaxb/pom.xml @@ -0,0 +1,33 @@ + + + + org.collectionspace.services.nagprainventory + org.collectionspace.services + ${revision} + + + 4.0.0 + org.collectionspace.services.nagprainventory.jaxb + services.nagprainventory.jaxb + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + + + collectionspace-services-nagprainventory-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + \ No newline at end of file diff --git a/services/nagprainventory/jaxb/src/main/resources/nagprainventory_common.xsd b/services/nagprainventory/jaxb/src/main/resources/nagprainventory_common.xsd new file mode 100644 index 000000000..c17f9b9ad --- /dev/null +++ b/services/nagprainventory/jaxb/src/main/resources/nagprainventory_common.xsd @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/nagprainventory/pom.xml b/services/nagprainventory/pom.xml new file mode 100644 index 000000000..c3b79dcb6 --- /dev/null +++ b/services/nagprainventory/pom.xml @@ -0,0 +1,58 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + ${revision} + + + 4.0.0 + org.collectionspace.services.nagprainventory + services.nagprainventory + 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/nagprainventory/service/pom.xml b/services/nagprainventory/service/pom.xml new file mode 100644 index 000000000..931497ebf --- /dev/null +++ b/services/nagprainventory/service/pom.xml @@ -0,0 +1,89 @@ + + + + + org.collectionspace.services + org.collectionspace.services.nagprainventory + ${revision} + + + 4.0.0 + org.collectionspace.services.nagprainventory.service + services.nagprainventory.service + jar + + + + org.collectionspace.services + org.collectionspace.services.common + + + org.collectionspace.services + org.collectionspace.services.nagprainventory.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.nagprainventory.client + ${project.version} + + + + + junit + junit + test + + + org.testng + testng + test + + + + + 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-nagprainventory + + diff --git a/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/NagpraInventoryResource.java b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/NagpraInventoryResource.java new file mode 100644 index 000000000..d7f797613 --- /dev/null +++ b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/NagpraInventoryResource.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 + * + * 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.nagprainventory; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import org.collectionspace.services.client.NagpraInventoryClient; +import org.collectionspace.services.common.NuxeoBasedResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Path(NagpraInventoryClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") +public class NagpraInventoryResource extends NuxeoBasedResource { + + @Override + protected String getVersionString() { + final String lastChangeRevision = "$LastChangedRevision$"; + return lastChangeRevision; + } + + @Override + public String getServiceName() { + return NagpraInventoryClient.SERVICE_NAME; + } + + @Override + public Class getCommonPartClass() { + return NagpraInventoriesCommon.class; + } +} diff --git a/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryDocumentModelHandler.java b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryDocumentModelHandler.java new file mode 100644 index 000000000..6ea420243 --- /dev/null +++ b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryDocumentModelHandler.java @@ -0,0 +1,30 @@ +/* + * 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.nagprainventory.nuxeo; + +import org.collectionspace.services.nagprainventory.NagpraInventoriesCommon; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; + +/** + * NagpraInventoryDocumentModelHandler + */ +public class NagpraInventoryDocumentModelHandler extends NuxeoDocumentModelHandler {} diff --git a/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryValidatorHandler.java b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryValidatorHandler.java new file mode 100644 index 000000000..c8af0ef00 --- /dev/null +++ b/services/nagprainventory/service/src/main/java/org/collectionspace/services/nagprainventory/nuxeo/NagpraInventoryValidatorHandler.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.nagprainventory.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.nagprainventory.NagpraInventoriesCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Validation handler for NagpraInventory. Checks for the common part and inventoryNumber on create. + */ +public class NagpraInventoryValidatorHandler extends ValidatorHandlerImpl { + + private static final Logger logger = LoggerFactory.getLogger(NagpraInventoryValidatorHandler.class); + + private static final String COMMON_PART_MISSING = "Validation exception: nagprainventories_common part is missing"; + private static final String INVENTORY_NUMBER_MISSING = + "Validation exception: The nagpra inventory field \"inventoryNumber\" cannot be empty or missing"; + + @Override + protected Class getCommonPartClass() { + return NagpraInventoriesCommon.class; + } + + @Override + protected void handleCreate() throws InvalidDocumentException { + final NagpraInventoriesCommon inventory = (NagpraInventoriesCommon) getCommonPart(); + if (inventory == null) { + logger.error(COMMON_PART_MISSING); + throw new InvalidDocumentException(COMMON_PART_MISSING); + } + + final String inventoryNumber = inventory.getInventoryNumber(); + if (inventoryNumber == null || inventoryNumber.isEmpty()) { + logger.error(INVENTORY_NUMBER_MISSING); + throw new InvalidDocumentException(INVENTORY_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 5bdead9ee..d6c28b176 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -99,6 +99,7 @@ iterationreport chronology nagpraclaim + nagprainventory IntegrationTests PerformanceTests security