From b154763de66c1065d791368f5b8ec13113f48bfc Mon Sep 17 00:00:00 2001 From: remillet Date: Thu, 22 Jan 2015 14:57:01 -0800 Subject: [PATCH] CSPACE-6375: In the middle of long break from code changes. Committing to prevent info and data loss. --- .../AbstractUpdateObjectLocationValues.java | 18 +- .../listener/UpdateRelationsOnDelete.java | 6 +- .../services/QuotesModerationService.java | 2 +- .../platform/quote/impl/QuoteManagerImpl.java | 21 +- .../quote/listener/AbstractQuoteListener.java | 1 + .../DocumentRemovedQuoteEventListener.java | 7 + .../listener/QuoteRemovedEventListener.java | 1 + .../thumbnail/AddThumbnailUnrestricted.java | 7 +- pom.xml | 43 +- services/JaxRsServiceProvider/pom.xml | 13 +- .../CollectionSpaceJaxRsApplication.java | 4 +- .../storage/AccountRoleDocumentHandler.java | 5 - .../acquisition/AcquisitionResource.java | 4 +- .../AcquisitionDocumentModelHandler.java | 4 +- services/authority/service/pom.xml | 544 ++++++------- .../common/vocabulary/AuthorityResource.java | 10 +- .../common/vocabulary/IVocabManager.java | 7 - .../common/vocabulary/VocabManager.java | 9 - .../common/vocabulary/VocabManagerImpl.java | 22 - .../nuxeo/AuthorityDocumentModelHandler.java | 15 +- .../AuthorityItemDocumentModelHandler.java | 15 +- .../services/batch/BatchInvocable.java | 2 +- .../services/batch/BatchResource.java | 4 +- .../nuxeo/BatchDocumentModelHandler.java | 103 ++- .../nuxeo/CreateAndLinkLoanOutBatchJob.java | 6 +- .../nuxeo/UpdateObjectLocationBatchJob.java | 28 +- services/blob/service/pom.xml | 203 ++--- .../services/blob/BlobResource.java | 12 +- .../blob/nuxeo/BlobDocumentModelHandler.java | 17 +- .../CollectionObjectResource.java | 4 +- .../CollectionObjectDocumentModelHandler.java | 4 +- services/common/pom.xml | 737 +++++++++--------- .../AbstractCollectionSpaceResourceImpl.java | 9 +- ...ourceBase.java => NuxeoBasedResource.java} | 25 +- .../services/common/ResourceMap.java | 2 +- .../services/common/ResourceMapImpl.java | 2 +- .../services/common/ServiceMain.java | 4 +- .../document/AbstractDocumentHandlerImpl.java | 36 +- .../AbstractMultipartDocumentHandlerImpl.java | 8 - .../document/MultipartDocumentHandler.java | 2 - .../common/imaging/nuxeo/NuxeoBlobUtils.java | 397 +--------- .../common/publicitem/PublicItemResource.java | 4 +- .../services/common/query/QueryContext.java | 3 - .../common/relation/RelationResource.java | 4 +- .../common/relation/RelationUtils.java | 11 +- .../common/repository/RepositoryClient.java | 4 +- .../repository/RepositoryClientFactory.java | 7 +- .../vocabulary/LazyAuthorityRefDocList.java | 7 +- .../vocabulary/RefNameServiceUtils.java | 39 +- .../nuxeo/WorkflowDocumentModelHandler.java | 4 +- ...terface.java => CoreSessionInterface.java} | 18 +- ...ceWrapper.java => CoreSessionWrapper.java} | 16 +- .../nuxeo/client/java/DocHandlerBase.java | 394 ---------- .../client/java/DocumentModelHandler.java | 15 +- .../client/java/NuxeoClientEmbedded.java | 100 +-- .../client/java/NuxeoConnectorEmbedded.java | 77 +- .../java/NuxeoDocumentModelHandler.java | 391 ++++++++++ .../java/RemoteDocumentModelHandlerImpl.java | 27 +- .../client/java/RepositoryJavaClientImpl.java | 153 ++-- .../services/nuxeo/util/NuxeoUtils.java | 83 +- .../ConditioncheckResource.java | 4 +- .../ConditioncheckDocumentModelHandler.java | 4 +- .../services/contact/ContactResource.java | 4 +- .../nuxeo/ContactDocumentModelHandler.java | 4 +- .../services/dimension/DimensionResource.java | 4 +- .../services/group/GroupResource.java | 4 +- .../nuxeo/GroupDocumentModelHandler.java | 4 +- .../services/imports/nuxeo/ImportCommand.java | 12 +- .../nuxeo/ImportsDocumentModelHandler.java | 4 +- .../services/intake/IntakeResource.java | 4 +- .../nuxeo/IntakeDocumentModelHandler.java | 4 +- .../services/loanin/LoaninResource.java | 4 +- .../nuxeo/LoaninDocumentModelHandler.java | 4 +- .../services/loanout/LoanoutResource.java | 4 +- .../nuxeo/LoanoutDocumentModelHandler.java | 4 +- .../services/media/MediaResource.java | 4 +- .../nuxeo/MediaDocumentModelHandler.java | 4 +- .../services/movement/MovementResource.java | 4 +- .../nuxeo/MovementDocumentModelHandler.java | 4 +- .../objectexit/ObjectExitResource.java | 4 +- .../nuxeo/ObjectExitDocumentModelHandler.java | 4 +- .../nuxeo/PublicItemDocumentModelHandler.java | 4 +- .../nuxeo/RelationDocumentModelHandler.java | 29 +- .../services/report/ReportResource.java | 4 +- .../nuxeo/ReportDocumentModelHandler.java | 15 +- .../servicegroup/ServiceGroupResource.java | 24 +- .../ServiceGroupDocumentModelHandler.java | 20 +- .../ValuationcontrolResource.java | 4 +- .../ValuationcontrolDocumentModelHandler.java | 4 +- .../services/workflow/WorkflowResource.java | 4 +- 90 files changed, 1732 insertions(+), 2188 deletions(-) delete mode 100644 services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java delete mode 100644 services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java delete mode 100644 services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java rename services/common/src/main/java/org/collectionspace/services/common/{ResourceBase.java => NuxeoBasedResource.java} (96%) rename services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/{RepositoryInstanceInterface.java => CoreSessionInterface.java} (89%) rename services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/{RepositoryInstanceWrapper.java => CoreSessionWrapper.java} (92%) delete mode 100644 services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java create mode 100644 services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java 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 48672cd68..cbb23bd1c 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 @@ -3,14 +3,18 @@ package org.collectionspace.services.listener; import java.util.GregorianCalendar; import java.util.HashSet; import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.movement.nuxeo.MovementConstants; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper; import org.collectionspace.services.nuxeo.util.NuxeoUtils; + import org.nuxeo.ecm.core.api.ClientException; -import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.event.Event; @@ -83,7 +87,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene // (The rest of the code flow below is then identical to that which // is followed when this document event involves a Movement record. String movementCsid = ""; - Enum notificationDocumentType; + Enum notificationDocumentType; if (documentMatchesType(docModel, RELATION_DOCTYPE)) { if (logger.isTraceEnabled()) { logger.trace("An event involving a Relation document was received by UpdateObjectLocationOnMove ..."); @@ -141,7 +145,9 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene logger.trace("Notification document type=" + notificationDocumentType.name()); } - CoreSession coreSession = docEventContext.getCoreSession(); + // All Nuxeo sessions that get passed around to CollectionSpace code need to be + // wrapped inside of a CoreSessionWrapper + CoreSessionInterface coreSession = new CoreSessionWrapper(docEventContext.getCoreSession()); Set collectionObjectCsids = new HashSet<>(); if (notificationDocumentType == EventNotificationDocumentType.RELATION) { @@ -210,7 +216,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene * related to the Movement record. */ private Set getCollectionObjectCsidsRelatedToMovement(String movementCsid, - CoreSession coreSession) throws ClientException { + CoreSessionInterface coreSession) throws ClientException { Set csids = new HashSet<>(); @@ -314,7 +320,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene * @return a document model for the document identified by the supplied * CSID. */ - protected static DocumentModel getCurrentDocModelFromCsid(CoreSession session, String collectionObjectCsid) { + protected static DocumentModel getCurrentDocModelFromCsid(CoreSessionInterface session, String collectionObjectCsid) { DocumentModelList collectionObjectDocModels = null; try { final String query = "SELECT * FROM " @@ -365,7 +371,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene * @return the most recent Movement record related to the CollectionObject * identified by the supplied CSID. */ - protected static DocumentModel getMostRecentMovement(CoreSession session, String collectionObjectCsid) + protected static DocumentModel getMostRecentMovement(CoreSessionInterface session, String collectionObjectCsid) throws ClientException { DocumentModel mostRecentMovementDocModel = null; // Get Relation records for Movements related to this CollectionObject. 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 9656ba139..9cd7c72a2 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 @@ -3,11 +3,13 @@ package org.collectionspace.services.listener; import java.util.ArrayList; import java.util.IllegalFormatException; import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.collectionspace.services.client.workflow.WorkflowClient; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper; import org.nuxeo.ecm.core.api.ClientException; -import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.impl.LifeCycleFilter; @@ -73,7 +75,7 @@ public class UpdateRelationsOnDelete implements EventListener { LifeCycleFilter workflowStateFilter = new LifeCycleFilter(null, workflowStatesToFilter); // Perform the filtered query - CoreSession session = docModel.getCoreSession(); + CoreSessionInterface session = new CoreSessionWrapper(docModel.getCoreSession()); DocumentModelList matchingDocuments; try { matchingDocuments = session.query(queryString.toString(), workflowStateFilter); diff --git a/3rdparty/nuxeo/nuxeo-platform-quote-api/src/main/java/org/collectionspace/ecm/platform/quote/workflow/services/QuotesModerationService.java b/3rdparty/nuxeo/nuxeo-platform-quote-api/src/main/java/org/collectionspace/ecm/platform/quote/workflow/services/QuotesModerationService.java index 78ed7b0ee..65953e34c 100644 --- a/3rdparty/nuxeo/nuxeo-platform-quote-api/src/main/java/org/collectionspace/ecm/platform/quote/workflow/services/QuotesModerationService.java +++ b/3rdparty/nuxeo/nuxeo-platform-quote-api/src/main/java/org/collectionspace/ecm/platform/quote/workflow/services/QuotesModerationService.java @@ -46,7 +46,7 @@ public interface QuotesModerationService { */ /** ProcessInstance getModerationProcess(JbpmService jbpmService, - CoreSession session, DocumentModel doc, String commentId) + CoreSessionInterface session, DocumentModel doc, String commentId) throws ClientException; **/ diff --git a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/impl/QuoteManagerImpl.java b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/impl/QuoteManagerImpl.java index 4deed9bc1..91a02d0d7 100644 --- a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/impl/QuoteManagerImpl.java +++ b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/impl/QuoteManagerImpl.java @@ -23,7 +23,6 @@ import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -35,6 +34,7 @@ import javax.security.auth.login.LoginException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.nuxeo.common.utils.IdUtils; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.ClientRuntimeException; @@ -103,16 +103,19 @@ public class QuoteManagerImpl implements QuoteManager { protected CoreSession openCoreSession(String repositoryName) throws ClientException { + CoreSession result = null; + try { - RepositoryManager repoMgr = Framework.getService(RepositoryManager.class); - return repoMgr.getRepository(repositoryName).open(); + result = CoreInstance.openCoreSession(repositoryName); } catch (Exception e) { throw new ClientException(e); } + + return result; } protected void closeCoreSession(LoginContext loginContext, - CoreSession session) throws ClientException { + CoreSession session) throws ClientException { if (loginContext != null) { try { loginContext.logout(); @@ -121,7 +124,7 @@ public class QuoteManagerImpl implements QuoteManager { } } if (session != null) { - CoreInstance.getInstance().close(session); + session.close(); } } @@ -132,8 +135,8 @@ public class QuoteManagerImpl implements QuoteManager { public List getQuotes(DocumentModel docModel) throws ClientException { RelationManager relationManager; - Map ctxMap = new HashMap(); - ctxMap.put(ResourceAdapter.CORE_SESSION_ID_CONTEXT_KEY, docModel.getSessionId()); + Map ctxMap = new HashMap(); + ctxMap.put(ResourceAdapter.CORE_SESSION_CONTEXT_KEY, docModel.getSessionId()); try { relationManager = getRelationManager(); } catch (Exception e) { @@ -570,8 +573,8 @@ public class QuoteManagerImpl implements QuoteManager { public List getDocumentsForQuote(DocumentModel comment) throws ClientException { RelationManager relationManager; - Map ctxMap = new HashMap(); - ctxMap.put(ResourceAdapter.CORE_SESSION_ID_CONTEXT_KEY, comment.getSessionId()); + Map ctxMap = new HashMap(); + ctxMap.put(ResourceAdapter.CORE_SESSION_CONTEXT_KEY, comment.getSessionId()); try { relationManager = getRelationManager(); } catch (Exception e) { diff --git a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/AbstractQuoteListener.java b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/AbstractQuoteListener.java index 32e056c4c..fe4157b5b 100644 --- a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/AbstractQuoteListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/AbstractQuoteListener.java @@ -21,6 +21,7 @@ package org.collectionspace.ecm.platform.quote.listener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; diff --git a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/DocumentRemovedQuoteEventListener.java b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/DocumentRemovedQuoteEventListener.java index a7977bd08..7983d1d16 100644 --- a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/DocumentRemovedQuoteEventListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/DocumentRemovedQuoteEventListener.java @@ -17,12 +17,19 @@ * $Id$ */ +/* + * An example Nuxeo event listener. + */ + package org.collectionspace.ecm.platform.quote.listener; + + import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; diff --git a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/QuoteRemovedEventListener.java b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/QuoteRemovedEventListener.java index 171acde82..a1a662e4c 100644 --- a/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/QuoteRemovedEventListener.java +++ b/3rdparty/nuxeo/nuxeo-platform-quote/src/main/java/org/collectionspace/ecm/platform/quote/listener/QuoteRemovedEventListener.java @@ -23,6 +23,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; diff --git a/3rdparty/nuxeo/nuxeo-platform-thumbnail/src/main/java/org/collectionspace/services/nuxeo/extension/thumbnail/AddThumbnailUnrestricted.java b/3rdparty/nuxeo/nuxeo-platform-thumbnail/src/main/java/org/collectionspace/services/nuxeo/extension/thumbnail/AddThumbnailUnrestricted.java index c21cd2094..a424edf25 100644 --- a/3rdparty/nuxeo/nuxeo-platform-thumbnail/src/main/java/org/collectionspace/services/nuxeo/extension/thumbnail/AddThumbnailUnrestricted.java +++ b/3rdparty/nuxeo/nuxeo-platform-thumbnail/src/main/java/org/collectionspace/services/nuxeo/extension/thumbnail/AddThumbnailUnrestricted.java @@ -1,9 +1,10 @@ package org.collectionspace.services.nuxeo.extension.thumbnail; +/* + * An example Nuxeo event "listener". + */ -import java.io.IOException; import java.io.Serializable; -import java.security.NoSuchAlgorithmException; import java.util.Calendar; import java.util.GregorianCalendar; @@ -43,7 +44,7 @@ public class AddThumbnailUnrestricted extends UnrestrictedSessionRunner { * (non-Javadoc) * @see org.nuxeo.ecm.core.api.UnrestrictedSessionRunner#run() * - * Creates a new thumbnail image and associates it with the document blob by adding a "Thumnail" facet + * Creates a new thumbnail image and associates it with the document blob by adding a "Thumbnail" facet * to the document blob. */ @Override diff --git a/pom.xml b/pom.xml index 32545c14d..2c94a0cd0 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ ${nuxeo.general.release} ${nuxeo.general.release} ${nuxeo.general.release} + 0.12.0-NX2 3.0.5.RELEASE 3.0.5.RELEASE @@ -292,7 +293,8 @@ - + org.eclipse.m2e lifecycle-mapping @@ -325,12 +327,10 @@ - + - + maven-antrun-plugin @@ -342,18 +342,25 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 365965205..fcaeb487b 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -410,7 +410,7 @@ ${nuxeo.core.version} - org.nuxeo.ecm.core + org.nuxeo.lib.core nuxeo-core-storage-sql-extensions ${nuxeo.core.version} @@ -419,17 +419,6 @@ nuxeo-core-storage-sql-ra ${nuxeo.core.version} - - org.nuxeo.ecm.core - nuxeo-core-client - ${nuxeo.core.version} - - - org.jboss.jbossas - jboss-as-jbossas-remoting - - - org.nuxeo.ecm.core nuxeo-core-query 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 710359ed3..654b30764 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 @@ -62,7 +62,7 @@ import java.util.Set; //import org.collectionspace.services.common.FileUtils; import org.collectionspace.services.authorization.PermissionResource; import org.collectionspace.services.authorization.RoleResource; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ResourceMapHolder; import org.collectionspace.services.common.ResourceMapImpl; @@ -136,7 +136,7 @@ public class CollectionSpaceJaxRsApplication extends Application // singletons.add(new PingResource()); } - private void addResourceToMapAndSingletons(ResourceBase resource) { + private void addResourceToMapAndSingletons(NuxeoBasedResource resource) { singletons.add(resource); resourceMap.put(resource.getServiceName(), resource); } diff --git a/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountRoleDocumentHandler.java b/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountRoleDocumentHandler.java index 150978b19..e38f6939a 100644 --- a/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountRoleDocumentHandler.java +++ b/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountRoleDocumentHandler.java @@ -26,20 +26,15 @@ package org.collectionspace.services.account.storage; import java.util.ArrayList; import java.util.List; -//import org.collectionspace.services.authorization.AccountRolesList; -//import org.collectionspace.services.authorization.AccountRolesList.AccountRoleListItem; - import org.collectionspace.services.common.authorization_mgt.AuthorizationRoleRel; import org.collectionspace.services.authorization.AccountRole; import org.collectionspace.services.authorization.AccountRoleRel; import org.collectionspace.services.authorization.AccountValue; -import org.collectionspace.services.authorization.PermissionsRolesList; import org.collectionspace.services.authorization.RoleValue; import org.collectionspace.services.authorization.SubjectType; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.storage.jpa.JpaDocumentHandler; -import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl; import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.context.ServiceContextProperties; diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java index b8a272b24..35114d3cd 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java @@ -29,7 +29,7 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import org.collectionspace.services.client.AcquisitionClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory; @Path(AcquisitionClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class AcquisitionResource extends ResourceBase { +public class AcquisitionResource extends NuxeoBasedResource { /** The logger. */ final Logger logger = LoggerFactory.getLogger(AcquisitionResource.class); diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java index f6a2e0245..5843233b0 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java @@ -24,13 +24,13 @@ package org.collectionspace.services.acquisition.nuxeo; import org.collectionspace.services.acquisition.AcquisitionsCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** AcquisitionDocumentModelHandler * $LastChangedRevision: $ * $LastChangedDate: $ */ public class AcquisitionDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/authority/service/pom.xml b/services/authority/service/pom.xml index 7435ca575..91eadeb8d 100644 --- a/services/authority/service/pom.xml +++ b/services/authority/service/pom.xml @@ -1,301 +1,273 @@ - - - org.collectionspace.services - org.collectionspace.services.authority - 4.2-SNAPSHOT - + + + org.collectionspace.services + org.collectionspace.services.authority + 4.2-SNAPSHOT + - 4.0.0 - org.collectionspace.services.authority.service - services.authority.service - jar + 4.0.0 + org.collectionspace.services.authority.service + services.authority.service + jar - - - - org.collectionspace.services - org.collectionspace.services.config - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.common-api - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.common - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authority.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.vocabulary.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authentication.jaxb - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authentication.service - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authorization.jaxb - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authorization.service - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.relation.service - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.relation.client - ${project.version} - + + + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common-api + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.vocabulary.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authentication.jaxb + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authentication.service + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authorization.jaxb + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authorization.service + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.relation.service + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.relation.client + ${project.version} + - + - - org.slf4j - slf4j-api - provided - - - org.slf4j - slf4j-log4j12 - provided - - - log4j - log4j - 1.2.14 - provided - - - org.apache.commons - commons-jexl - 2.0.1 - - + + org.slf4j + slf4j-api + provided + + + org.slf4j + slf4j-log4j12 + provided + + + log4j + log4j + 1.2.14 + provided + + + org.apache.commons + commons-jexl + 2.0.1 + + commons-codec commons-codec 1.4 - + - - - javax.servlet - servlet-api - 2.5 - provided - + + + javax.servlet + servlet-api + provided + + + javax.security + jaas + 1.0.01 + provided + + + javax.security + jacc + 1.0 + provided + + + mysql + mysql-connector-java + + + postgresql + postgresql + + + javax.persistence + persistence-api + - - javax.security - jaas - 1.0.01 - provided - - - javax.security - jacc - 1.0 - provided - - - - mysql - mysql-connector-java - - - postgresql - postgresql - - - javax.persistence - persistence-api - + + com.sun.xml.bind + jaxb-impl + + + org.jvnet.jaxb2-commons + property-listener-injector + - - com.sun.xml.bind - jaxb-impl - - - org.jvnet.jaxb2-commons - property-listener-injector - - + + + org.jboss.resteasy + jaxrs-api + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + - - - org.jboss.resteasy - jaxrs-api - - - org.jboss.resteasy - resteasy-jaxrs - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - - - org.jboss.resteasy - resteasy-multipart-provider - - - - org.hibernate - hibernate-entitymanager - - - - jboss - jbosssx - 4.2.3.GA - provided - - - jboss - jboss-remoting - 2.2.2.SP8 - provided - - - - org.nuxeo.ecm.platform - nuxeo-platform-mimetype-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-core - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-filemanager-api - ${nuxeo.platform.version} - - - org.nuxeo.common - nuxeo-common - ${nuxeo.core.version} - provided - - - org.nuxeo.runtime - nuxeo-runtime - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-api - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-client - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-query - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-schema - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-storage-sql - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-io - ${nuxeo.core.version} - - - - org.nuxeo.ecm.core - nuxeo-core-io - ${nuxeo.core.version} - - - org.nuxeo.runtime - nuxeo-runtime-osgi - ${nuxeo.core.version} - - - org.osgi - org.osgi.core - 4.1.0 - - + + org.hibernate + hibernate-entitymanager + + + + jboss + jbosssx + 4.2.3.GA + provided + + + jboss + jboss-remoting + 2.2.2.SP8 + provided + + + + org.nuxeo.ecm.platform + nuxeo-platform-mimetype-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-filemanager-api + ${nuxeo.platform.version} + + + org.nuxeo.common + nuxeo-common + ${nuxeo.core.version} + provided + + + org.nuxeo.runtime + nuxeo-runtime + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-api + + + org.nuxeo.ecm.core + nuxeo-core-query + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-schema + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-storage-sql + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-io + ${nuxeo.core.version} + + + + org.nuxeo.ecm.core + nuxeo-core-io + ${nuxeo.core.version} + + + org.nuxeo.runtime + nuxeo-runtime-osgi + ${nuxeo.core.version} + + + org.osgi + org.osgi.core + 4.1.0 + + diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index d7354748f..ed28be1f3 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -34,7 +34,6 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Request; @@ -48,7 +47,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.ServiceMessages; @@ -79,14 +78,13 @@ import org.collectionspace.services.config.ClientType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.lifecycle.TransitionDef; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.workflow.WorkflowCommon; import org.jboss.resteasy.util.HttpResponseCodes; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,7 +106,7 @@ import org.slf4j.LoggerFactory; @Consumes("application/xml") @Produces("application/xml") public abstract class AuthorityResource - extends ResourceBase { + extends NuxeoBasedResource { final static String SEARCH_TYPE_TERMSTATUS = "ts"; @@ -327,7 +325,7 @@ public abstract class AuthorityResource * Resource. They then call this method on that resource. */ @Override - public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item) + public DocumentModel getDocModelForAuthorityItem(CoreSessionInterface repoSession, RefName.AuthorityItem item) throws Exception, DocumentNotFoundException { if(item == null) { return null; diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java deleted file mode 100644 index ad272c82a..000000000 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/IVocabManager.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.collectionspace.services.common.vocabulary; - -public interface IVocabManager { - - public void exampleMethod(String someParam); - -} diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java deleted file mode 100644 index 27d1cfdad..000000000 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManager.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.collectionspace.services.common.vocabulary; - -public class VocabManager { - static private final IVocabManager vocabManager = new VocabManagerImpl(); - - static public void exampleMethod(String someParam) { - vocabManager.exampleMethod(someParam); - } -} diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java deleted file mode 100644 index 655eb125e..000000000 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/VocabManagerImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.collectionspace.services.common.vocabulary; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.nuxeo.ecm.core.client.NuxeoClient; - -//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector; -import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; -//import org.collectionspace.services.common.query.IQueryManager; - -public class VocabManagerImpl implements IVocabManager { - - private final Logger logger = LoggerFactory - .getLogger(VocabManagerImpl.class); - - public void exampleMethod(String someParam) { - } -} diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index 0887cf267..6a5656a23 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -25,25 +25,20 @@ package org.collectionspace.services.common.vocabulary.nuxeo; import java.util.Map; -import javax.ws.rs.core.MultivaluedMap; - -import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.RefName.Authority; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.config.service.ObjectPartType; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +49,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public abstract class AuthorityDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { private final Logger logger = LoggerFactory.getLogger(AuthorityDocumentModelHandler.class); private String authorityCommonSchemaName; @@ -150,7 +145,7 @@ public abstract class AuthorityDocumentModelHandler String result = null; DocumentModel docModel = docWrapper.getWrappedObject(); - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); RefName.Authority refname = (RefName.Authority)getRefName(ctx, docModel); result = refname.getDisplayName(); @@ -159,7 +154,7 @@ public abstract class AuthorityDocumentModelHandler public String getShortIdentifier(String authCSID, String schemaName) throws Exception { String shortIdentifier = null; - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; ServiceContext ctx = this.getServiceContext(); RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index d8d031d4e..506f1f12d 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -43,18 +43,15 @@ import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ObjectPartType; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.relation.RelationsCommonList; -import org.collectionspace.services.relation.RelationsDocListItem; import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,7 +74,7 @@ import java.util.regex.PatternSyntaxException; * $LastChangedDate: $ */ public abstract class AuthorityItemDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class); private String authorityItemCommonSchemaName; @@ -102,7 +99,7 @@ public abstract class AuthorityItemDocumentModelHandler String result = null; DocumentModel docModel = docWrapper.getWrappedObject(); - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); RefName.AuthorityItem refname = (RefName.AuthorityItem)getRefName(ctx, docModel); result = refname.getDisplayName(); @@ -358,7 +355,7 @@ public abstract class AuthorityItemDocumentModelHandler } ServiceContext ctx = getServiceContext(); RepositoryClient repoClient = getRepositoryClient(ctx); - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); // Update all the existing records that have a field with the old refName in it int nUpdated = RefNameServiceUtils.updateAuthorityRefDocs(ctx, repoClient, repoSession, @@ -473,7 +470,7 @@ public abstract class AuthorityItemDocumentModelHandler String propertyName, String itemcsid) throws Exception { AuthorityRefDocList authRefDocList = null; - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; boolean releaseRepoSession = false; try { 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 5275e58e3..724b70932 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 @@ -3,7 +3,7 @@ package org.collectionspace.services.batch; import java.util.HashMap; import java.util.Set; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.invocable.Invocable; diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java index f0aee5427..8b37cb046 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java @@ -32,7 +32,7 @@ import org.collectionspace.services.client.BatchClient; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.context.ServiceContext; @@ -69,7 +69,7 @@ import javax.ws.rs.core.UriInfo; @Path(BatchClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class BatchResource extends ResourceBase { +public class BatchResource extends NuxeoBasedResource { protected final String COMMON_SCHEMA = "batch_common"; diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java index 3aa4b552d..ce825c5a0 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java @@ -25,71 +25,63 @@ package org.collectionspace.services.batch.nuxeo; import java.util.List; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import org.collectionspace.services.BatchJAXBSchema; import org.collectionspace.services.jaxb.InvocableJAXBSchema; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.batch.BatchCommon; import org.collectionspace.services.batch.BatchInvocable; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ResourceMap; -import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.BadRequestException; import org.collectionspace.services.common.document.DocumentException; -import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.invocable.Invocable; import org.collectionspace.services.common.invocable.InvocationContext; import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.common.invocable.Invocable.InvocationError; + import org.jboss.resteasy.spi.ResteasyProviderFactory; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BatchDocumentModelHandler - extends DocHandlerBase { - private final Logger logger = LoggerFactory.getLogger(BatchDocumentModelHandler.class); +public class BatchDocumentModelHandler extends NuxeoDocumentModelHandler { + private final Logger logger = LoggerFactory.getLogger(BatchDocumentModelHandler.class); protected final int BAD_REQUEST_STATUS = Response.Status.BAD_REQUEST.getStatusCode(); - - public InvocationResults invokeBatchJob( - ServiceContext ctx, - String csid, - ResourceMap resourceMap, - InvocationContext invContext) throws Exception { - - RepositoryInstanceInterface repoSession = null; + + public InvocationResults invokeBatchJob(ServiceContext ctx, String csid, + ResourceMap resourceMap, InvocationContext invContext) throws Exception { + + CoreSessionInterface repoSession = null; boolean releaseRepoSession = false; String invocationMode = invContext.getMode(); String modeProperty = null; boolean checkDocType = true; - if(BatchInvocable.INVOCATION_MODE_SINGLE.equalsIgnoreCase(invocationMode)) { + if (BatchInvocable.INVOCATION_MODE_SINGLE.equalsIgnoreCase(invocationMode)) { modeProperty = BatchJAXBSchema.SUPPORTS_SINGLE_DOC; - } else if(BatchInvocable.INVOCATION_MODE_LIST.equalsIgnoreCase(invocationMode)) { + } else if (BatchInvocable.INVOCATION_MODE_LIST.equalsIgnoreCase(invocationMode)) { modeProperty = BatchJAXBSchema.SUPPORTS_DOC_LIST; - } else if(BatchInvocable.INVOCATION_MODE_GROUP.equalsIgnoreCase(invocationMode)) { + } else if (BatchInvocable.INVOCATION_MODE_GROUP.equalsIgnoreCase(invocationMode)) { modeProperty = BatchJAXBSchema.SUPPORTS_GROUP; - } else if(Invocable.INVOCATION_MODE_NO_CONTEXT.equalsIgnoreCase(invocationMode)) { + } else if (Invocable.INVOCATION_MODE_NO_CONTEXT.equalsIgnoreCase(invocationMode)) { modeProperty = InvocableJAXBSchema.SUPPORTS_NO_CONTEXT; checkDocType = false; } else { - throw new BadRequestException("BatchResource: unknown Invocation Mode: " - +invocationMode); + throw new BadRequestException("BatchResource: unknown Invocation Mode: " + invocationMode); } - RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx); + RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl) this.getRepositoryClient(ctx); repoSession = this.getRepositorySession(); if (repoSession == null) { repoSession = repoClient.getRepositorySession(ctx); @@ -101,22 +93,19 @@ public class BatchDocumentModelHandler try { DocumentWrapper wrapper = repoClient.getDoc(repoSession, ctx, csid); DocumentModel docModel = wrapper.getWrappedObject(); - Boolean supports = (Boolean)docModel.getPropertyValue(modeProperty); - if(!supports) { + Boolean supports = (Boolean) docModel.getPropertyValue(modeProperty); + if (!supports) { throw new BadRequestException("BatchResource: This Batch Job does not support Invocation Mode: " - +invocationMode); + + invocationMode); } - if(checkDocType) { - List forDocTypeList = - (List)docModel.getPropertyValue(BatchJAXBSchema.FOR_DOC_TYPES); - if(forDocTypeList==null - || !forDocTypeList.contains(invContext.getDocType())) { - throw new BadRequestException( - "BatchResource: Invoked with unsupported document type: " - +invContext.getDocType()); + if (checkDocType) { + List forDocTypeList = (List) docModel.getPropertyValue(BatchJAXBSchema.FOR_DOC_TYPES); + if (forDocTypeList == null || !forDocTypeList.contains(invContext.getDocType())) { + throw new BadRequestException("BatchResource: Invoked with unsupported document type: " + + invContext.getDocType()); } } - className = (String)docModel.getPropertyValue(BatchJAXBSchema.BATCH_CLASS_NAME); + className = (String) docModel.getPropertyValue(BatchJAXBSchema.BATCH_CLASS_NAME); } catch (PropertyException pe) { if (logger.isDebugEnabled()) { logger.debug("Property exception getting batch values: ", pe); @@ -137,50 +126,50 @@ public class BatchDocumentModelHandler repoClient.releaseRepositorySession(ctx, repoSession); } } + className = className.trim(); ClassLoader tccl = Thread.currentThread().getContextClassLoader(); Class c = tccl.loadClass(className); // enable validation assertions tccl.setClassAssertionStatus(className, true); - if(!BatchInvocable.class.isAssignableFrom(c)) { - throw new RuntimeException("BatchResource: Class: " - +className+" does not implement BatchInvocable!"); + if (!BatchInvocable.class.isAssignableFrom(c)) { + throw new RuntimeException("BatchResource: Class: " + className + " does not implement BatchInvocable!"); } - BatchInvocable batchInstance = (BatchInvocable)c.newInstance(); + + BatchInvocable batchInstance = (BatchInvocable) c.newInstance(); List modes = batchInstance.getSupportedInvocationModes(); - if(!modes.contains(invocationMode)) { - throw new BadRequestException( - "BatchResource: Invoked with unsupported context mode: " - +invocationMode); + if (!modes.contains(invocationMode)) { + throw new BadRequestException("BatchResource: Invoked with unsupported context mode: " + invocationMode); } + batchInstance.setInvocationContext(invContext); - if(resourceMap!=null) { + + if (resourceMap != null) { batchInstance.setResourceMap(resourceMap); } else { resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); - if(resourceMap!=null) { + if (resourceMap != null) { batchInstance.setResourceMap(resourceMap); } else { logger.warn("BatchResource.invoke did not get a resourceMapHolder in Context!"); } } + batchInstance.run(); int status = batchInstance.getCompletionStatus(); - if(status == Invocable.STATUS_ERROR) { + if (status == Invocable.STATUS_ERROR) { InvocationError error = batchInstance.getErrorInfo(); - if(error.getResponseCode() == BAD_REQUEST_STATUS) { - throw new BadRequestException( - "BatchResouce: batchProcess encountered error: " - +batchInstance.getErrorInfo()); + if (error.getResponseCode() == BAD_REQUEST_STATUS) { + throw new BadRequestException("BatchResouce: batchProcess encountered error: " + + batchInstance.getErrorInfo()); } else { - throw new RuntimeException( - "BatchResouce: batchProcess encountered error: " - +batchInstance.getErrorInfo()); + throw new RuntimeException("BatchResouce: batchProcess encountered error: " + + batchInstance.getErrorInfo()); } } + InvocationResults results = batchInstance.getResults(); return results; } } - diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java index c13420c08..f3e99be9f 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java @@ -8,7 +8,7 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.batch.BatchInvocable; import org.collectionspace.services.client.CollectionSpaceClientUtils; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; import org.collectionspace.services.common.invocable.InvocationContext; @@ -134,7 +134,7 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable { // First, create the Loanout // We fetch the resource class by service name - ResourceBase resource = resourceMap.get( LoanoutClient.SERVICE_NAME); + NuxeoBasedResource resource = resourceMap.get( LoanoutClient.SERVICE_NAME); Response response = resource.create(resourceMap, null, loanoutPayload); if(response.getStatus() != CREATED_STATUS) { completionStatus = STATUS_ERROR; @@ -160,7 +160,7 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable { + ""+RELATION_TYPE+"" + ""+RELATION_PREDICATE_DISP+"" + ""; - ResourceBase resource = resourceMap.get(RelationClient.SERVICE_NAME); + NuxeoBasedResource resource = resourceMap.get(RelationClient.SERVICE_NAME); Response response = resource.create(resourceMap, null, relationPayload); if(response.getStatus() != CREATED_STATUS) { completionStatus = STATUS_ERROR; diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java index d9d722ca6..8a80800a0 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java @@ -18,7 +18,7 @@ import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.MovementClient; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.api.RefNameUtils; import org.collectionspace.services.common.api.Tools; @@ -130,8 +130,8 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { private InvocationResults updateComputedCurrentLocations(List csids) { ResourceMap resourcemap = getResourceMap(); - ResourceBase collectionObjectResource = resourcemap.get(CollectionObjectClient.SERVICE_NAME); - ResourceBase movementResource = resourcemap.get(MovementClient.SERVICE_NAME); + NuxeoBasedResource collectionObjectResource = resourcemap.get(CollectionObjectClient.SERVICE_NAME); + NuxeoBasedResource movementResource = resourcemap.get(MovementClient.SERVICE_NAME); String computedCurrentLocation; int numUpdated = 0; @@ -282,7 +282,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { // // Note: any such values must first be exposed in Movement list items, // in turn via configuration in Services tenant bindings ("listResultsField"). - protected int updateCollectionObjectValues(ResourceBase collectionObjectResource, + protected int updateCollectionObjectValues(NuxeoBasedResource collectionObjectResource, String collectionObjectCsid, AbstractCommonList.ListItem mostRecentMovement, ResourceMap resourcemap, int numUpdated) throws DocumentException, URISyntaxException { @@ -377,11 +377,11 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { // UC Berkeley Botanical Garden v2.4 implementation. // ################################################################# protected PoxPayloadOut findByCsid(String serviceName, String csid) throws URISyntaxException, DocumentException { - ResourceBase resource = getResourceMap().get(serviceName); + NuxeoBasedResource resource = getResourceMap().get(serviceName); return findByCsid(resource, csid); } - protected PoxPayloadOut findByCsid(ResourceBase resource, String csid) throws URISyntaxException, DocumentException { + protected PoxPayloadOut findByCsid(NuxeoBasedResource resource, String csid) throws URISyntaxException, DocumentException { byte[] response = resource.get(null, createUriInfo(), csid); PoxPayloadOut payload = new PoxPayloadOut(response); return payload; @@ -432,7 +432,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { return value; } - private boolean isRecordDeleted(ResourceBase resource, String collectionObjectCsid) + private boolean isRecordDeleted(NuxeoBasedResource resource, String collectionObjectCsid) throws URISyntaxException, DocumentException { boolean isDeleted = false; byte[] workflowResponse = resource.getWorkflow(createUriInfo(), collectionObjectCsid); @@ -456,7 +456,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { return uriInfo; } - private AbstractCommonList getRecordsRelatedToCsid(ResourceBase resource, String csid, + private AbstractCommonList getRecordsRelatedToCsid(NuxeoBasedResource resource, String csid, String relationshipDirection, boolean excludeDeletedRecords) throws URISyntaxException { UriInfo uriInfo = createUriInfo(); uriInfo.getQueryParameters().add(relationshipDirection, csid); @@ -486,7 +486,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { * record * @throws URISyntaxException */ - private AbstractCommonList getRecordsRelatedToObjectCsid(ResourceBase resource, String csid, boolean excludeDeletedRecords) throws URISyntaxException { + private AbstractCommonList getRecordsRelatedToObjectCsid(NuxeoBasedResource resource, String csid, boolean excludeDeletedRecords) throws URISyntaxException { return getRecordsRelatedToCsid(resource, csid, IQueryManager.SEARCH_RELATED_TO_CSID_AS_OBJECT, excludeDeletedRecords); } @@ -503,11 +503,11 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { * record * @throws URISyntaxException */ - private AbstractCommonList getRecordsRelatedToSubjectCsid(ResourceBase resource, String csid, boolean excludeDeletedRecords) throws URISyntaxException { + private AbstractCommonList getRecordsRelatedToSubjectCsid(NuxeoBasedResource resource, String csid, boolean excludeDeletedRecords) throws URISyntaxException { return getRecordsRelatedToCsid(resource, csid, IQueryManager.SEARCH_RELATED_TO_CSID_AS_SUBJECT, excludeDeletedRecords); } - private AbstractCommonList getRelatedRecords(ResourceBase resource, String csid, boolean excludeDeletedRecords) + private AbstractCommonList getRelatedRecords(NuxeoBasedResource resource, String csid, boolean excludeDeletedRecords) throws URISyntaxException, DocumentException { AbstractCommonList relatedRecords = new AbstractCommonList(); AbstractCommonList recordsRelatedToObjectCSID = getRecordsRelatedToObjectCsid(resource, csid, excludeDeletedRecords); @@ -536,11 +536,11 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { private List getMemberCsidsFromGroup(String serviceName, String groupCsid) throws URISyntaxException, DocumentException { ResourceMap resourcemap = getResourceMap(); - ResourceBase resource = resourcemap.get(serviceName); + NuxeoBasedResource resource = resourcemap.get(serviceName); return getMemberCsidsFromGroup(resource, groupCsid); } - private List getMemberCsidsFromGroup(ResourceBase resource, String groupCsid) throws URISyntaxException, DocumentException { + private List getMemberCsidsFromGroup(NuxeoBasedResource resource, String groupCsid) throws URISyntaxException, DocumentException { // The 'resource' type used here identifies the record type of the // related records to be retrieved AbstractCommonList relatedRecords = @@ -551,7 +551,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { private List getNoContextCsids() throws URISyntaxException { ResourceMap resourcemap = getResourceMap(); - ResourceBase collectionObjectResource = resourcemap.get(CollectionObjectClient.SERVICE_NAME); + NuxeoBasedResource collectionObjectResource = resourcemap.get(CollectionObjectClient.SERVICE_NAME); UriInfo uriInfo = createUriInfo(); uriInfo = addFilterToExcludeSoftDeletedRecords(uriInfo); AbstractCommonList collectionObjects = collectionObjectResource.getList(uriInfo); diff --git a/services/blob/service/pom.xml b/services/blob/service/pom.xml index 849f347dd..84530b5ca 100644 --- a/services/blob/service/pom.xml +++ b/services/blob/service/pom.xml @@ -1,108 +1,113 @@ - + - - org.collectionspace.services - org.collectionspace.services.blob - 4.2-SNAPSHOT - - - 4.0.0 - org.collectionspace.services.blob.service - services.blob.service - jar + + org.collectionspace.services + org.collectionspace.services.blob + 4.2-SNAPSHOT + - - - org.collectionspace.services - org.collectionspace.services.common - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.config - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.blob.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.publicitem.client - ${project.version} - - - - - junit - junit - test - - - org.testng - testng - - - + 4.0.0 + org.collectionspace.services.blob.service + services.blob.service + jar - - javax.security - jaas - 1.0.01 - provided - + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.blob.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.publicitem.client + ${project.version} + - - dom4j - dom4j - 1.6.1 - provided - - - + + + junit + junit + test + + + org.testng + testng + + + javax.servlet + servlet-api + - - org.jboss.resteasy - resteasy-jaxrs - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - - - org.jboss.resteasy - resteasy-multipart-provider - - - + - - org.nuxeo.ecm.core - nuxeo-core-api - - - jboss-remoting - jboss - - - - - - - collectionspace-services-blob - + + javax.security + jaas + 1.0.01 + provided + + + + dom4j + dom4j + 1.6.1 + provided + + + + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + + + + org.nuxeo.ecm.core + nuxeo-core-api + + + jboss-remoting + jboss + + + + + + + collectionspace-services-blob + diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java index 5e182268d..be4121244 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java @@ -25,12 +25,11 @@ package org.collectionspace.services.blob; import org.collectionspace.services.publicitem.PublicitemsCommon; import org.collectionspace.services.client.BlobClient; -import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PayloadPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.FileUtils; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.blob.BlobInput; @@ -47,32 +46,27 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.UriInfo; -import java.io.File; import java.io.InputStream; import java.util.List; import java.util.Map; -import java.util.UUID; //FIXME: REM - We should not have Nuxeo dependencies in our resource classes. @Path(BlobClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class BlobResource extends ResourceBase { +public class BlobResource extends NuxeoBasedResource { @Override public String getServiceName(){ @@ -121,7 +115,7 @@ public class BlobResource extends ResourceBase { return result; } - private InputStream getBlobContent(ServiceContext ctx, + private InputStream getBlobContent(ServiceContext ctx, String csid, String derivativeTerm, StringBuffer outMimeType) throws CSWebApplicationException { diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java index 8c0d3a853..8d094ce07 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java @@ -24,7 +24,7 @@ package org.collectionspace.services.blob.nuxeo; import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.client.BlobClient; import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; @@ -40,28 +40,25 @@ import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.jaxb.BlobJAXBSchema; import org.collectionspace.services.nuxeo.client.java.CommonList; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; - -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.IdRef; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; import java.util.Map; - import javax.ws.rs.core.MultivaluedMap; - import org.dom4j.Element; /** * The Class BlobDocumentModelHandler. */ public class BlobDocumentModelHandler -extends DocHandlerBase { +extends NuxeoDocumentModelHandler { /** The logger. */ private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class); @@ -115,7 +112,7 @@ extends DocHandlerBase { ObjectPartType partMeta = partsMetaMap.get(metadataLabel); if (partMeta != null) { - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); if (nuxeoImageID != null && nuxeoImageID.isEmpty() == false) try { IdRef documentRef = new IdRef(nuxeoImageID); DocumentModel docModel = repoSession.getDocument(documentRef); @@ -139,7 +136,7 @@ extends DocHandlerBase { throws Exception { ServiceContext ctx = this.getServiceContext(); BlobInput blobInput = BlobUtil.getBlobInput(ctx); // the blobInput was set by the Blob JAX-RS resource code and put into the service context - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); DocumentModel docModel = wrapDoc.getWrappedObject(); BlobsCommon blobsCommon = this.getCommonPartProperties(docModel); String blobRepositoryId = blobsCommon.getRepositoryId(); //cache the value to pass to the blob retriever @@ -220,7 +217,7 @@ extends DocHandlerBase { // If blobInput has a file then we just received a multipart/form-data file post or a URI query parameter // DocumentModel documentModel = wrapDoc.getWrappedObject(); - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); BlobsCommon blobsCommon = NuxeoBlobUtils.createBlobInRepository(ctx, repoSession, blobInput, purgeOriginal, true); blobInput.setBlobCsid(documentModel.getName()); //Assumption here is that the documentModel "name" field is storing a CSID diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index 7b3228ccd..1daca950e 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -28,7 +28,7 @@ package org.collectionspace.services.collectionobject; import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.Profiler; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationshipType; @@ -54,7 +54,7 @@ import java.util.List; @Path(CollectionObjectClient.SERVICE_PATH_COMPONENT) @Consumes("application/xml") @Produces("application/xml") -public class CollectionObjectResource extends ResourceBase { +public class CollectionObjectResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class); diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java index 1bfb82e8b..073492ac3 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java @@ -24,7 +24,7 @@ package org.collectionspace.services.collectionobject.nuxeo; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** * CollectionObjectDocumentModelHandler @@ -33,6 +33,6 @@ import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; * $LastChangedDate: $ */ public class CollectionObjectDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/common/pom.xml b/services/common/pom.xml index 9dc2e6316..1b69fb0a0 100644 --- a/services/common/pom.xml +++ b/services/common/pom.xml @@ -1,412 +1,395 @@ - - - org.collectionspace.services - org.collectionspace.services.main - 4.2-SNAPSHOT - + + + org.collectionspace.services + org.collectionspace.services.main + 4.2-SNAPSHOT + - 4.0.0 - org.collectionspace.services.common - services.common - jar + 4.0.0 + org.collectionspace.services.common + services.common + jar - - - - org.collectionspace.services - org.collectionspace.services.config - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.3rdparty.nuxeo.thumbnail - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.common-api - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authorization-mgt.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.relation.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.publicitem.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.publicitem.jaxb - ${project.version} - - + + org.collectionspace.services + org.collectionspace.services.config + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.3rdparty.nuxeo.thumbnail + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.common-api + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authorization-mgt.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.relation.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.publicitem.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.publicitem.jaxb + ${project.version} + + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authority.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.hyperjaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authentication.jaxb + ${project.version} + provided + + org.collectionspace.services - org.collectionspace.services.3rdparty.nuxeo.quote-api - ${project.version} - - --> - - org.collectionspace.services - org.collectionspace.services.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authority.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.hyperjaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.client - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authentication.jaxb - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authentication.service - ${project.version} - provided - - - org.collectionspace.services - org.collectionspace.services.authorization.jaxb - ${project.version} - - - org.collectionspace.services - org.collectionspace.services.authorization.service - ${project.version} - + org.collectionspace.services.authentication.service + ${project.version} + provided + + + org.collectionspace.services + org.collectionspace.services.authorization.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.authorization.service + ${project.version} + - - - - org.restlet - org.restlet - 1.0.7 - - - com.noelios.restlet - com.noelios.restlet.ext.httpclient - 1.0.7 - - - com.noelios.restlet - com.noelios.restlet - 1.0.7 - + + + + org.restlet + org.restlet + 1.0.7 + + + com.noelios.restlet + com.noelios.restlet.ext.httpclient + 1.0.7 + + + com.noelios.restlet + com.noelios.restlet + 1.0.7 + - - org.slf4j - slf4j-api - provided - - - org.slf4j - slf4j-log4j12 - provided - - - log4j - log4j - 1.2.14 - provided - - - org.apache.commons - commons-jexl - 2.0.1 - - - commons-dbcp - commons-dbcp - 1.3-RC1 - provided - - + + org.slf4j + slf4j-api + provided + + + org.slf4j + slf4j-log4j12 + provided + + + log4j + log4j + 1.2.14 + provided + + + org.apache.commons + commons-jexl + 2.0.1 + + + commons-dbcp + commons-dbcp + 1.3-RC1 + provided + + commons-codec commons-codec 1.4 - - - commons-lang - commons-lang - 2.6 - - - org.apache.tomcat - dbcp - 6.0.33 - provided - + + + commons-lang + commons-lang + 2.6 + + + org.apache.tomcat + dbcp + 6.0.33 + provided + org.apache.tomcat catalina - 6.0.33 - provided + 6.0.33 + provided - - - javax.servlet - servlet-api - provided - + + + javax.servlet + servlet-api + provided + - - javax.security - jaas - 1.0.01 - provided - - - javax.security - jacc - 1.0 - provided - - - - mysql - mysql-connector-java - provided - - - postgresql - postgresql - provided - - - javax.persistence - persistence-api - + + javax.security + jaas + 1.0.01 + provided + + + javax.security + jacc + 1.0 + provided + + + + mysql + mysql-connector-java + provided + + + postgresql + postgresql + provided + + + javax.persistence + persistence-api + - - - org.jboss.resteasy - jaxrs-api - - - org.jboss.resteasy - resteasy-jaxrs - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - - - org.jboss.resteasy - resteasy-multipart-provider - + + + org.jboss.resteasy + jaxrs-api + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + - - org.hibernate - hibernate-entitymanager - - - + + org.hibernate + hibernate-entitymanager + + + org.jboss.security jbosssx 2.0.3.SP1 provided - + org.jboss.remoting jboss-remoting provided - - - org.nuxeo.lib.runtime - nuxeo-runtime-launcher - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-mimetype-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-mimetype-core - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-types-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-types-core - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-core - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-imaging-api - ${nuxeo.platform.version} - - - org.nuxeo.ecm.platform - nuxeo-platform-filemanager-api - ${nuxeo.platform.version} - - - org.nuxeo.common - nuxeo-common - ${nuxeo.core.version} - provided - - - org.nuxeo.runtime - nuxeo-runtime - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-api - - - - org.nuxeo.ecm.core - nuxeo-core-query - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-schema - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-storage-sql - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-storage-sql-ra - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-io - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-core-convert - ${nuxeo.core.version} - - - - org.nuxeo.runtime - nuxeo-runtime-osgi - ${nuxeo.core.version} - - - org.nuxeo.ecm.core - nuxeo-opencmis-bindings - ${nuxeo.core.version} - - - org.apache.chemistry.opencmis - chemistry-opencmis-server-bindings - 0.6.0 - classes - - - org.osgi - org.osgi.core - 4.1.0 - + + + org.nuxeo.lib.runtime + nuxeo-runtime-launcher + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-mimetype-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-mimetype-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-types-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-types-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-imaging-api + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-platform-filemanager-api + ${nuxeo.platform.version} + + + org.nuxeo.common + nuxeo-common + ${nuxeo.core.version} + provided + + + org.nuxeo.runtime + nuxeo-runtime + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-api + + + org.nuxeo.ecm.core + nuxeo-core-query + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-schema + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-storage-sql + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-storage-sql-ra + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-io + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-core-convert + ${nuxeo.core.version} + + + + org.nuxeo.runtime + nuxeo-runtime-osgi + ${nuxeo.core.version} + + + org.nuxeo.ecm.core + nuxeo-opencmis-bindings + ${nuxeo.core.version} + + + org.apache.chemistry.opencmis + chemistry-opencmis-server-bindings + ${chemistry.opencmis.version.nx} + + + com.sun.xml.ws + jaxws-rt + + + + + org.osgi + org.osgi.core + 4.1.0 + - commons-fileupload - commons-fileupload - 1.2 - - - ch.elca.el4j.modules - module-xml_merge-common - 3.1 - provided - - - commons-io - commons-io - - - org.springframework.security - spring-security-acl - ${spring.security.version} - provided - + commons-fileupload + commons-fileupload + 1.2 + + + ch.elca.el4j.modules + module-xml_merge-common + 3.1 + provided + + + commons-io + commons-io + + + org.springframework.security + spring-security-acl + ${spring.security.version} + provided + org.springframework spring-aop ${spring.version} - - + + - - collectionspace-services-common - install - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - - - + + collectionspace-services-common + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java b/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java index e4ff2d089..48e166563 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java @@ -28,7 +28,6 @@ import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; @@ -68,10 +67,10 @@ public abstract class AbstractCollectionSpaceResourceImpl // Fields for default client factory and client /** The repository client factory. */ - private RepositoryClientFactory repositoryClientFactory; + private RepositoryClientFactory repositoryClientFactory; /** The repository client. */ - private RepositoryClient repositoryClient; + private RepositoryClient repositoryClient; /** The storage client. */ private StorageClient storageClient; @@ -94,7 +93,7 @@ public abstract class AbstractCollectionSpaceResourceImpl * Instantiates a new abstract collection space resource. */ public AbstractCollectionSpaceResourceImpl() { - repositoryClientFactory = RepositoryClientFactory.getInstance(); + repositoryClientFactory = (RepositoryClientFactory) RepositoryClientFactory.getInstance(); } /* (non-Javadoc) @@ -108,7 +107,7 @@ public abstract class AbstractCollectionSpaceResourceImpl * @see org.collectionspace.services.common.CollectionSpaceResource#getRepositoryClient(org.collectionspace.services.common.context.ServiceContext) */ @Override - synchronized public RepositoryClient getRepositoryClient(ServiceContext ctx) { + synchronized public RepositoryClient getRepositoryClient(ServiceContext ctx) { if(repositoryClient != null){ return repositoryClient; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java similarity index 96% rename from services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java rename to services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java index 4ded3611f..de4c957d1 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java @@ -53,21 +53,21 @@ import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; import org.collectionspace.services.nuxeo.util.NuxeoUtils; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; + import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.util.HttpResponseCodes; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; - /** * $LastChangedRevision: $ * $LastChangedDate: $ * Author: Laramie Crocker */ -public abstract class ResourceBase +public abstract class NuxeoBasedResource extends AbstractMultiPartCollectionSpaceResourceImpl { public static final String CREATE = "create"; @@ -332,7 +332,8 @@ public abstract class ResourceBase } } - protected AbstractCommonList finish_getList(ServiceContext ctx, DocumentHandler handler) { + protected AbstractCommonList finish_getList(ServiceContext ctx, + DocumentHandler handler) { try { getRepositoryClient(ctx).getFiltered(ctx, handler); // REM - Side effect of this call sets the handler's common part list value return (AbstractCommonList) handler.getCommonPartList(); @@ -503,17 +504,17 @@ public abstract class ResourceBase * for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get * the map, and pass it in. */ - public static DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName, ResourceMap resourceMap) + public static DocumentModel getDocModelForRefName(CoreSessionInterface repoSession, String refName, ResourceMap resourceMap) throws Exception, DocumentNotFoundException { RefName.AuthorityItem item = RefName.AuthorityItem.parse(refName); if(item != null) { - ResourceBase resource = resourceMap.get(item.inAuthority.resource); + NuxeoBasedResource resource = resourceMap.get(item.inAuthority.resource); return resource.getDocModelForAuthorityItem(repoSession, item); } RefName.Authority authority = RefName.Authority.parse(refName); // Handle case of objects refNames, which must be csid based. if(authority != null && !Tools.isEmpty(authority.csid)) { - ResourceBase resource = resourceMap.get(authority.resource); + NuxeoBasedResource resource = resourceMap.get(authority.resource); // Ensure we have the right context. ServiceContext ctx = resource.createServiceContext(authority.resource); @@ -524,15 +525,15 @@ public abstract class ResourceBase return null; } - // THis is ugly, but prevents us parsing the refName twice. Once we make refName a little more + // This is ugly, but prevents us parsing the refName twice. Once we make refName a little more // general, and less Authority(Item) specific, this will look better. - public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item) + public DocumentModel getDocModelForAuthorityItem(CoreSessionInterface repoSession, RefName.AuthorityItem item) throws Exception, DocumentNotFoundException { logger.warn("Default (ResourceBase) getDocModelForAuthorityItem called - should not happen!"); return null; } - public DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName) + public DocumentModel getDocModelForRefName(CoreSessionInterface repoSession, String refName) throws Exception, DocumentNotFoundException { return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName)); } @@ -623,7 +624,5 @@ public abstract class ResourceBase protected TenantBindingConfigReaderImpl getTenantBindingsReader() { return ServiceMain.getInstance().getTenantBindingConfigReader(); } - - } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java index d1d990cb3..6d1ef8642 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java @@ -5,6 +5,6 @@ import java.util.Map; /* * Maps service names to Resource instances. Use the Service Client Class to get the service name. */ -public interface ResourceMap extends Map { +public interface ResourceMap extends Map { } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceMapImpl.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceMapImpl.java index a49b6865b..ee9dc3036 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceMapImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceMapImpl.java @@ -2,6 +2,6 @@ package org.collectionspace.services.common; import java.util.HashMap; -public class ResourceMapImpl extends HashMap implements ResourceMap { +public class ResourceMapImpl extends HashMap implements ResourceMap { } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index db2ee3fbd..153b9b6bc 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -761,9 +761,9 @@ public class ServiceMain { */ private synchronized void populateUriTemplateRegistry() { if (uriTemplateRegistry.isEmpty()) { - ResourceBase resource = null; + NuxeoBasedResource resource = null; ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); - for (Map.Entry entry : resourceMap.entrySet()) { + for (Map.Entry entry : resourceMap.entrySet()) { resource = entry.getValue(); Map entries = resource.getUriRegistryEntries(); diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java index 2dae5e072..2d37eb5aa 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java @@ -26,13 +26,13 @@ package org.collectionspace.services.common.document; import java.util.HashMap; import java.util.List; import java.util.Map; - import java.util.StringTokenizer; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.query.QueryContext; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,7 +161,16 @@ public abstract class AbstractDocumentHandlerImpl validate(action); prepareDelete(); break; - + + case WORKFLOW: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; + + default: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; } } @@ -225,7 +234,16 @@ public abstract class AbstractDocumentHandlerImpl case DELETE: handleDelete((DocumentWrapper) wrapDoc); break; - + + case WORKFLOW: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; + + default: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; } } @@ -286,6 +304,16 @@ public abstract class AbstractDocumentHandlerImpl case DELETE: completeDelete((DocumentWrapper) wrapDoc); break; + + case WORKFLOW: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; + + default: + logger.error("Should never get to this code path. If you did, there is a bug in the code."); + Thread.dumpStack(); + break; } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java index 6436951f4..648288389 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java @@ -23,12 +23,6 @@ */ package org.collectionspace.services.common.document; - - -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * AbstractMultipartDocumentHandler * @@ -43,8 +37,6 @@ public abstract class AbstractMultipartDocumentHandlerImpl extends AbstractDocumentHandlerImpl implements MultipartDocumentHandler { - private final Logger logger = LoggerFactory.getLogger(AbstractMultipartDocumentHandlerImpl.class); - public AbstractMultipartDocumentHandlerImpl() { //Empty constructor } diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/MultipartDocumentHandler.java b/services/common/src/main/java/org/collectionspace/services/common/document/MultipartDocumentHandler.java index 7617e7c68..88965eb61 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/MultipartDocumentHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/MultipartDocumentHandler.java @@ -17,8 +17,6 @@ */ package org.collectionspace.services.common.document; -import org.collectionspace.services.common.document.DocumentHandler.Action; - /** * MultipartDocumentHandler is a DocumentHandler provides document processing * methods for entities using schema extension that are mapped to multipart diff --git a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java index 4e2b69512..e8e166a4d 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java @@ -28,11 +28,8 @@ package org.collectionspace.services.common.imaging.nuxeo; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.IOException; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; @@ -41,10 +38,6 @@ import java.util.List; import java.util.Map; import org.nuxeo.runtime.api.Framework; -//import org.nuxeo.runtime.api.ServiceManager; -//import org.nuxeo.runtime.api.ServiceDescriptor; - -//import org.nuxeo.common.utils.FileUtils; import org.nuxeo.ecm.platform.picture.api.ImageInfo; import org.nuxeo.ecm.platform.picture.api.ImagingDocumentConstants; @@ -58,49 +51,23 @@ import org.nuxeo.ecm.platform.filemanager.service.FileManagerService; import org.nuxeo.ecm.platform.filemanager.service.extension.FileImporter; import org.nuxeo.ecm.platform.filemanager.utils.FileManagerUtils; import org.nuxeo.ecm.platform.types.TypeManager; -import org.nuxeo.ecm.core.repository.RepositoryDescriptor; -import org.nuxeo.ecm.core.repository.RepositoryManager; -import org.nuxeo.ecm.core.repository.RepositoryService; -import org.nuxeo.ecm.core.storage.sql.BinaryManager; -import org.nuxeo.ecm.core.storage.sql.DefaultBinaryManager; - -/* - * Keep these commented out import statements as reminders of Nuxeo's blob management -import org.nuxeo.runtime.model.ComponentManager; -import org.nuxeo.runtime.model.impl.ComponentManagerImpl; -import org.nuxeo.ecm.core.api.ejb.DocumentManagerBean; -import org.nuxeo.ecm.core.storage.sql.RepositoryImpl; -import org.nuxeo.ecm.core.storage.sql.Repository; -import org.nuxeo.ecm.core.storage.sql.Binary; -import org.nuxeo.ecm.core.storage.sql.RepositoryImpl; -import org.nuxeo.ecm.core.storage.sql.RepositoryResolver; -import org.nuxeo.ecm.core.storage.sql.coremodel.SQLBlob; -import org.nuxeo.ecm.core.storage.sql.coremodel.SQLRepository; -import org.nuxeo.ecm.core.storage.sql.RepositoryDescriptor; -import org.nuxeo.ecm.core.api.DocumentResolver; -*/ +import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.IdRef; import org.nuxeo.ecm.core.api.blobholder.BlobHolder; import org.nuxeo.ecm.core.api.blobholder.DocumentBlobHolder; import org.nuxeo.ecm.core.api.impl.blob.FileBlob; import org.nuxeo.ecm.core.api.impl.blob.InputStreamBlob; -import org.nuxeo.ecm.core.api.impl.blob.StreamingBlob; -import org.nuxeo.ecm.core.api.impl.blob.ByteArrayBlob; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.nuxeo.ecm.core.api.repository.Repository; import org.nuxeo.ecm.core.api.Blob; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentRef; -import org.nuxeo.ecm.core.event.EventServiceAdmin; -import org.nuxeo.ecm.core.schema.SchemaManager; -import org.nuxeo.ecm.core.schema.types.Schema; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -//import org.nuxeo.ecm.core.repository.jcr.testing.RepositoryOSGITestCase; import org.apache.commons.io.IOUtils; + import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.FileUtils; @@ -118,13 +85,12 @@ import org.collectionspace.services.blob.MeasuredPartGroup; import org.collectionspace.services.blob.MeasuredPartGroupList; import org.collectionspace.services.jaxb.BlobJAXBSchema; import org.collectionspace.services.nuxeo.client.java.CommonList; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.config.service.ListResultField; - /** * The Class NuxeoBlobUtils. */ @@ -186,22 +152,6 @@ public class NuxeoBlobUtils { public static final String SCHEMA_IPTC = "iptc"; public static final String SCHEMA_IMAGE_METADATA = "image_metadata"; - private static final int THUMB_SIZE_HEIGHT = 100; - private static final int THUMB_SIZE_WIDTH = 75; - - // static DefaultBinaryManager binaryManager = new DefaultBinaryManager(); - // //can we get this from Nuxeo? i.e., - // Framework.getService(BinaryManger.class) - - // /** The temp file name. */ - // static String tempFileName = "sunset.jpg"; - // - // /** The file separator. */ - // static String fileSeparator = System.getProperty("file.separator"); - // - // /** The cur dir. */ - // static String curDir = System.getProperty("user.dir"); - /** * Instantiates a new nuxeo image utils. */ @@ -298,7 +248,7 @@ public class NuxeoBlobUtils { return result; } - static public CommonList getBlobDerivatives(RepositoryInstanceInterface repoSession, + static public CommonList getBlobDerivatives(CoreSessionInterface repoSession, String repositoryId, List resultsFields, String uri) throws Exception { CommonList commonList = new CommonList(); @@ -482,8 +432,8 @@ public class NuxeoBlobUtils { ThumbnailConstants.THUMBNAIL_PROPERTY_NAME); } catch (ClientException e) { errorMsg = "Could not extract the name of the thumbnail preview image file."; - if (logger.isTraceEnabled()) { - logger.trace(errorMsg, e); + if (logger.isDebugEnabled()) { + logger.debug(errorMsg, e); } } @@ -498,102 +448,6 @@ public class NuxeoBlobUtils { return result; } - /* - * This is a prototype method that is not currently used as of 1/1/2012. However, - * it may be useful now that we've transitioned to using an embedded Nuxeo server. - */ - static private File getBlobFile(RepositoryInstanceInterface ri, - DocumentModel documentModel, Blob blob) { - DefaultBinaryManager binaryManager = null; - RepositoryDescriptor descriptor = null; - File file = null; - - try { - RepositoryService repositoryService1 = (RepositoryService) Framework - .getRuntime().getComponent(RepositoryService.NAME); - - String repositoryName = documentModel.getRepositoryName(); - RepositoryManager repositoryManager = repositoryService1 - .getRepositoryManager(); - descriptor = repositoryManager.getDescriptor(repositoryName); - -// Keep this code around for future work/enhancements -// binaryManager = new DefaultBinaryManager(); -// -// File storageDir = binaryManager.getStorageDir(); -// // SQLBlob blob = (SQLBlob) -// // doc.getPropertyValue("schema:blobField"); -// File file = binaryManager.getFileForDigest(blob.getDigest(), false); - - } catch (Exception e) { - e.printStackTrace(); - } - -// Keep this code around for future work/enhancements -// try { -// binaryManager.initialize(SQLRepository.getDescriptor(descriptor)); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - -// Keep this code around for future work/enhancements -// File storageDir = binaryManager.getStorageDir(); -// SQLBlob blob = (SQLBlob) -// documentModel.getPropertyValue("schema:blobField"); -// File file = binaryManager.getFileForDigest(blob.getDigest(), false); - - return file; - } - - /** - * Returns a schema, given the name of a schema. Possibly usefule in the future - * - * @param schemaName - * a schema name. - * @return a schema. - */ - private static Schema getSchemaFromName(String schemaName) { - SchemaManager schemaManager = null; - try { - schemaManager = Framework.getService(SchemaManager.class); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return schemaManager != null ? schemaManager.getSchema(schemaName) - : null; - } - - /** - * Gets the blob. Not in use now, but might be useful in the future. - * - * @param nuxeoSession - * the nuxeo session - * @param id - * the id - * @return the blob - */ - static private Blob getBlob(RepositoryInstanceInterface repoSession, String id) { - Blob result = null; - - try { - Repository repository = repoSession.getRepositoryInstance().getRepository(); - // binaryManager.initialize(new RepositoryDescriptor()); - // binaryManager.getBinary("a4cac052ae0281979f2dcf5ab2e61a6c"); - // DocumentResolver.resolveReference(nuxeoSession, documentRef); - // binaryManager = repository.getBinaryManager(); - // documentModel.getr - } catch (Exception x) { - x.printStackTrace(); - } - - return result; - } - static private Blob checkMimeType(Blob blob, String fullname) throws ClientException { final String mimeType = blob.getMimeType(); @@ -629,169 +483,10 @@ public class NuxeoBlobUtils { return typeService; } - /** - * Gets the bytes. - * - * @param fis - * the fis - * @return the bytes - */ - private static byte[] getBytes(InputStream fis) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - byte[] buf = new byte[128 * 1024]; - try { - for (int readNum; (readNum = fis.read(buf)) != -1;) { - bos.write(buf, 0, readNum); - // no doubt here is 0 - /* - * Writes len bytes from the specified byte array starting at - * offset off to this byte array output stream. - */ - System.out.println("read " + readNum + " bytes,"); - } - } catch (IOException ex) { - logger.error(ex.getMessage(), ex); - } - byte[] bytes = bos.toByteArray(); - // bytes is the ByteArray we need - return bytes; - } - - /** - * Creates the serializable blob. We may need this code, do not remove. - * - * @param fileInputStream - * the file input stream - * @param filename - * the filename - * @param mimeType - * the mime type - * @return the blob - */ - private static Blob createSerializableBlob(InputStream fileInputStream, - String filename, String mimeType) { - Blob blob = null; - try { - // persisting the blob makes it possible to read the binary content - // of the request stream several times (mimetype sniffing, digest - // computation, core binary storage) - byte[] bytes = getBytes(fileInputStream); - blob = new ByteArrayBlob(bytes); - // filename - if (filename != null) { - filename = getCleanFileName(filename); - } - blob.setFilename(filename); - // mimetype detection - MimetypeRegistry mimeService = Framework - .getService(MimetypeRegistry.class); - String detectedMimeType = mimeService - .getMimetypeFromFilenameAndBlobWithDefault(filename, blob, - null); - if (detectedMimeType == null) { - if (mimeType != null) { - detectedMimeType = mimeType; - } else { - // default - detectedMimeType = "application/octet-stream"; - } - } - blob.setMimeType(detectedMimeType); - } catch (MimetypeDetectionException e) { - logger.error(String.format("could not fetch mimetype for file %s", - filename), e); - } catch (Exception e) { - logger.error("", e); - } - return blob; - } - - /** - * Creates a serializable blob from a stream, with filename and mimetype - * detection. - * - *

