]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
Duty of Care Updates (#419)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Tue, 30 Jul 2024 20:34:42 +0000 (16:34 -0400)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2024 20:34:42 +0000 (16:34 -0400)
services/dutyofcare/client/src/main/java/org/collectionspace/services/client/DutyofcareClient.java
services/dutyofcare/client/src/test/java/org/collectionspace/services/client/DutyofcareServiceTest.java
services/dutyofcare/jaxb/src/main/resources/dutiesofcare_common.xsd [moved from services/dutyofcare/jaxb/src/main/resources/dutyofcares_common.xsd with 89% similarity]
services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/DutyofcareResource.java
services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareDocumentModelHandler.java
services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareValidatorHandler.java

index 56d7da228a045b36dd558cb1767279de07f86581..2fac46ca9f3e4e03882a6e208c4cfc56146a0199 100644 (file)
  */
 package org.collectionspace.services.client;
 
-import org.collectionspace.services.dutyofcare.DutyofcaresCommon;
+import org.collectionspace.services.dutyofcare.DutiesOfCareCommon;
 
 /**
  * DutyofcareClient.java
  */
-public class DutyofcareClient extends AbstractCommonListPoxServiceClientImpl<DutyofcareProxy, DutyofcaresCommon> {
+public class DutyofcareClient extends AbstractCommonListPoxServiceClientImpl<DutyofcareProxy, DutiesOfCareCommon> {
 
-    public static final String SERVICE_NAME = "dutyofcares";
+    public static final String SERVICE_NAME = "dutiesofcare";
     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 + "/";
index 67f5d561cb3d6ace54c1e3b1ab9b4647177ce258..a3f88afef92f6bfe172974ef2cec67af89fa49af 100644 (file)
@@ -25,20 +25,20 @@ package org.collectionspace.services.client;
 import javax.ws.rs.core.Response;
 import org.collectionspace.services.client.test.AbstractPoxServiceTestImpl;
 import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.dutyofcare.DutyofcaresCommon;
+import org.collectionspace.services.dutyofcare.DutiesOfCareCommon;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 
-public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, DutyofcaresCommon> {
+public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, DutiesOfCareCommon> {
 
     private final Logger logger = LoggerFactory.getLogger(DutyofcareServiceTest.class);
 
     /** The service path component. */
-    final String SERVICE_NAME = "dutyofcares";
+    final String SERVICE_NAME = "dutiesofcare";
 
-    final String SERVICE_PATH_COMPONENT = "dutyofcares";
+    final String SERVICE_PATH_COMPONENT = "dutiesofcare";
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -156,9 +156,9 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
 
         // Get the common part of the response and verify that it is not null.
         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
-        DutyofcaresCommon dutyofcareCommon = null;
+        DutiesOfCareCommon dutyofcareCommon = null;
         if (payloadInputPart != null) {
-            dutyofcareCommon = (DutyofcaresCommon) payloadInputPart.getBody();
+            dutyofcareCommon = (DutiesOfCareCommon) payloadInputPart.getBody();
         }
         Assert.assertNotNull(dutyofcareCommon);
     }
@@ -265,9 +265,9 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
 
         // Extract the common part from the response.
         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
-        DutyofcaresCommon dutyofcareCommon = null;
+        DutiesOfCareCommon dutyofcareCommon = null;
         if (payloadInputPart != null) {
-            dutyofcareCommon = (DutyofcaresCommon) payloadInputPart.getBody();
+            dutyofcareCommon = (DutiesOfCareCommon) payloadInputPart.getBody();
         }
         Assert.assertNotNull(dutyofcareCommon);
 
@@ -275,7 +275,7 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
         dutyofcareCommon.setDutyOfCareNumber("updated-" + dutyofcareCommon.getDutyOfCareNumber());
 
         logger.debug("to be updated object");
-        logger.debug(objectAsXmlString(dutyofcareCommon, DutyofcaresCommon.class));
+        logger.debug(objectAsXmlString(dutyofcareCommon, DutiesOfCareCommon.class));
 
         setupUpdate();
 
@@ -302,9 +302,9 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
 
         // Extract the updated common part from the response.
         payloadInputPart = input.getPart(client.getCommonPartName());
-        DutyofcaresCommon updatedDutyofcareCommon = null;
+        DutiesOfCareCommon updatedDutyofcareCommon = null;
         if (payloadInputPart != null) {
-            updatedDutyofcareCommon = (DutyofcaresCommon) payloadInputPart.getBody();
+            updatedDutyofcareCommon = (DutiesOfCareCommon) payloadInputPart.getBody();
         }
         Assert.assertNotNull(updatedDutyofcareCommon);
 
@@ -461,14 +461,14 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
      * @throws Exception
      */
     private PoxPayloadOut createDutyofcareInstance(String dutyofcareNumber) throws Exception {
-        DutyofcaresCommon dutyofcareCommon = new DutyofcaresCommon();
+        DutiesOfCareCommon dutyofcareCommon = new DutiesOfCareCommon();
         dutyofcareCommon.setDutyOfCareNumber(dutyofcareNumber);
 
         PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
         PayloadOutputPart commonPart = multipart.addPart(new DutyofcareClient().getCommonPartName(), dutyofcareCommon);
 
         logger.debug("to be created, dutyofcare common");
-        logger.debug(objectAsXmlString(dutyofcareCommon, DutyofcaresCommon.class));
+        logger.debug(objectAsXmlString(dutyofcareCommon, DutiesOfCareCommon.class));
 
         return multipart;
     }
@@ -485,13 +485,13 @@ public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
     }
 
     @Override
-    protected DutyofcaresCommon updateInstance(DutyofcaresCommon commonPartObject) {
+    protected DutiesOfCareCommon updateInstance(DutiesOfCareCommon commonPartObject) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    protected void compareUpdatedInstances(DutyofcaresCommon original, DutyofcaresCommon updated) {
+    protected void compareUpdatedInstances(DutiesOfCareCommon original, DutiesOfCareCommon updated) {
         // TODO Auto-generated method stub
     }
 }
similarity index 89%
rename from services/dutyofcare/jaxb/src/main/resources/dutyofcares_common.xsd
rename to services/dutyofcare/jaxb/src/main/resources/dutiesofcare_common.xsd
index 4c99b46603496393740f77a89c4d2794d5449a19..46517dc65bbcd6619742112d560376b6ac283b72 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 
 <!--
-    Dutyofcare schema (XSD)
+    Duty-of-Care schema (XSD)
     Entity  : Dutyofcare
     Part    : Common
     Used for: JAXB binding between XML and Java objects
   version="0.1"
 >
 
-  <!--
-      Avoid XmlRootElement nightmare:
-      See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
-  -->
-
   <!--  Dutyofcare Information Group -->
-  <xs:element name="dutyofcares_common">
+  <xs:element name="dutiesofcare_common">
+    <xs:annotation>
+      <xs:appinfo>
+        <jaxb:class name="DutiesOfCareCommon" />
+      </xs:appinfo>
+    </xs:annotation>
+
     <xs:complexType>
       <xs:sequence>
         <xs:element name="dutyOfCareNumber" type="xs:string"/>
         <xs:element name="dutyOfCareDate" type="xs:date"/>
-        <xs:element name="title" type="xs:string"/>
+        <xs:element name="dutyOfCareTitle" type="xs:string"/>
 
         <xs:element name="notes" type="notes"/>
         <xs:element name="partiesInvolvedGroupList" type="partiesInvolvedGroupList"/>
index 0ce4b6e30c981be9d3474419d0354c316919be95..54a04c408b67df68e1a1d1271fc97c72e6fe45e2 100644 (file)
@@ -48,7 +48,7 @@ public class DutyofcareResource extends NuxeoBasedResource {
     }
 
     @Override
-    public Class<DutyofcaresCommon> getCommonPartClass() {
-        return DutyofcaresCommon.class;
+    public Class<DutiesOfCareCommon> getCommonPartClass() {
+        return DutiesOfCareCommon.class;
     }
 }
index 6a029744626e0ee9ddc0919f41442697c9c14c5b..299f37ef3aaa229fa671e3871dd78587b4daf5bd 100644 (file)
  */
 package org.collectionspace.services.dutyofcare.nuxeo;
 
-import org.collectionspace.services.dutyofcare.DutyofcaresCommon;
+import org.collectionspace.services.dutyofcare.DutiesOfCareCommon;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 
 /**
  * DutyofcareDocumentModelHandler
  */
-public class DutyofcareDocumentModelHandler extends NuxeoDocumentModelHandler<DutyofcaresCommon> {}
+public class DutyofcareDocumentModelHandler extends NuxeoDocumentModelHandler<DutiesOfCareCommon> {}
index ece48694e3edc14669cb140071ee8d24ae816cee..d662dceb5244c51666306f4636873b5fda3e7ce8 100644 (file)
  */
 package org.collectionspace.services.dutyofcare.nuxeo;
 
-import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.DocumentHandler.Action;
+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.ValidatorHandler;
+import org.collectionspace.services.common.document.ValidatorHandlerImpl;
+import org.collectionspace.services.dutyofcare.DutiesOfCareCommon;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class DutyofcareValidatorHandler implements ValidatorHandler {
+public class DutyofcareValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {
+
+    private final Logger logger = LoggerFactory.getLogger(DutyofcareValidatorHandler.class);
+
+    private static final String COMMON_PART_MISSING = "Validation exception: dutiesofcare_common part is missing";
+    private static final String DOCUMENTATION_NUMBER_MISSING =
+            "Validation exception: The duty of care field \"dutyOfCareNumber\" cannot be empty or missing";
 
     @Override
-    public void validate(Action action, ServiceContext ctx) throws InvalidDocumentException {
-        // TODO Auto-generated method stub
-        System.out.println("DutyofcareValidatorHandler executed.");
+    protected Class<?> getCommonPartClass() {
+        return DutiesOfCareCommon.class;
     }
+
+    @Override
+    protected void handleCreate() throws InvalidDocumentException {
+        final DutiesOfCareCommon common = (DutiesOfCareCommon) getCommonPart();
+        if (common == null) {
+            logger.error(COMMON_PART_MISSING);
+            throw new InvalidDocumentException(COMMON_PART_MISSING);
+        }
+
+        final String dutyOfCareNumber = common.getDutyOfCareNumber();
+        if (dutyOfCareNumber == null || dutyOfCareNumber.isEmpty()) {
+            logger.error(DOCUMENTATION_NUMBER_MISSING);
+            throw new InvalidDocumentException(DOCUMENTATION_NUMBER_MISSING);
+        }
+    }
+
+    @Override
+    protected void handleGet() throws InvalidDocumentException {}
+
+    @Override
+    protected void handleGetAll() throws InvalidDocumentException {}
+
+    @Override
+    protected void handleUpdate() throws InvalidDocumentException {}
+
+    @Override
+    protected void handleDelete() throws InvalidDocumentException {}
 }