From: Richard Millet Date: Sat, 28 Aug 2010 00:02:23 +0000 (+0000) Subject: CSPACE-2338: Develop Basic Object Exit Code developed by Laramie and submitted as... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=f22bb60020f1402de43607c6b3b73b27e9994ea7;p=tmp%2Fjakarta-migration.git CSPACE-2338: Develop Basic Object Exit Code developed by Laramie and submitted as a patch. --- diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 473e1e88a..3140db166 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -99,6 +99,11 @@ org.collectionspace.services.loanout.service ${project.version} + + org.collectionspace.services + org.collectionspace.services.objectexit.service + ${project.version} + org.collectionspace.services org.collectionspace.services.location.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 5ea199c76..6be3537f2 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 @@ -29,6 +29,7 @@ import org.collectionspace.services.note.NoteResource; import org.collectionspace.services.intake.IntakeResource; import org.collectionspace.services.loanin.LoaninResource; import org.collectionspace.services.loanout.LoanoutResource; +import org.collectionspace.services.objectexit.ObjectExitResource; import org.collectionspace.services.location.LocationAuthorityResource; import org.collectionspace.services.movement.MovementResource; import org.collectionspace.services.report.ReportResource; @@ -84,6 +85,7 @@ public class CollectionSpaceJaxRsApplication extends Application { singletons.add(new IntakeResource()); singletons.add(new LoaninResource()); singletons.add(new LoanoutResource()); + singletons.add(new ObjectExitResource()); singletons.add(new LocationAuthorityResource()); singletons.add(new MovementResource()); singletons.add(new ReportResource()); diff --git a/services/build.xml b/services/build.xml index ce708f5e3..c230d6c0a 100644 --- a/services/build.xml +++ b/services/build.xml @@ -159,6 +159,7 @@ + @@ -182,6 +183,7 @@ + @@ -216,6 +218,7 @@ + diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java index 15446ec27..e682a0d5e 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java @@ -52,6 +52,7 @@ import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.testng.Assert; import org.testng.annotations.DataProvider; import org.w3c.dom.Document; @@ -176,7 +177,7 @@ public abstract class BaseServiceTest { * * @param expectedStatusCode A status code expected to be returned in the response. * - * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). + * @param reqType A type of service request (e.g. CREATE, DELETE). */ protected void testSetup( int expectedStatusCode, @@ -191,7 +192,7 @@ public abstract class BaseServiceTest { * specific call to a service does not fall within a set of valid status * codes for that service. * - * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). + * @param requestType A type of service request (e.g. CREATE, DELETE). * * @param statusCode The invalid status code that was returned in the response, * from submitting that type of request to the service. @@ -257,7 +258,7 @@ public abstract class BaseServiceTest { "Exception during HTTP " + method + " request to " + url + ":", e); } finally { - httpMethod.releaseConnection(); + if (httpMethod != null) httpMethod.releaseConnection(); } return statusCode; } @@ -273,12 +274,11 @@ public abstract class BaseServiceTest { * * @param mediaType The media type of the entity body to be submitted. * - * @param entity The contents of the entity body to be submitted. + * @param entityStr The contents of the entity body to be submitted. * * @return The status code received in the HTTP response. */ - protected int submitRequest(String method, String url, String mediaType, - String entityStr) { + protected int submitRequest(String method, String url, String mediaType, String entityStr) { int statusCode = 0; EntityEnclosingMethod httpMethod = null; try { @@ -299,7 +299,7 @@ public abstract class BaseServiceTest { "Exception during HTTP " + method + " request to " + url + ":", e); } finally { - httpMethod.releaseConnection(); + if (httpMethod != null) httpMethod.releaseConnection(); } return statusCode; } @@ -385,10 +385,13 @@ public abstract class BaseServiceTest { if (logger.isDebugEnabled()) { logger.debug("extracted part as str=\n" + partStr); } - obj = part.getBody(clazz, null); - if (logger.isDebugEnabled()) { - logger.debug("extracted part as obj=\n", - objectAsXmlString(obj, clazz)); + try { + obj = part.getBody(clazz, null); + if (logger.isDebugEnabled()) { + logger.debug("extracted part as obj="+objectAsXmlString(obj, clazz)); + } + } catch (Throwable t) { + logger.error("Could not get part body based on content and classname. "+ clazz.getName()+ " error: "+t); } } break; @@ -428,7 +431,7 @@ public abstract class BaseServiceTest { try { bais.close(); } catch (Exception e) { - if (logger.isDebugEnabled() == true) { + if (logger.isDebugEnabled()) { e.printStackTrace(); } } @@ -595,4 +598,14 @@ public abstract class BaseServiceTest { } return className; } + + public void assertStatusCode(ClientResponse res, String 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(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + + } diff --git a/services/common/src/main/config/services/tenant-bindings.xml b/services/common/src/main/config/services/tenant-bindings.xml index 42d0448f2..77d50335e 100644 --- a/services/common/src/main/config/services/tenant-bindings.xml +++ b/services/common/src/main/config/services/tenant-bindings.xml @@ -267,6 +267,47 @@ + + + + default-domain + + + org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler + + + org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler + + + + + + + + + + + authRefcurrentOwner + authRefdepositor + + + + + + + + + + @@ -1371,6 +1412,47 @@ + + + + + default-domain + + + org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler + + + org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler + + + + + + + + + + + authRefcurrentOwner + authRefdepositor + + + + + + + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java b/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java index 8c1acf1f4..4e5b1d4f2 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java @@ -34,6 +34,8 @@ import org.collectionspace.services.common.document.DocumentHandler; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class AbstractMultiPartCollectionSpaceResourceImpl. @@ -41,16 +43,16 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends AbstractCollectionSpaceResourceImpl { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Override public ServiceContextFactory getServiceContextFactory() { - return (ServiceContextFactory)MultipartServiceContextFactory.get(); + return MultipartServiceContextFactory.get(); } @Override public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { - DocumentHandler docHandler = createDocumentHandler(ctx, ctx.getCommonPartLabel(), - getCommonPartClass()); - return docHandler; + return createDocumentHandler(ctx, ctx.getCommonPartLabel(),getCommonPartClass()); } /** @@ -72,9 +74,7 @@ public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends if (ctx.getInput() != null) { commonPart = ctx.getInputPart(schemaName, commonClass); } - DocumentHandler docHandler = super.createDocumentHandler(ctx, commonPart); - - return docHandler; + return super.createDocumentHandler(ctx, commonPart); } /** diff --git a/services/pom.xml b/services/pom.xml index 26a3b906d..e8b649779 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -41,6 +41,7 @@ intake loanin loanout + objectexit location movement report