- * Creates an in-memory blob if data is under 64K, otherwise constructs a - * serializable FileBlob which stores data in a temporary file on the hard - * disk. - *

- * - * @param file - * the input stream holding data - * @param filename - * the file name. Will be set on the blob and will used for - * mimetype detection. - * @param mimeType - * the detected mimetype at upload. Can be null. Will be verified - * by the mimetype service. - * @return the blob - */ - private static Blob createStreamingBlob(File file, String filename, - String mimeType) { - Blob blob = null; - try { - // persisting the blob makes it possible to read the binary content - // of the request stream several times (mimetype sniffing, digest - // computation, core binary storage) - blob = StreamingBlob.createFromFile(file, mimeType).persist(); - // filename - if (filename != null) { - filename = getCleanFileName(filename); - } - blob.setFilename(filename); - // mimetype detection - MimetypeRegistry mimeService = Framework - .getService(MimetypeRegistry.class); - String detectedMimeType = mimeService - .getMimetypeFromFilenameAndBlobWithDefault(filename, blob, - null); - if (detectedMimeType == null) { - if (mimeType != null) { - detectedMimeType = mimeType; - } else { - // default - detectedMimeType = "application/octet-stream"; - } - } - blob.setMimeType(detectedMimeType); - } catch (MimetypeDetectionException e) { - logger.error(String.format("could not fetch mimetype for file %s", - filename), e); - } catch (IOException e) { - logger.error("", e); - } catch (Exception e) { - logger.error("", e); - } - return blob; - } - private static Blob createNuxeoFileBasedBlob(File file) throws Exception { return new FileBlob(file); } - /** - * Returns a clean filename, stripping upload path on client side. - *

- * Fixes NXP-544 - *

- * - * @param filename - * the filename - * @return the clean file name - */ - private static String getCleanFileName(String filename) { - String res = null; - int lastWinSeparator = filename.lastIndexOf('\\'); - int lastUnixSeparator = filename.lastIndexOf('/'); - int lastSeparator = Math.max(lastWinSeparator, lastUnixSeparator); - if (lastSeparator != -1) { - res = filename.substring(lastSeparator + 1, filename.length()); - } else { - res = filename; - } - return res; - } - /** * Gets Nuxeo's file manager service. * @@ -834,51 +529,10 @@ public class NuxeoBlobUtils { return result; } - /** - * Gets Nuxeo's file manager service. - * - * @return the file manager service - * @throws ClientException - * the client exception - */ - private static FileManager getFileManagerServicex() throws ClientException { - FileManager result = null; - try { - result = Framework.getService(FileManager.class); - } catch (Exception e) { - String msg = "Unable to get Nuxeo's FileManager service."; - logger.error(msg, e); - throw new ClientException("msg", e); - } - return result; - } - - private static EventServiceAdmin getEventServiceAdmin() throws ClientException { - EventServiceAdmin result = null; - try { - result = Framework.getService(EventServiceAdmin.class); - } catch (Exception e) { - String msg = "Unable to get Nuxeo's EventServiceAdmin service."; - logger.error(msg, e); - throw new ClientException("msg", e); - } - return result; - } - - private static BinaryManager getBinaryManagerService() throws ClientException { - BinaryManager result = null; - try { - result = Framework.getService(BinaryManager.class); - } catch (Exception e) { - String msg = "Unable to get Nuxeo's BinaryManager service."; - logger.error(msg, e); - throw new ClientException("msg", e); - } - return result; - } - static private RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) { - RepositoryInstanceInterface result = null; + static private CoreSessionInterface getRepositorySession(ServiceContext ctx, + RepositoryClient repositoryClient) { + CoreSessionInterface result = null; RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient; try { @@ -890,7 +544,9 @@ public class NuxeoBlobUtils { return result; } - static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstanceInterface repoSession) throws TransactionException { + static private void releaseRepositorySession(ServiceContext ctx, + RepositoryClient repositoryClient, + CoreSessionInterface repoSession) throws TransactionException { RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient; nuxeoClient.releaseRepositorySession(ctx, repoSession); } @@ -908,7 +564,7 @@ public class NuxeoBlobUtils { } private static DocumentModel createDocumentFromBlob( - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, Blob inputStreamBlob, String blobLocation, boolean overwrite, @@ -923,21 +579,20 @@ public class NuxeoBlobUtils { // image derivatives. // result = getFileManager().createDocumentFromBlob( - repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName); + repoSession.getCoreSession(), inputStreamBlob, blobLocation, true, blobName); } else { // // User Nuxeo's default file importer/adapter explicitly. This avoids specialized functionality from happening like // image derivative creation. // - String digestAlgorithm = getFileManager() - .getDigestAlgorithm(); // Only call this because we seem to need some way of initializing Nuxeo's FileManager with a call. + String digestAlgorithm = getFileManager().getDigestAlgorithm(); // Only call this because we seem to need some way of initializing Nuxeo's FileManager with a call. FileManagerService fileManagerService = getFileManagerService(); inputStreamBlob = checkMimeType(inputStreamBlob, blobName); FileImporter defaultFileImporter = fileManagerService.getPluginByName("DefaultFileImporter"); result = defaultFileImporter.create( - repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName, getTypeService()); + repoSession.getCoreSession(), inputStreamBlob, blobLocation, true, blobName, getTypeService()); } return result; @@ -945,14 +600,14 @@ public class NuxeoBlobUtils { static public BlobsCommon createBlobInRepository( ServiceContext ctx, - RepositoryClient repositoryClient, + RepositoryClient repositoryClient, InputStream inputStream, String blobName, boolean useNuxeoAdaptors) throws TransactionException { BlobsCommon result = null; boolean repoSessionCleanup = false; - RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession(); + CoreSessionInterface repoSession = (CoreSessionInterface)ctx.getCurrentRepositorySession(); if (repoSession == null) { repoSession = getRepositorySession(ctx, repositoryClient); repoSessionCleanup = true; @@ -999,7 +654,7 @@ public class NuxeoBlobUtils { */ public static BlobsCommon createBlobInRepository( ServiceContext ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, BlobInput blobInput, boolean purgeOriginal, boolean useNuxeoAdaptors) throws Exception { @@ -1085,7 +740,7 @@ public class NuxeoBlobUtils { * the mime type * @return the string */ - static private BlobsCommon createBlobInRepository(RepositoryInstanceInterface nuxeoSession, + static private BlobsCommon createBlobInRepository(CoreSessionInterface nuxeoSession, DocumentModel blobLocation, boolean purgeOriginal, File file, @@ -1172,14 +827,14 @@ public class NuxeoBlobUtils { return result; } - static public BlobOutput getBlobOutput(ServiceContext ctx, - RepositoryClient repositoryClient, + static public BlobOutput getBlobOutput(ServiceContext ctx, + RepositoryClient repositoryClient, String repositoryId, StringBuffer outMimeType) throws TransactionException { BlobOutput result = null; boolean repoSessionCleanup = false; - RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession(); + CoreSessionInterface repoSession = (CoreSessionInterface)ctx.getCurrentRepositorySession(); if (repoSession == null) { repoSession = getRepositorySession(ctx, repositoryClient); repoSessionCleanup = true; @@ -1244,8 +899,8 @@ public class NuxeoBlobUtils { * the derivative term * @return the image */ - static public BlobOutput getBlobOutput(ServiceContext ctx, - RepositoryInstanceInterface repoSession, + static public BlobOutput getBlobOutput(ServiceContext ctx, + CoreSessionInterface repoSession, String repositoryId, String derivativeTerm, Boolean getContentFlag, diff --git a/services/common/src/main/java/org/collectionspace/services/common/publicitem/PublicItemResource.java b/services/common/src/main/java/org/collectionspace/services/common/publicitem/PublicItemResource.java index e0d80e197..cac53c19d 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/publicitem/PublicItemResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/publicitem/PublicItemResource.java @@ -30,7 +30,7 @@ import org.collectionspace.services.publicitem.PublicitemsCommon; import org.collectionspace.services.client.PublicItemClient; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.blob.BlobOutput; import org.collectionspace.services.common.context.RemoteServiceContext; @@ -54,7 +54,7 @@ import javax.ws.rs.core.UriInfo; @Path(PublicItemClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class PublicItemResource extends ResourceBase { +public class PublicItemResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(PublicItemResource.class); diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java b/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java index 1e99e9161..b660a46c7 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java @@ -8,9 +8,6 @@ import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.DocumentNotFoundException; -import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; - // TODO: Auto-generated Javadoc /** * The Class QueryContext. diff --git a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java index ee137fe93..2a368922e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java @@ -30,7 +30,7 @@ import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentHandler; @@ -54,7 +54,7 @@ import javax.ws.rs.core.UriInfo; @Path("/relations") @Consumes("application/xml") @Produces("application/xml") -public class RelationResource extends ResourceBase { +public class RelationResource extends NuxeoBasedResource { public final static String serviceName = "relations"; final Logger logger = LoggerFactory.getLogger(RelationResource.class); diff --git a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java index 74e1a82f3..94110d4e5 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java @@ -14,12 +14,13 @@ import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.repository.RepositoryClient; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; + 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.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,9 +34,9 @@ public class RelationUtils { * Performs an NXQL query to find refName references in relationship records. */ private static DocumentModelList findRelationsWithRefName( - ServiceContext ctx, + ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String refName, String targetField, String orderByClause, @@ -66,7 +67,7 @@ public class RelationUtils { public static void updateRefNamesInRelations( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String targetField, String oldRefName, String newRefName) throws Exception { diff --git a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java index 35502c210..fa9cf3a53 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java +++ b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java @@ -33,7 +33,7 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.storage.StorageClient; import org.collectionspace.services.config.tenant.RepositoryDomainType; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; // // All of these Nuxeo specific classes should not be here. This is supposed to be // a repository-neutral interface. @@ -132,7 +132,7 @@ public interface RepositoryClient extends StorageClient { * @param where NXQL where clause to get the document * @throws DocumentException */ - public String findDocCSID(RepositoryInstanceInterface repoSession, + public String findDocCSID(CoreSessionInterface repoSession, ServiceContext ctx, String where) throws DocumentNotFoundException, DocumentException; diff --git a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java index 9d9d508cc..698e950f5 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClientFactory.java @@ -24,6 +24,7 @@ package org.collectionspace.services.common.repository; import java.util.Hashtable; + import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.config.ServicesConfigReaderImpl; import org.collectionspace.services.config.RepositoryClientConfigType; @@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory; */ public class RepositoryClientFactory { - private static final RepositoryClientFactory self = new RepositoryClientFactory(); + private static final RepositoryClientFactory self = new RepositoryClientFactory(); final Logger logger = LoggerFactory.getLogger(RepositoryClientFactory.class); //clients key=client name, value=repository client private Hashtable> clients = new Hashtable>(); @@ -52,7 +53,7 @@ public class RepositoryClientFactory { String clientName = repositoryClientConfig.getName(); ClassLoader cloader = Thread.currentThread().getContextClassLoader(); - Class jclazz = cloader.loadClass(clientClassName); + Class jclazz = cloader.loadClass(clientClassName); RepositoryClient jclient = (RepositoryClient)jclazz.newInstance(); clients.put(clientName, jclient); @@ -61,7 +62,7 @@ public class RepositoryClientFactory { } } - public static RepositoryClientFactory getInstance() { + public static RepositoryClientFactory getInstance() { return self; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/LazyAuthorityRefDocList.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/LazyAuthorityRefDocList.java index 7a0b85691..4f97aada4 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/LazyAuthorityRefDocList.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/LazyAuthorityRefDocList.java @@ -12,12 +12,11 @@ import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo; import org.collectionspace.services.config.service.ServiceBindingType; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import com.google.common.collect.AbstractIterator; @@ -37,7 +36,7 @@ public class LazyAuthorityRefDocList extends DocumentModelListImpl { private ServiceContext ctx; private RepositoryClient repoClient; - private RepositoryInstanceInterface repoSession; + private CoreSessionInterface repoSession; private List serviceTypes; private String refName; private String refPropName; @@ -71,7 +70,7 @@ public class LazyAuthorityRefDocList extends DocumentModelListImpl { public LazyAuthorityRefDocList( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, List serviceTypes, + CoreSessionInterface repoSession, List serviceTypes, String refName, String refPropName, Map queriedServiceBindings, diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 8f1174659..50f0ad311 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -35,7 +35,7 @@ import org.nuxeo.ecm.core.api.model.Property; import org.nuxeo.ecm.core.api.model.PropertyException; import org.nuxeo.ecm.core.api.model.PropertyNotFoundException; import org.nuxeo.ecm.core.api.model.impl.primitives.StringProperty; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +import org.nuxeo.ecm.core.api.CoreSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,8 +66,8 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.relation.RelationUtils; import org.collectionspace.services.common.repository.RepositoryClient; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.common.security.SecurityUtils; import org.collectionspace.services.config.service.ServiceBindingType; @@ -216,7 +216,7 @@ public class RefNameServiceUtils { public static void updateRefNamesInRelations( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String oldRefName, String newRefName) throws Exception { // @@ -230,20 +230,19 @@ public class RefNameServiceUtils { RelationUtils.updateRefNamesInRelations(ctx, repoClient, repoSession, IRelationsManager.OBJECT_REFNAME, oldRefName, newRefName); } - public static List getConfiguredAuthorityRefs(ServiceContext ctx) { - List authRefFields = - ((AbstractServiceContextImpl) ctx).getAllPartsPropertyValues( - ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES); - ArrayList authRefsInfo = new ArrayList(authRefFields.size()); - for (String spec : authRefFields) { - AuthRefConfigInfo arci = new AuthRefConfigInfo(spec); - authRefsInfo.add(arci); - } - return authRefsInfo; - } + public static List getConfiguredAuthorityRefs(ServiceContext ctx) { + List authRefFields = ((AbstractServiceContextImpl) ctx).getAllPartsPropertyValues( + ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES); + ArrayList authRefsInfo = new ArrayList(authRefFields.size()); + for (String spec : authRefFields) { + AuthRefConfigInfo arci = new AuthRefConfigInfo(spec); + authRefsInfo.add(arci); + } + return authRefsInfo; + } public static AuthorityRefDocList getAuthorityRefDocs( - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, ServiceContext ctx, UriTemplateRegistry uriTemplateRegistry, RepositoryClient repoClient, @@ -405,7 +404,7 @@ public class RefNameServiceUtils { public static int updateAuthorityRefDocs( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String oldRefName, String newRefName, String refPropName) throws Exception { @@ -479,7 +478,7 @@ public class RefNameServiceUtils { private static DocumentModelList findAllAuthorityRefDocs( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, List serviceTypes, + CoreSessionInterface repoSession, List serviceTypes, String refName, String refPropName, Map queriedServiceBindings, @@ -497,7 +496,7 @@ public class RefNameServiceUtils { protected static DocumentModelList findAuthorityRefDocs( ServiceContext ctx, RepositoryClient repoClient, - RepositoryInstanceInterface repoSession, List serviceTypes, + CoreSessionInterface repoSession, List serviceTypes, String refName, String refPropName, Map queriedServiceBindings, @@ -728,7 +727,7 @@ public class RefNameServiceUtils { ilistItem.setUri(uri); try { ilistItem.setWorkflowState(docModel.getCurrentLifeCycleState()); - ilistItem.setUpdatedAt(DocHandlerBase.getUpdatedAtAsString(docModel)); + ilistItem.setUpdatedAt(NuxeoDocumentModelHandler.getUpdatedAtAsString(docModel)); } catch (Exception e) { logger.error("Error getting core values for doc [" + csid + "]: " + e.getLocalizedMessage()); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java index 54c9a1f34..1ce127f7a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/workflow/service/nuxeo/WorkflowDocumentModelHandler.java @@ -35,7 +35,7 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.workflow.jaxb.WorkflowJAXBSchema; import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.lifecycle.TransitionDef; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.workflow.WorkflowCommon; import org.nuxeo.ecm.core.api.ClientException; @@ -44,7 +44,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class WorkflowDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { /** The logger. */ private static final Logger logger = LoggerFactory.getLogger(WorkflowDocumentModelHandler.class); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionInterface.java similarity index 89% rename from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java rename to services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionInterface.java index 2537811a2..5fbb014db 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceInterface.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionInterface.java @@ -3,17 +3,18 @@ package org.collectionspace.services.nuxeo.client.java; import java.security.Principal; import org.nuxeo.ecm.core.api.ClientException; +import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.Filter; import org.nuxeo.ecm.core.api.IterableQueryResult; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +import org.nuxeo.ecm.core.api.impl.LifeCycleFilter; -public interface RepositoryInstanceInterface { +public interface CoreSessionInterface { - public RepositoryInstance getRepositoryInstance(); + public CoreSession getCoreSession(); /** * Gets the root document of this repository. @@ -70,6 +71,17 @@ public interface RepositoryInstanceInterface { * @throws ClientException */ public DocumentModelList query(String query, int max) throws ClientException; + + /** + * Executes the given NXQL query and returns the result that matches the + * filter. + * + * @param query the query to execute + * @param filter the filter to apply to result + * @return the query result + * @throws ClientException + */ + public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter); /** * Gets a document model given its reference. diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionWrapper.java similarity index 92% rename from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java rename to services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionWrapper.java index 797805a0e..95ccdf1ce 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryInstanceWrapper.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CoreSessionWrapper.java @@ -10,18 +10,19 @@ import org.nuxeo.ecm.core.api.Filter; import org.nuxeo.ecm.core.api.IterableQueryResult; import org.nuxeo.ecm.core.api.NoRollbackOnException; import org.nuxeo.ecm.core.api.event.DocumentEventTypes; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +import org.nuxeo.ecm.core.api.impl.LifeCycleFilter; +import org.nuxeo.ecm.core.api.CoreSession; -public class RepositoryInstanceWrapper implements RepositoryInstanceInterface { +public class CoreSessionWrapper implements CoreSessionInterface { - private RepositoryInstance repoSession; + private CoreSession repoSession; - public RepositoryInstanceWrapper(RepositoryInstance repoSession) { + public CoreSessionWrapper(CoreSession repoSession) { this.repoSession = repoSession; } @Override - public RepositoryInstance getRepositoryInstance() { + public CoreSession getCoreSession() { return repoSession; } @@ -88,6 +89,11 @@ public class RepositoryInstanceWrapper implements RepositoryInstanceInterface { public DocumentModelList query(String query) throws ClientException { return repoSession.query(query); } + + @Override + public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter) { + return repoSession.query(query, workflowStateFilter); + } /** * Gets a document model given its reference. diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java deleted file mode 100644 index 337a3d37d..000000000 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java +++ /dev/null @@ -1,394 +0,0 @@ -/** - * This document is a part of the source code and related artifacts - * for CollectionSpace, an open source collections management system - * for museums and related institutions: - - * http://www.collectionspace.org - * http://wiki.collectionspace.org - - * Copyright 2009 University of California at Berkeley - - * Licensed under the Educational Community License (ECL), Version 2.0. - * You may not use this file except in compliance with this License. - - * You may obtain a copy of the ECL 2.0 License at - - * https://source.collectionspace.org/collection-space/LICENSE.txt - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.collectionspace.services.nuxeo.client.java; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - -import org.collectionspace.services.client.CollectionSpaceClient; -import org.collectionspace.services.client.IQueryManager; -import org.collectionspace.services.client.IRelationsManager; -import org.collectionspace.services.common.ReflectionMapper; -import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; -import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.config.ServiceConfigUtils; -import org.collectionspace.services.common.context.AbstractServiceContextImpl; -import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.DocumentException; -import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.query.QueryContext; -import org.collectionspace.services.common.relation.nuxeo.RelationsUtils; -import org.collectionspace.services.config.service.DocHandlerParams; -import org.collectionspace.services.config.service.ListResultField; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.nuxeo.client.java.CommonList; -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class is generified by the marker type T, - * where T is expected to map to something like BlobCommon, MediaCommon, ObjectexitCommon, etc., - * and so on for every JAXB-generated schema class. - * - * User: laramie - * $LastChangedRevision: $ - * $LastChangedDate: $ - * - */ -public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl { - - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - private AbstractCommonList commonList; - - protected static final int NUM_STANDARD_LIST_RESULT_FIELDS = 5; - protected static final String STANDARD_LIST_CSID_FIELD = "csid"; - protected static final String STANDARD_LIST_URI_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_URI; - protected static final String STANDARD_LIST_REFNAME_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME; - protected static final String STANDARD_LIST_UPDATED_AT_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT; - protected static final String STANDARD_LIST_WORKFLOW_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE; - protected static final String STANDARD_LIST_MARK_RT_FIELD = "related"; - - @Override - public AbstractCommonList getCommonPartList() { - return commonList; - } - - @Override - public void setCommonPartList(AbstractCommonList aCommonList) { - this.commonList = aCommonList; - } - - private T commonPart; - - @Override - public T getCommonPart() { - return (T)commonPart; - } - - @Override - public void setCommonPart(T commonPart) { - this.commonPart = commonPart; - } - - - /** Subclass DocHandlers may override this method to control exact creation of the common list. - * This class instantiates an AbstractCommonList from the classname returned by getDocHandlerParams().AbstractCommonListClassname. - * @return - * @throws Exception - */ - public AbstractCommonList createAbstractCommonListImpl() throws Exception { - // String classname = this.commonList.getClass().getName(); - ServiceContext ctx = this.getServiceContext(); - String classname = ServiceConfigUtils.getDocHandlerParams(ctx).getAbstractCommonListClassname(); - if (classname == null){ - throw new Exception("in createAbstractCommonListImpl. getDocHandlerParams().getAbstractCommonListClassname() is null"); - } - classname = classname.trim(); - return (AbstractCommonList)(ReflectionMapper.instantiate(classname)); - } - - - /** DocHandlerBase calls this method with the CSID as id */ - public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { - ServiceContext ctx = this.getServiceContext(); - return createItemForCommonList(ServiceConfigUtils.getDocHandlerParams(ctx).getCommonListItemClassname(), - docModel, label, id, true); - } - - public String getSummaryFields(AbstractCommonList theCommonList) throws DocumentException { - ServiceContext ctx = this.getServiceContext(); - return ServiceConfigUtils.getDocHandlerParams(ctx).getSummaryFields(); - } - - public void setListItemArrayExtended(boolean isExtended) throws DocumentException { - ServiceContext ctx = this.getServiceContext(); - ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().setExtended(isExtended); - } - - public boolean isListItemArrayExtended() throws DocumentException { - ServiceContext ctx = this.getServiceContext(); - return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().isExtended(); - } - - public List getListItemsArray() throws DocumentException { - ServiceContext ctx = this.getServiceContext(); - return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().getListResultField(); - } - - @Override - public T extractCommonPart(DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public void fillCommonPart(T objectexitObject, DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - protected static String getRefname(DocumentModel docModel) throws Exception { - String result = (String)docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA, - CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME); - return result; - } - - public static String getUpdatedAtAsString(DocumentModel docModel) throws Exception { - GregorianCalendar cal = (GregorianCalendar) - docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA, - CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT); - String updatedAt = GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp(cal); - return updatedAt; - } - - @Override - public AbstractCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - CommonList commonList = new CommonList(); - String markRtSbj = null; - RepositoryInstanceInterface repoSession = null; - RepositoryJavaClientImpl repoClient = null; - RepositoryJavaClientImpl nuxeoRepoClient = null; - boolean releaseRepoSession = false; - - AbstractServiceContextImpl sc = (AbstractServiceContextImpl)getServiceContext(); - MultivaluedMap queryParams = getServiceContext().getQueryParams(); - markRtSbj = queryParams.getFirst(IQueryManager.MARK_RELATED_TO_CSID_AS_SUBJECT); // REM - We need to document what this query param is for -i.e., what's its purpose? - if(markRtSbj!=null && markRtSbj.isEmpty()) - markRtSbj = null; - - try { - if(markRtSbj!=null) { - repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(sc); - nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient; - repoSession = this.getRepositorySession(); - if (repoSession == null) { - repoSession = repoClient.getRepositorySession(sc); - releaseRepoSession = true; - } - } - - String commonSchema = getServiceContext().getCommonPartLabel(); - extractPagingInfo(commonList, wrapDoc); - List resultsFields = getListItemsArray(); - int nFields = resultsFields.size() + NUM_STANDARD_LIST_RESULT_FIELDS; - int baseFields = NUM_STANDARD_LIST_RESULT_FIELDS; - if(markRtSbj!=null) { - nFields++; - baseFields++; - } - String fields[] = new String[nFields]; // REM - Why can't this just be a static array defined once at the top? Then there'd be no need for these hardcoded "[x]" statements and no need for NUM_STANDARD_LIST_RESULT_FIELDS constant as well. - fields[0] = STANDARD_LIST_CSID_FIELD; - fields[1] = STANDARD_LIST_URI_FIELD; - fields[2] = STANDARD_LIST_REFNAME_FIELD; - fields[3] = STANDARD_LIST_UPDATED_AT_FIELD; - fields[4] = STANDARD_LIST_WORKFLOW_FIELD; - if(markRtSbj != null) { - fields[5] = STANDARD_LIST_MARK_RT_FIELD; - } - for(int i = baseFields; i < nFields; i++) { - ListResultField field = resultsFields.get(i - baseFields); - fields[i] = field.getElement(); - } - commonList.setFieldsReturned(fields); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - HashMap item = new HashMap(); - while (iter.hasNext()) { - DocumentModel docModel = iter.next(); - String id = NuxeoUtils.getCsid(docModel); - item.put(STANDARD_LIST_CSID_FIELD, id); - if (markRtSbj != null) { - String relationClause = RelationsUtils.buildWhereClause( - markRtSbj, null, null, id, null); - String whereClause = relationClause - + IQueryManager.SEARCH_QUALIFIER_AND - + NuxeoUtils.buildWorkflowNotDeletedWhereClause(); - QueryContext queryContext = new QueryContext(sc, - whereClause); - queryContext.setDocType(IRelationsManager.DOC_TYPE); - String query = NuxeoUtils.buildNXQLQuery(sc, queryContext); - // Search for 1 relation that matches. 1 is enough to fail - // the filter - DocumentModelList docList = repoSession.query(query, null, - 1, 0, false); - item.put(STANDARD_LIST_MARK_RT_FIELD, - docList.isEmpty() ? "false" : "true"); - } - String uri = getUri(docModel); - item.put(STANDARD_LIST_URI_FIELD, uri); - item.put(STANDARD_LIST_REFNAME_FIELD, getRefname(docModel)); - item.put(STANDARD_LIST_UPDATED_AT_FIELD, - getUpdatedAtAsString(docModel)); - item.put(STANDARD_LIST_WORKFLOW_FIELD, - docModel.getCurrentLifeCycleState()); - - for (ListResultField field : resultsFields) { - String schema = field.getSchema(); - if (schema == null || schema.trim().isEmpty()) { - schema = commonSchema; - } - Object value = getListResultValue(docModel, schema, field); - if (value != null && value instanceof String) { // If it is String that is either null or empty, we set our value to null - String strValue = (String) value; - if (strValue.trim().isEmpty() == true) { - value = null; // We found an "empty" string value, so just set the value to null so we don't return anything. - } - } - if (value != null) { - item.put(field.getElement(), value); - } - } - commonList.addItem(item); - item.clear(); - } - } catch (Exception e) { - if (logger.isDebugEnabled()) { - logger.debug("Caught exception ", e); - } - throw new DocumentException(e); - } finally { - // If we got/aquired a new session then we're responsible for releasing it. - if (releaseRepoSession && repoSession != null) { - repoClient.releaseRepositorySession(sc, repoSession); - } - } - - return commonList; - } - - // TODO - get rid of this if we can - appears to be unused. - @Override - public String getQProperty(String prop) throws DocumentException { - ServiceContext ctx = this.getServiceContext(); - return ServiceConfigUtils.getDocHandlerParams(ctx).getSchemaName() + ":" + prop; - } - - //============= dublin core handling ======================================= - - @Override - public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { - super.fillAllParts(wrapDoc, action); - fillDublinCoreObject(wrapDoc); - } - - /** - * Fill dublin core object, but only if there are document handler parameters in the service - * bindings. - * - * @param wrapDoc the wrap doc - * @throws Exception the exception - */ - // TODO - Remove this? - // This look like it is never used in a sensible way. It just stuffs a static - // String that matches the service name into a bogus field. - protected void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception { - DocHandlerParams.Params docHandlerParams = null; - try { - docHandlerParams = ServiceConfigUtils.getDocHandlerParams(getServiceContext()); - } catch (Exception e) { - logger.warn(e.getMessage()); - } - - if (docHandlerParams != null) { - String title = docHandlerParams.getDublinCoreTitle(); - if (Tools.isEmpty(title) == false){ - DocumentModel docModel = wrapDoc.getWrappedObject(); - docModel.setPropertyValue("dublincore:title", title); - } - } - } - - //================== UTILITY METHODS ================================================ - public static ReflectionMapper.STATUS callPropertySetterWithXPathValue(DocumentModel docModel, - Object listItem, - String setterName, - String schema, - String xpath) - throws Exception { - //Object prop = docModel.getProperty(label, elementName); - String value = (String)NuxeoUtils.getXPathValue(docModel, schema, xpath); - return ReflectionMapper.callSetter(listItem, setterName, value); - } - - public static ReflectionMapper.STATUS callSimplePropertySetter(Object target, String name, Object arg) { - return ReflectionMapper.callSetter(target, name, arg); - } - - /** @param commonListClassname is a package-qualified java classname, including inner class $ notation, such as - * "org.collectionspace.services.objectexit.ObjectexitCommonList$ObjectexitListItem". - * @param includeStdFields set to true to have the method set Uri and Csid automatically, based on id param. - */ - public Object createItemForCommonList(String commonListClassname, DocumentModel docModel, - String schema, String id, boolean includeStdFields) throws Exception { - //createItemForCommonList(docModel, label, id); - Object item = ReflectionMapper.instantiate(commonListClassname); - List resultsFields = getListItemsArray(); - for (ListResultField field : resultsFields ){ - callPropertySetterWithXPathValue(docModel, item, - field.getSetter(), schema, field.getXpath()); - } - if (includeStdFields){ - callSimplePropertySetter(item, "setCsid", id); - callSimplePropertySetter(item, "setUri", getServiceContextPath() + id); - } - return item; - } - - /** Subclasses should override this method if they don't want to automatically - * call List createItemsList(AbstractCommonList commonList, String listItemMethodName) - * which will use introspection to create a summary list, and will find the primary - * field for you if specified. - */ - public List createItemsList(AbstractCommonList commonList) throws Exception { - ServiceContext ctx = this.getServiceContext(); - return createItemsList(commonList, - ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsItemMethodName()); - } - - /** e.g. createItemsList(commonList, "getObjectexitListItem" */ - public List createItemsList(AbstractCommonList commonList, String listItemMethodName) throws Exception { - Class commonListClass = commonList.getClass(); - Class[] types = new Class[] {}; - try { - Method m = commonListClass.getMethod(listItemMethodName, types); - return (List)(ReflectionMapper.fireGetMethod(m, commonList)); - } catch (NoSuchMethodException nsm){ - return new ArrayList(); - } - } - - - -} - diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java index b42d52895..14977bac4 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java @@ -29,6 +29,7 @@ import java.util.List; import javax.ws.rs.core.MultivaluedMap; import org.apache.commons.lang.StringUtils; + import org.collectionspace.services.client.Profiler; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IQueryManager; @@ -58,13 +59,14 @@ import org.collectionspace.services.lifecycle.StateList; import org.collectionspace.services.lifecycle.TransitionDef; import org.collectionspace.services.lifecycle.TransitionDefList; import org.collectionspace.services.lifecycle.TransitionList; + import org.nuxeo.ecm.core.NXCore; 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.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.nuxeo.ecm.core.lifecycle.LifeCycleService; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,7 +81,7 @@ public abstract class DocumentModelHandler extends AbstractMultipartDocumentHandlerImpl { private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class); - private RepositoryInstanceInterface repositorySession; + private CoreSessionInterface repositorySession; protected String oldRefNameOnUpdate = null; // FIXME: REM - We should have setters and getters for these protected String newRefNameOnUpdate = null; // FIXME: two fields. @@ -205,7 +207,8 @@ public abstract class DocumentModelHandler } public RepositoryClient getRepositoryClient(ServiceContext ctx) { - RepositoryClient repositoryClient = RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName()); + RepositoryClient repositoryClient = + (RepositoryClient) RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName()); return repositoryClient; } @@ -213,7 +216,7 @@ public abstract class DocumentModelHandler * getRepositorySession returns Nuxeo Repository Session * @return */ - public RepositoryInstanceInterface getRepositorySession() { + public CoreSessionInterface getRepositorySession() { return repositorySession; } @@ -222,7 +225,7 @@ public abstract class DocumentModelHandler * setRepositorySession sets repository session * @param repoSession */ - public void setRepositorySession(RepositoryInstanceInterface repoSession) { + public void setRepositorySession(CoreSessionInterface repoSession) { this.repositorySession = repoSession; } @@ -410,7 +413,7 @@ public abstract class DocumentModelHandler return result; } - protected void handleRefNameChanges(ServiceContext ctx, DocumentModel docModel) throws ClientException { + protected void handleRefNameChanges(ServiceContext ctx, DocumentModel docModel) throws ClientException { // First get the old refName this.oldRefNameOnUpdate = (String)docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA, CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java index 7dbd1b9fa..0547e446b 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoClientEmbedded.java @@ -23,16 +23,17 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import java.security.Principal; import org.collectionspace.services.common.repository.RepositoryInstanceWrapperAdvice; import org.collectionspace.services.config.tenant.RepositoryDomainType; -import org.jboss.remoting.InvokerLocator; + import org.nuxeo.ecm.core.api.repository.Repository; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; -import org.nuxeo.ecm.core.api.repository.RepositoryInstanceHandler; +import org.nuxeo.ecm.core.api.CoreInstance; +import org.nuxeo.ecm.core.api.CoreSession; +import org.nuxeo.ecm.core.api.NuxeoPrincipal; +import org.nuxeo.ecm.core.api.SystemPrincipal; import org.nuxeo.ecm.core.api.repository.RepositoryManager; -import org.nuxeo.ecm.core.client.DefaultLoginHandler; -import org.nuxeo.ecm.core.client.LoginHandler; import org.nuxeo.runtime.api.Framework; import org.nuxeo.runtime.transaction.TransactionHelper; @@ -50,11 +51,7 @@ public final class NuxeoClientEmbedded { private Logger logger = LoggerFactory.getLogger(NuxeoClientEmbedded.class); - private LoginHandler loginHandler; - - private final HashMap repositoryInstances; - - private InvokerLocator locator; + private final HashMap repositoryInstances; private RepositoryManager repositoryMgr; @@ -65,9 +62,7 @@ public final class NuxeoClientEmbedded { * of this constructor is recommended. */ private NuxeoClientEmbedded() { - loginHandler = loginHandler == null ? new DefaultLoginHandler() - : loginHandler; - repositoryInstances = new HashMap(); + repositoryInstances = new HashMap(); } public static NuxeoClientEmbedded getInstance() { @@ -75,18 +70,14 @@ public final class NuxeoClientEmbedded { } public synchronized void tryDisconnect() throws Exception { - if (locator == null) { - return; // do nothing - } doDisconnect(); } private void doDisconnect() throws Exception { - locator = null; - // close repository sessions if any - Iterator> it = repositoryInstances.entrySet().iterator(); + // close the open Nuxeo repository sessions if any + Iterator> it = repositoryInstances.entrySet().iterator(); while (it.hasNext()) { - Entry repo = it.next(); + Entry repo = it.next(); try { repo.getValue().close(); } catch (Exception e) { @@ -98,22 +89,6 @@ public final class NuxeoClientEmbedded { repositoryMgr = null; } - public synchronized boolean isConnected() { - return true; - } - - public InvokerLocator getLocator() { - return locator; - } - - public synchronized LoginHandler getLoginHandler() { - return loginHandler; - } - - public synchronized void setLoginHandler(LoginHandler loginHandler) { - this.loginHandler = loginHandler; - } - public RepositoryManager getRepositoryManager() throws Exception { if (repositoryMgr == null) { repositoryMgr = Framework.getService(RepositoryManager.class); @@ -142,19 +117,19 @@ public final class NuxeoClientEmbedded { /* * Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period */ - public RepositoryInstanceInterface openRepository(RepositoryDomainType repoDomain) throws Exception { + public CoreSessionInterface openRepository(RepositoryDomainType repoDomain) throws Exception { return openRepository(repoDomain.getRepositoryName(), -1); } /* * Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period */ - public RepositoryInstanceInterface openRepository(String repoName) throws Exception { + public CoreSessionInterface openRepository(String repoName) throws Exception { return openRepository(repoName, -1); } - public RepositoryInstanceInterface openRepository(String repoName, int timeoutSeconds) throws Exception { - RepositoryInstanceInterface result = null; + public CoreSessionInterface openRepository(String repoName, int timeoutSeconds) throws Exception { + CoreSessionInterface result = null; // // If the called passed in a custom timeout setting, use it to configure Nuxeo's transaction manager. @@ -200,7 +175,7 @@ public final class NuxeoClientEmbedded { // Nuxeo repository so we can check for network related failures and perform a series of retries. // if (repository != null) { - result = getRepositoryInstanceWrapper(repository); + result = getCoreSessionWrapper(repository); logger.trace(String.format("A new transaction was started on thread '%d' : %s.", Thread.currentThread().getId(), startedTransaction ? "true" : "false")); logger.trace(String.format("Added a new repository instance to our repo list. Current count is now: %d", @@ -220,39 +195,45 @@ public final class NuxeoClientEmbedded { // wrap each call to the Nuxeo repo with code that catches network related errors/exceptions and // re-attempts the calls to see if it recovers. // - private RepositoryInstanceInterface getAOPProxy(RepositoryInstance repositoryInstance) { - RepositoryInstanceInterface result = null; + private CoreSessionInterface getAOPProxy(CoreSession repositoryInstance) { + CoreSessionInterface result = null; try { - ProxyFactory factory = new ProxyFactory(new RepositoryInstanceWrapper(repositoryInstance)); + ProxyFactory factory = new ProxyFactory(new CoreSessionWrapper(repositoryInstance)); factory.addAdvice(new RepositoryInstanceWrapperAdvice()); factory.setExposeProxy(true); - result = (RepositoryInstanceInterface)factory.getProxy(); + result = (CoreSessionInterface)factory.getProxy(); } catch (Exception e) { - logger.error("Could not create AOP proxy for: " + RepositoryInstanceWrapper.class.getName(), e); + logger.error("Could not create AOP proxy for: " + CoreSessionWrapper.class.getName(), e); } return result; } + private Principal getSystemPrincipal() { + NuxeoPrincipal principal = new SystemPrincipal(null); + return principal; + } + /* * From the Repository object (a description of the repository), get repository instance wrapper. Our wrapper * will using the Spring AOP mechanism to intercept all calls to the repository. We will wrap all the calls to the * Nuxeo repository and check for network related failures. We will retry all calls to the Nuxeo repo that fail because * of network erros. */ - private RepositoryInstanceInterface getRepositoryInstanceWrapper(Repository repository) throws Exception { - RepositoryInstanceInterface result = null; + private CoreSessionInterface getCoreSessionWrapper(Repository repository) throws Exception { + CoreSessionInterface result = null; - RepositoryInstance repositoryInstance = new RepositoryInstanceHandler(repository).getProxy(); // A Nuxeo repo instance handler proxy - if (repositoryInstance != null) { - result = this.getAOPProxy(repositoryInstance); // This is our AOP proxy + CoreSession coreSession = CoreInstance.openCoreSession(repository.getName(), getSystemPrincipal()); // A Nuxeo repo instance handler proxy + + if (coreSession != null) { + result = this.getAOPProxy(coreSession); // This is our AOP proxy if (result != null) { String key = result.getSessionId(); repositoryInstances.put(key, result); } else { String errMsg = String.format("Could not instantiate a Spring AOP proxy for class '%s'.", - RepositoryInstanceWrapper.class.getName()); + CoreSessionWrapper.class.getName()); logger.error(errMsg); throw new Exception(errMsg); } @@ -265,17 +246,20 @@ public final class NuxeoClientEmbedded { return result; } - public void releaseRepository(RepositoryInstanceInterface repo) throws Exception { - String key = repo.getSessionId(); + public void releaseRepository(CoreSessionInterface repoSession) throws Exception { + String key = repoSession.getSessionId(); + String name = repoSession.getRepositoryName(); try { - repo.save(); - repo.close(); + repoSession.save(); + repoSession.close(); } catch (Exception e) { - logger.error("Possible data loss. Could not save and/or release the repository.", e); + String errMsg = String.format("Possible data loss. Could not save and/or close the Nuxeo repository name = '%s'.", + name); + logger.error(errMsg, e); throw e; } finally { - RepositoryInstanceInterface wasRemoved = repositoryInstances.remove(key); + CoreSessionInterface wasRemoved = repositoryInstances.remove(key); if (logger.isTraceEnabled()) { if (wasRemoved != null) { logger.trace("Removed a repository instance from our repo list. Current count is now: " diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java index 06900aad5..82a0eae0e 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoConnectorEmbedded.java @@ -14,13 +14,12 @@ import org.collectionspace.services.config.RepositoryClientConfigType; import org.collectionspace.services.config.tenant.RepositoryDomainType; import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.NXCore; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; +import org.nuxeo.ecm.core.api.repository.RepositoryManager; import org.nuxeo.ecm.core.model.Repository; import org.nuxeo.osgi.application.FrameworkBootstrap; -import org.nuxeo.ecm.core.repository.RepositoryDescriptor; -import org.nuxeo.ecm.core.repository.RepositoryFactory; +import org.nuxeo.runtime.api.Framework; import org.nuxeo.ecm.core.storage.sql.ra.ConnectionFactoryImpl; import org.nuxeo.ecm.core.storage.sql.ra.ManagedConnectionFactoryImpl; @@ -38,19 +37,19 @@ public class NuxeoConnectorEmbedded { public final static String NUXEO_SERVER_DIR = JEEServerDeployment.NUXEO_SERVER_DIR; private final static String ERROR_CONNECTOR_NOT_INITIALIZED = "NuxeoConnector is not initialized!"; - private final static String CSPACE_JEESERVER_HOME = "CSPACE_CONTAINER"; private final static String CSPACE_NUXEO_HOME = "CSPACE_NUXEO_HOME"; private static final NuxeoConnectorEmbedded self = new NuxeoConnectorEmbedded(); private NuxeoClientEmbedded client; - private ServletContext servletContext = null; private volatile boolean initialized = false; // use volatile for lazy // initialization in // singleton - private RepositoryClientConfigType repositoryClientConfig; public FrameworkBootstrap fb; + private ServletContext servletContext; + private RepositoryClientConfigType repositoryClientConfig; private NuxeoConnectorEmbedded() { + // empty constructor } public final static NuxeoConnectorEmbedded getInstance() { @@ -152,15 +151,20 @@ public class NuxeoConnectorEmbedded { } } + /* + * This is a debug-only method. Use to look at runtime values of Nuxeo internal + * data structures. + */ public String getDatabaseName(String repoName) { String result = null; - - try { - this.getRepositoryDescriptor(repoName); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } + +// TODO: Remove after CSPACE-6375 issue is resolved. +// try { +// List repositoryDescriptorList = this.getRepositoryDescriptor(repoName); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } Repository repository = null; try { @@ -172,7 +176,7 @@ public class NuxeoConnectorEmbedded { ConnectionFactoryImpl connectionFactory = (ConnectionFactoryImpl)repository; ManagedConnectionFactoryImpl managedConnectionFactory = connectionFactory.getManagedConnectionFactory(); - String serverUrl = managedConnectionFactory.getServerURL(); + String property = managedConnectionFactory.getProperty(); return result; } @@ -183,7 +187,7 @@ public class NuxeoConnectorEmbedded { * @param repoSession * @throws java.lang.Exception */ - public void releaseRepositorySession(RepositoryInstanceInterface repoSession) + public void releaseRepositorySession(CoreSessionInterface repoSession) throws Exception { if (repoSession != null) { getClient().releaseRepository(repoSession); @@ -200,8 +204,8 @@ public class NuxeoConnectorEmbedded { * @return RepositoryInstance * @throws java.lang.Exception */ - public RepositoryInstanceInterface getRepositorySession(RepositoryDomainType repoDomain) throws Exception { - RepositoryInstanceInterface repoSession = getClient().openRepository(repoDomain); + public CoreSessionInterface getRepositorySession(RepositoryDomainType repoDomain) throws Exception { + CoreSessionInterface repoSession = getClient().openRepository(repoDomain); if (logger.isDebugEnabled() && repoSession != null) { logger.debug("getRepositorySession() opened repository session"); @@ -214,37 +218,42 @@ public class NuxeoConnectorEmbedded { public Repository lookupRepository(String name) throws Exception { Repository repo; + RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class); + try { // needed by glassfish - repo = (Repository) new InitialContext().lookup("NXRepository/" - + name); + repo = (Repository) new InitialContext().lookup("NXRepository/" + name); } catch (NamingException e) { try { // needed by jboss repo = (Repository) new InitialContext().lookup("java:NXRepository/" + name); } catch (NamingException ee) { - repo = (Repository) NXCore.getRepositoryService().getRepositoryManager().getRepository( + repo = (Repository) repositoryManager.getRepository( name); } } + if (repo == null) { throw new IllegalArgumentException("Repository not found: " + name); } + return repo; } - public RepositoryDescriptor getRepositoryDescriptor(String name) throws Exception { - RepositoryDescriptor repo = null; - Iterable descriptorsList = NXCore.getRepositoryService().getRepositoryManager().getDescriptors(); - for (RepositoryDescriptor descriptor : descriptorsList) { - String homeDir = descriptor.getHomeDirectory(); - String config = descriptor.getConfigurationFile(); - RepositoryFactory factor = descriptor.getFactory(); - } - - return repo; - } +// TODO: Remove after CSPACE-6375 issue is resolved. +// public List getRepositoryDescriptor(String name) throws Exception { +// RepositoryDescriptor repo = null; +// RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class); +// Iterable descriptorsList = repositoryManager.getDescriptors(); +// for (RepositoryDescriptor descriptor : descriptorsList) { +// String homeDir = descriptor.getHomeDirectory(); +// String config = descriptor.getConfigurationFile(); +// RepositoryFactory factor = descriptor.getFactory(); +// } +// +// return repo; +// } /** * getClient get Nuxeo client for accessing Nuxeo services remotely using @@ -255,9 +264,7 @@ public class NuxeoConnectorEmbedded { */ public NuxeoClientEmbedded getClient() throws Exception { if (initialized == true) { - if (client.isConnected()) { - return client; - } + return client; } // // Nuxeo connection was not initialized @@ -288,7 +295,7 @@ public class NuxeoConnectorEmbedded { */ public Hashtable retrieveWorkspaceIds(RepositoryDomainType repoDomain) throws Exception { - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; Hashtable workspaceIds = new Hashtable(); try { repoSession = getRepositorySession(repoDomain); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java new file mode 100644 index 000000000..830814d2e --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java @@ -0,0 +1,391 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.nuxeo.client.java; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.IQueryManager; +import org.collectionspace.services.client.IRelationsManager; +import org.collectionspace.services.client.PoxPayloadIn; +import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.ReflectionMapper; +import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; +import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.config.ServiceConfigUtils; +import org.collectionspace.services.common.context.AbstractServiceContextImpl; +import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.common.document.DocumentException; +import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.query.QueryContext; +import org.collectionspace.services.common.relation.nuxeo.RelationsUtils; +import org.collectionspace.services.config.service.DocHandlerParams; +import org.collectionspace.services.config.service.ListResultField; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; +import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; + +import org.nuxeo.ecm.core.api.DocumentModel; +import org.nuxeo.ecm.core.api.DocumentModelList; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class is generified by the marker type T, + * where T is expected to map to something like BlobCommon, MediaCommon, ObjectexitCommon, etc., + * and so on for every JAXB-generated schema class. + * + * User: laramie + * $LastChangedRevision: $ + * $LastChangedDate: $ + * + */ +public abstract class NuxeoDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + + /** The logger. */ + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private AbstractCommonList commonList; + + protected static final int NUM_STANDARD_LIST_RESULT_FIELDS = 5; + protected static final String STANDARD_LIST_CSID_FIELD = "csid"; + protected static final String STANDARD_LIST_URI_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_URI; + protected static final String STANDARD_LIST_REFNAME_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME; + protected static final String STANDARD_LIST_UPDATED_AT_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT; + protected static final String STANDARD_LIST_WORKFLOW_FIELD = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE; + protected static final String STANDARD_LIST_MARK_RT_FIELD = "related"; + + @Override + public AbstractCommonList getCommonPartList() { + return commonList; + } + + @Override + public void setCommonPartList(AbstractCommonList aCommonList) { + this.commonList = aCommonList; + } + + private T commonPart; + + @Override + public T getCommonPart() { + return (T) commonPart; + } + + @Override + public void setCommonPart(T commonPart) { + this.commonPart = commonPart; + } + + /** + * Subclass DocHandlers may override this method to control exact creation of the common list. + * This class instantiates an AbstractCommonList from the classname returned by getDocHandlerParams().AbstractCommonListClassname. + * + * @return + * @throws Exception + */ + public AbstractCommonList createAbstractCommonListImpl() throws Exception { + // String classname = this.commonList.getClass().getName(); + ServiceContext ctx = this.getServiceContext(); + String classname = ServiceConfigUtils.getDocHandlerParams(ctx).getAbstractCommonListClassname(); + if (classname == null) { + throw new Exception( + "in createAbstractCommonListImpl. getDocHandlerParams().getAbstractCommonListClassname() is null"); + } + classname = classname.trim(); + return (AbstractCommonList) (ReflectionMapper.instantiate(classname)); + } + + /** DocHandlerBase calls this method with the CSID as id */ + public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { + ServiceContext ctx = this.getServiceContext(); + return createItemForCommonList(ServiceConfigUtils.getDocHandlerParams(ctx).getCommonListItemClassname(), + docModel, label, id, true); + } + + public String getSummaryFields(AbstractCommonList theCommonList) throws DocumentException { + ServiceContext ctx = this.getServiceContext(); + return ServiceConfigUtils.getDocHandlerParams(ctx).getSummaryFields(); + } + + public void setListItemArrayExtended(boolean isExtended) throws DocumentException { + ServiceContext ctx = this.getServiceContext(); + ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().setExtended(isExtended); + } + + public boolean isListItemArrayExtended() throws DocumentException { + ServiceContext ctx = this.getServiceContext(); + return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().isExtended(); + } + + public List getListItemsArray() throws DocumentException { + ServiceContext ctx = this.getServiceContext(); + return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().getListResultField(); + } + + @Override + public T extractCommonPart(DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public void fillCommonPart(T objectexitObject, DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + protected static String getRefname(DocumentModel docModel) throws Exception { + String result = (String) docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA, + CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME); + return result; + } + + public static String getUpdatedAtAsString(DocumentModel docModel) throws Exception { + GregorianCalendar cal = (GregorianCalendar) docModel.getProperty( + CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA, + CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT); + String updatedAt = GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp(cal); + return updatedAt; + } + + @Override + public AbstractCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + CommonList commonList = new CommonList(); + String markRtSbj = null; + CoreSessionInterface repoSession = null; + RepositoryJavaClientImpl repoClient = null; + boolean releaseRepoSession = false; + + AbstractServiceContextImpl ctx = (AbstractServiceContextImpl) getServiceContext(); + MultivaluedMap queryParams = getServiceContext().getQueryParams(); + markRtSbj = queryParams.getFirst(IQueryManager.MARK_RELATED_TO_CSID_AS_SUBJECT); + if (markRtSbj != null && markRtSbj.isEmpty()) + markRtSbj = null; + + try { + if (markRtSbj != null) { + repoClient = (RepositoryJavaClientImpl) this.getRepositoryClient(ctx); + RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient; + repoSession = this.getRepositorySession(); + if (repoSession == null) { + repoSession = repoClient.getRepositorySession(ctx); + releaseRepoSession = true; + } + } + + String commonSchema = getServiceContext().getCommonPartLabel(); + extractPagingInfo(commonList, wrapDoc); + List resultsFields = getListItemsArray(); + int nFields = resultsFields.size() + NUM_STANDARD_LIST_RESULT_FIELDS; + int baseFields = NUM_STANDARD_LIST_RESULT_FIELDS; + if (markRtSbj != null) { + nFields++; + baseFields++; + } + + String fields[] = new String[nFields]; // REM - Why can't this just be a static array defined once at the top? Then there'd be no need for these hardcoded "[x]" statements and no need for NUM_STANDARD_LIST_RESULT_FIELDS constant as well. + fields[0] = STANDARD_LIST_CSID_FIELD; + fields[1] = STANDARD_LIST_URI_FIELD; + fields[2] = STANDARD_LIST_REFNAME_FIELD; + fields[3] = STANDARD_LIST_UPDATED_AT_FIELD; + fields[4] = STANDARD_LIST_WORKFLOW_FIELD; + + if (markRtSbj != null) { + fields[5] = STANDARD_LIST_MARK_RT_FIELD; + } + + for (int i = baseFields; i < nFields; i++) { + ListResultField field = resultsFields.get(i - baseFields); + fields[i] = field.getElement(); + } + commonList.setFieldsReturned(fields); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + HashMap item = new HashMap(); + while (iter.hasNext()) { + DocumentModel docModel = iter.next(); + String id = NuxeoUtils.getCsid(docModel); + item.put(STANDARD_LIST_CSID_FIELD, id); + if (markRtSbj != null) { + String relationClause = RelationsUtils.buildWhereClause(markRtSbj, null, null, id, null); + String whereClause = relationClause + IQueryManager.SEARCH_QUALIFIER_AND + + NuxeoUtils.buildWorkflowNotDeletedWhereClause(); + QueryContext queryContext = new QueryContext(ctx, whereClause); + queryContext.setDocType(IRelationsManager.DOC_TYPE); + String query = NuxeoUtils.buildNXQLQuery(ctx, queryContext); + // Search for 1 relation that matches. 1 is enough to fail + // the filter + DocumentModelList docList = repoSession.query(query, null, 1, 0, false); + item.put(STANDARD_LIST_MARK_RT_FIELD, docList.isEmpty() ? "false" : "true"); + } + String uri = getUri(docModel); + item.put(STANDARD_LIST_URI_FIELD, uri); + item.put(STANDARD_LIST_REFNAME_FIELD, getRefname(docModel)); + item.put(STANDARD_LIST_UPDATED_AT_FIELD, getUpdatedAtAsString(docModel)); + item.put(STANDARD_LIST_WORKFLOW_FIELD, docModel.getCurrentLifeCycleState()); + + for (ListResultField field : resultsFields) { + String schema = field.getSchema(); + if (schema == null || schema.trim().isEmpty()) { + schema = commonSchema; + } + Object value = getListResultValue(docModel, schema, field); + if (value != null && value instanceof String) { // If it is String that is either null or empty, we set our value to null + String strValue = (String) value; + if (strValue.trim().isEmpty() == true) { + value = null; // We found an "empty" string value, so just set the value to null so we don't return anything. + } + } + if (value != null) { + item.put(field.getElement(), value); + } + } + commonList.addItem(item); + item.clear(); + } + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception ", e); + } + throw new DocumentException(e); + } finally { + // If we got/aquired a new session then we're responsible for releasing it. + if (releaseRepoSession && repoSession != null) { + repoClient.releaseRepositorySession(ctx, repoSession); + } + } + + return commonList; + } + + // TODO - get rid of this if we can - appears to be unused. + @Override + public String getQProperty(String prop) throws DocumentException { + ServiceContext ctx = this.getServiceContext(); + return ServiceConfigUtils.getDocHandlerParams(ctx).getSchemaName() + ":" + prop; + } + + // ============= dublin core handling ======================================= + + @Override + public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { + super.fillAllParts(wrapDoc, action); + fillDublinCoreObject(wrapDoc); + } + + /** + * Fill dublin core object, but only if there are document handler parameters in the service + * bindings. + * + * @param wrapDoc + * the wrap doc + * @throws Exception + * the exception + */ + // TODO - Remove this? + // This look like it is never used in a sensible way. It just stuffs a static + // String that matches the service name into a bogus field. + protected void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception { + DocHandlerParams.Params docHandlerParams = null; + try { + docHandlerParams = ServiceConfigUtils.getDocHandlerParams(getServiceContext()); + } catch (Exception e) { + logger.warn(e.getMessage()); + } + + if (docHandlerParams != null) { + String title = docHandlerParams.getDublinCoreTitle(); + if (Tools.isEmpty(title) == false) { + DocumentModel docModel = wrapDoc.getWrappedObject(); + docModel.setPropertyValue("dublincore:title", title); + } + } + } + + // ================== UTILITY METHODS ================================================ + public static ReflectionMapper.STATUS callPropertySetterWithXPathValue(DocumentModel docModel, Object listItem, + String setterName, String schema, String xpath) throws Exception { + // Object prop = docModel.getProperty(label, elementName); + String value = (String) NuxeoUtils.getXPathValue(docModel, schema, xpath); + return ReflectionMapper.callSetter(listItem, setterName, value); + } + + public static ReflectionMapper.STATUS callSimplePropertySetter(Object target, String name, Object arg) { + return ReflectionMapper.callSetter(target, name, arg); + } + + /** + * @param commonListClassname + * is a package-qualified java classname, including inner class $ notation, such as + * "org.collectionspace.services.objectexit.ObjectexitCommonList$ObjectexitListItem". + * @param includeStdFields + * set to true to have the method set Uri and Csid automatically, based on id param. + */ + public Object createItemForCommonList(String commonListClassname, DocumentModel docModel, String schema, String id, + boolean includeStdFields) throws Exception { + // createItemForCommonList(docModel, label, id); + Object item = ReflectionMapper.instantiate(commonListClassname); + List resultsFields = getListItemsArray(); + for (ListResultField field : resultsFields) { + callPropertySetterWithXPathValue(docModel, item, field.getSetter(), schema, field.getXpath()); + } + if (includeStdFields) { + callSimplePropertySetter(item, "setCsid", id); + callSimplePropertySetter(item, "setUri", getServiceContextPath() + id); + } + + return item; + } + + /** + * Subclasses should override this method if they don't want to automatically + * call List createItemsList(AbstractCommonList commonList, String listItemMethodName) + * which will use introspection to create a summary list, and will find the primary + * field for you if specified. + */ + public List createItemsList(AbstractCommonList commonList) throws Exception { + ServiceContext ctx = this.getServiceContext(); + return createItemsList(commonList, ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsItemMethodName()); + } + + /** e.g. createItemsList(commonList, "getObjectexitListItem" */ + public List createItemsList(AbstractCommonList commonList, String listItemMethodName) throws Exception { + Class commonListClass = commonList.getClass(); + Class[] types = new Class[] {}; + try { + Method m = commonListClass.getMethod(listItemMethodName, types); + return (List) (ReflectionMapper.fireGetMethod(m, commonList)); + } catch (NoSuchMethodException nsm) { + return new ArrayList(); + } + } + +} diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index 6cc3b95a0..39060c28d 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -50,7 +49,7 @@ import org.collectionspace.services.client.Profiler; import org.collectionspace.services.client.RelationClient; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.config.ServiceConfigUtils; import org.collectionspace.services.common.context.JaxRsContext; @@ -80,11 +79,13 @@ import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationsDocListItem; import org.collectionspace.services.relation.RelationshipType; + import org.dom4j.Element; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -124,7 +125,7 @@ public abstract class RemoteDocumentModelHandlerImpl private String getRefnameDisplayName(DocumentModel docModel) { // Look in the tenant bindings to see what field should be our display name for our refname value String result = null; - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); DocHandlerParams.Params params = null; try { @@ -152,7 +153,7 @@ public abstract class RemoteDocumentModelHandlerImpl DocHandlerParams.Params params = null; try { - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); params = ServiceConfigUtils.getDocHandlerParams(ctx); Boolean bool = params.isSupportsHierarchy(); if (bool != null) { @@ -175,7 +176,7 @@ public abstract class RemoteDocumentModelHandlerImpl DocHandlerParams.Params params = null; try { - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); params = ServiceConfigUtils.getDocHandlerParams(ctx); Boolean bool = params.isSupportsVersioning(); if (bool != null) { @@ -619,7 +620,7 @@ public abstract class RemoteDocumentModelHandlerImpl boolean releaseRepoSession = false; ServiceContext ctx = this.getServiceContext(); RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx); - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); if (repoSession == null) { repoSession = repoClient.getRepositorySession(ctx); releaseRepoSession = true; @@ -1265,7 +1266,7 @@ public abstract class RemoteDocumentModelHandlerImpl logger.trace("Fetching CSID for child with only refname: "+newChildRefName); } DocumentModel newChildDocModel = - ResourceBase.getDocModelForRefName(this.getRepositorySession(), + NuxeoBasedResource.getDocModelForRefName(this.getRepositorySession(), newChildRefName, getServiceContext().getResourceMap()); newChildCsid = getCsid(newChildDocModel); } @@ -1318,7 +1319,7 @@ public abstract class RemoteDocumentModelHandlerImpl * and sets URI correctly for related items. * Operates directly on the items in the list. Does not change the list ordering, does not add or remove any items. */ - protected void fixupInboundListItems(ServiceContext ctx, + protected void fixupInboundListItems(ServiceContext ctx, List inboundList, DocumentModel docModel, String itemCSID) throws Exception { @@ -1405,8 +1406,8 @@ public abstract class RemoteDocumentModelHandlerImpl // since a save on Create might fail, and we would not want to create relations for something // that may not be created... private void handleRelationsPayload(DocumentWrapper wrapDoc, boolean fUpdate) throws Exception { - ServiceContext ctx = getServiceContext(); - PoxPayloadIn input = (PoxPayloadIn) ctx.getInput(); + ServiceContext ctx = getServiceContext(); + PoxPayloadIn input = ctx.getInput(); DocumentModel documentModel = (wrapDoc.getWrappedObject()); String itemCsid = documentModel.getName(); @@ -1419,7 +1420,7 @@ public abstract class RemoteDocumentModelHandlerImpl //now we add part for relations list //ServiceContext ctx = getServiceContext(); //PayloadOutputPart foo = (PayloadOutputPart) ctx.getProperty(RelationClient.SERVICE_COMMON_LIST_NAME); - ((PoxPayloadOut) ctx.getOutput()).addPart(payloadOutputPart); + ctx.getOutput().addPart(payloadOutputPart); } /** @@ -1431,7 +1432,7 @@ public abstract class RemoteDocumentModelHandlerImpl if (hasRefNameUpdate() == true) { ServiceContext ctx = getServiceContext(); RepositoryClient repoClient = getRepositoryClient(ctx); - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); // Update all the relationship records that referred to the old refName RefNameServiceUtils.updateRefNamesInRelations(ctx, repoClient, repoSession, diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java index 0b8cdc93d..6d4f231b6 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java @@ -32,19 +32,21 @@ import java.util.UUID; import javax.sql.rowset.CachedRowSet; import javax.ws.rs.core.MultivaluedMap; +import org.collectionspace.services.lifecycle.TransitionDef; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; + import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.Profiler; import org.collectionspace.services.client.workflow.WorkflowClient; + import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.query.QueryContext; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.storage.JDBCTools; import org.collectionspace.services.common.storage.PreparedStatementSimpleBuilder; -import org.collectionspace.services.lifecycle.TransitionDef; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.common.document.BadRequestException; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentFilter; @@ -54,8 +56,25 @@ import org.collectionspace.services.common.document.DocumentHandler.Action; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.document.DocumentWrapperImpl; import org.collectionspace.services.common.document.TransactionException; +import org.collectionspace.services.common.CSWebApplicationException; +import org.collectionspace.services.common.ServiceMain; +import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.config.ConfigUtils; +import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; +import org.collectionspace.services.common.config.TenantBindingUtils; +import org.collectionspace.services.common.storage.PreparedStatementBuilder; + +import org.collectionspace.services.config.tenant.TenantBindingType; import org.collectionspace.services.config.tenant.RepositoryDomainType; +// +// CSPACE-5036 - How to make CMISQL queries from Nuxeo +// +import org.apache.chemistry.opencmis.commons.enums.CmisVersion; +import org.apache.chemistry.opencmis.commons.server.CallContext; +import org.apache.chemistry.opencmis.server.impl.CallContextImpl; +import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory; + import org.nuxeo.common.utils.IdUtils; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; @@ -67,22 +86,9 @@ import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.IdRef; import org.nuxeo.ecm.core.api.PathRef; import org.nuxeo.runtime.transaction.TransactionRuntimeException; - -// -// CSPACE-5036 - How to make CMISQL queries from Nuxeo -// -import org.apache.chemistry.opencmis.commons.server.CallContext; -import org.apache.chemistry.opencmis.server.impl.CallContextImpl; -import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ServiceMain; -import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.config.ConfigUtils; -import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; -import org.collectionspace.services.common.config.TenantBindingUtils; -import org.collectionspace.services.common.storage.PreparedStatementBuilder; -import org.collectionspace.services.config.tenant.TenantBindingType; +import org.nuxeo.ecm.core.opencmis.bindings.NuxeoCmisServiceFactory; import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService; -import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoRepository; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -121,7 +127,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, DocumentModel docModel) throws DocumentNotFoundException, ClientException { MultivaluedMap queryParams = ctx.getQueryParams(); if (queryParams != null) { @@ -178,7 +184,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient getDoc( - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, ServiceContext ctx, String csid) throws DocumentNotFoundException, DocumentException { DocumentWrapper wrapDoc = null; @@ -371,7 +377,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient getDoc( ServiceContext ctx, String csid) throws DocumentNotFoundException, TransactionException, DocumentException { - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; DocumentWrapper wrapDoc = null; try { @@ -400,7 +406,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient findDoc( - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, ServiceContext ctx, String whereClause) throws DocumentNotFoundException, DocumentException { @@ -454,7 +460,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, String whereClause) throws DocumentNotFoundException, TransactionException, DocumentException { - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; DocumentWrapper wrapDoc = null; try { @@ -487,7 +493,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, String whereClause) throws DocumentNotFoundException, TransactionException, DocumentException { String csid = null; @@ -521,7 +527,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient findDocs( ServiceContext ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, List docTypes, String whereClause, String orderByClause, @@ -577,7 +583,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient findDocs( ServiceContext ctx, DocumentHandler handler, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, List docTypes) throws DocumentNotFoundException, DocumentException { DocumentWrapper wrapDoc = null; @@ -636,7 +642,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient wrapDoc = null; try { @@ -674,7 +680,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient getDocFromCsid( ServiceContext ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String csid) throws Exception { DocumentWrapper result = null; - result = new DocumentWrapperImpl(NuxeoUtils.getDocFromCsid(ctx, repoSession, csid)); + result = new DocumentWrapperImpl(NuxeoUtils.getDocFromCsid(ctx, repoSession, csid)); return result; } @@ -788,7 +794,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient result = null; - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; try { repoSession = getRepositorySession(ctx); result = getDocFromCsid(ctx, repoSession, csid); @@ -823,25 +829,29 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, DocumentHandler handler) throws Exception { DocumentModelList result = new DocumentModelListImpl(); @@ -1210,7 +1220,8 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, DocumentHandler handler, QueryContext queryContext) throws DocumentNotFoundException, DocumentException { DocumentModelList result = new DocumentModelListImpl(); @@ -1322,7 +1333,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, DocumentModel docModel, boolean fSaveSession) throws ClientException, DocumentException { @@ -1421,14 +1432,14 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, DocumentModelList docList, boolean fSaveSession) throws ClientException, DocumentException { @@ -1467,7 +1478,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx) throws Exception { return getRepositorySession(ctx, ctx.getRepositoryName()); } - public RepositoryInstanceInterface getRepositorySession(String repoName) throws Exception { + public CoreSessionInterface getRepositorySession(String repoName) throws Exception { return getRepositorySession(null, repoName); } @@ -1722,8 +1733,8 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, String repoName) throws Exception { + CoreSessionInterface repoSession = null; Profiler profiler = new Profiler("getRepositorySession():", 2); profiler.start(); @@ -1732,7 +1743,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx, CoreSessionInterface repoSession) throws TransactionException { try { NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient(); // release session @@ -1879,7 +1890,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient ctx) { boolean restrict = true; // If data for the current service, in the current tenant, is isolated // within its own separate, per-tenant repository, as contrasted with diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java index b7c512752..1ef9a9dd9 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java @@ -41,15 +41,15 @@ import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.query.QueryContext; import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; + import org.dom4j.Document; import org.dom4j.io.SAXReader; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.ClientException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.nuxeo.ecm.core.api.Blob; -import org.nuxeo.ecm.core.api.ConnectionException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.IdRef; @@ -62,10 +62,10 @@ import org.nuxeo.ecm.core.io.impl.DocumentPipeImpl; import org.nuxeo.ecm.core.io.impl.plugins.SingleDocumentReader; import org.nuxeo.ecm.core.io.impl.plugins.XMLDocumentWriter; import org.nuxeo.ecm.core.schema.SchemaManager; -import org.nuxeo.ecm.core.search.api.client.querymodel.descriptor.QueryModelDescriptor; -import org.nuxeo.ecm.core.storage.sql.Binary; +import org.nuxeo.ecm.core.storage.binary.Binary; import org.nuxeo.ecm.core.storage.sql.coremodel.SQLBlob; import org.nuxeo.runtime.api.Framework; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -138,10 +138,10 @@ public class NuxeoUtils { Set result = null; try { - Field f = docModel.getClass().getDeclaredField("facets"); - f.setAccessible(true); - result = (Set) f.get(docModel); - f.setAccessible(false); + Field field = docModel.getClass().getDeclaredField("facets"); + field.setAccessible(true); + result = (Set) field.get(docModel); + field.setAccessible(false); } catch (Exception e) { logger.error("Could not remove facet from DocumentModel instance: " + docModel.getId(), e); } @@ -220,7 +220,7 @@ public class NuxeoUtils { * @return * @throws DocumentException */ - public static Document getDocument(RepositoryInstanceInterface repoSession, DocumentModel nuxeoDoc) + public static Document getDocument(CoreSessionInterface repoSession, DocumentModel nuxeoDoc) throws DocumentException { Document doc = null; DocumentWriter writer = null; @@ -230,7 +230,7 @@ public class NuxeoUtils { try { baos = new ByteArrayOutputStream(); //nuxeo io.impl begin - reader = new SingleDocumentReader(repoSession.getRepositoryInstance(), nuxeoDoc); + reader = new SingleDocumentReader(repoSession.getCoreSession(), nuxeoDoc); writer = new XMLDocumentWriter(baos); DocumentPipe pipe = new DocumentPipeImpl(); //nuxeo io.impl end @@ -280,7 +280,7 @@ public class NuxeoUtils { * * @throws DocumentException the document exception */ - public static Document getDocument(RepositoryInstanceInterface repoSession, String csid) + public static Document getDocument(CoreSessionInterface repoSession, String csid) throws DocumentException { Document result = null; @@ -303,7 +303,7 @@ public class NuxeoUtils { * @throws ClientException the client exception */ public static DocumentModel getWorkspaceModel( - RepositoryInstanceInterface repoSession, String workspaceName) + CoreSessionInterface repoSession, String workspaceName) throws DocumentException, IOException, ClientException { DocumentModel result = null; //FIXME: commented out as this does not work without tenant qualification @@ -330,7 +330,7 @@ public class NuxeoUtils { * @throws DocumentException the document exception */ public static DocumentModel getDocumentModel( - RepositoryInstanceInterface repoSession, String nuxeoId) + CoreSessionInterface repoSession, String nuxeoId) throws DocumentException { DocumentModel result = null; @@ -475,7 +475,7 @@ public class NuxeoUtils { * @return an NXQL query * @throws Exception if supplied values in the query are invalid. */ - static public final String buildNXQLQuery(ServiceContext ctx, QueryContext queryContext) throws Exception { + static public final String buildNXQLQuery(ServiceContext ctx, QueryContext queryContext) throws Exception { StringBuilder query = new StringBuilder("SELECT * FROM "); // Since we have a tenant qualification in the WHERE clause, we do not need // tenant-specific doc types @@ -486,7 +486,7 @@ public class NuxeoUtils { return query.toString(); } - static public final String buildCMISQuery(ServiceContext ctx, QueryContext queryContext) throws Exception { + static public final String buildCMISQuery(ServiceContext ctx, QueryContext queryContext) throws Exception { StringBuilder query = new StringBuilder("SELECT * FROM "); /* @@ -536,7 +536,7 @@ public class NuxeoUtils { static public DocumentModel getDocFromCsid( ServiceContext ctx, - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, String csid) throws Exception { DocumentModel result = null; @@ -586,7 +586,7 @@ public class NuxeoUtils { * @param id * @return PathRef */ - public static DocumentRef createPathRef(ServiceContext ctx, String id) { + public static DocumentRef createPathRef(ServiceContext ctx, String id) { return new PathRef("/" + ctx.getRepositoryDomainStorageName() + "/" + Workspaces + "/" + ctx.getRepositoryWorkspaceName() + @@ -621,40 +621,25 @@ public class NuxeoUtils { return id; } - public static boolean documentExists(RepositoryInstanceInterface repoSession, + /** + * Return the string literal in a form ready to embed in an NXQL statement. + * + * @param s + * @return + */ + public static String prepareStringLiteral(String s) { + return "'" + s.replaceAll("'", "\\\\'") + "'"; + } + + public static boolean documentExists(CoreSessionInterface repoSession, String csid) throws ClientException { boolean result = false; - /* - * This is the code that Nuxeo support suggested, however it will not work with their - * remote API's -it only works locally. - - String qname = QueryModelDescriptor.prepareStringLiteral(csid); - String statement = String.format( - "SELECT ecm:uuid FROM Document WHERE ecm:name = %s", qname); - ResultSetQueryResult res = (ResultSetQueryResult) repoSession - .queryAndFetch(statement, "NXQL"); - result = res.hasNext(); - if (result = false) { - if (logger.isDebugEnabled() == true) { - logger.debug("Existance check failed for document with CSID = " + csid); - } - } else { - //String uuid = (String) res.next().get(NXQL.ECM_UUID); - } - */ - - /* - * Until I hear back from Nuxeo, we can use the following code: - */ - String qname = QueryModelDescriptor.prepareStringLiteral(csid); String statement = String.format( - "SELECT ecm:uuid FROM Document WHERE ecm:name = %s", qname); -// ResultSetQueryResult res = (ResultSetQueryResult) repoSession -// .queryAndFetch(statement, "NXQL"); - DocumentModelList res = repoSession.query(statement, 1/*return no more than 1*/);//, "NXQL"); + "SELECT ecm:uuid FROM Document WHERE ecm:name = %s", prepareStringLiteral(csid)); + final int RETURN_ONE_ROW = 1; // Return no more than 1 row + DocumentModelList res = repoSession.query(statement, RETURN_ONE_ROW); -// result = res.hasNext(); result = res.iterator().hasNext(); if (result = false) { if (logger.isDebugEnabled() == true) { @@ -680,7 +665,7 @@ public class NuxeoUtils { } - public static String getTenantQualifiedDocType(ServiceContext ctx, String docType) throws Exception { + public static String getTenantQualifiedDocType(ServiceContext ctx, String docType) throws Exception { String result = docType; String tenantQualifiedDocType = ctx.getTenantQualifiedDoctype(docType); @@ -691,7 +676,7 @@ public class NuxeoUtils { return result; } - public static String getTenantQualifiedDocType(ServiceContext ctx) throws NuxeoDocumentException { + public static String getTenantQualifiedDocType(ServiceContext ctx) throws NuxeoDocumentException { String result = null; try { diff --git a/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/ConditioncheckResource.java b/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/ConditioncheckResource.java index 921c4d287..23165d90f 100644 --- a/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/ConditioncheckResource.java +++ b/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/ConditioncheckResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.conditioncheck; import org.collectionspace.services.client.ConditioncheckClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(ConditioncheckClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class ConditioncheckResource extends ResourceBase { +public class ConditioncheckResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(ConditioncheckResource.class); diff --git a/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/nuxeo/ConditioncheckDocumentModelHandler.java b/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/nuxeo/ConditioncheckDocumentModelHandler.java index 240320db5..2dadc8563 100644 --- a/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/nuxeo/ConditioncheckDocumentModelHandler.java +++ b/services/conditioncheck/service/src/main/java/org/collectionspace/services/conditioncheck/nuxeo/ConditioncheckDocumentModelHandler.java @@ -24,10 +24,10 @@ package org.collectionspace.services.conditioncheck.nuxeo; import org.collectionspace.services.conditioncheck.ConditionchecksCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** ConditioncheckDocumentModelHandler */ public class ConditioncheckDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/ContactResource.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/ContactResource.java index 5b95e14c2..30cf88b99 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/ContactResource.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/ContactResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.contact; import org.collectionspace.services.client.ContactClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(ContactClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class ContactResource extends ResourceBase { +public class ContactResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(ContactResource.class); @Override diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java index 55d9a5cab..eb12ee287 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java @@ -30,7 +30,7 @@ import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.contact.ContactJAXBSchema; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.contact.ContactsCommon; import org.nuxeo.ecm.core.api.DocumentModel; @@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory; * The Class ContactDocumentModelHandler. */ public class ContactDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { private final Logger logger = LoggerFactory.getLogger(ContactDocumentModelHandler.class); private static final String COMMON_PART_LABEL = "contacts_common"; diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java index 096af4c5e..4fe8590dd 100644 --- a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.dimension; import org.collectionspace.services.client.DimensionClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(DimensionClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class DimensionResource extends ResourceBase { +public class DimensionResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(DimensionResource.class); diff --git a/services/group/service/src/main/java/org/collectionspace/services/group/GroupResource.java b/services/group/service/src/main/java/org/collectionspace/services/group/GroupResource.java index 3f856be97..cfd933231 100644 --- a/services/group/service/src/main/java/org/collectionspace/services/group/GroupResource.java +++ b/services/group/service/src/main/java/org/collectionspace/services/group/GroupResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.group; import org.collectionspace.services.client.GroupClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import javax.ws.rs.Consumes; import javax.ws.rs.Path; @@ -33,7 +33,7 @@ import javax.ws.rs.Produces; @Path(GroupClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class GroupResource extends ResourceBase { +public class GroupResource extends NuxeoBasedResource { @Override public String getServiceName(){ diff --git a/services/group/service/src/main/java/org/collectionspace/services/group/nuxeo/GroupDocumentModelHandler.java b/services/group/service/src/main/java/org/collectionspace/services/group/nuxeo/GroupDocumentModelHandler.java index e39abbb7a..61760f19c 100644 --- a/services/group/service/src/main/java/org/collectionspace/services/group/nuxeo/GroupDocumentModelHandler.java +++ b/services/group/service/src/main/java/org/collectionspace/services/group/nuxeo/GroupDocumentModelHandler.java @@ -23,10 +23,10 @@ */ package org.collectionspace.services.group.nuxeo; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.group.GroupsCommon; public class GroupDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java index 2d943836d..6754b5e22 100644 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java @@ -6,13 +6,11 @@ import java.util.HashMap; import java.util.Map; import java.util.TreeSet; -import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.nuxeo.client.java.NuxeoClientEmbedded; import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentRef; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.nuxeo.ecm.core.io.DocumentPipe; import org.nuxeo.ecm.core.io.DocumentReader; import org.nuxeo.ecm.core.io.DocumentTranslationMap; @@ -32,7 +30,7 @@ public class ImportCommand { File file = new File(src); ///cspace way of configuring client and auth: NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient(); - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; try { repoSession = client.openRepository(repoName, timeOut); if (logger.isDebugEnabled()) { @@ -51,7 +49,7 @@ public class ImportCommand { } } - String importTree(RepositoryInstanceInterface repoSession, File file, String toPath) throws Exception { + String importTree(CoreSessionInterface repoSession, File file, String toPath) throws Exception { Exception failed = null; DocumentReader reader = null; DocumentWriter writer = null; @@ -67,7 +65,7 @@ public class ImportCommand { logger.info("importTree reading file: " + file + (file != null ? " exists? " + file.exists() : " file param is null")); } reader = new LoggedXMLDirectoryReader(file); //our overload of XMLDirectoryReader. - writer = new DocumentModelWriter(repoSession.getRepositoryInstance(), toPath, 10); + writer = new DocumentModelWriter(repoSession.getCoreSession(), toPath, 10); DocumentPipe pipe = new DocumentPipeImpl(10); // pipe.addTransformer(transformer); pipe.setReader(reader); @@ -75,7 +73,7 @@ public class ImportCommand { DocumentTranslationMap dtm = pipe.run(); Map documentRefs = dtm.getDocRefMap(); // FIXME: Should be checking for null here! dump.append(""); - for (Map.Entry entry : documentRefs.entrySet()) { + for (Map.Entry entry : documentRefs.entrySet()) { keyDocRef = (DocumentRef) entry.getKey(); valueDocRef = (DocumentRef) entry.getValue(); if (keyDocRef == null || valueDocRef == null) { diff --git a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportsDocumentModelHandler.java b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportsDocumentModelHandler.java index 27a24f334..5875bcdd3 100644 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportsDocumentModelHandler.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportsDocumentModelHandler.java @@ -23,10 +23,10 @@ */ package org.collectionspace.services.imports.nuxeo; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.imports.ImportsCommon; public class ImportsDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java index 910ee0bbc..10f8d5b51 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.intake; import org.collectionspace.services.client.IntakeClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(IntakeClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class IntakeResource extends ResourceBase { +public class IntakeResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(IntakeResource.class); diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java index be75254cf..204c32777 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java @@ -24,7 +24,7 @@ package org.collectionspace.services.intake.nuxeo; import org.collectionspace.services.intake.IntakesCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** * IntakeDocumentModelHandler @@ -33,6 +33,6 @@ import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; * $LastChangedDate: $ */ public class IntakeDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java index d270c7c64..adf161b5e 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.loanin; import org.collectionspace.services.client.LoaninClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(LoaninClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class LoaninResource extends ResourceBase { +public class LoaninResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(LoaninResource.class); diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java index d3244a9aa..01095fd88 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java @@ -24,13 +24,13 @@ package org.collectionspace.services.loanin.nuxeo; import org.collectionspace.services.loanin.LoansinCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** LoaninDocumentModelHandler * $LastChangedRevision$ * $LastChangedDate$ */ public class LoaninDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java index dd7ae6561..74d2b93b6 100644 --- a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java +++ b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java @@ -23,7 +23,7 @@ */ package org.collectionspace.services.loanout; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ import javax.ws.rs.Produces; //@Path(LoanoutClient.SERVICE_PATH_COMPONENT) @Consumes("application/xml") @Produces("application/xml") -public class LoanoutResource extends ResourceBase { +public class LoanoutResource extends NuxeoBasedResource { private final static String serviceName = "loansout"; diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java index cb9c88a12..fc649a718 100644 --- a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java +++ b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java @@ -24,13 +24,13 @@ package org.collectionspace.services.loanout.nuxeo; import org.collectionspace.services.loanout.LoansoutCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** * The Class LoanoutDocumentModelHandler. */ public class LoanoutDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java index 9580ff4dd..9f2c18a6c 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java @@ -31,7 +31,7 @@ import org.collectionspace.services.client.MediaClient; import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.blob.BlobInput; @@ -60,7 +60,7 @@ import javax.ws.rs.core.UriInfo; @Path(MediaClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class MediaResource extends ResourceBase { +public class MediaResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(MediaResource.class); final static MediaClient mediaClient = new MediaClient(); diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java b/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java index 9389ba30d..4b6995e1a 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java @@ -24,7 +24,7 @@ package org.collectionspace.services.media.nuxeo; import org.collectionspace.services.MediaJAXBSchema; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.client.BlobClient; import org.collectionspace.services.common.blob.BlobInput; import org.collectionspace.services.common.blob.BlobUtil; @@ -43,7 +43,7 @@ import javax.ws.rs.core.MultivaluedMap; * The Class MediaDocumentModelHandler. */ public class MediaDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { //============================================================================== diff --git a/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java b/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java index 75172b919..f535861ca 100644 --- a/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java +++ b/services/movement/service/src/main/java/org/collectionspace/services/movement/MovementResource.java @@ -27,7 +27,7 @@ import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.MovementClient; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentHandler; @@ -49,7 +49,7 @@ import javax.ws.rs.core.MultivaluedMap; @Path(MovementClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class MovementResource extends ResourceBase { +public class MovementResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(MovementResource.class); diff --git a/services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java b/services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java index 8d0d62fa5..b45afbcc6 100644 --- a/services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java +++ b/services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java @@ -24,7 +24,7 @@ package org.collectionspace.services.movement.nuxeo; import org.collectionspace.services.movement.MovementsCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ public class MovementDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class); } diff --git a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java index 3027f33ff..a808e1da1 100644 --- a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java +++ b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.objectexit; import org.collectionspace.services.client.ObjectExitClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import javax.ws.rs.Consumes; import javax.ws.rs.Path; @@ -33,7 +33,7 @@ import javax.ws.rs.Produces; @Path(ObjectExitClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class ObjectExitResource extends ResourceBase { +public class ObjectExitResource extends NuxeoBasedResource { @Override public String getServiceName(){ diff --git a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java index 11093d97a..0d5ad493b 100644 --- a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java +++ b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java @@ -23,10 +23,10 @@ */ package org.collectionspace.services.objectexit.nuxeo; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.collectionspace.services.objectexit.ObjectexitCommon; public class ObjectExitDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/publicitem/service/src/main/java/org/collectionspace/services/publicitem/nuxeo/PublicItemDocumentModelHandler.java b/services/publicitem/service/src/main/java/org/collectionspace/services/publicitem/nuxeo/PublicItemDocumentModelHandler.java index ea889b92e..6b77c8bd5 100644 --- a/services/publicitem/service/src/main/java/org/collectionspace/services/publicitem/nuxeo/PublicItemDocumentModelHandler.java +++ b/services/publicitem/service/src/main/java/org/collectionspace/services/publicitem/nuxeo/PublicItemDocumentModelHandler.java @@ -29,7 +29,7 @@ import org.collectionspace.services.PublicitemsCommonJAXBSchema; import org.collectionspace.services.publicitem.PublicitemsCommon; import org.collectionspace.services.client.PublicItemClient; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; import org.nuxeo.ecm.core.api.DocumentModel; /** PublicItemDocumentModelHandler @@ -37,7 +37,7 @@ import org.nuxeo.ecm.core.api.DocumentModel; * $LastChangedDate$ */ public class PublicItemDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { @Override public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index 2d34e46ba..def69bf10 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -29,10 +29,9 @@ import java.net.HttpURLConnection; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ServiceException; import org.collectionspace.services.common.ServiceMain; -import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.context.ServiceBindingUtils; @@ -48,27 +47,18 @@ import org.collectionspace.services.relation.RelationsCommon; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationsCommonList.RelationListItem; import org.collectionspace.services.relation.RelationsDocListItem; - -// HACK HACK HACK import org.collectionspace.services.client.CollectionSpaceClient; -import org.collectionspace.services.client.PersonAuthorityClient; -import org.collectionspace.services.client.CitationAuthorityClient; -import org.collectionspace.services.client.OrgAuthorityClient; -import org.collectionspace.services.client.LocationAuthorityClient; -import org.collectionspace.services.client.TaxonomyAuthorityClient; -import org.collectionspace.services.client.PlaceAuthorityClient; -import org.collectionspace.services.client.WorkAuthorityClient; -import org.collectionspace.services.client.ConceptAuthorityClient; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; + 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.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +91,7 @@ public class RelationDocumentModelHandler DocumentModel relationDocModel = wrapDoc.getWrappedObject(); String errMsg = ERROR_TERMS_IN_WORKFLOWSTATE + workflowState; - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); try { DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL); DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL); @@ -177,8 +167,7 @@ public class RelationDocumentModelHandler // we will also set those. // Note that this introduces another caching problem... DocumentModel relationDocModel = wrapDoc.getWrappedObject(); - ServiceContext ctx = this.getServiceContext(); - RepositoryInstanceInterface repoSession = this.getRepositorySession(); + CoreSessionInterface repoSession = this.getRepositorySession(); DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL); DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL); @@ -230,7 +219,7 @@ public class RelationDocumentModelHandler public RelationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { RelationsCommonList relList = this.extractPagingInfo(new RelationsCommonList(), wrapDoc); relList.setFieldsReturned("subjectCsid|relationshipType|predicateDisplayName|relationshipMetaType|objectCsid|uri|csid|subject|object"); - ServiceContext ctx = getServiceContext(); + ServiceContext ctx = getServiceContext(); String serviceContextPath = getServiceContextPath(); TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader(); @@ -376,7 +365,7 @@ public class RelationDocumentModelHandler private final boolean OBJ_DOC_MODEL = false; private DocumentModel getSubjectOrObjectDocModel( - RepositoryInstanceInterface repoSession, + CoreSessionInterface repoSession, DocumentModel relationDocModel, boolean fSubject) throws Exception { ServiceContext ctx = this.getServiceContext(); @@ -405,7 +394,7 @@ public class RelationDocumentModelHandler try { refName = (String) relationDocModel.getProperty(commonPartLabel, (fSubject?RelationJAXBSchema.SUBJECT_REFNAME:RelationJAXBSchema.OBJECT_REFNAME)); - docModel = ResourceBase.getDocModelForRefName(repoSession, refName, ctx.getResourceMap()); + docModel = NuxeoBasedResource.getDocModelForRefName(repoSession, refName, ctx.getResourceMap()); } catch (Exception e) { throw new InvalidDocumentException( "Relation record must have a CSID or refName to identify the object of the relation.", e); diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java index 566d4e3b9..c9526b603 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java @@ -33,7 +33,7 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.ReportClient; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.context.ServiceContext; @@ -65,7 +65,7 @@ import javax.ws.rs.core.Response.ResponseBuilder; @Consumes("application/xml") @Produces("application/xml") //@Produces("application/xml;charset=UTF-8") -public class ReportResource extends ResourceBase { +public class ReportResource extends NuxeoBasedResource { private static String REPOSITORY_NAME = JDBCTools.NUXEO_DATASOURCE_NAME; private static String REPORTS_FOLDER = "reports"; private static String CSID_LIST_SEPARATOR = ","; diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java index eb291dfec..1748a7a24 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java @@ -37,7 +37,6 @@ import java.util.Map; import javax.ws.rs.core.MediaType; import javax.naming.NamingException; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import net.sf.jasperreports.engine.JRException; @@ -45,7 +44,6 @@ import net.sf.jasperreports.engine.JRExporter; import net.sf.jasperreports.engine.JRExporterParameter; import net.sf.jasperreports.engine.JRParameter; import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.export.JRCsvExporter; @@ -57,7 +55,6 @@ import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter; import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; -import org.bouncycastle.crypto.RuntimeCryptoException; import org.collectionspace.services.ReportJAXBSchema; import org.collectionspace.services.report.ReportsCommon; import org.collectionspace.services.client.PoxPayloadIn; @@ -68,7 +65,6 @@ import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.api.JEEServerDeployment; import org.collectionspace.services.common.api.FileTools; import org.collectionspace.services.common.api.Tools; -import org.collectionspace.services.common.config.ConfigReader; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.BadRequestException; import org.collectionspace.services.common.document.DocumentException; @@ -77,13 +73,12 @@ import org.collectionspace.services.common.invocable.Invocable; import org.collectionspace.services.common.invocable.InvocationContext; import org.collectionspace.services.common.storage.JDBCTools; import org.collectionspace.services.jaxb.InvocableJAXBSchema; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.jfree.util.Log; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +88,7 @@ import org.slf4j.LoggerFactory; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class ReportDocumentModelHandler extends DocHandlerBase { +public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler { private final Logger logger = LoggerFactory.getLogger(ReportDocumentModelHandler.class); private static String REPORTS_FOLDER = "reports"; private static String CSID_LIST_SEPARATOR = ","; @@ -109,7 +104,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase { InvocationContext invContext, StringBuffer outMimeType, StringBuffer outReportFileName) throws Exception { - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; boolean releaseRepoSession = false; String invocationMode = invContext.getMode(); @@ -400,7 +395,7 @@ public class ReportDocumentModelHandler extends DocHandlerBase { private Connection getConnection() throws NamingException, SQLException { Connection result = null; - ServiceContext ctx = this.getServiceContext(); + ServiceContext ctx = this.getServiceContext(); try { String repositoryName = ctx.getRepositoryName(); if (repositoryName != null && repositoryName.trim().isEmpty() == false) { diff --git a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java index 3b6d27ab5..630355742 100644 --- a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java +++ b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java @@ -35,33 +35,22 @@ import org.collectionspace.services.client.ServiceGroupClient; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.context.MultipartServiceContextFactory; -import org.collectionspace.services.common.context.RemoteServiceContextFactory; import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.context.ServiceContextFactory; -import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentHandler; -import org.collectionspace.services.common.document.DocumentNotFoundException; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.query.QueryManager; -import org.collectionspace.services.common.repository.RepositoryClient; -import org.collectionspace.services.common.repository.RepositoryClientFactory; import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.config.service.ServiceObjectType; import org.collectionspace.services.nuxeo.client.java.CommonList; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.servicegroup.nuxeo.ServiceGroupDocumentModelHandler; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,7 +59,6 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -79,7 +67,7 @@ import javax.ws.rs.core.UriInfo; @Path(ServiceGroupClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl { +public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -103,7 +91,7 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl { @Override //public Class getCommonPartClass() { - public Class getCommonPartClass() { + public Class getCommonPartClass() { try { return Class.forName("org.collectionspace.services.servicegroup.ServicegroupsCommon");//.class; } catch (ClassNotFoundException e){ @@ -166,7 +154,7 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl { @Context UriInfo ui, @PathParam("csid") String groupname) { PoxPayloadOut result = null; - ensureCSID(groupname, ResourceBase.READ); + ensureCSID(groupname, NuxeoBasedResource.READ); try { ServiceContext ctx = createServiceContext(); TenantBindingConfigReaderImpl tReader = @@ -220,7 +208,7 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl { public AbstractCommonList getItems( @Context UriInfo ui, @PathParam("csid") String serviceGroupName) { - ensureCSID(serviceGroupName, ResourceBase.READ); + ensureCSID(serviceGroupName, NuxeoBasedResource.READ); AbstractCommonList list = null; try { ServiceContext ctx = createServiceContext(ui); diff --git a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java index 257dc729a..37b8ab39b 100644 --- a/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java +++ b/services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java @@ -29,19 +29,18 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; -import org.collectionspace.services.ServiceGroupListItemJAXBSchema; import org.collectionspace.services.nuxeo.client.java.CommonList; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; +import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; + import org.collectionspace.services.common.CSWebApplicationException; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.ServiceMessages; @@ -49,29 +48,26 @@ import org.collectionspace.services.common.StoredValuesUriTemplate; import org.collectionspace.services.common.UriTemplateFactory; import org.collectionspace.services.common.UriTemplateRegistry; import org.collectionspace.services.common.UriTemplateRegistryKey; -import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.query.QueryManager; -import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.security.SecurityUtils; + import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.config.service.ServiceObjectType; import org.collectionspace.services.servicegroup.ServicegroupsCommon; + import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; -import org.nuxeo.ecm.core.api.model.PropertyException; -import org.nuxeo.ecm.core.api.repository.RepositoryInstance; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ServiceGroupDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -85,7 +81,7 @@ public class ServiceGroupDocumentModelHandler List serviceGroupNames) throws Exception { CommonList commonList = new CommonList(); AbstractCommonList list = (AbstractCommonList)commonList; - RepositoryInstanceInterface repoSession = null; + CoreSessionInterface repoSession = null; boolean releaseRepoSession = false; try { diff --git a/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/ValuationcontrolResource.java b/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/ValuationcontrolResource.java index 31de133f6..b16335fe9 100644 --- a/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/ValuationcontrolResource.java +++ b/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/ValuationcontrolResource.java @@ -24,7 +24,7 @@ package org.collectionspace.services.valuationcontrol; import org.collectionspace.services.client.ValuationcontrolClient; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.ws.rs.Produces; @Path(ValuationcontrolClient.SERVICE_PATH) @Consumes("application/xml") @Produces("application/xml") -public class ValuationcontrolResource extends ResourceBase { +public class ValuationcontrolResource extends NuxeoBasedResource { final Logger logger = LoggerFactory.getLogger(ValuationcontrolResource.class); diff --git a/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/nuxeo/ValuationcontrolDocumentModelHandler.java b/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/nuxeo/ValuationcontrolDocumentModelHandler.java index 7c53a6910..2df775989 100644 --- a/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/nuxeo/ValuationcontrolDocumentModelHandler.java +++ b/services/valuationcontrol/service/src/main/java/org/collectionspace/services/valuationcontrol/nuxeo/ValuationcontrolDocumentModelHandler.java @@ -24,10 +24,10 @@ package org.collectionspace.services.valuationcontrol.nuxeo; import org.collectionspace.services.valuationcontrol.ValuationcontrolsCommon; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; /** ValuationcontrolDocumentModelHandler */ public class ValuationcontrolDocumentModelHandler - extends DocHandlerBase { + extends NuxeoDocumentModelHandler { } diff --git a/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java b/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java index 19a8af562..2830de301 100644 --- a/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java +++ b/services/workflow/service/src/main/java/org/collectionspace/services/workflow/WorkflowResource.java @@ -25,7 +25,7 @@ package org.collectionspace.services.workflow; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.CSWebApplicationException; -import org.collectionspace.services.common.ResourceBase; +import org.collectionspace.services.common.NuxeoBasedResource; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.ServiceMessages; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -45,7 +45,7 @@ import javax.ws.rs.core.UriInfo; @Path(WorkflowClient.SERVICE_PATH) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public class WorkflowResource extends ResourceBase { +public class WorkflowResource extends NuxeoBasedResource { @Override public String getServiceName(){ -- 2.47.3