From b5c33235e313822877a4da9a5fab6b4b9dbcab8b Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Fri, 5 Jul 2024 12:36:39 -0600 Subject: [PATCH] DRYD-1390: Consultation Procedure (#414) --- services/JaxRsServiceProvider/pom.xml | 5 + .../CollectionSpaceJaxRsApplication.java | 2 + .../db/postgresql/load_id_generators.sql | 36 ++++++ services/consultation/build.xml | 106 ++++++++++++++++++ services/consultation/client/pom.xml | 61 ++++++++++ .../services/client/ConsultationClient.java | 51 +++++++++ .../services/client/ConsultationProxy.java | 27 +++++ services/consultation/jaxb/pom.xml | 33 ++++++ .../main/resources/consultations_common.xsd | 61 ++++++++++ services/consultation/pom.xml | 58 ++++++++++ services/consultation/service/pom.xml | 89 +++++++++++++++ .../consultation/ConsultationResource.java | 49 ++++++++ .../ConsultationDocumentModelHandler.java | 30 +++++ .../nuxeo/ConsultationValidatorHandler.java | 64 +++++++++++ services/pom.xml | 1 + 15 files changed, 673 insertions(+) create mode 100644 services/consultation/build.xml create mode 100644 services/consultation/client/pom.xml create mode 100644 services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationClient.java create mode 100644 services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationProxy.java create mode 100644 services/consultation/jaxb/pom.xml create mode 100644 services/consultation/jaxb/src/main/resources/consultations_common.xsd create mode 100644 services/consultation/pom.xml create mode 100644 services/consultation/service/pom.xml create mode 100644 services/consultation/service/src/main/java/org/collectionspace/services/consultation/ConsultationResource.java create mode 100644 services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationDocumentModelHandler.java create mode 100644 services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationValidatorHandler.java diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 0b3a70ebe..a1b61e04d 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -446,6 +446,11 @@ org.collectionspace.services.heldintrust.service ${project.version} + + org.collectionspace.services + org.collectionspace.services.consultation.service + ${project.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/consultation/client/pom.xml b/services/consultation/client/pom.xml new file mode 100644 index 000000000..848d86dca --- /dev/null +++ b/services/consultation/client/pom.xml @@ -0,0 +1,61 @@ + + + + org.collectionspace.services + org.collectionspace.services.consultation + ${revision} + + + 4.0.0 + org.collectionspace.services.consultation.client + services.consultation.client + + + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.consultation.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-consultation-client + + \ No newline at end of file diff --git a/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationClient.java b/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationClient.java new file mode 100644 index 000000000..10809acc4 --- /dev/null +++ b/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationClient.java @@ -0,0 +1,51 @@ +/* + * 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.consultation.ConsultationsCommon; + +/** + * ConsultationClient.java + */ +public class ConsultationClient extends AbstractCommonListPoxServiceClientImpl { + + public static final String SERVICE_NAME = "consultations"; + 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 ConsultationClient() throws Exception { + super(); + } + + public ConsultationClient(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 ConsultationProxy.class; + } +} diff --git a/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationProxy.java b/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationProxy.java new file mode 100644 index 000000000..b36b2a0f7 --- /dev/null +++ b/services/consultation/client/src/main/java/org/collectionspace/services/client/ConsultationProxy.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; + +/** + * ConsultationProxy.java + */ +@Path(ConsultationClient.SERVICE_PATH_PROXY) +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface ConsultationProxy extends CollectionSpaceCommonListPoxProxy {} diff --git a/services/consultation/jaxb/pom.xml b/services/consultation/jaxb/pom.xml new file mode 100644 index 000000000..98cc85558 --- /dev/null +++ b/services/consultation/jaxb/pom.xml @@ -0,0 +1,33 @@ + + + + org.collectionspace.services.consultation + org.collectionspace.services + ${revision} + + + 4.0.0 + org.collectionspace.services.consultation.jaxb + services.consultation.jaxb + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + + + collectionspace-services-consultation-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + \ No newline at end of file diff --git a/services/consultation/jaxb/src/main/resources/consultations_common.xsd b/services/consultation/jaxb/src/main/resources/consultations_common.xsd new file mode 100644 index 000000000..0f1af8bb8 --- /dev/null +++ b/services/consultation/jaxb/src/main/resources/consultations_common.xsd @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/consultation/pom.xml b/services/consultation/pom.xml new file mode 100644 index 000000000..d32e28c08 --- /dev/null +++ b/services/consultation/pom.xml @@ -0,0 +1,58 @@ + + + + org.collectionspace.services + org.collectionspace.services.main + ${revision} + + + 4.0.0 + org.collectionspace.services.consultation + services.consultation + 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/consultation/service/pom.xml b/services/consultation/service/pom.xml new file mode 100644 index 000000000..67491afc7 --- /dev/null +++ b/services/consultation/service/pom.xml @@ -0,0 +1,89 @@ + + + + + org.collectionspace.services + org.collectionspace.services.consultation + ${revision} + + + 4.0.0 + org.collectionspace.services.consultation.service + services.consultation.service + jar + + + + org.collectionspace.services + org.collectionspace.services.common + + + org.collectionspace.services + org.collectionspace.services.consultation.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.consultation.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-consultation + + diff --git a/services/consultation/service/src/main/java/org/collectionspace/services/consultation/ConsultationResource.java b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/ConsultationResource.java new file mode 100644 index 000000000..4333cc6d0 --- /dev/null +++ b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/ConsultationResource.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.consultation; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import org.collectionspace.services.client.ConsultationClient; +import org.collectionspace.services.common.NuxeoBasedResource; + +@Path(ConsultationClient.SERVICE_PATH) +@Consumes("application/xml") +@Produces("application/xml") +public class ConsultationResource extends NuxeoBasedResource { + + @Override + protected String getVersionString() { + return "$LastChangedRevision$"; + } + + @Override + public String getServiceName() { + return ConsultationClient.SERVICE_NAME; + } + + @Override + public Class getCommonPartClass() { + return ConsultationsCommon.class; + } +} diff --git a/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationDocumentModelHandler.java b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationDocumentModelHandler.java new file mode 100644 index 000000000..1fd08da94 --- /dev/null +++ b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationDocumentModelHandler.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.consultation.nuxeo; + +import org.collectionspace.services.consultation.ConsultationsCommon; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; + +/** + * ConsultationDocumentModelHandler + */ +public class ConsultationDocumentModelHandler extends NuxeoDocumentModelHandler {} diff --git a/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationValidatorHandler.java b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationValidatorHandler.java new file mode 100644 index 000000000..fcc91c599 --- /dev/null +++ b/services/consultation/service/src/main/java/org/collectionspace/services/consultation/nuxeo/ConsultationValidatorHandler.java @@ -0,0 +1,64 @@ +/* + * 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.consultation.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.consultation.ConsultationsCommon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConsultationValidatorHandler extends ValidatorHandlerImpl { + + private static final Logger logger = LoggerFactory.getLogger(ConsultationValidatorHandler.class); + + private static final String COMMON_PART_MISSING = "Validation exception: nagprainventories_common part is missing"; + private static final String CONSULTATION_NUMBER_MISSING = + "Validation exception: The consultation field \"consultationNumber\" cannot be empty or missing"; + + @Override + protected Class getCommonPartClass() { + return ConsultationsCommon.class; + } + + @Override + protected void handleCreate() throws InvalidDocumentException { + final ConsultationsCommon consultation = (ConsultationsCommon) getCommonPart(); + if (consultation == null) { + logger.error(COMMON_PART_MISSING); + throw new InvalidDocumentException(COMMON_PART_MISSING); + } + + final String consultationNumber = consultation.getConsultationNumber(); + if (consultationNumber == null || consultationNumber.isEmpty()) { + logger.error(CONSULTATION_NUMBER_MISSING); + throw new InvalidDocumentException(CONSULTATION_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 ea2552fc9..5ca7ab40e 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -103,6 +103,7 @@ nagprainventory summarydocumentation heldintrust + consultation IntegrationTests PerformanceTests security -- 2.47.3