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;
// (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<EventNotificationDocumentType> notificationDocumentType;
if (documentMatchesType(docModel, RELATION_DOCTYPE)) {
if (logger.isTraceEnabled()) {
logger.trace("An event involving a Relation document was received by UpdateObjectLocationOnMove ...");
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<String> collectionObjectCsids = new HashSet<>();
if (notificationDocumentType == EventNotificationDocumentType.RELATION) {
* related to the Movement record.
*/
private Set<String> getCollectionObjectCsidsRelatedToMovement(String movementCsid,
- CoreSession coreSession) throws ClientException {
+ CoreSessionInterface coreSession) throws ClientException {
Set<String> csids = new HashSet<>();
* @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 "
* @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.
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;
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);
*/
/**
ProcessInstance getModerationProcess(JbpmService jbpmService,
- CoreSession session, DocumentModel doc, String commentId)
+ CoreSessionInterface session, DocumentModel doc, String commentId)
throws ClientException;
**/
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;
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;
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();
}
}
if (session != null) {
- CoreInstance.getInstance().close(session);
+ session.close();
}
}
public List<DocumentModel> getQuotes(DocumentModel docModel)
throws ClientException {
RelationManager relationManager;
- Map<String, Serializable> ctxMap = new HashMap<String, Serializable>();
- ctxMap.put(ResourceAdapter.CORE_SESSION_ID_CONTEXT_KEY, docModel.getSessionId());
+ Map<String, Object> ctxMap = new HashMap<String, Object>();
+ ctxMap.put(ResourceAdapter.CORE_SESSION_CONTEXT_KEY, docModel.getSessionId());
try {
relationManager = getRelationManager();
} catch (Exception e) {
public List<DocumentModel> getDocumentsForQuote(DocumentModel comment)
throws ClientException {
RelationManager relationManager;
- Map<String, Serializable> ctxMap = new HashMap<String, Serializable>();
- ctxMap.put(ResourceAdapter.CORE_SESSION_ID_CONTEXT_KEY, comment.getSessionId());
+ Map<String, Object> ctxMap = new HashMap<String, Object>();
+ ctxMap.put(ResourceAdapter.CORE_SESSION_CONTEXT_KEY, comment.getSessionId());
try {
relationManager = getRelationManager();
} catch (Exception e) {
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;
* $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;
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;
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;
* (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
<nuxeo.shell.version>${nuxeo.general.release}</nuxeo.shell.version>
<nuxeo.platform.version>${nuxeo.general.release}</nuxeo.platform.version>
<nuxeo.core.version>${nuxeo.general.release}</nuxeo.core.version>
+ <chemistry.opencmis.version.nx>0.12.0-NX2</chemistry.opencmis.version.nx>
<spring.version>3.0.5.RELEASE</spring.version>
<spring.security.version>3.0.5.RELEASE</spring.security.version>
</properties>
</executions>
</plugin>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
</plugin>
</plugins>
</pluginManagement>
-
+
<plugins>
- <!--
- This plugin ensures that the required environment variables are set before we perform
- any build related tasks.
- -->
+ <!-- This plugin ensures that the required environment variables are set
+ before we perform any build related tasks. -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
</goals>
<configuration>
<tasks>
- <fail unless="env.CSPACE_JEESERVER_HOME" message="Required environment variable CSPACE_JEESERVER_HOME has not been set." />
- <fail unless="env.DB_CSPACE_PASSWORD" message="Required environment variable DB_CSPACE_PASSWORD has not been set." />
- <fail unless="env.DB_NUXEO_PASSWORD" message="Required environment variable DB_NUXEO_PASSWORD has not been set." />
- <fail unless="env.DB_READER_PASSWORD" message="Required environment variable DB_READER_PASSWORD has not been set." />
- <fail unless="env.DB_CSADMIN_PASSWORD" message="Required environment variable DB_CSADMIN_PASSWORD has not been set." />
- <!--
- Fail if these deprecated environment variables are set.
- -->
- <fail if="env.DB_USER" message="The deprecated environment variable DB_USER should not be set." />
- <fail if="env.DB_PASSWORD" message="The deprecated environment variable DB_PASSWORD should not be set. Ensure that DB_CSADMIN_PASSWORD is set instead." />
- <fail if="env.DB_PASSWORD_CSPACE" message="The deprecated environment variable DB_PASSWORD_CSPACE should not be set. Ensure that DB_CSPACE_PASSWORD is set instead." />
- <fail if="env.DB_PASSWORD_NUXEO" message="The deprecated environment variable DB_PASSWORD_NUXEO should not be set. Ensure that DB_NUXEO_PASSWORD is set instead." />
+ <fail unless="env.CSPACE_JEESERVER_HOME"
+ message="Required environment variable CSPACE_JEESERVER_HOME has not been set." />
+ <fail unless="env.DB_CSPACE_PASSWORD"
+ message="Required environment variable DB_CSPACE_PASSWORD has not been set." />
+ <fail unless="env.DB_NUXEO_PASSWORD"
+ message="Required environment variable DB_NUXEO_PASSWORD has not been set." />
+ <fail unless="env.DB_READER_PASSWORD"
+ message="Required environment variable DB_READER_PASSWORD has not been set." />
+ <fail unless="env.DB_CSADMIN_PASSWORD"
+ message="Required environment variable DB_CSADMIN_PASSWORD has not been set." />
+ <!-- Fail if these deprecated environment variables are set. -->
+ <fail if="env.DB_USER"
+ message="The deprecated environment variable DB_USER should not be set." />
+ <fail if="env.DB_PASSWORD"
+ message="The deprecated environment variable DB_PASSWORD should not be set. Ensure that DB_CSADMIN_PASSWORD is set instead." />
+ <fail if="env.DB_PASSWORD_CSPACE"
+ message="The deprecated environment variable DB_PASSWORD_CSPACE should not be set. Ensure that DB_CSPACE_PASSWORD is set instead." />
+ <fail if="env.DB_PASSWORD_NUXEO"
+ message="The deprecated environment variable DB_PASSWORD_NUXEO should not be set. Ensure that DB_NUXEO_PASSWORD is set instead." />
</tasks>
</configuration>
</execution>
<version>${nuxeo.core.version}</version>
</dependency>
<dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
+ <groupId>org.nuxeo.lib.core</groupId>
<artifactId>nuxeo-core-storage-sql-extensions</artifactId>
<version>${nuxeo.core.version}</version>
</dependency>
<artifactId>nuxeo-core-storage-sql-ra</artifactId>
<version>${nuxeo.core.version}</version>
</dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-client</artifactId>
- <version>${nuxeo.core.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-jbossas-remoting</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-query</artifactId>
//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;
// singletons.add(new PingResource());
}
- private void addResourceToMapAndSingletons(ResourceBase resource) {
+ private void addResourceToMapAndSingletons(NuxeoBasedResource resource) {
singletons.add(resource);
resourceMap.put(resource.getServiceName(), resource);
}
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;
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;
@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);
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<AcquisitionsCommon> {
+ extends NuxeoDocumentModelHandler<AcquisitionsCommon> {
}
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authority</artifactId>
- <version>4.2-SNAPSHOT</version>
- </parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authority</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.collectionspace.services.authority.service</artifactId>
- <name>services.authority.service</name>
- <packaging>jar</packaging>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.authority.service</artifactId>
+ <name>services.authority.service</name>
+ <packaging>jar</packaging>
- <dependencies>
- <!-- CollectionSpace dependencies -->
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.common-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.vocabulary.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authentication.service</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authorization.service</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.relation.service</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.relation.client</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependencies>
+ <!-- CollectionSpace dependencies -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.vocabulary.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authentication.service</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authorization.service</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.relation.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.relation.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <!-- Utilities -->
+ <!-- Utilities -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jexl</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
- </dependency>
+ </dependency>
- <!-- javax -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
+ <!-- javax -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jacc</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jaas</artifactId>
- <version>1.0.01</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jacc</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <!--
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <scope>provided</scope>
- </dependency>
- -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2-commons</groupId>
+ <artifactId>property-listener-injector</artifactId>
+ </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jvnet.jaxb2-commons</groupId>
- <artifactId>property-listener-injector</artifactId>
- </dependency>
- <!--
- <dependency>
- <groupId>org.jvnet.jaxb2_commons</groupId>
- <artifactId>runtime</artifactId>
- </dependency>
- -->
+ <!-- jboss -->
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>jaxrs-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
- <!-- jboss -->
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>jaxrs-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <exclusions>
- <exclusion>
- <groupId>tjws</groupId>
- <artifactId>webserver</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxb-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-multipart-provider</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- </dependency>
- <!-- jboss -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jbosssx</artifactId>
- <version>4.2.3.GA</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-remoting</artifactId>
- <version>2.2.2.SP8</version>
- <scope>provided</scope>
- </dependency>
- <!-- nuxeo -->
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-mimetype-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-imaging-core</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-imaging-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-filemanager-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.common</groupId>
- <artifactId>nuxeo-common</artifactId>
- <version>${nuxeo.core.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.runtime</groupId>
- <artifactId>nuxeo-runtime</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-api</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-client</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-query</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-schema</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-storage-sql</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-io</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <!--
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-facade</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-io</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.runtime</groupId>
- <artifactId>nuxeo-runtime-osgi</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.1.0</version>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <!-- jboss -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbosssx</artifactId>
+ <version>4.2.3.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>2.2.2.SP8</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- nuxeo -->
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-mimetype-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-imaging-core</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-imaging-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-filemanager-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.common</groupId>
+ <artifactId>nuxeo-common</artifactId>
+ <version>${nuxeo.core.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.runtime</groupId>
+ <artifactId>nuxeo-runtime</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-query</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-schema</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-storage-sql</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-io</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <!-- <dependency> <groupId>org.nuxeo.ecm.core</groupId> <artifactId>nuxeo-core-facade</artifactId>
+ <version>${nuxeo.core.version}</version> </dependency> -->
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-io</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.runtime</groupId>
+ <artifactId>nuxeo-runtime-osgi</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.1.0</version>
+ </dependency>
+ </dependencies>
</project>
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;
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;
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;
@Consumes("application/xml")
@Produces("application/xml")
public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
- extends ResourceBase {
+ extends NuxeoBasedResource {
final static String SEARCH_TYPE_TERMSTATUS = "ts";
* 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;
+++ /dev/null
-package org.collectionspace.services.common.vocabulary;
-
-public interface IVocabManager {
-
- public void exampleMethod(String someParam);
-
-}
+++ /dev/null
-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);
- }
-}
+++ /dev/null
-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) {
- }
-}
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;
* $LastChangedDate: $
*/
public abstract class AuthorityDocumentModelHandler<AuthCommon>
- extends DocHandlerBase<AuthCommon> {
+ extends NuxeoDocumentModelHandler<AuthCommon> {
private final Logger logger = LoggerFactory.getLogger(AuthorityDocumentModelHandler.class);
private String authorityCommonSchemaName;
String result = null;
DocumentModel docModel = docWrapper.getWrappedObject();
- ServiceContext ctx = this.getServiceContext();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
RefName.Authority refname = (RefName.Authority)getRefName(ctx, docModel);
result = refname.getDisplayName();
public String getShortIdentifier(String authCSID, String schemaName) throws Exception {
String shortIdentifier = null;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
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;
* $LastChangedDate: $
*/
public abstract class AuthorityItemDocumentModelHandler<AICommon>
- extends DocHandlerBase<AICommon> {
+ extends NuxeoDocumentModelHandler<AICommon> {
private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
private String authorityItemCommonSchemaName;
String result = null;
DocumentModel docModel = docWrapper.getWrappedObject();
- ServiceContext ctx = this.getServiceContext();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
RefName.AuthorityItem refname = (RefName.AuthorityItem)getRefName(ctx, docModel);
result = refname.getDisplayName();
}
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
RepositoryClient<PoxPayloadIn, PoxPayloadOut> 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,
String propertyName,
String itemcsid) throws Exception {
AuthorityRefDocList authRefDocList = null;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
boolean releaseRepoSession = false;
try {
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;
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;
@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";
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<BatchCommon> {
- private final Logger logger = LoggerFactory.getLogger(BatchDocumentModelHandler.class);
+public class BatchDocumentModelHandler extends NuxeoDocumentModelHandler<BatchCommon> {
+ private final Logger logger = LoggerFactory.getLogger(BatchDocumentModelHandler.class);
protected final int BAD_REQUEST_STATUS = Response.Status.BAD_REQUEST.getStatusCode();
-
- public InvocationResults invokeBatchJob(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- String csid,
- ResourceMap resourceMap,
- InvocationContext invContext) throws Exception {
-
- RepositoryInstanceInterface repoSession = null;
+
+ public InvocationResults invokeBatchJob(ServiceContext<PoxPayloadIn, PoxPayloadOut> 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);
try {
DocumentWrapper<DocumentModel> 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<String> forDocTypeList =
- (List<String>)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<String> forDocTypeList = (List<String>) 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);
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<String> 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;
}
}
-
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;
// 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;
+ "<relationshipType>"+RELATION_TYPE+"</relationshipType>"
+ "<predicateDisplayName>"+RELATION_PREDICATE_DISP+"</predicateDisplayName>"
+ "</ns2:relations_common></document>";
- 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;
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;
private InvocationResults updateComputedCurrentLocations(List<String> 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;
//
// 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 {
// 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;
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);
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);
* 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);
}
* 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);
private List<String> 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<String> getMemberCsidsFromGroup(ResourceBase resource, String groupCsid) throws URISyntaxException, DocumentException {
+ private List<String> 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 =
private List<String> 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);
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.blob</artifactId>
- <version>4.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.collectionspace.services.blob.service</artifactId>
- <name>services.blob.service</name>
- <packaging>jar</packaging>
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.blob</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.blob.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.publicitem.client</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- External dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </dependency>
-
- <!-- javax -->
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.blob.service</artifactId>
+ <name>services.blob.service</name>
+ <packaging>jar</packaging>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jaas</artifactId>
- <version>1.0.01</version>
- <scope>provided</scope>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.blob.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.publicitem.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- jboss -->
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <exclusions>
- <exclusion>
- <groupId>tjws</groupId>
- <artifactId>webserver</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxb-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-multipart-provider</artifactId>
- </dependency>
-
- <!-- nuxeo -->
+ <!-- javax -->
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-api</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>jboss-remoting</artifactId>
- <groupId>jboss</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <build>
- <finalName>collectionspace-services-blob</finalName>
- </build>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- jboss -->
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
+
+ <!-- nuxeo -->
+
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-remoting</artifactId>
+ <groupId>jboss</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-blob</finalName>
+ </build>
</project>
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;
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(){
return result;
}
- private InputStream getBlobContent(ServiceContext ctx,
+ private InputStream getBlobContent(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String csid,
String derivativeTerm,
StringBuffer outMimeType) throws CSWebApplicationException {
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;
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<BlobsCommon> {
+extends NuxeoDocumentModelHandler<BlobsCommon> {
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class);
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);
throws Exception {
ServiceContext<PoxPayloadIn, PoxPayloadOut> 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
// 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
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;
@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);
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
* $LastChangedDate: $
*/
public class CollectionObjectDocumentModelHandler
- extends DocHandlerBase<CollectionobjectsCommon> {
+ extends NuxeoDocumentModelHandler<CollectionobjectsCommon> {
}
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.main</artifactId>
- <version>4.2-SNAPSHOT</version>
- </parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.main</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.collectionspace.services.common</artifactId>
- <name>services.common</name>
- <packaging>jar</packaging>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <name>services.common</name>
+ <packaging>jar</packaging>
- <dependencies>
- <!-- CollectionSpace dependencies -->
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.3rdparty.nuxeo.thumbnail</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.common-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authorization-mgt.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.relation.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.publicitem.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.publicitem.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!--
- <dependency>
+ <dependencies>
+ <!-- CollectionSpace dependencies -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.3rdparty.nuxeo.thumbnail</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authorization-mgt.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.relation.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.publicitem.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.publicitem.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- <dependency> <groupId>org.collectionspace.services</groupId> <artifactId>org.collectionspace.services.3rdparty.nuxeo.quote-api</artifactId>
+ <version>${project.version}</version> </dependency> -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.hyperjaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.3rdparty.nuxeo.quote-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.hyperjaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authentication.service</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.authorization.service</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <artifactId>org.collectionspace.services.authentication.service</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authorization.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <!-- Utilities -->
- <!-- For NuxeoRESTClient.java class -->
- <dependency>
- <groupId>org.restlet</groupId>
- <artifactId>org.restlet</artifactId>
- <version>1.0.7</version>
- </dependency>
- <dependency>
- <groupId>com.noelios.restlet</groupId>
- <artifactId>com.noelios.restlet.ext.httpclient</artifactId>
- <version>1.0.7</version>
- </dependency>
- <dependency>
- <groupId>com.noelios.restlet</groupId>
- <artifactId>com.noelios.restlet</artifactId>
- <version>1.0.7</version>
- </dependency>
+ <!-- Utilities -->
+ <!-- For NuxeoRESTClient.java class -->
+ <dependency>
+ <groupId>org.restlet</groupId>
+ <artifactId>org.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.3-RC1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jexl</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.3-RC1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>dbcp</artifactId>
- <version>6.0.33</version>
- <scope>provided</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>dbcp</artifactId>
+ <version>6.0.33</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
- <version>6.0.33</version>
- <scope>provided</scope>
+ <version>6.0.33</version>
+ <scope>provided</scope>
</dependency>
- <!-- javax -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
+ <!-- javax -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jaas</artifactId>
- <version>1.0.01</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jacc</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <!--
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <scope>provided</scope>
- </dependency>
- -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jacc</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId>
+ <version>1.6.1</version> <scope>provided</scope> </dependency> -->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
- <!-- jboss -->
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>jaxrs-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <exclusions>
- <exclusion>
- <groupId>tjws</groupId>
- <artifactId>webserver</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxb-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-multipart-provider</artifactId>
- </dependency>
+ <!-- jboss -->
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>jaxrs-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- </dependency>
- <!-- jboss -->
- <dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <!-- jboss -->
+ <dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jbosssx</artifactId>
<version>2.0.3.SP1</version>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
<scope>provided</scope>
</dependency>
- <!-- nuxeo -->
- <dependency>
- <groupId>org.nuxeo.lib.runtime</groupId>
- <artifactId>nuxeo-runtime-launcher</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-mimetype-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-mimetype-core</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-types-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-types-core</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-imaging-core</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-imaging-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.platform</groupId>
- <artifactId>nuxeo-platform-filemanager-api</artifactId>
- <version>${nuxeo.platform.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.common</groupId>
- <artifactId>nuxeo-common</artifactId>
- <version>${nuxeo.core.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.runtime</groupId>
- <artifactId>nuxeo-runtime</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-api</artifactId>
- </dependency>
- <!--
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-client</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-query</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-schema</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-storage-sql</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-storage-sql-ra</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-io</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-convert</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
-<!--
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-core-facade</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.nuxeo.runtime</groupId>
- <artifactId>nuxeo-runtime-osgi</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.nuxeo.ecm.core</groupId>
- <artifactId>nuxeo-opencmis-bindings</artifactId>
- <version>${nuxeo.core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.chemistry.opencmis</groupId>
- <artifactId>chemistry-opencmis-server-bindings</artifactId>
- <version>0.6.0</version>
- <classifier>classes</classifier>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.1.0</version>
- </dependency>
+ <!-- nuxeo -->
+ <dependency>
+ <groupId>org.nuxeo.lib.runtime</groupId>
+ <artifactId>nuxeo-runtime-launcher</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-mimetype-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-mimetype-core</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-types-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-types-core</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-imaging-core</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-imaging-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-filemanager-api</artifactId>
+ <version>${nuxeo.platform.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.common</groupId>
+ <artifactId>nuxeo-common</artifactId>
+ <version>${nuxeo.core.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.runtime</groupId>
+ <artifactId>nuxeo-runtime</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-query</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-schema</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-storage-sql</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-storage-sql-ra</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-io</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-convert</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <!-- <dependency> <groupId>org.nuxeo.ecm.core</groupId> <artifactId>nuxeo-core-facade</artifactId>
+ <version>${nuxeo.core.version}</version> </dependency> -->
+ <dependency>
+ <groupId>org.nuxeo.runtime</groupId>
+ <artifactId>nuxeo-runtime-osgi</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-opencmis-bindings</artifactId>
+ <version>${nuxeo.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.chemistry.opencmis</groupId>
+ <artifactId>chemistry-opencmis-server-bindings</artifactId>
+ <version>${chemistry.opencmis.version.nx}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.1.0</version>
+ </dependency>
<dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>ch.elca.el4j.modules</groupId>
- <artifactId>module-xml_merge-common</artifactId>
- <version>3.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-acl</artifactId>
- <version>${spring.security.version}</version>
- <scope>provided</scope>
- </dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.elca.el4j.modules</groupId>
+ <artifactId>module-xml_merge-common</artifactId>
+ <version>3.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-acl</artifactId>
+ <version>${spring.security.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
- </dependency>
- </dependencies>
+ </dependency>
+ </dependencies>
- <build>
- <finalName>collectionspace-services-common</finalName>
- <defaultGoal>install</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.jvnet.jaxb2.maven2</groupId>
- <artifactId>maven-jaxb2-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <finalName>collectionspace-services-common</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
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;
// Fields for default client factory and client
/** The repository client factory. */
- private RepositoryClientFactory repositoryClientFactory;
+ private RepositoryClientFactory<IT, OT> repositoryClientFactory;
/** The repository client. */
- private RepositoryClient repositoryClient;
+ private RepositoryClient<IT, OT> repositoryClient;
/** The storage client. */
private StorageClient storageClient;
* Instantiates a new abstract collection space resource.
*/
public AbstractCollectionSpaceResourceImpl() {
- repositoryClientFactory = RepositoryClientFactory.getInstance();
+ repositoryClientFactory = (RepositoryClientFactory<IT, OT>) RepositoryClientFactory.getInstance();
}
/* (non-Javadoc)
* @see org.collectionspace.services.common.CollectionSpaceResource#getRepositoryClient(org.collectionspace.services.common.context.ServiceContext)
*/
@Override
- synchronized public RepositoryClient getRepositoryClient(ServiceContext<IT, OT> ctx) {
+ synchronized public RepositoryClient<IT, OT> getRepositoryClient(ServiceContext<IT, OT> ctx) {
if(repositoryClient != null){
return repositoryClient;
}
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";
}
}
- protected AbstractCommonList finish_getList(ServiceContext ctx, DocumentHandler handler) {
+ protected AbstractCommonList finish_getList(ServiceContext<PoxPayloadIn, PoxPayloadOut> 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();
* 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<PoxPayloadIn, PoxPayloadOut> ctx =
resource.createServiceContext(authority.resource);
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));
}
protected TenantBindingConfigReaderImpl getTenantBindingsReader() {
return ServiceMain.getInstance().getTenantBindingConfigReader();
}
-
-
}
/*
* Maps service names to Resource instances. Use the Service Client Class to get the service name.
*/
-public interface ResourceMap extends Map<String, ResourceBase> {
+public interface ResourceMap extends Map<String, NuxeoBasedResource> {
}
import java.util.HashMap;
-public class ResourceMapImpl extends HashMap<String, ResourceBase> implements ResourceMap {
+public class ResourceMapImpl extends HashMap<String, NuxeoBasedResource> implements ResourceMap {
}
*/
private synchronized void populateUriTemplateRegistry() {
if (uriTemplateRegistry.isEmpty()) {
- ResourceBase resource = null;
+ NuxeoBasedResource resource = null;
ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
- for (Map.Entry<String, ResourceBase> entry : resourceMap.entrySet()) {
+ for (Map.Entry<String, NuxeoBasedResource> entry : resourceMap.entrySet()) {
resource = entry.getValue();
Map<UriTemplateRegistryKey, StoredValuesUriTemplate> entries =
resource.getUriRegistryEntries();
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;
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;
}
}
case DELETE:
handleDelete((DocumentWrapper<WT>) 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;
}
}
case DELETE:
completeDelete((DocumentWrapper<WT>) 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;
}
}
*/
package org.collectionspace.services.common.document;
-
-
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* AbstractMultipartDocumentHandler
*
extends AbstractDocumentHandlerImpl<T, TL, WT, WTL>
implements MultipartDocumentHandler<T, TL, WT, WTL> {
- private final Logger logger = LoggerFactory.getLogger(AbstractMultipartDocumentHandlerImpl.class);
-
public AbstractMultipartDocumentHandlerImpl() {
//Empty constructor
}
*/
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
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;
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;
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;
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.
*/
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.
*/
return result;
}
- static public CommonList getBlobDerivatives(RepositoryInstanceInterface repoSession,
+ static public CommonList getBlobDerivatives(CoreSessionInterface repoSession,
String repositoryId, List<ListResultField> resultsFields, String uri)
throws Exception {
CommonList commonList = new CommonList();
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);
}
}
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();
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.
- *
- * <p>
- * 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.
- * </p>
- *
- * @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.
- * <p>
- * Fixes NXP-544
- * </p>
- *
- * @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.
*
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<PoxPayloadIn, PoxPayloadOut> ctx,
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient) {
+ CoreSessionInterface result = null;
RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;
try {
return result;
}
- static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstanceInterface repoSession) throws TransactionException {
+ static private void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient,
+ CoreSessionInterface repoSession) throws TransactionException {
RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;
nuxeoClient.releaseRepositorySession(ctx, repoSession);
}
}
private static DocumentModel createDocumentFromBlob(
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
Blob inputStreamBlob,
String blobLocation,
boolean overwrite,
// 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;
static public BlobsCommon createBlobInRepository(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryClient repositoryClient,
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> 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;
*/
public static BlobsCommon createBlobInRepository(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
BlobInput blobInput,
boolean purgeOriginal,
boolean useNuxeoAdaptors) throws Exception {
* the mime type
* @return the string
*/
- static private BlobsCommon createBlobInRepository(RepositoryInstanceInterface nuxeoSession,
+ static private BlobsCommon createBlobInRepository(CoreSessionInterface nuxeoSession,
DocumentModel blobLocation,
boolean purgeOriginal,
File file,
return result;
}
- static public BlobOutput getBlobOutput(ServiceContext ctx,
- RepositoryClient repositoryClient,
+ static public BlobOutput getBlobOutput(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> 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;
* the derivative term
* @return the image
*/
- static public BlobOutput getBlobOutput(ServiceContext ctx,
- RepositoryInstanceInterface repoSession,
+ static public BlobOutput getBlobOutput(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ CoreSessionInterface repoSession,
String repositoryId,
String derivativeTerm,
Boolean getContentFlag,
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;
@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);
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.
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;
@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);
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;
* Performs an NXQL query to find refName references in relationship records.
*/
private static DocumentModelList findRelationsWithRefName(
- ServiceContext ctx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String refName,
String targetField,
String orderByClause,
public static void updateRefNamesInRelations(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String targetField,
String oldRefName,
String newRefName) throws Exception {
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.
* @param where NXQL where clause to get the document
* @throws DocumentException
*/
- public String findDocCSID(RepositoryInstanceInterface repoSession,
+ public String findDocCSID(CoreSessionInterface repoSession,
ServiceContext<IT, OT> ctx, String where)
throws DocumentNotFoundException, DocumentException;
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;
*/
public class RepositoryClientFactory<IT, OT> {
- private static final RepositoryClientFactory self = new RepositoryClientFactory();
+ private static final RepositoryClientFactory<?, ?> self = new RepositoryClientFactory<Object, Object>();
final Logger logger = LoggerFactory.getLogger(RepositoryClientFactory.class);
//clients key=client name, value=repository client
private Hashtable<String, RepositoryClient<IT, OT>> clients = new Hashtable<String, RepositoryClient<IT, OT>>();
String clientName = repositoryClientConfig.getName();
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- Class jclazz = cloader.loadClass(clientClassName);
+ Class<?> jclazz = cloader.loadClass(clientClassName);
RepositoryClient<IT, OT> jclient = (RepositoryClient<IT, OT>)jclazz.newInstance();
clients.put(clientName, jclient);
}
}
- public static RepositoryClientFactory getInstance() {
+ public static RepositoryClientFactory<?, ?> getInstance() {
return self;
}
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;
private ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;
private RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient;
- private RepositoryInstanceInterface repoSession;
+ private CoreSessionInterface repoSession;
private List<String> serviceTypes;
private String refName;
private String refPropName;
public LazyAuthorityRefDocList(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession, List<String> serviceTypes,
+ CoreSessionInterface repoSession, List<String> serviceTypes,
String refName,
String refPropName,
Map<String, ServiceBindingType> queriedServiceBindings,
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;
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;
public static void updateRefNamesInRelations(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String oldRefName,
String newRefName) throws Exception {
//
RelationUtils.updateRefNamesInRelations(ctx, repoClient, repoSession, IRelationsManager.OBJECT_REFNAME, oldRefName, newRefName);
}
- public static List<AuthRefConfigInfo> getConfiguredAuthorityRefs(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
- List<String> authRefFields =
- ((AbstractServiceContextImpl) ctx).getAllPartsPropertyValues(
- ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
- ArrayList<AuthRefConfigInfo> authRefsInfo = new ArrayList<AuthRefConfigInfo>(authRefFields.size());
- for (String spec : authRefFields) {
- AuthRefConfigInfo arci = new AuthRefConfigInfo(spec);
- authRefsInfo.add(arci);
- }
- return authRefsInfo;
- }
+ public static List<AuthRefConfigInfo> getConfiguredAuthorityRefs(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
+ List<String> authRefFields = ((AbstractServiceContextImpl) ctx).getAllPartsPropertyValues(
+ ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
+ ArrayList<AuthRefConfigInfo> authRefsInfo = new ArrayList<AuthRefConfigInfo>(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<PoxPayloadIn, PoxPayloadOut> ctx,
UriTemplateRegistry uriTemplateRegistry,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
public static int updateAuthorityRefDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String oldRefName,
String newRefName,
String refPropName) throws Exception {
private static DocumentModelList findAllAuthorityRefDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession, List<String> serviceTypes,
+ CoreSessionInterface repoSession, List<String> serviceTypes,
String refName,
String refPropName,
Map<String, ServiceBindingType> queriedServiceBindings,
protected static DocumentModelList findAuthorityRefDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstanceInterface repoSession, List<String> serviceTypes,
+ CoreSessionInterface repoSession, List<String> serviceTypes,
String refName,
String refPropName,
Map<String, ServiceBindingType> queriedServiceBindings,
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());
}
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;
import org.slf4j.LoggerFactory;
public class WorkflowDocumentModelHandler
- extends DocHandlerBase<WorkflowCommon> {
+ extends NuxeoDocumentModelHandler<WorkflowCommon> {
/** The logger. */
private static final Logger logger = LoggerFactory.getLogger(WorkflowDocumentModelHandler.class);
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.
* @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.
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;
}
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.
+++ /dev/null
-/**
- * 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<T> extends RemoteDocumentModelHandlerImpl<T, AbstractCommonList> {
-
- /** 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<ListResultField> getListItemsArray() throws DocumentException {
- ServiceContext ctx = this.getServiceContext();
- return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().getListResultField();
- }
-
- @Override
- public T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void fillCommonPart(T objectexitObject, DocumentWrapper<DocumentModel> 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<DocumentModelList> 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<String, String> 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<ListResultField> 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<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- HashMap<String, Object> item = new HashMap<String, Object>();
- 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<DocumentModel> 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<DocumentModel> 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<ListResultField> 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();
- }
- }
-
-
-
-}
-
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;
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;
extends AbstractMultipartDocumentHandlerImpl<T, TL, DocumentModel, DocumentModelList> {
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.
}
public RepositoryClient<PoxPayloadIn, PoxPayloadOut> getRepositoryClient(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
- RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient = RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName());
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient =
+ (RepositoryClient<PoxPayloadIn, PoxPayloadOut>) RepositoryClientFactory.getInstance().getClient(ctx.getRepositoryClientName());
return repositoryClient;
}
* getRepositorySession returns Nuxeo Repository Session
* @return
*/
- public RepositoryInstanceInterface getRepositorySession() {
+ public CoreSessionInterface getRepositorySession() {
return repositorySession;
}
* setRepositorySession sets repository session
* @param repoSession
*/
- public void setRepositorySession(RepositoryInstanceInterface repoSession) {
+ public void setRepositorySession(CoreSessionInterface repoSession) {
this.repositorySession = repoSession;
}
return result;
}
- protected void handleRefNameChanges(ServiceContext ctx, DocumentModel docModel) throws ClientException {
+ protected void handleRefNameChanges(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, DocumentModel docModel) throws ClientException {
// First get the old refName
this.oldRefNameOnUpdate = (String)docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME);
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;
private Logger logger = LoggerFactory.getLogger(NuxeoClientEmbedded.class);
- private LoginHandler loginHandler;
-
- private final HashMap<String, RepositoryInstanceInterface> repositoryInstances;
-
- private InvokerLocator locator;
+ private final HashMap<String, CoreSessionInterface> repositoryInstances;
private RepositoryManager repositoryMgr;
* of this constructor is recommended.
*/
private NuxeoClientEmbedded() {
- loginHandler = loginHandler == null ? new DefaultLoginHandler()
- : loginHandler;
- repositoryInstances = new HashMap<String, RepositoryInstanceInterface>();
+ repositoryInstances = new HashMap<String, CoreSessionInterface>();
}
public static NuxeoClientEmbedded getInstance() {
}
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<Entry<String, RepositoryInstanceInterface>> it = repositoryInstances.entrySet().iterator();
+ // close the open Nuxeo repository sessions if any
+ Iterator<Entry<String, CoreSessionInterface>> it = repositoryInstances.entrySet().iterator();
while (it.hasNext()) {
- Entry<String, RepositoryInstanceInterface> repo = it.next();
+ Entry<String, CoreSessionInterface> repo = it.next();
try {
repo.getValue().close();
} catch (Exception e) {
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);
/*
* 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.
// 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",
// 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);
}
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: "
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;
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() {
}
}
+ /*
+ * 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<RepositoryDescriptor> repositoryDescriptorList = this.getRepositoryDescriptor(repoName);
+// } catch (Exception e1) {
+// // TODO Auto-generated catch block
+// e1.printStackTrace();
+// }
Repository repository = null;
try {
ConnectionFactoryImpl connectionFactory = (ConnectionFactoryImpl)repository;
ManagedConnectionFactoryImpl managedConnectionFactory = connectionFactory.getManagedConnectionFactory();
- String serverUrl = managedConnectionFactory.getServerURL();
+ String property = managedConnectionFactory.getProperty();
return result;
}
* @param repoSession
* @throws java.lang.Exception
*/
- public void releaseRepositorySession(RepositoryInstanceInterface repoSession)
+ public void releaseRepositorySession(CoreSessionInterface repoSession)
throws Exception {
if (repoSession != null) {
getClient().releaseRepository(repoSession);
* @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");
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<RepositoryDescriptor> 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<RepositoryDescriptor> getRepositoryDescriptor(String name) throws Exception {
+// RepositoryDescriptor repo = null;
+// RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
+// Iterable<RepositoryDescriptor> 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
*/
public NuxeoClientEmbedded getClient() throws Exception {
if (initialized == true) {
- if (client.isConnected()) {
- return client;
- }
+ return client;
}
//
// Nuxeo connection was not initialized
*/
public Hashtable<String, String> retrieveWorkspaceIds(RepositoryDomainType repoDomain)
throws Exception {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
Hashtable<String, String> workspaceIds = new Hashtable<String, String>();
try {
repoSession = getRepositorySession(repoDomain);
--- /dev/null
+/**
+ * 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<T> extends RemoteDocumentModelHandlerImpl<T, AbstractCommonList> {
+
+ /** 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<PoxPayloadIn, PoxPayloadOut> 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<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ return createItemForCommonList(ServiceConfigUtils.getDocHandlerParams(ctx).getCommonListItemClassname(),
+ docModel, label, id, true);
+ }
+
+ public String getSummaryFields(AbstractCommonList theCommonList) throws DocumentException {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getSummaryFields();
+ }
+
+ public void setListItemArrayExtended(boolean isExtended) throws DocumentException {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().setExtended(isExtended);
+ }
+
+ public boolean isListItemArrayExtended() throws DocumentException {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().isExtended();
+ }
+
+ public List<ListResultField> getListItemsArray() throws DocumentException {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().getListResultField();
+ }
+
+ @Override
+ public T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void fillCommonPart(T objectexitObject, DocumentWrapper<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
+ CommonList commonList = new CommonList();
+ String markRtSbj = null;
+ CoreSessionInterface repoSession = null;
+ RepositoryJavaClientImpl repoClient = null;
+ boolean releaseRepoSession = false;
+
+ AbstractServiceContextImpl ctx = (AbstractServiceContextImpl) getServiceContext();
+ MultivaluedMap<String, String> 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<ListResultField> 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<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ HashMap<String, Object> item = new HashMap<String, Object>();
+ 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<DocumentModel> 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<DocumentModel> 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<ListResultField> 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<PoxPayloadIn, PoxPayloadOut> 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();
+ }
+ }
+
+}
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;
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;
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;
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<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
DocHandlerParams.Params params = null;
try {
DocHandlerParams.Params params = null;
try {
- ServiceContext ctx = this.getServiceContext();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
params = ServiceConfigUtils.getDocHandlerParams(ctx);
Boolean bool = params.isSupportsHierarchy();
if (bool != null) {
DocHandlerParams.Params params = null;
try {
- ServiceContext ctx = this.getServiceContext();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
params = ServiceConfigUtils.getDocHandlerParams(ctx);
Boolean bool = params.isSupportsVersioning();
if (bool != null) {
boolean releaseRepoSession = false;
ServiceContext<PoxPayloadIn, PoxPayloadOut> 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;
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);
}
* 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<PoxPayloadIn, PoxPayloadOut> ctx,
List<RelationsCommonList.RelationListItem> inboundList,
DocumentModel docModel,
String itemCSID) throws Exception {
// 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<DocumentModel> wrapDoc, boolean fUpdate) throws Exception {
- ServiceContext ctx = getServiceContext();
- PoxPayloadIn input = (PoxPayloadIn) ctx.getInput();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
+ PoxPayloadIn input = ctx.getInput();
DocumentModel documentModel = (wrapDoc.getWrappedObject());
String itemCsid = documentModel.getName();
//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);
}
/**
if (hasRefNameUpdate() == true) {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
RepositoryClient<PoxPayloadIn, PoxPayloadOut> 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,
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;
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;
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;
//Empty constructor
}
- public void assertWorkflowState(ServiceContext ctx,
+ public void assertWorkflowState(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
DocumentModel docModel) throws DocumentNotFoundException, ClientException {
MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
if (queryParams != null) {
+ " check if the workspace exists in the Nuxeo repository");
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.CREATE);
repoSession = getRepositorySession(ctx);
"RepositoryJavaClient.get: handler is missing");
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.GET);
repoSession = getRepositorySession(ctx);
public void get(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, TransactionException, DocumentException {
QueryContext queryContext = new QueryContext(ctx, handler);
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.GET);
}
public DocumentWrapper<DocumentModel> getDoc(
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String csid) throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModel> wrapDoc = null;
public DocumentWrapper<DocumentModel> getDoc(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String csid) throws DocumentNotFoundException, TransactionException, DocumentException {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
DocumentWrapper<DocumentModel> wrapDoc = null;
try {
}
public DocumentWrapper<DocumentModel> findDoc(
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String whereClause)
throws DocumentNotFoundException, DocumentException {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String whereClause)
throws DocumentNotFoundException, TransactionException, DocumentException {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
DocumentWrapper<DocumentModel> wrapDoc = null;
try {
* @return the CollectionSpace ID (CSID) of the requested document
*/
@Override
- public String findDocCSID(RepositoryInstanceInterface repoSession,
+ public String findDocCSID(CoreSessionInterface repoSession,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String whereClause)
throws DocumentNotFoundException, TransactionException, DocumentException {
String csid = null;
public DocumentWrapper<DocumentModelList> findDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
List<String> docTypes,
String whereClause,
String orderByClause,
public DocumentWrapper<DocumentModelList> findDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
DocumentHandler handler,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
List<String> docTypes)
throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModelList> wrapDoc = null;
String whereClause,
int pageSize, int pageNum, boolean computeTotal)
throws DocumentNotFoundException, TransactionException, DocumentException {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
DocumentWrapper<DocumentModelList> wrapDoc = null;
try {
"RepositoryJavaClient.getAll: handler is missing");
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.GET_ALL);
repoSession = getRepositorySession(ctx);
+ " check if the workspace exists in the Nuxeo repository.");
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.GET_ALL);
repoSession = getRepositorySession(ctx);
public DocumentWrapper<DocumentModel> getDocFromCsid(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String csid)
throws Exception {
DocumentWrapper<DocumentModel> result = null;
- result = new DocumentWrapperImpl(NuxeoUtils.getDocFromCsid(ctx, repoSession, csid));
+ result = new DocumentWrapperImpl<DocumentModel>(NuxeoUtils.getDocFromCsid(ctx, repoSession, csid));
return result;
}
String csid)
throws Exception {
DocumentWrapper<DocumentModel> result = null;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
repoSession = getRepositorySession(ctx);
result = getDocFromCsid(ctx, repoSession, csid);
/*
* See CSPACE-5036 - How to make CMISQL queries from Nuxeo
*/
- private IterableQueryResult makeCMISQLQuery(RepositoryInstanceInterface repoSession, String query, QueryContext queryContext) throws DocumentException {
+ private IterableQueryResult makeCMISQLQuery(CoreSessionInterface repoSession, String query, QueryContext queryContext) throws DocumentException {
IterableQueryResult result = null;
-
- // the NuxeoRepository should be constructed only once, then cached
- // (its construction is expensive)
+ /** Threshold over which temporary files are not kept in memory. */
+ final int THRESHOLD = 1024 * 1024;
+
try {
- NuxeoRepository repo = new NuxeoRepository(
- repoSession.getRepositoryName(), repoSession
- .getRootDocument().getId());
- logger.debug("Repository ID:" + repo.getId() + " Root folder:"
- + repo.getRootFolderId());
+ logger.debug(String.format("Performing a CMIS query on Nuxeo repository named %s",
+ repoSession.getRepositoryName()));
+ ThresholdOutputStreamFactory streamFactory = ThresholdOutputStreamFactory.newInstance(
+ null, THRESHOLD, -1, false);
CallContextImpl callContext = new CallContextImpl(
- CallContext.BINDING_LOCAL, repo.getId(), false);
- callContext.put(CallContext.USERNAME, repoSession.getPrincipal()
- .getName());
- NuxeoCmisService cmisService = new NuxeoCmisService(repo,
- callContext, repoSession.getRepositoryInstance());
-
+ CallContext.BINDING_LOCAL,
+ CmisVersion.CMIS_1_1,
+ repoSession.getRepositoryName(),
+ null, // ServletContext
+ null, // HttpServletRequest
+ null, // HttpServletResponse
+ new NuxeoCmisServiceFactory(),
+ streamFactory);
+ callContext.put(CallContext.USERNAME, repoSession.getPrincipal().getName());
+
+ NuxeoCmisService cmisService = new NuxeoCmisService(repoSession.getCoreSession());
result = repoSession.queryAndFetch(query, "CMISQL", cmisService);
} catch (ClientException e) {
// TODO Auto-generated catch block
}
QueryContext queryContext = new QueryContext(ctx, handler);
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.GET_ALL);
repoSession = getRepositorySession(ctx); //Keeps a refcount here for the repository session so you need to release this when finished
* @return a list of document models matching the search criteria.
* @throws Exception
*/
- private DocumentModelList getFilteredJDBC(RepositoryInstanceInterface repoSession, ServiceContext ctx,
+ private DocumentModelList getFilteredJDBC(CoreSessionInterface repoSession, ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
DocumentHandler handler) throws Exception {
DocumentModelList result = new DocumentModelListImpl();
}
- private DocumentModelList getFilteredCMIS(RepositoryInstanceInterface repoSession, ServiceContext ctx, DocumentHandler handler, QueryContext queryContext)
+ private DocumentModelList getFilteredCMIS(CoreSessionInterface repoSession,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, DocumentHandler handler, QueryContext queryContext)
throws DocumentNotFoundException, DocumentException {
DocumentModelList result = new DocumentModelListImpl();
"RepositoryJavaClient.update: document handler is missing.");
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.UPDATE);
repoSession = getRepositorySession(ctx);
* @param ctx service context under which this method is invoked
* @param repoSession
* @param docModel the document to save
- * @param fSaveSession if TRUE, will call CoreSession.save() to save
+ * @param fSaveSession if TRUE, will call CoreSessionInterface.save() to save
* accumulated changes.
* @throws ClientException
* @throws DocumentException
*/
public void saveDocWithoutHandlerProcessing(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
DocumentModel docModel,
boolean fSaveSession)
throws ClientException, DocumentException {
* @param ctx service context under which this method is invoked
* @param repoSession a repository session
* @param docModelList a list of document models
- * @param fSaveSession if TRUE, will call CoreSession.save() to save
+ * @param fSaveSession if TRUE, will call CoreSessionInterface.save() to save
* accumulated changes.
* @throws ClientException
* @throws DocumentException
*/
public void saveDocListWithoutHandlerProcessing(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
DocumentModelList docList,
boolean fSaveSession)
throws ClientException, DocumentException {
if (logger.isDebugEnabled()) {
logger.debug("Deleting document with CSID=" + id);
}
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
handler.prepare(Action.DELETE);
repoSession = getRepositorySession(ctx);
@Override
public String createDomain(RepositoryDomainType repositoryDomain) throws Exception {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
String domainId = null;
try {
//
@Override
public String getDomainId(RepositoryDomainType repositoryDomain) throws Exception {
String domainId = null;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
String repoName = repositoryDomain.getRepositoryName();
String domainStorageName = repositoryDomain.getStorageName();
/*
* Returns the workspaces root directory for a given domain.
*/
- private DocumentModel getWorkspacesRoot(RepositoryInstanceInterface repoSession,
+ private DocumentModel getWorkspacesRoot(CoreSessionInterface repoSession,
String domainName) throws Exception {
DocumentModel result = null;
*/
@Override
public String createWorkspace(RepositoryDomainType repositoryDomain, String workspaceName) throws Exception {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
String workspaceId = null;
try {
String repoName = repositoryDomain.getRepositoryName();
public String getWorkspaceId(String tenantDomain, String workspaceName) throws Exception {
String workspaceId = null;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
try {
- repoSession = getRepositorySession((ServiceContext) null);
+ repoSession = getRepositorySession((ServiceContext<PoxPayloadIn, PoxPayloadOut>) null);
DocumentRef docRef = new PathRef(
"/" + tenantDomain
+ "/" + NuxeoUtils.Workspaces
return workspaceId;
}
- public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx) throws Exception {
+ public CoreSessionInterface getRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> 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);
}
* @return the repository session
* @throws Exception the exception
*/
- public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, String repoName) throws Exception {
- RepositoryInstanceInterface repoSession = null;
+ public CoreSessionInterface getRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String repoName) throws Exception {
+ CoreSessionInterface repoSession = null;
Profiler profiler = new Profiler("getRepositorySession():", 2);
profiler.start();
//
if (ctx != null) {
repoName = ctx.getRepositoryName(); // Notice we are overriding the passed in 'repoName' since we have a valid service context passed in to us
- repoSession = (RepositoryInstanceInterface) ctx.getCurrentRepositorySession(); // Look to see if one exists in the context before creating one
+ repoSession = (CoreSessionInterface) ctx.getCurrentRepositorySession(); // Look to see if one exists in the context before creating one
} else if (repoName == null || repoName.trim().isEmpty()) {
String errMsg = String.format("We can't get a connection to the Nuxeo repo because the service context passed in was null and no repository name was passed in either.");
logger.error(errMsg);
*
* @param repoSession the repo session
*/
- public void releaseRepositorySession(ServiceContext ctx, RepositoryInstanceInterface repoSession) throws TransactionException {
+ public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, CoreSessionInterface repoSession) throws TransactionException {
try {
NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
// release session
* @return true if a restriction on tenant ID is required in the query;
* false if a restriction is not required.
*/
- private boolean restrictJDBCQueryByTenantID(TenantBindingType tenantBinding, ServiceContext ctx) {
+ private boolean restrictJDBCQueryByTenantID(TenantBindingType tenantBinding, ServiceContext<PoxPayloadIn, PoxPayloadOut> 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
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;
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;
Set<String> result = null;
try {
- Field f = docModel.getClass().getDeclaredField("facets");
- f.setAccessible(true);
- result = (Set<String>) f.get(docModel);
- f.setAccessible(false);
+ Field field = docModel.getClass().getDeclaredField("facets");
+ field.setAccessible(true);
+ result = (Set<String>) field.get(docModel);
+ field.setAccessible(false);
} catch (Exception e) {
logger.error("Could not remove facet from DocumentModel instance: " + docModel.getId(), e);
}
* @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;
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
*
* @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;
* @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
* @throws DocumentException the document exception
*/
public static DocumentModel getDocumentModel(
- RepositoryInstanceInterface repoSession, String nuxeoId)
+ CoreSessionInterface repoSession, String nuxeoId)
throws DocumentException {
DocumentModel result = null;
* @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<PoxPayloadIn, PoxPayloadOut> 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
return query.toString();
}
- static public final String buildCMISQuery(ServiceContext ctx, QueryContext queryContext) throws Exception {
+ static public final String buildCMISQuery(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, QueryContext queryContext) throws Exception {
StringBuilder query = new StringBuilder("SELECT * FROM ");
/*
static public DocumentModel getDocFromCsid(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
String csid) throws Exception {
DocumentModel result = null;
* @param id
* @return PathRef
*/
- public static DocumentRef createPathRef(ServiceContext ctx, String id) {
+ public static DocumentRef createPathRef(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String id) {
return new PathRef("/" + ctx.getRepositoryDomainStorageName() +
"/" + Workspaces +
"/" + ctx.getRepositoryWorkspaceName() +
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) {
}
- public static String getTenantQualifiedDocType(ServiceContext ctx, String docType) throws Exception {
+ public static String getTenantQualifiedDocType(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String docType) throws Exception {
String result = docType;
String tenantQualifiedDocType = ctx.getTenantQualifiedDoctype(docType);
return result;
}
- public static String getTenantQualifiedDocType(ServiceContext ctx) throws NuxeoDocumentException {
+ public static String getTenantQualifiedDocType(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws NuxeoDocumentException {
String result = null;
try {
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;
@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);
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<ConditionchecksCommon> {
+ extends NuxeoDocumentModelHandler<ConditionchecksCommon> {
}
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;
@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
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;
* The Class ContactDocumentModelHandler.
*/
public class ContactDocumentModelHandler
- extends DocHandlerBase<ContactsCommon> {
+ extends NuxeoDocumentModelHandler<ContactsCommon> {
private final Logger logger = LoggerFactory.getLogger(ContactDocumentModelHandler.class);
private static final String COMMON_PART_LABEL = "contacts_common";
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;
@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);
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;
@Path(GroupClient.SERVICE_PATH)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public class GroupResource extends ResourceBase {
+public class GroupResource extends NuxeoBasedResource {
@Override
public String getServiceName(){
*/
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<GroupsCommon> {
+ extends NuxeoDocumentModelHandler<GroupsCommon> {
}
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;
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()) {
}
}
- 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;
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);
DocumentTranslationMap dtm = pipe.run();
Map<DocumentRef, DocumentRef> documentRefs = dtm.getDocRefMap(); // FIXME: Should be checking for null here!
dump.append("<importedRecords>");
- for (Map.Entry entry : documentRefs.entrySet()) {
+ for (Map.Entry<DocumentRef, DocumentRef> entry : documentRefs.entrySet()) {
keyDocRef = (DocumentRef) entry.getKey();
valueDocRef = (DocumentRef) entry.getValue();
if (keyDocRef == null || valueDocRef == null) {
*/
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<ImportsCommon> {
+ extends NuxeoDocumentModelHandler<ImportsCommon> {
}
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;
@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);
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
* $LastChangedDate: $
*/
public class IntakeDocumentModelHandler
- extends DocHandlerBase<IntakesCommon> {
+ extends NuxeoDocumentModelHandler<IntakesCommon> {
}
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;
@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);
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<LoansinCommon> {
+ extends NuxeoDocumentModelHandler<LoansinCommon> {
}
*/
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;
//@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";
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<LoansoutCommon> {
+ extends NuxeoDocumentModelHandler<LoansoutCommon> {
}
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;
@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();
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;
* The Class MediaDocumentModelHandler.
*/
public class MediaDocumentModelHandler
- extends DocHandlerBase<MediaCommon> {
+ extends NuxeoDocumentModelHandler<MediaCommon> {
//==============================================================================
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;
@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);
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;
* $LastChangedDate$
*/
public class MovementDocumentModelHandler
- extends DocHandlerBase<MovementsCommon> {
+ extends NuxeoDocumentModelHandler<MovementsCommon> {
final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
}
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;
@Path(ObjectExitClient.SERVICE_PATH)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public class ObjectExitResource extends ResourceBase {
+public class ObjectExitResource extends NuxeoBasedResource {
@Override
public String getServiceName(){
*/
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<ObjectexitCommon> {
+ extends NuxeoDocumentModelHandler<ObjectexitCommon> {
}
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
* $LastChangedDate$
*/
public class PublicItemDocumentModelHandler
- extends DocHandlerBase<PublicitemsCommon> {
+ extends NuxeoDocumentModelHandler<PublicitemsCommon> {
@Override
public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
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;
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;
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);
// we will also set those.
// Note that this introduces another caching problem...
DocumentModel relationDocModel = wrapDoc.getWrappedObject();
- ServiceContext<PoxPayloadIn, PoxPayloadOut> 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);
public RelationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> 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<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
String serviceContextPath = getServiceContextPath();
TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
private final boolean OBJ_DOC_MODEL = false;
private DocumentModel getSubjectOrObjectDocModel(
- RepositoryInstanceInterface repoSession,
+ CoreSessionInterface repoSession,
DocumentModel relationDocModel,
boolean fSubject) throws Exception {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
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);
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;
@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 = ",";
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;
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;
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;
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;
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;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
+public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<ReportsCommon> {
private final Logger logger = LoggerFactory.getLogger(ReportDocumentModelHandler.class);
private static String REPORTS_FOLDER = "reports";
private static String CSID_LIST_SEPARATOR = ",";
InvocationContext invContext,
StringBuffer outMimeType,
StringBuffer outReportFileName) throws Exception {
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
boolean releaseRepoSession = false;
String invocationMode = invContext.getMode();
private Connection getConnection() throws NamingException, SQLException {
Connection result = null;
- ServiceContext ctx = this.getServiceContext();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
try {
String repositoryName = ctx.getRepositoryName();
if (repositoryName != null && repositoryName.trim().isEmpty() == false) {
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;
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;
@Path(ServiceGroupClient.SERVICE_PATH)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
+public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl<PoxPayloadIn, PoxPayloadOut> {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
//public Class<ServicegroupsCommon> getCommonPartClass() {
- public Class getCommonPartClass() {
+ public Class<?> getCommonPartClass() {
try {
return Class.forName("org.collectionspace.services.servicegroup.ServicegroupsCommon");//.class;
} catch (ClassNotFoundException e){
@Context UriInfo ui,
@PathParam("csid") String groupname) {
PoxPayloadOut result = null;
- ensureCSID(groupname, ResourceBase.READ);
+ ensureCSID(groupname, NuxeoBasedResource.READ);
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
TenantBindingConfigReaderImpl tReader =
public AbstractCommonList getItems(
@Context UriInfo ui,
@PathParam("csid") String serviceGroupName) {
- ensureCSID(serviceGroupName, ResourceBase.READ);
+ ensureCSID(serviceGroupName, NuxeoBasedResource.READ);
AbstractCommonList list = null;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
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;
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<ServicegroupsCommon> {
+ extends NuxeoDocumentModelHandler<ServicegroupsCommon> {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
List<String> serviceGroupNames) throws Exception {
CommonList commonList = new CommonList();
AbstractCommonList list = (AbstractCommonList)commonList;
- RepositoryInstanceInterface repoSession = null;
+ CoreSessionInterface repoSession = null;
boolean releaseRepoSession = false;
try {
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;
@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);
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<ValuationcontrolsCommon> {
+ extends NuxeoDocumentModelHandler<ValuationcontrolsCommon> {
}
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;
@Path(WorkflowClient.SERVICE_PATH)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public class WorkflowResource extends ResourceBase {
+public class WorkflowResource extends NuxeoBasedResource {
@Override
public String getServiceName(){