From 115c327c9c8a2de7adc2996d185b038dcc32410e Mon Sep 17 00:00:00 2001 From: remillet Date: Mon, 3 Apr 2017 16:58:37 -0700 Subject: [PATCH] CSPACE-6909: All UCB botgarden service level procedures added and tested. --- .../botgarden/CreateVersionListener.java | 3 +- .../botgarden/DeleteDeadLocationListener.java | 5 +- .../botgarden/UpdateAccessCodeListener.java | 3 +- .../botgarden/UpdateDeadFlagListener.java | 3 +- .../botgarden/UpdateLocationListener.java | 3 +- .../botgarden/UpdateRareFlagListener.java | 7 +- .../botgarden/UpdateStyledNameListener.java | 7 +- .../UpdateFormattedDisplayNameListener.java | 4 +- .../listener/UpdateImageDerivatives.java | 2 +- .../AbstractUpdateObjectLocationValues.java | 29 ++--- .../listener/UpdateRelationsOnDelete.java | 3 +- .../CollectionSpaceJaxRsApplication.java | 4 +- .../client/test/AccountServiceTest.java | 26 ----- .../common/vocabulary/AuthorityResource.java | 39 +++---- .../client/test/PermissionServiceTest.java | 68 ++++++++--- .../jaxb/src/main/resources/bindings.xjb | 29 +++++ .../jaxb/src/main/resources/roles.xsd | 13 +-- .../main/resources/schemas/batch_common.xsd | 6 +- services/batch/build.xml | 2 +- services/batch/pom.xml | 1 - .../batch/AbstractBatchInvocable.java | 6 +- .../services/batch/BatchInvocable.java | 4 +- .../batch/nuxeo/AbstractBatchJob.java | 11 +- .../ClearLocationLabelRequestBatchJob.java | 1 + .../ClearPotTagLabelRequestBatchJob.java | 1 + .../ClearVoucherLabelRequestBatchJob.java | 1 + .../batch/nuxeo/CreateVoucherBatchJob.java | 1 + .../batch/nuxeo/FormatTaxonBatchJob.java | 1 + .../nuxeo/FormatVoucherNameBatchJob.java | 1 + .../nuxeo/MergeAuthorityItemsBatchJob.java | 3 +- .../batch/nuxeo/ReindexFullTextBatchJob.java | 5 +- .../batch/nuxeo/UpdateDeadFlagBatchJob.java | 1 + .../test/AbstractAuthorityServiceTest.java | 32 ++++- .../test/AbstractPoxServiceTestImpl.java | 56 ++++++++- .../client/test/AbstractServiceTestImpl.java | 45 +++++++- .../services/client/test/BaseServiceTest.java | 109 +++++++++--------- .../botgarden-tenant-bindings.delta.xml | 18 +++ .../common/CSWebApplicationException.java | 2 +- .../services/common/NuxeoBasedResource.java | 4 +- .../services/common/ResourceMapHolder.java | 5 +- .../listener/AbstractCSEventListenerImpl.java | 105 ++++++++++------- .../hyperjaxb/src/main/resources/bindings.xjb | 18 +++ .../test/MaterialAuthorityServiceTest.java | 12 +- services/pom.xml | 3 + .../collectionspace-client.properties | 6 + .../client/test/PottagServiceTest.java | 42 +++---- .../collectionspace-client.properties | 6 + .../client/test/PropagationAuthRefsTest.java | 8 +- .../main/resources/propagations-common.xsd | 1 + .../client/test/VocabularyServiceTest.java | 10 +- 50 files changed, 496 insertions(+), 279 deletions(-) rename 3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/{ucb => naturalhistory}/UpdateFormattedDisplayNameListener.java (97%) create mode 100644 services/authorization/jaxb/src/main/resources/bindings.xjb create mode 100644 services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml create mode 100644 services/hyperjaxb/src/main/resources/bindings.xjb create mode 100644 services/pottag/client/src/main/resources/collectionspace-client.properties create mode 100644 services/propagation/client/src/main/resources/collectionspace-client.properties diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java index b380ae4e2..a30c848e7 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java @@ -17,10 +17,11 @@ public class CreateVersionListener extends AbstractCSEventListenerImpl { final Log logger = LogFactory.getLog(CreateVersionListener.class); + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; if (ec.hasProperty(SKIP_PROPERTY) && ((Boolean) ec.getProperty(SKIP_PROPERTY))) { diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java index e8d14949b..45436ad9b 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java @@ -18,10 +18,11 @@ public class DeleteDeadLocationListener extends AbstractCSEventListenerImpl { /* * Delete dead locations. */ - public void handleEvent(Event event) { + @Override + public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java index 36beffc0a..64989d1ad 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java @@ -48,10 +48,11 @@ public class UpdateAccessCodeListener extends AbstractCSEventListenerImpl { private static final String TAXONOMIC_IDENT_GROUP_LIST_FIELD_NAME = TAXON_PATH_ELEMENTS[0]; private static final String TAXON_FIELD_NAME = TAXON_PATH_ELEMENTS[2]; + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java index 751ab8e93..58c61f25e 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java @@ -24,10 +24,11 @@ public class UpdateDeadFlagListener extends AbstractCSEventListenerImpl { /* * Set the dead flag and dead date on collectionobjects related to a new or modified movement record. */ + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java index c07711e89..49e2f3aca 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java @@ -25,10 +25,11 @@ public class UpdateLocationListener extends AbstractCSEventListenerImpl { *
  • Set the previousLocation field to the previous value of the currentLocation field
  • * */ + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java index 3c7129ac8..1f04c5320 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java @@ -6,8 +6,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.collectionspace.services.batch.nuxeo.UpdateRareFlagBatchJob; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants; import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants; @@ -42,10 +40,11 @@ public class UpdateRareFlagListener extends AbstractCSEventListenerImpl { private static final String PLANT_ATTRIBUTES_GROUP_LIST_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[0]; private static final String CONSERVATION_CATEGORY_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[2]; + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); @@ -191,7 +190,7 @@ public class UpdateRareFlagListener extends AbstractCSEventListenerImpl { } private UpdateRareFlagBatchJob createUpdater() { - ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); + ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); UpdateRareFlagBatchJob updater = new UpdateRareFlagBatchJob(); updater.setResourceMap(resourceMap); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java index 7208e89ad..1952efc32 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java @@ -5,8 +5,6 @@ import org.apache.commons.logging.LogFactory; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.collectionspace.services.batch.nuxeo.FormatVoucherNameBatchJob; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.loanout.nuxeo.LoanoutBotGardenConstants; @@ -24,10 +22,11 @@ public class UpdateStyledNameListener extends AbstractCSEventListenerImpl { final Log logger = LogFactory.getLog(UpdateStyledNameListener.class); + @Override public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); @@ -83,7 +82,7 @@ public class UpdateStyledNameListener extends AbstractCSEventListenerImpl { } private FormatVoucherNameBatchJob createFormatter() { - ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); + ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); FormatVoucherNameBatchJob formatter = new FormatVoucherNameBatchJob(); formatter.setResourceMap(resourceMap); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/ucb/UpdateFormattedDisplayNameListener.java b/3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/naturalhistory/UpdateFormattedDisplayNameListener.java similarity index 97% rename from 3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/ucb/UpdateFormattedDisplayNameListener.java rename to 3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/naturalhistory/UpdateFormattedDisplayNameListener.java index 5663176af..fcf6a4a69 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/ucb/UpdateFormattedDisplayNameListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/naturalhistory/UpdateFormattedDisplayNameListener.java @@ -1,4 +1,4 @@ -package org.collectionspace.services.listener.ucb; +package org.collectionspace.services.listener.naturalhistory; import java.util.HashMap; import java.util.List; @@ -36,7 +36,7 @@ public class UpdateFormattedDisplayNameListener extends AbstractCSEventListenerI public void handleEvent(Event event) { EventContext ec = event.getContext(); - if (ec instanceof DocumentEventContext) { + if (isRegistered(event) && ec instanceof DocumentEventContext) { DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updateimagederivatives/src/main/java/org/collectionspace/services/listener/UpdateImageDerivatives.java b/3rdparty/nuxeo/nuxeo-platform-listener/updateimagederivatives/src/main/java/org/collectionspace/services/listener/UpdateImageDerivatives.java index 240362866..2d2164e12 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updateimagederivatives/src/main/java/org/collectionspace/services/listener/UpdateImageDerivatives.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updateimagederivatives/src/main/java/org/collectionspace/services/listener/UpdateImageDerivatives.java @@ -113,7 +113,7 @@ public class UpdateImageDerivatives extends AbstractCSEventListenerImpl { EventContext eventContext = event.getContext(); if (eventContext != null) { - if (eventContext instanceof DocumentEventContext) { + if (isRegistered(event) && eventContext instanceof DocumentEventContext) { result = true; } } diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java index 9430b3e92..68cb1432a 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java @@ -7,6 +7,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.collectionspace.services.client.LocationAuthorityClient; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants; @@ -18,9 +19,7 @@ import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper; import org.collectionspace.services.nuxeo.listener.AbstractCSEventListenerImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.common.collections.ScopeType; -import org.nuxeo.common.collections.ScopedMap; -import org.nuxeo.ecm.core.api.ClientException; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; @@ -138,7 +137,7 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent } @Override - public void handleEvent(Event event) throws ClientException { + public void handleEvent(Event event) { // Ensure we have all the event data we need to proceed. if (isRegistered(event) == false || !(event.getContext() instanceof DocumentEventContext)) { if (logger.isTraceEnabled() == true) { @@ -147,7 +146,7 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent return; } - Map params = this.getParams(event); + Map params = this.getParams(event); // Will be null if no params were configured. logEvent(event, "Update Location"); DocumentEventContext docEventContext = (DocumentEventContext) event.getContext(); @@ -302,7 +301,7 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent * related to the Movement record. */ private Set getCollectionObjectCsidsRelatedToMovement(String movementCsid, - CoreSessionInterface coreSession) throws ClientException { + CoreSessionInterface coreSession) { Set csids = new HashSet<>(); @@ -387,13 +386,9 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent boolean isActiveDocument = false; if (docModel != null) { - try { - if (!docModel.getCurrentLifeCycleState().contains(WorkflowClient.WORKFLOWSTATE_DELETED)) { - isActiveDocument = true; - } - } catch (ClientException ce) { - logger.warn("Error while identifying whether document is an active document: ", ce); - } + if (!docModel.getCurrentLifeCycleState().contains(WorkflowClient.WORKFLOWSTATE_DELETED)) { + isActiveDocument = true; + } // // If doc model is the target of the "aboutToBeRemoved" event, mark it as not active. // @@ -495,8 +490,7 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent */ protected String getMostRecentLocation(Event event, CoreSessionInterface session, String collectionObjectCsid, - boolean isAboutToBeRemovedEvent, String eventMovementCsid) - throws ClientException { + boolean isAboutToBeRemovedEvent, String eventMovementCsid) { // // Assume we can determine the most recent location by creating an indeterminate result // @@ -739,7 +733,7 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent * and related document types. */ protected static String getCsidForDesiredDocTypeFromRelation(DocumentModel relationDocModel, - String desiredDocType, String relatedDocType) throws ClientException { + String desiredDocType, String relatedDocType) { String csid = null; String subjectDocType = (String) relationDocModel.getProperty(RELATIONS_COMMON_SCHEMA, SUBJECT_DOCTYPE_PROPERTY); String objectDocType = (String) relationDocModel.getProperty(RELATIONS_COMMON_SCHEMA, OBJECT_DOCTYPE_PROPERTY); @@ -768,6 +762,5 @@ public abstract class AbstractUpdateObjectLocationValues extends AbstractCSEvent */ protected abstract boolean updateCollectionObjectLocation(DocumentModel collectionObjectDocModel, DocumentModel movmentDocModel, - String movementRecordsLocation) - throws ClientException; + String movementRecordsLocation); } \ No newline at end of file diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java b/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java index 2e1477d5e..861838cbe 100644 --- a/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java +++ b/3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/src/main/java/org/collectionspace/services/listener/UpdateRelationsOnDelete.java @@ -15,7 +15,6 @@ import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.impl.LifeCycleFilter; import org.nuxeo.ecm.core.event.Event; import org.nuxeo.ecm.core.event.EventContext; -import org.nuxeo.ecm.core.event.EventListener; import org.nuxeo.ecm.core.event.impl.DocumentEventContext; public class UpdateRelationsOnDelete extends AbstractCSEventListenerImpl { @@ -35,7 +34,7 @@ public class UpdateRelationsOnDelete extends AbstractCSEventListenerImpl { EventContext eventContext = event.getContext(); - if (isDocumentSoftDeletedEvent(eventContext)) { + if (isRegistered(event) && isDocumentSoftDeletedEvent(eventContext)) { logger.trace("A soft deletion event was received by UpdateRelationsOnDelete ..."); 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 112e365a4..067d2fae0 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 @@ -25,8 +25,6 @@ package org.collectionspace.services.jaxrs; import org.collectionspace.services.account.AccountResource; import org.collectionspace.services.account.TenantResource; import org.collectionspace.services.blob.BlobResource; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.collectionobject.CollectionObjectResource; import org.collectionspace.services.id.IDResource; import org.collectionspace.services.media.MediaResource; @@ -168,7 +166,7 @@ public class CollectionSpaceJaxRsApplication extends Application } @Override - public ResourceMap getResourceMap() { + public ResourceMap getResourceMap() { return resourceMap; } diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java index 3887bbcc7..e1ae0fffa 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java @@ -384,32 +384,6 @@ public class AccountServiceTest extends AbstractServiceTestImpl return tempResult.CSID; } - protected String lookupParentCSID(ServiceContext ctx, String parentspecifier, String method, + protected String lookupParentCSID(ServiceContext ctx, String parentspecifier, String method, String op, UriInfo uriInfo) throws Exception { CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(ctx, parentspecifier, method, op, uriInfo); @@ -236,7 +236,7 @@ public abstract class AuthorityResource private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer( - ServiceContext existingCtx, // Ok to be null + ServiceContext existingCtx, // Ok to be null String parentIdentifier, String method, String op, @@ -630,7 +630,7 @@ public abstract class AuthorityResource * @return * @throws Exception */ - protected Response createAuthorityItem(ServiceContext ctx, String parentIdentifier, + protected Response createAuthorityItem(ServiceContext ctx, String parentIdentifier, boolean shouldUpdateRevNumber, boolean isProposed, boolean isSasItem) throws Exception { @@ -662,7 +662,7 @@ public abstract class AuthorityResource * @return * @throws Exception */ - public Response createAuthorityItemWithParentContext(ServiceContext parentCtx, + public Response createAuthorityItemWithParentContext(ServiceContext parentCtx, String parentIdentifier, PoxPayloadIn input, boolean shouldUpdateRevNumber, @@ -742,7 +742,7 @@ public abstract class AuthorityResource PoxPayloadOut result = null; try { - ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); result = updateItemWorkflowWithTransition(ctx, parentIdentifier, itemIdentifier, transition, AuthorityServiceUtils.UPDATE_REV); } catch (Exception e) { @@ -761,7 +761,7 @@ public abstract class AuthorityResource * @return * @throws DocumentReferenceException */ - public PoxPayloadOut updateItemWorkflowWithTransition(ServiceContext existingContext, + public PoxPayloadOut updateItemWorkflowWithTransition(ServiceContext existingContext, String parentIdentifier, String itemIdentifier, String transition, @@ -818,7 +818,7 @@ public abstract class AuthorityResource } private PoxPayloadOut getAuthorityItem( - ServiceContext ctx, + ServiceContext ctx, String parentIdentifier, String itemIdentifier) throws Exception { PoxPayloadOut result = null; @@ -852,12 +852,12 @@ public abstract class AuthorityResource } public PoxPayloadOut getAuthorityItemWithExistingContext( - ServiceContext existingCtx, + ServiceContext existingCtx, String parentIdentifier, String itemIdentifier) throws Exception { PoxPayloadOut result = null; - ServiceContext ctx = createServiceContext(getItemServiceName(), existingCtx.getResourceMap(), existingCtx.getUriInfo()); + ServiceContext ctx = createServiceContext(getItemServiceName(), existingCtx.getResourceMap(), existingCtx.getUriInfo()); if (existingCtx.getCurrentRepositorySession() != null) { ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists ctx.setProperties(existingCtx.getProperties()); @@ -938,7 +938,7 @@ public abstract class AuthorityResource * @param ui passed to include additional parameters, like pagination controls * */ - public AbstractCommonList getAuthorityItemList(ServiceContext existingContext, + public AbstractCommonList getAuthorityItemList(ServiceContext existingContext, String authorityIdentifier, UriInfo uriInfo) throws Exception { AbstractCommonList result = null; @@ -1061,7 +1061,7 @@ public abstract class AuthorityResource } public AuthorityRefDocList getReferencingObjects( - ServiceContext existingContext, + ServiceContext existingContext, String parentspecifier, String itemspecifier, UriTemplateRegistry uriTemplateRegistry, @@ -1116,7 +1116,6 @@ public abstract class AuthorityResource try { // Note that we have to create the service context for the Items, not the main service ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); - MultivaluedMap queryParams = ctx.getQueryParams(); String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItemAuthRefs(parent)", "GET_ITEM_AUTH_REFS", uriInfo); // We omit the parentShortId, only needed when doing a create... DocumentModelHandler handler = @@ -1141,9 +1140,8 @@ public abstract class AuthorityResource * @return * @throws Exception */ - @SuppressWarnings("unchecked") - private PoxPayloadOut synchronizeItem( - ServiceContext ctx, + private PoxPayloadOut synchronizeItem( + ServiceContext ctx, String parentIdentifier, String itemIdentifier, boolean syncHierarchicalRelationships) throws Exception { @@ -1180,7 +1178,7 @@ public abstract class AuthorityResource * @throws Exception */ public PoxPayloadOut synchronizeItemWithExistingContext( - ServiceContext existingCtx, + ServiceContext existingCtx, String parentIdentifier, String itemIdentifier, boolean syncHierarchicalRelationships @@ -1276,7 +1274,7 @@ public abstract class AuthorityResource } public PoxPayloadOut updateAuthorityItem( - ServiceContext itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls + ServiceContext itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls ResourceMap resourceMap, UriInfo uriInfo, String parentspecifier, @@ -1342,7 +1340,7 @@ public abstract class AuthorityResource } try { - ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); deleteAuthorityItem(ctx, parentIdentifier, itemIdentifier, AuthorityServiceUtils.UPDATE_REV); result = Response.status(HttpResponseCodes.SC_OK).build(); } catch (Exception e) { @@ -1360,7 +1358,7 @@ public abstract class AuthorityResource * @throws Exception */ @SuppressWarnings("rawtypes") - public boolean deleteAuthorityItem(ServiceContext existingCtx, + public boolean deleteAuthorityItem(ServiceContext existingCtx, String parentIdentifier, String itemIdentifier, boolean shouldUpdateRevNumber @@ -1452,7 +1450,8 @@ public abstract class AuthorityResource /** * */ - public ServiceDescription getDescription(ServiceContext ctx) { + @Override + public ServiceDescription getDescription(ServiceContext ctx) { ServiceDescription result = super.getDescription(ctx); result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId())); return result; diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java index eea6502f5..b6871cdf9 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java @@ -38,6 +38,7 @@ import org.collectionspace.services.authorization.perms.PermissionAction; import org.collectionspace.services.authorization.perms.PermissionsList; import org.collectionspace.services.client.PermissionFactory; import org.collectionspace.services.client.test.AbstractServiceTestImpl; +import org.collectionspace.services.client.test.ServiceRequestType; import org.testng.Assert; import org.testng.annotations.Test; import org.slf4j.Logger; @@ -89,7 +90,8 @@ public class PermissionServiceTest extends AbstractServiceTestImpl getEntityResponseType() { + @Override + public Class getEntityResponseType() { return Permission.class; } @@ -107,6 +109,36 @@ public class PermissionServiceTest extends AbstractServiceTestImpl + + \ No newline at end of file diff --git a/services/authorization/jaxb/src/main/resources/roles.xsd b/services/authorization/jaxb/src/main/resources/roles.xsd index ee3103d23..e9d9492ab 100644 --- a/services/authorization/jaxb/src/main/resources/roles.xsd +++ b/services/authorization/jaxb/src/main/resources/roles.xsd @@ -1,15 +1,4 @@ - - - - + diff --git a/services/batch/3rdparty/nuxeo-platform-cs-batch/src/main/resources/schemas/batch_common.xsd b/services/batch/3rdparty/nuxeo-platform-cs-batch/src/main/resources/schemas/batch_common.xsd index d0e5c1729..ac277ba68 100644 --- a/services/batch/3rdparty/nuxeo-platform-cs-batch/src/main/resources/schemas/batch_common.xsd +++ b/services/batch/3rdparty/nuxeo-platform-cs-batch/src/main/resources/schemas/batch_common.xsd @@ -24,14 +24,14 @@ - + - + @@ -46,7 +46,7 @@ - + diff --git a/services/batch/build.xml b/services/batch/build.xml index 6984ff89b..b672c881b 100644 --- a/services/batch/build.xml +++ b/services/batch/build.xml @@ -107,7 +107,7 @@ - + diff --git a/services/batch/pom.xml b/services/batch/pom.xml index 7e5fd97f3..2ca7ff38c 100644 --- a/services/batch/pom.xml +++ b/services/batch/pom.xml @@ -8,7 +8,6 @@ 4.0.0 - org.collectionspace.services org.collectionspace.services.batch services.batch pom diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java index a61886197..92b9507de 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java @@ -41,7 +41,7 @@ public abstract class AbstractBatchInvocable implements BatchInvocable { private ServiceContext ctx; private List invocationModes; - private ResourceMap resourceMap; + private ResourceMap resourceMap; protected InvocationContext invocationCtx; protected int completionStatus; @@ -70,12 +70,12 @@ public abstract class AbstractBatchInvocable implements BatchInvocable { this.invocationModes = invocationModes; } - public ResourceMap getResourceMap() { + public ResourceMap getResourceMap() { return resourceMap; } @Override - public void setResourceMap(ResourceMap resourceMap) { + public void setResourceMap(ResourceMap resourceMap) { this.resourceMap = resourceMap; } diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchInvocable.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchInvocable.java index 2ddc5a12a..d608b39f5 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchInvocable.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchInvocable.java @@ -1,7 +1,5 @@ package org.collectionspace.services.batch; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.invocable.Invocable; import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; @@ -12,7 +10,7 @@ public interface BatchInvocable extends Invocable { * Sets the invocation context for the batch job. Called before run(). * @param context an instance of InvocationContext. */ - public void setResourceMap(ResourceMap resourceMap); + public void setResourceMap(ResourceMap resourceMap); public CoreSessionInterface getRepoSession(); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/AbstractBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/AbstractBatchJob.java index e37ce40a8..a99ece77b 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/AbstractBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/AbstractBatchJob.java @@ -14,6 +14,7 @@ import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; + import org.collectionspace.services.batch.AbstractBatchInvocable; import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.CollectionSpaceClient; @@ -33,6 +34,7 @@ import org.collectionspace.services.common.UriTemplateRegistry; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.common.context.ServiceBindingUtils; +import org.collectionspace.services.common.query.UriInfoImpl; import org.collectionspace.services.common.relation.RelationResource; import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -45,23 +47,16 @@ import org.dom4j.Element; import org.dom4j.Node; import org.jboss.resteasy.specimpl.PathSegmentImpl; -//import org.jboss.resteasy.specimpl.UriInfoImpl; -import org.collectionspace.services.batch.UriInfoImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AbstractBatchJob extends AbstractBatchInvocable { - public final int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - public final int BAD_REQUEST_STATUS = Response.Status.BAD_REQUEST.getStatusCode(); - public final int INT_ERROR_STATUS = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); final Logger logger = LoggerFactory.getLogger(AbstractBatchJob.class); private Map authorityServiceNamesByDocType; - - public abstract void run(); - + protected String getFieldXml(Map fields, String fieldName) { return getFieldXml(fieldName, fields.get(fieldName)); } diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearLocationLabelRequestBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearLocationLabelRequestBatchJob.java index 8be238954..0d726d4c3 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearLocationLabelRequestBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearLocationLabelRequestBatchJob.java @@ -24,6 +24,7 @@ public class ClearLocationLabelRequestBatchJob extends AbstractBatchJob { setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT)); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearPotTagLabelRequestBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearPotTagLabelRequestBatchJob.java index 41821d3b3..3da909574 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearPotTagLabelRequestBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearPotTagLabelRequestBatchJob.java @@ -23,6 +23,7 @@ public class ClearPotTagLabelRequestBatchJob extends AbstractBatchJob { setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT)); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearVoucherLabelRequestBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearVoucherLabelRequestBatchJob.java index 98b8a4040..c48c5d338 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearVoucherLabelRequestBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearVoucherLabelRequestBatchJob.java @@ -23,6 +23,7 @@ public class ClearVoucherLabelRequestBatchJob extends AbstractBatchJob { this.setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT)); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java index b6c7af9da..6a23c190c 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java @@ -35,6 +35,7 @@ public class CreateVoucherBatchJob extends AbstractBatchJob { setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE)); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatTaxonBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatTaxonBatchJob.java index f79694092..b745018f1 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatTaxonBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatTaxonBatchJob.java @@ -30,6 +30,7 @@ public class FormatTaxonBatchJob extends AbstractBatchJob { this.taxonFormatter = new TaxonFormatter(); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatVoucherNameBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatVoucherNameBatchJob.java index afab83b22..eb7be0a42 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatVoucherNameBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatVoucherNameBatchJob.java @@ -36,6 +36,7 @@ public class FormatVoucherNameBatchJob extends AbstractBatchJob { this.taxonFormatter = new TaxonFormatter(); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java index cc23a47c5..4a2df3a6c 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java @@ -25,12 +25,13 @@ import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.common.relation.RelationResource; import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.relation.RelationsCommonList; -import org.collectionspace.services.relation.RelationsCommonList.RelationListItem; + import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.Node; + import org.nuxeo.common.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ReindexFullTextBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ReindexFullTextBatchJob.java index d4350e085..bd388c7f2 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ReindexFullTextBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ReindexFullTextBatchJob.java @@ -20,8 +20,6 @@ import java.util.Map; import java.util.Set; import org.apache.commons.lang.StringUtils; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.CollectionSpaceResource; import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.StoredValuesUriTemplate; @@ -33,7 +31,6 @@ import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.nuxeo.util.ReindexFulltextRoot.ReindexInfo; import org.nuxeo.ecm.core.api.AbstractSession; -import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.IterableQueryResult; import org.nuxeo.ecm.core.api.NuxeoException; @@ -222,7 +219,7 @@ public class ReindexFullTextBatchJob extends AbstractBatchJob { private void initResourceMap() { resourcesByDocType = new HashMap(); - for (CollectionSpaceResource resource : getResourceMap().values()) { + for (CollectionSpaceResource resource : getResourceMap().values()) { Map entries = resource.getUriRegistryEntries(); for (UriTemplateRegistryKey key : entries.keySet()) { diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java index 0e5397da9..c1b2f3849 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java @@ -26,6 +26,7 @@ public class UpdateDeadFlagBatchJob extends AbstractBatchJob { this.setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE)); } + @Override public void run() { setCompletionStatus(STATUS_MIN_PROGRESS); diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java index 5f65c036c..13493d78e 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java @@ -12,7 +12,6 @@ import org.collectionspace.services.client.AbstractCommonListUtils; import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.client.CollectionSpaceClient; 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.client.RelationClient; @@ -1467,4 +1466,35 @@ public abstract class AbstractAuthorityServiceTest getEntityResponseType() { + @Override + public Class getEntityResponseType() { return String.class; } @@ -130,4 +132,54 @@ public abstract class AbstractPoxServiceTestImpl { * @param clazz the clazz * @return the string */ - static protected String objectAsXmlString(Object o, Class clazz) { - StringWriter sw = new StringWriter(); - try { - JAXBContext jc = JAXBContext.newInstance(clazz); - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(o, sw); - } catch (Exception e) { - e.printStackTrace(); - } - return sw.toString(); - } + static protected String objectAsXmlString(Object o, Class clazz) { + StringWriter sw = new StringWriter(); + JAXBContext jc; + try { + jc = JAXBContext.newInstance(clazz); + Marshaller m = jc.createMarshaller(); + try { + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.marshal(o, sw); + } catch (MarshalException e) { + sw = new StringWriter(); // reset the StringWriter value + JAXBElement root = new JAXBElement(new QName("uri", "local"), clazz, o); + m.marshal(root, sw); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (JAXBException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + return sw.toString(); + } static protected String objectAsXmlString(Object o) { - StringWriter sw = new StringWriter(); - try { - JAXBContext jc = JAXBContext.newInstance(o.getClass()); - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(o, sw); - } catch (Exception e) { - e.printStackTrace(); - } - return sw.toString(); - } + return objectAsXmlString(o, o.getClass()); + } /** * getObjectFromFile get object of given class from given file (in classpath) @@ -806,6 +809,24 @@ public abstract class BaseServiceTest { // Status code setup methods for tests // + /** + * Sets up create tests with empty entity body. + */ + protected void setupCreateWithEmptyEntityBody() { + testExpectedStatusCode = STATUS_BAD_REQUEST; + testRequestType = ServiceRequestType.CREATE; + testSetup(testExpectedStatusCode, testRequestType); + } + + /** + * Sets up create tests with empty entity body. + */ + protected void setupCreateWithInvalidBody() { + testExpectedStatusCode = STATUS_BAD_REQUEST; + testRequestType = ServiceRequestType.CREATE; + testSetup(testExpectedStatusCode, testRequestType); + } + /** * Sets up create tests with malformed xml. */ @@ -913,6 +934,15 @@ public abstract class BaseServiceTest { testRequestType = ServiceRequestType.DELETE; testSetup(testExpectedStatusCode, testRequestType); } + + /** + * Sets up create tests with empty entity body. + */ + protected void setupUpdateWithInvalidBody() { + testExpectedStatusCode = STATUS_BAD_REQUEST; + testRequestType = ServiceRequestType.UPDATE; + testSetup(testExpectedStatusCode, testRequestType); + } // Failure outcomes @@ -924,34 +954,7 @@ public abstract class BaseServiceTest { testRequestType = ServiceRequestType.DELETE; testSetup(testExpectedStatusCode, testRequestType); } - - /** - * Sets up create tests with empty entity body. - */ - protected void setupCreateWithEmptyEntityBody() { - testExpectedStatusCode = STATUS_BAD_REQUEST; - testRequestType = ServiceRequestType.CREATE; - testSetup(testExpectedStatusCode, testRequestType); - } - - /** - * Sets up create tests with empty entity body. - */ - protected void setupCreateWithInvalidBody() { - testExpectedStatusCode = STATUS_BAD_REQUEST; - testRequestType = ServiceRequestType.CREATE; - testSetup(testExpectedStatusCode, testRequestType); - } - - /** - * Sets up create tests with empty entity body. - */ - protected void setupUpdateWithInvalidBody() { - testExpectedStatusCode = STATUS_BAD_REQUEST; - testRequestType = ServiceRequestType.UPDATE; - testSetup(testExpectedStatusCode, testRequestType); - } - + public void updateWithEmptyEntityBody(String testName) throws Exception { //FIXME: Should this test really be empty? If so, please comment accordingly. } diff --git a/services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml new file mode 100644 index 000000000..65f3b3d50 --- /dev/null +++ b/services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/CSWebApplicationException.java b/services/common/src/main/java/org/collectionspace/services/common/CSWebApplicationException.java index 11718744c..c1341b157 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CSWebApplicationException.java +++ b/services/common/src/main/java/org/collectionspace/services/common/CSWebApplicationException.java @@ -36,7 +36,7 @@ public class CSWebApplicationException extends WebApplicationException { } public CSWebApplicationException(Throwable cause, Response response) { - super(cause); + super(cause, response); this.response = getFinalResponse(cause, response); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java index ccfc4344a..ae2f1f355 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java @@ -643,7 +643,7 @@ public abstract class NuxeoBasedResource } @Override - public ServiceDescription getDescription(ServiceContext ctx) { + public ServiceDescription getDescription(ServiceContext ctx) { ServiceDescription result = new ServiceDescription(); result.setDocumentType(getDocType(ctx.getTenantId())); @@ -656,7 +656,7 @@ public abstract class NuxeoBasedResource * for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get * the map, and pass it in. */ - public static DocumentModel getDocModelForRefName(ServiceContext ctx, String refName, ResourceMap resourceMap) + public static DocumentModel getDocModelForRefName(ServiceContext ctx, String refName, ResourceMap resourceMap) throws Exception, DocumentNotFoundException { return NuxeoUtils.getDocModelForRefName(ctx, refName, resourceMap); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceMapHolder.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceMapHolder.java index 4e81e5a0e..950ec7c3a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceMapHolder.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceMapHolder.java @@ -1,8 +1,5 @@ package org.collectionspace.services.common; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; - public interface ResourceMapHolder { - public ResourceMap getResourceMap(); + public ResourceMap getResourceMap(); } diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/listener/AbstractCSEventListenerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/listener/AbstractCSEventListenerImpl.java index ed6579b77..9805c5311 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/listener/AbstractCSEventListenerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/listener/AbstractCSEventListenerImpl.java @@ -15,7 +15,7 @@ import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.event.Event; public abstract class AbstractCSEventListenerImpl implements CSEventListener { - private static List repositoryNameList = new ArrayList(); + private static Map> mapOfrepositoryNames = new HashMap>(); // private static Map>> eventListenerParamsMap = new HashMap>>(); // >> private static Map nameMap = new HashMap(); @@ -25,25 +25,44 @@ public abstract class AbstractCSEventListenerImpl implements CSEventListener { // Intentionally left blank } - protected List getRepositoryNameList() { - return repositoryNameList; - } - - protected Map>> getEventListenerParamsMap() { - return eventListenerParamsMap; - } - + /** + * Find out if we (the event listener) are registered (via tenant bindings config) to respond events. + */ @Override public boolean isRegistered(Event event) { boolean result = false; if (event != null && event.getContext() != null) { - result = repositoryNameList.contains(event.getContext().getRepositoryName()); + result = getRepositoryNameList().contains(event.getContext().getRepositoryName()); } return result; } - + + /** + * An event listener can be registered by multiple tenants, so we keep track of that here. + * + * @return - the list of tenants/repositories that an event listener is registered with. + */ + protected List getRepositoryNameList() { + String key = this.getClass().getName(); + List result = mapOfrepositoryNames.get(key); + + if (result == null) synchronized(this) { + result = new ArrayList(); + mapOfrepositoryNames.put(key, result); + } + + return result; + } + + /** + * The list of parameters (specified in a tenant's bindings) for event listeners + * @return + */ + protected Map>> getEventListenerParamsMap() { + return eventListenerParamsMap; + } /** * Returns 'true' if this collection changed as a result of the call. @@ -60,34 +79,36 @@ public abstract class AbstractCSEventListenerImpl implements CSEventListener { result = true; } - // Set this event listeners parameters, if any. Params are qualified with the repositoryName since multiple tenants might be registering the same event listener but with different params. - List paramList = eventListenerConfig.getParamList().getParam(); // values from the tenant bindings that we need to copy into the event listener - if (paramList != null) { - // - // Get the list of event listeners for a given repository - Map> eventListenerRepoParams = getEventListenerParamsMap().get(respositoryName); // Get the set of event listers for a given repository - if (eventListenerRepoParams == null) { - eventListenerRepoParams = new HashMap>(); - getEventListenerParamsMap().put(respositoryName, eventListenerRepoParams); // create and put an empty map - result = true; - } - // - // Get the list of params for a given event listener for a given repository - Map eventListenerParams = eventListenerRepoParams.get(eventListenerConfig.getId()); // Get the set of params for a given event listener for a given repository - if (eventListenerParams == null) { - eventListenerParams = new HashMap(); - eventListenerRepoParams.put(eventListenerConfig.getId(), eventListenerParams); // create and put an empty map - result = true; - } - // - // copy all the values from the tenant bindings into the event listener - for (Param params : paramList) { - String key = params.getKey(); - String value = params.getValue(); - if (Tools.notBlank(key)) { - eventListenerParams.put(key, value); + if (eventListenerConfig.getParamList() != null) { + // Set this event listeners parameters, if any. Params are qualified with the repositoryName since multiple tenants might be registering the same event listener but with different params. + List paramList = eventListenerConfig.getParamList().getParam(); // values from the tenant bindings that we need to copy into the event listener + if (paramList != null) { + // + // Get the list of event listeners for a given repository + Map> eventListenerRepoParams = getEventListenerParamsMap().get(respositoryName); // Get the set of event listers for a given repository + if (eventListenerRepoParams == null) { + eventListenerRepoParams = new HashMap>(); + getEventListenerParamsMap().put(respositoryName, eventListenerRepoParams); // create and put an empty map + result = true; + } + // + // Get the list of params for a given event listener for a given repository + Map eventListenerParams = eventListenerRepoParams.get(eventListenerConfig.getId()); // Get the set of params for a given event listener for a given repository + if (eventListenerParams == null) { + eventListenerParams = new HashMap(); + eventListenerRepoParams.put(eventListenerConfig.getId(), eventListenerParams); // create and put an empty map result = true; } + // + // copy all the values from the tenant bindings into the event listener + for (Param params : paramList) { + String key = params.getKey(); + String value = params.getValue(); + if (Tools.notBlank(key)) { + eventListenerParams.put(key, value); + result = true; + } + } } } @@ -100,8 +121,14 @@ public abstract class AbstractCSEventListenerImpl implements CSEventListener { @Override public Map getParams(Event event) { - String repositoryName = event.getContext().getRepositoryName(); - return getEventListenerParamsMap().get(repositoryName).get(getName(repositoryName)); // We need to qualify with the repositoryName since this event listener might be register by multiple tenants using different params + Map result = null; + try { + String repositoryName = event.getContext().getRepositoryName(); + result = getEventListenerParamsMap().get(repositoryName).get(getName(repositoryName)); // We need to qualify with the repositoryName since this event listener might be register by multiple tenants using different params + } catch (NullPointerException e) { + // Do nothing. Just means no params were configured. + } + return result; } @Override diff --git a/services/hyperjaxb/src/main/resources/bindings.xjb b/services/hyperjaxb/src/main/resources/bindings.xjb new file mode 100644 index 000000000..ce5cc40c4 --- /dev/null +++ b/services/hyperjaxb/src/main/resources/bindings.xjb @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/services/material/client/src/test/java/org/collectionspace/services/client/test/MaterialAuthorityServiceTest.java b/services/material/client/src/test/java/org/collectionspace/services/client/test/MaterialAuthorityServiceTest.java index a41ad978b..6e4103ef6 100644 --- a/services/material/client/src/test/java/org/collectionspace/services/client/test/MaterialAuthorityServiceTest.java +++ b/services/material/client/src/test/java/org/collectionspace/services/client/test/MaterialAuthorityServiceTest.java @@ -243,7 +243,8 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest bindings.xjb + + -Xannotate + true true false diff --git a/services/pottag/client/src/main/resources/collectionspace-client.properties b/services/pottag/client/src/main/resources/collectionspace-client.properties new file mode 100644 index 000000000..12a5aa41a --- /dev/null +++ b/services/pottag/client/src/main/resources/collectionspace-client.properties @@ -0,0 +1,6 @@ +#url of the collectionspace server +cspace.url=http://localhost:8180/cspace-services/ +cspace.ssl=false +cspace.auth=true +cspace.user=admin@botgarden.collectionspace.org +cspace.password=Administrator diff --git a/services/pottag/client/src/test/java/org/collectionspace/services/client/test/PottagServiceTest.java b/services/pottag/client/src/test/java/org/collectionspace/services/client/test/PottagServiceTest.java index fcd0b7de8..5439757b4 100644 --- a/services/pottag/client/src/test/java/org/collectionspace/services/client/test/PottagServiceTest.java +++ b/services/pottag/client/src/test/java/org/collectionspace/services/client/test/PottagServiceTest.java @@ -24,9 +24,7 @@ package org.collectionspace.services.client.test; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.PottagClient; -import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.pottag.PottagsCommon; @@ -47,9 +45,6 @@ public class PottagServiceTest extends AbstractPoxServiceTestImpl AuthorityRefList list = null; try { assertStatusCode(res, testName); - list = (AuthorityRefList) res.getEntity(); + list = (AuthorityRefList)res.readEntity(AuthorityRefList.class); Assert.assertNotNull(list); } finally { if (res != null) { @@ -270,7 +270,8 @@ public class PropagationAuthRefsTest extends BaseServiceTest * may be expected to be deleted by certain tests. * @throws Exception */ - @AfterClass(alwaysRun=true) + @Override + @AfterClass(alwaysRun=true) public void cleanUp() throws Exception { String noTest = System.getProperty("noTestCleanup"); if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { @@ -306,7 +307,8 @@ public class PropagationAuthRefsTest extends BaseServiceTest // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- - public String getServiceName() { + @Override + public String getServiceName() { return PropagationClient.SERVICE_NAME; } diff --git a/services/propagation/jaxb/src/main/resources/propagations-common.xsd b/services/propagation/jaxb/src/main/resources/propagations-common.xsd index 69cb7cfaa..2b98fec5e 100644 --- a/services/propagation/jaxb/src/main/resources/propagations-common.xsd +++ b/services/propagation/jaxb/src/main/resources/propagations-common.xsd @@ -35,6 +35,7 @@ + diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index a81f5d56d..2d7883a16 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -158,11 +158,19 @@ public class VocabularyServiceTest extends AbstractAuthorityServiceTest