From: Michael Ritter Date: Tue, 30 Jul 2024 20:34:42 +0000 (-0400) Subject: Duty of Care Updates (#419) X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=5d9f1518753bd073eb280e1eed8e6beb7edcb46f;p=tmp%2Fjakarta-migration.git Duty of Care Updates (#419) --- diff --git a/services/dutyofcare/client/src/main/java/org/collectionspace/services/client/DutyofcareClient.java b/services/dutyofcare/client/src/main/java/org/collectionspace/services/client/DutyofcareClient.java index 56d7da228..2fac46ca9 100644 --- a/services/dutyofcare/client/src/main/java/org/collectionspace/services/client/DutyofcareClient.java +++ b/services/dutyofcare/client/src/main/java/org/collectionspace/services/client/DutyofcareClient.java @@ -14,14 +14,14 @@ */ package org.collectionspace.services.client; -import org.collectionspace.services.dutyofcare.DutyofcaresCommon; +import org.collectionspace.services.dutyofcare.DutiesOfCareCommon; /** * DutyofcareClient.java */ -public class DutyofcareClient extends AbstractCommonListPoxServiceClientImpl { +public class DutyofcareClient extends AbstractCommonListPoxServiceClientImpl { - 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 + "/"; diff --git a/services/dutyofcare/client/src/test/java/org/collectionspace/services/client/DutyofcareServiceTest.java b/services/dutyofcare/client/src/test/java/org/collectionspace/services/client/DutyofcareServiceTest.java index 67f5d561c..a3f88afef 100644 --- a/services/dutyofcare/client/src/test/java/org/collectionspace/services/client/DutyofcareServiceTest.java +++ b/services/dutyofcare/client/src/test/java/org/collectionspace/services/client/DutyofcareServiceTest.java @@ -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 { +public class DutyofcareServiceTest extends AbstractPoxServiceTestImpl { 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 - - + + + + + + + - + diff --git a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/DutyofcareResource.java b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/DutyofcareResource.java index 0ce4b6e30..54a04c408 100644 --- a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/DutyofcareResource.java +++ b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/DutyofcareResource.java @@ -48,7 +48,7 @@ public class DutyofcareResource extends NuxeoBasedResource { } @Override - public Class getCommonPartClass() { - return DutyofcaresCommon.class; + public Class getCommonPartClass() { + return DutiesOfCareCommon.class; } } diff --git a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareDocumentModelHandler.java b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareDocumentModelHandler.java index 6a0297446..299f37ef3 100644 --- a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareDocumentModelHandler.java +++ b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareDocumentModelHandler.java @@ -21,10 +21,10 @@ */ 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 {} +public class DutyofcareDocumentModelHandler extends NuxeoDocumentModelHandler {} diff --git a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareValidatorHandler.java b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareValidatorHandler.java index ece48694e..d662dceb5 100644 --- a/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareValidatorHandler.java +++ b/services/dutyofcare/service/src/main/java/org/collectionspace/services/dutyofcare/nuxeo/DutyofcareValidatorHandler.java @@ -14,16 +14,51 @@ */ 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 { + + 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 {} }