-->\r
<cspace.services.version>4.1-SNAPSHOT</cspace.services.version>\r
<cspace.services.client.version>4.1-SNAPSHOT</cspace.services.client.version>\r
- <spring.version>3.0.0.RELEASE</spring.version>\r
- <spring.security.version>3.0.2.RELEASE</spring.security.version>\r
+ <spring.version>3.0.5.RELEASE</spring.version>\r
+ <spring.security.version>3.0.5.RELEASE</spring.security.version>\r
</properties>\r
\r
<distributionManagement>\r
# CollectionSpace loggers and default levels - all loggers using the rootLogger if not otherwise specified\r
#\r
log4j.logger.org.collectionspace=INFO\r
-log4j.logger.org.collectionspace.services.nuxeo.client.java=TRACE\r
+log4j.logger.org.collectionspace.services.nuxeo.client.java=ERROR\r
log4j.logger.org.collectionspace.services.common.storage.JDBCTools=ERROR\r
-log4j.logger.org.collectionspace.services.common.profile.CSpaceFilter=DEBUG\r
+log4j.logger.org.collectionspace.services.common.profile.CSpaceFilter=ERROR\r
\r
#log4j.logger.org.collectionspace.services.common.vocabulary.nuxeo=TRACE\r
\r
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!--
debugging tips : enable following categories in
<value>cspace</value> <!-- value should be same as in application-policy in JBoss login-config.xml -->
</property>
<property name="loginConfig">
- <value>/WEB-INF/login.conf</value> <!-- filler, not used at runtime -->
+ <value>/WEB-INF/login.conf</value>
</property>
<property name="callbackHandlers">
<list>
\r
<!--\r
- Location of the XML file that defines the root application context\r
- - Applied by ContextLoaderListener.\r
+ - Applied by Spring's ContextLoaderListener.\r
-->\r
<context-param>\r
<param-name>contextConfigLocation</param-name>\r
- delayBetweenAttemptsMillis - How long to wait between retries.\r
-\r
-->\r
+ <!-- \r
<filter>\r
<filter-name>networkErrorRetryFilter</filter-name>\r
<filter-class>org.collectionspace.services.common.NetworkErrorRetryFilter</filter-class>\r
<filter-name>networkErrorRetryFilter</filter-name>\r
<url-pattern>/*</url-pattern>\r
</filter-mapping>\r
- \r
+ -->\r
+ \r
<!--\r
A filter that logs profiling information.\r
-->\r
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.RepositoryJavaClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.workflow.WorkflowCommon;
* Resource. They then call this method on that resource.
*/
@Override
- public DocumentModel getDocModelForAuthorityItem(RepositoryInstance repoSession, RefName.AuthorityItem item)
+ public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item)
throws Exception, DocumentNotFoundException {
if(item == null) {
return null;
import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
import org.nuxeo.ecm.core.client.NuxeoClient;\r
\r
-import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
+//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
//import org.collectionspace.services.common.query.IQueryManager;\r
\r
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.RepositoryJavaClientImpl;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
public String getShortIdentifier(String authCSID, String schemaName) throws Exception {
String shortIdentifier = null;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
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.RepositoryJavaClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.relation.RelationsCommonList;
}
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = getRepositoryClient(ctx);
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface 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;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
boolean releaseRepoSession = false;
try {
--- /dev/null
+/target
+/target
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.RepositoryJavaClientImpl;
import org.collectionspace.services.batch.BatchCommon;
import org.collectionspace.services.batch.BatchInvocable;
ResourceMap resourceMap,
InvocationContext invContext) throws Exception {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
boolean releaseRepoSession = false;
String invocationMode = invContext.getMode();
import org.collectionspace.services.nuxeo.client.java.CommonList;
+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;
ObjectPartType partMeta = partsMetaMap.get(metadataLabel);
if (partMeta != null) {
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface 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
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface 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();
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface 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
--- /dev/null
+/target
+/target
<version>${spring.security.version}</version>\r
<scope>provided</scope>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-aop</artifactId>\r
+ <version>${spring.version}</version>\r
+ </dependency> \r
</dependencies>\r
\r
<repositories>\r
import java.util.HashMap;\r
import java.util.List;\r
import java.util.Map;\r
+\r
import javax.ws.rs.*;\r
import javax.ws.rs.core.*;\r
\r
import org.collectionspace.services.client.IQueryManager;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
-\r
import org.collectionspace.services.common.api.RefName;\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
import org.collectionspace.services.common.query.QueryManager;\r
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;\r
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo;\r
-\r
import org.collectionspace.services.config.ClientType;\r
import org.collectionspace.services.config.service.DocHandlerParams;\r
import org.collectionspace.services.config.service.ListResultField;\r
import org.collectionspace.services.config.service.ServiceBindingType;\r
-\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
-\r
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
import org.jboss.resteasy.util.HttpResponseCodes;\r
-\r
import org.nuxeo.ecm.core.api.DocumentModel;\r
import org.nuxeo.ecm.core.api.DocumentModelList;\r
import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
* for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get\r
* the map, and pass it in.\r
*/\r
- public static DocumentModel getDocModelForRefName(RepositoryInstance repoSession, String refName, ResourceMap resourceMap) \r
+ public static DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName, ResourceMap resourceMap) \r
throws Exception, DocumentNotFoundException {\r
RefName.AuthorityItem item = RefName.AuthorityItem.parse(refName);\r
if(item != null) {\r
\r
// THis is ugly, but prevents us parsing the refName twice. Once we make refName a little more\r
// general, and less Authority(Item) specific, this will look better.\r
- public DocumentModel getDocModelForAuthorityItem(RepositoryInstance repoSession, RefName.AuthorityItem item) \r
+ public DocumentModel getDocModelForAuthorityItem(RepositoryInstanceInterface repoSession, RefName.AuthorityItem item) \r
throws Exception, DocumentNotFoundException {\r
logger.warn("Default (ResourceBase) getDocModelForAuthorityItem called - should not happen!");\r
return null;\r
}\r
\r
- public DocumentModel getDocModelForRefName(RepositoryInstance repoSession, String refName) \r
+ public DocumentModel getDocModelForRefName(RepositoryInstanceInterface repoSession, String refName) \r
throws Exception, DocumentNotFoundException {\r
return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));\r
}\r
import org.collectionspace.services.blob.MeasuredPartGroupList;\r
import org.collectionspace.services.jaxb.BlobJAXBSchema;\r
import org.collectionspace.services.nuxeo.client.java.CommonList;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants;\r
import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
return result;\r
}\r
\r
- static public CommonList getBlobDerivatives(RepositoryInstance repoSession,\r
+ static public CommonList getBlobDerivatives(RepositoryInstanceInterface repoSession,\r
String repositoryId, List<ListResultField> resultsFields, String uri)\r
throws Exception {\r
CommonList commonList = new CommonList();\r
* This is a prototype method that is not currently used as of 1/1/2012. However,\r
* it may be useful now that we've transitioned to using an embedded Nuxeo server.\r
*/\r
- static private File getBlobFile(RepositoryInstance ri,\r
+ static private File getBlobFile(RepositoryInstanceInterface ri,\r
DocumentModel documentModel, Blob blob) {\r
DefaultBinaryManager binaryManager = null;\r
RepositoryDescriptor descriptor = null;\r
* the id\r
* @return the blob\r
*/\r
- static private Blob getBlob(RepositoryInstance nuxeoSession, String id) {\r
+ static private Blob getBlob(RepositoryInstanceInterface repoSession, String id) {\r
Blob result = null;\r
\r
try {\r
- Repository repository = nuxeoSession.getRepository();\r
+ Repository repository = repoSession.getRepositoryInstance().getRepository();\r
// binaryManager.initialize(new RepositoryDescriptor());\r
// binaryManager.getBinary("a4cac052ae0281979f2dcf5ab2e61a6c");\r
// DocumentResolver.resolveReference(nuxeoSession, documentRef);\r
return result;\r
}\r
\r
- static private RepositoryInstance getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) {\r
- RepositoryInstance result = null; \r
+ static private RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient) {\r
+ RepositoryInstanceInterface result = null; \r
RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
\r
try {\r
return result;\r
}\r
\r
- static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstance repoSession) throws TransactionException {\r
+ static private void releaseRepositorySession(ServiceContext ctx, RepositoryClient repositoryClient, RepositoryInstanceInterface repoSession) throws TransactionException {\r
RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;\r
nuxeoClient.releaseRepositorySession(ctx, repoSession);\r
}\r
}\r
\r
private static DocumentModel createDocumentFromBlob(\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
Blob inputStreamBlob, \r
String blobLocation, \r
boolean overwrite, \r
// image derivatives.\r
//\r
result = getFileManager().createDocumentFromBlob(\r
- repoSession, inputStreamBlob, blobLocation, true, blobName);\r
+ repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName);\r
} else {\r
//\r
// User Nuxeo's default file importer/adapter explicitly. This avoids specialized functionality from happening like\r
\r
FileImporter defaultFileImporter = fileManagerService.getPluginByName("DefaultFileImporter");\r
result = defaultFileImporter.create(\r
- repoSession, inputStreamBlob, blobLocation, true, blobName, getTypeService()); \r
+ repoSession.getRepositoryInstance(), inputStreamBlob, blobLocation, true, blobName, getTypeService()); \r
}\r
\r
return result;\r
BlobsCommon result = null;\r
\r
boolean repoSessionCleanup = false;\r
- RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+ RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession();\r
if (repoSession == null) {\r
repoSession = getRepositorySession(ctx, repositoryClient);\r
repoSessionCleanup = true;\r
*/\r
public static BlobsCommon createBlobInRepository(\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
BlobInput blobInput,\r
boolean purgeOriginal,\r
boolean useNuxeoAdaptors) throws Exception {\r
* the mime type\r
* @return the string\r
*/\r
- static private BlobsCommon createBlobInRepository(RepositoryInstance nuxeoSession,\r
+ static private BlobsCommon createBlobInRepository(RepositoryInstanceInterface nuxeoSession,\r
DocumentModel blobLocation,\r
boolean purgeOriginal,\r
File file,\r
BlobOutput result = null;\r
\r
boolean repoSessionCleanup = false;\r
- RepositoryInstance repoSession = (RepositoryInstance)ctx.getCurrentRepositorySession();\r
+ RepositoryInstanceInterface repoSession = (RepositoryInstanceInterface)ctx.getCurrentRepositorySession();\r
if (repoSession == null) {\r
repoSession = getRepositorySession(ctx, repositoryClient);\r
repoSessionCleanup = true;\r
* @return the image\r
*/\r
static public BlobOutput getBlobOutput(ServiceContext ctx,\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
String repositoryId,\r
String derivativeTerm,\r
Boolean getContentFlag,\r
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.repository.RepositoryClient;
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
*/
private static DocumentModelList findRelationsWithRefName(
ServiceContext ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
String refName,
String targetField,
String orderByField,
public static void updateRefNamesInRelations(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
String targetField,
String oldRefName,
String newRefName) {
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.storage.StorageClient;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
+
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;
+//
+// All of these Nuxeo specific classes should not be here. This is supposed to be
+// a repository-neutral interface.
+//
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;
/**
* RepositoryClient is a generic Document Repository client
* @param where NXQL where clause to get the document
* @throws DocumentException
*/
- public String findDocCSID(RepositoryInstance repoSession,
+ public String findDocCSID(RepositoryInstanceInterface repoSession,
ServiceContext<IT, OT> ctx, String where)
throws DocumentNotFoundException, DocumentException;
--- /dev/null
+package org.collectionspace.services.common.repository;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+
+
+public class RepositoryInstanceWrapperAdvice implements MethodInterceptor {
+
+ public RepositoryInstanceWrapperAdvice() {
+ // TODO Auto-generated constructor stub
+ }
+
+ //@Override
+ public Object invoke(MethodInvocation methodInvocation) throws Throwable {
+ try {
+ // proceed to original method call
+ Object result = methodInvocation.proceed();
+ return result;
+ } catch (IllegalArgumentException e) {
+ throw e;
+ }
+ }
+}
import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
-\r
import org.collectionspace.services.client.CollectionSpaceClient;\r
import org.collectionspace.services.client.IRelationsManager;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.common.relation.RelationUtils;\r
import org.collectionspace.services.common.repository.RepositoryClient;\r
import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
import org.collectionspace.services.common.security.SecurityUtils;\r
import org.collectionspace.services.config.service.ServiceBindingType;\r
public static void updateRefNamesInRelations(\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
String oldRefName,\r
String newRefName) {\r
//\r
}\r
\r
public static AuthorityRefDocList getAuthorityRefDocs(\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
UriTemplateRegistry uriTemplateRegistry,\r
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
public static int updateAuthorityRefDocs(\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
- RepositoryInstance repoSession,\r
+ RepositoryInstanceInterface repoSession,\r
String oldRefName,\r
String newRefName,\r
String refPropName) throws Exception {\r
private static DocumentModelList findAuthorityRefDocs(\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient,\r
- RepositoryInstance repoSession, List<String> serviceTypes,\r
+ RepositoryInstanceInterface repoSession, List<String> serviceTypes,\r
String refName,\r
String refPropName,\r
Map<String, ServiceBindingType> queriedServiceBindings,\r
public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
CommonList commonList = new CommonList();\r
String markRtSbj = null;\r
- RepositoryInstance repoSession = null;\r
+ RepositoryInstanceInterface repoSession = null;\r
RepositoryJavaClientImpl repoClient = null;\r
RepositoryJavaClientImpl nuxeoRepoClient = null;\r
boolean releaseRepoSession = false;\r
extends AbstractMultipartDocumentHandlerImpl<T, TL, DocumentModel, DocumentModelList> {
private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
- private RepositoryInstance repositorySession;
+ private RepositoryInstanceInterface repositorySession;
protected String oldRefNameOnUpdate = null; // FIXME: REM - We should have setters and getters for these
protected String newRefNameOnUpdate = null; // FIXME: two fields.
* getRepositorySession returns Nuxeo Repository Session
* @return
*/
- public RepositoryInstance getRepositorySession() {
+ public RepositoryInstanceInterface getRepositorySession() {
return repositorySession;
}
* setRepositorySession sets repository session
* @param repoSession
*/
- public void setRepositorySession(RepositoryInstance repoSession) {
+ public void setRepositorySession(RepositoryInstanceInterface repoSession) {
this.repositorySession = repoSession;
}
import java.util.Iterator;\r
import java.util.Map.Entry;\r
\r
-import javax.transaction.TransactionManager;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
+import org.collectionspace.services.common.repository.RepositoryInstanceWrapperAdvice;\r
import org.collectionspace.services.config.tenant.RepositoryDomainType;\r
import org.jboss.remoting.InvokerLocator;\r
import org.nuxeo.ecm.core.api.repository.Repository;\r
import org.nuxeo.ecm.core.api.repository.RepositoryManager;\r
import org.nuxeo.ecm.core.client.DefaultLoginHandler;\r
import org.nuxeo.ecm.core.client.LoginHandler;\r
-//import org.nuxeo.ecm.core.repository.RepositoryDescriptor;\r
import org.nuxeo.runtime.api.Framework;\r
import org.nuxeo.runtime.transaction.TransactionHelper;\r
+\r
+import javax.transaction.TransactionManager;\r
+\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
+import org.springframework.aop.framework.ProxyFactory;\r
\r
/**\r
* @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>\r
\r
private LoginHandler loginHandler;\r
\r
- private final HashMap<String, RepositoryInstance> repositoryInstances;\r
+ private final HashMap<String, RepositoryInstanceInterface> repositoryInstances;\r
\r
private InvokerLocator locator;\r
\r
private RepositoryManager repositoryMgr;\r
\r
private static final NuxeoClientEmbedded instance = new NuxeoClientEmbedded();\r
-\r
- private static final Log log = LogFactory.getLog(NuxeoClientEmbedded.class);\r
-\r
+ \r
/**\r
* Constructs a new NuxeoClient. NOTE: Using {@link #getInstance()} instead\r
* of this constructor is recommended.\r
*/\r
- public NuxeoClientEmbedded() {\r
+ private NuxeoClientEmbedded() {\r
loginHandler = loginHandler == null ? new DefaultLoginHandler()\r
: loginHandler;\r
- repositoryInstances = new HashMap<String, RepositoryInstance>();\r
+ repositoryInstances = new HashMap<String, RepositoryInstanceInterface>();\r
}\r
-\r
+ \r
public static NuxeoClientEmbedded getInstance() {\r
return instance;\r
}\r
private void doDisconnect() throws Exception {\r
locator = null;\r
// close repository sessions if any\r
- Iterator<Entry<String, RepositoryInstance>> it = repositoryInstances.entrySet().iterator();\r
+ Iterator<Entry<String, RepositoryInstanceInterface>> it = repositoryInstances.entrySet().iterator();\r
while (it.hasNext()) {\r
- Entry<String, RepositoryInstance> repo = it.next();\r
+ Entry<String, RepositoryInstanceInterface> repo = it.next();\r
try {\r
repo.getValue().close();\r
} catch (Exception e) {\r
- log.debug("Error while trying to close " + repo, e);\r
+ logger.debug("Error while trying to close " + repo, e);\r
}\r
it.remove();\r
}\r
/*\r
* Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period\r
*/\r
- public RepositoryInstance openRepository(RepositoryDomainType repoDomain) throws Exception {\r
+ public RepositoryInstanceInterface openRepository(RepositoryDomainType repoDomain) throws Exception {\r
return openRepository(repoDomain.getRepositoryName(), -1);\r
}\r
\r
/*\r
* Open a Nuxeo repo session using the passed in repoDomain and use the default tx timeout period\r
*/\r
- public RepositoryInstance openRepository(String repoName) throws Exception {\r
+ public RepositoryInstanceInterface openRepository(String repoName) throws Exception {\r
return openRepository(repoName, -1);\r
} \r
\r
- public RepositoryInstance openRepository(String repoName, int timeoutSeconds) throws Exception {\r
- RepositoryInstance result = null;\r
+ public RepositoryInstanceInterface openRepository(String repoName, int timeoutSeconds) throws Exception {\r
+ RepositoryInstanceInterface result = null;\r
\r
+ //\r
+ // If the called passed in a custom timeout setting, use it to configure Nuxeo's transaction manager.\r
+ //\r
if (timeoutSeconds > 0) {\r
TransactionManager transactionMgr = TransactionHelper.lookupTransactionManager();\r
transactionMgr.setTransactionTimeout(timeoutSeconds);\r
}\r
}\r
\r
+ //\r
+ // Start a new Nuxeo transaction\r
+ //\r
boolean startedTransaction = false;\r
if (TransactionHelper.isTransactionActive() == false) {\r
startedTransaction = TransactionHelper.startTransaction();\r
logger.warn("A request to start a new transaction was made, but a transaction is already open.");\r
}\r
\r
- Repository repository = null;\r
+ //\r
+ // From the repository name that the caller passed in, get an instance of Nuxeo's Repository class.\r
+ // The Repository class is just a metadata description of the repository.\r
+ //\r
+ Repository repository;\r
if (repoName != null) {\r
repository = getRepositoryManager().getRepository(repoName);\r
} else {\r
logger.warn(String.format("Using default repository '%s' because no name was specified.", repository.getName()));\r
}\r
\r
+ //\r
+ // Using the Repository class, get a Spring AOP proxied instance. We use Spring AOP to "wrap" all calls to the\r
+ // Nuxeo repository so we can check for network related failures and perform a series of retries.\r
+ //\r
if (repository != null) {\r
- result = newRepositoryInstance(repository);\r
- if (result != null) {\r
+ result = getRepositoryInstanceWrapper(repository);\r
+ logger.trace(String.format("A new transaction was started on thread '%d' : %s.",\r
+ Thread.currentThread().getId(), startedTransaction ? "true" : "false"));\r
+ logger.trace(String.format("Added a new repository instance to our repo list. Current count is now: %d",\r
+ repositoryInstances.size()));\r
+ } else {\r
+ String errMsg = String.format("Could not open a session to the Nuxeo repository='%s'", repoName);\r
+ logger.error(errMsg);\r
+ throw new Exception(errMsg);\r
+ } \r
+ \r
+ \r
+ return result;\r
+ }\r
+ \r
+ //\r
+ // Returns a proxied interface to a Nuxeo repository instance. Our proxy uses Spring AOP to\r
+ // wrap each call to the Nuxeo repo with code that catches network related errors/exceptions and\r
+ // re-attempts the calls to see if it recovers.\r
+ //\r
+ private RepositoryInstanceInterface getAOPProxy(RepositoryInstance repositoryInstance) {\r
+ RepositoryInstanceInterface result = null;\r
+ \r
+ try {\r
+ ProxyFactory factory = new ProxyFactory(new RepositoryInstanceWrapper(repositoryInstance));\r
+ factory.addAdvice(new RepositoryInstanceWrapperAdvice());\r
+ factory.setExposeProxy(true);\r
+ result = (RepositoryInstanceInterface)factory.getProxy();\r
+ } catch (Exception e) {\r
+ logger.error("Could not create AOP proxy for: " + RepositoryInstanceWrapper.class.getName(), e);\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+ /*\r
+ * From the Repository object (a description of the repository), get repository instance wrapper. Our wrapper\r
+ * will using the Spring AOP mechanism to intercept all calls to the repository. We will wrap all the calls to the\r
+ * Nuxeo repository and check for network related failures. We will retry all calls to the Nuxeo repo that fail because\r
+ * of network erros.\r
+ */\r
+ private RepositoryInstanceInterface getRepositoryInstanceWrapper(Repository repository) throws Exception {\r
+ RepositoryInstanceInterface result = null;\r
+ \r
+ RepositoryInstance repositoryInstance = new RepositoryInstanceHandler(repository).getProxy(); // A Nuxeo repo instance handler proxy\r
+ if (repositoryInstance != null) {\r
+ result = this.getAOPProxy(repositoryInstance); // This is our AOP proxy\r
+ if (result != null) {\r
String key = result.getSessionId();\r
repositoryInstances.put(key, result);\r
- if (logger.isTraceEnabled()) {\r
- logger.trace(String.format("A new transaction was started on thread '%d' : %s.",\r
- Thread.currentThread().getId(), startedTransaction ? "true" : "false"));\r
- logger.trace(String.format("Added a new repository instance to our repo list. Current count is now: %d",\r
- repositoryInstances.size()));\r
- }\r
- } else {\r
- String errMsg = String.format("Could not create a new repository instance for '%s' repository.", repository.getName());\r
- logger.error(errMsg);\r
- throw new Exception(errMsg);\r
- }\r
+ } else {\r
+ String errMsg = String.format("Could not instantiate a Spring AOP proxy for class '%s'.",\r
+ RepositoryInstanceWrapper.class.getName());\r
+ logger.error(errMsg);\r
+ throw new Exception(errMsg);\r
+ }\r
} else {\r
- String errMsg = String.format("Could not open a session to the Nuxeo repository='%s'", repoName);\r
+ String errMsg = String.format("Could not create a new repository instance for '%s' repository.", repository.getName());\r
logger.error(errMsg);\r
throw new Exception(errMsg);\r
}\r
-\r
- return result;\r
+ \r
+ return result;\r
}\r
\r
- public void releaseRepository(RepositoryInstance repo) throws Exception {\r
+ public void releaseRepository(RepositoryInstanceInterface repo) throws Exception {\r
String key = repo.getSessionId();\r
\r
try {\r
logger.error("Possible data loss. Could not save and/or release the repository.", e);\r
throw e;\r
} finally {\r
- RepositoryInstance wasRemoved = repositoryInstances.remove(key);\r
+ RepositoryInstanceInterface wasRemoved = repositoryInstances.remove(key);\r
if (logger.isTraceEnabled()) {\r
if (wasRemoved != null) {\r
logger.trace("Removed a repository instance from our repo list. Current count is now: "\r
logger.trace(String.format("Transaction closed on thread '%d'", Thread.currentThread().getId()));\r
}\r
}\r
- }\r
-\r
- public static RepositoryInstance newRepositoryInstance(Repository repository) {\r
- return new RepositoryInstanceHandler(repository).getProxy(); // Why a proxy here?\r
- }\r
-\r
+ } \r
}\r
+++ /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.io.File;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.collectionspace.services.config.RepositoryClientConfigType;
-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.DefaultLoginHandler;
-import org.nuxeo.ecm.core.client.NuxeoApp;
-import org.nuxeo.ecm.core.client.NuxeoClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * NuxeoConnector creates Nuxeo remoting runtime and provides access to Nuxeo client.
- * @author
- */
-public class NuxeoConnector {
-
- public final static String NUXEO_CLIENT_DIR = "nuxeo-client";
- private Logger logger = LoggerFactory.getLogger(NuxeoConnector.class);
- private static final NuxeoConnector self = new NuxeoConnector();
- private static final String NUXEO_CLIENT_USERNAME = "NUXEO_CLIENT_USERNAME";
- private static final String NUXEO_CLIENT_PASSWORD = "NUXEO_CLIENT_PASSWORD";
- private NuxeoApp app;
- private NuxeoClient client;
- private volatile boolean initialized = false; //use volatile for lazy initialization in singleton
- private RepositoryClientConfigType repositoryClientConfig;
-
- private NuxeoConnector() {
- }
-
- public final static NuxeoConnector getInstance() {
- return self;
- }
-
- private String getClientUserName(RepositoryClientConfigType repositoryClientConfig) {
- String username = System.getenv(NUXEO_CLIENT_USERNAME);
- if (username == null) {
- username = repositoryClientConfig.getUser();
- }
- return username;
- }
-
- private String getClientPassword(RepositoryClientConfigType repositoryClientConfig) {
- String password = System.getenv(NUXEO_CLIENT_PASSWORD);
- if (password == null) {
- password = repositoryClientConfig.getPassword();
- }
- return password;
- }
-
- /**
- * initialize initialize the Nuxeo connector. It makes sure that the connector
- * is initialized in a thread-safe manner and not initialized more than once.
- * Initialization involves starting Nuxeo runtime, loading Nuxeo APIs jars
- * in OSGI container as well as establishing initial connection.
- * @param repositoryClientConfig
- * @throws java.lang.Exception
- */
- public void initialize(RepositoryClientConfigType repositoryClientConfig) throws Exception {
-
- if(initialized == false){
- synchronized(this){
- if(initialized == false){
- try{
- this.repositoryClientConfig = repositoryClientConfig;
- setProperties(repositoryClientConfig);
- app = new NuxeoApp();
- app.start();
- if(logger.isDebugEnabled()){
- logger.debug("initialize() NuxeoApp started");
- }
- loadBundles();
- client = NuxeoClient.getInstance();
- String username = getClientUserName(repositoryClientConfig);
- String password = getClientPassword(repositoryClientConfig);
-// DefaultLoginHandler loginHandler = new DefaultLoginHandler(
-// repositoryClientConfig.getUser(), repositoryClientConfig.getPassword());
- DefaultLoginHandler loginHandler = new DefaultLoginHandler(username, password);
- client.setLoginHandler(loginHandler);
- client.connect(repositoryClientConfig.getHost(),
- repositoryClientConfig.getPort());
- if(logger.isDebugEnabled()){
- logger.debug("initialize(): connection successful port=" +
- repositoryClientConfig.getPort());
- }
- initialized = true;
- }catch(Exception e){
- if(logger.isDebugEnabled()){
- logger.debug("Caught exception while initializing", e);
- }
- }
- }
- }
- }
- }
-
- /**
- * release releases resources occupied by Nuxeo remoting client runtime
- * @throws java.lang.Exception
- */
- public void release() throws Exception {
- if(initialized == true){
- client.disconnect();
- app.shutdown();
- }
- }
-
- private void loadBundles() throws Exception {
- String bundles = "nuxeo-client/lib/nuxeo-runtime-*:nuxeo-client/lib/nuxeo-*";
-// String serverRootDir = ServiceMain.getInstance().getServerRootDir();
- //can't call ServiceMain here because loadBundles is called within
- //the iniitialization context of ServiceMain, recrusion problem
- String serverRootDir = System.getProperty("jboss.server.home.dir");
- if(serverRootDir == null){
- serverRootDir = "."; //assume server is started from server root, e.g. server/cspace
- }
- File clientLibDir = new File(serverRootDir);
- if(!clientLibDir.exists()){
- String msg = "Library bundles requried to deploy Nuxeo client not found: " +
- " directory named nuxeo-client with bundles does not exist in " + serverRootDir;
- logger.error(msg);
- throw new IllegalStateException(msg);
- }
- Collection<File> files = null;
- if(bundles != null){
- files = NuxeoApp.getBundleFiles(new File(serverRootDir), bundles, ":");
- }
- if(logger.isDebugEnabled()){
- logger.debug("loadBundles(): deploying bundles: " + files);
- }
- if(files != null){
- app.deployBundles(files);
- }
- }
-
- private void setProperties(RepositoryClientConfigType repositoryClientConfig) {
- System.setProperty("nuxeo.client.on.jboss", Boolean.TRUE.toString());
- System.setProperty("org.nuxeo.runtime.server.enabled", Boolean.FALSE.toString());
- System.setProperty("org.nuxeo.runtime.server.port", "" + repositoryClientConfig.getPort());
- System.setProperty("org.nuxeo.runtime.server.host", repositoryClientConfig.getHost());
- //System.setProperty("org.nuxeo.runtime.1.3.3.streaming.port", "3233");
- System.setProperty("org.nuxeo.runtime.streaming.serverLocator", "socket://" + repositoryClientConfig.getHost() + ":3233");
- System.setProperty("org.nuxeo.runtime.streaming.isServer", Boolean.FALSE.toString());
- //org.nuxeo.client.remote is part of the fix to Nuxeo Runtime to use Java Remote APIs
- //from JBoss
- System.setProperty("org.nuxeo.client.remote", Boolean.TRUE.toString());
- }
-
- /**
- * getClient get Nuxeo client for accessing Nuxeo services remotely using
- * Nuxeo Java (EJB) Remote APIS
- * @return NuxeoClient
- * @throws java.lang.Exception
- */
- public NuxeoClient getClient() throws Exception {
- if(initialized == true){
- if(client.isConnected()){
- client.login();
- return client;
- }else{
- client.forceConnect(repositoryClientConfig.getHost(), repositoryClientConfig.getPort());
- if(logger.isDebugEnabled()){
- logger.debug("getClient(): connection successful port=" +
- repositoryClientConfig.getPort());
- }
- return client;
- }
- }
- String msg = "NuxeoConnector is not initialized!";
- logger.error(msg);
- throw new IllegalStateException(msg);
- }
-
- /**
- * getRepositorySession get session to default repository
- * @return RepositoryInstance
- * @throws java.lang.Exception
- */
- public RepositoryInstance getRepositorySession() throws Exception {
- RepositoryInstance repoSession = getClient().openRepository();
- if(logger.isDebugEnabled()){
- logger.debug("getRepositorySession() opened repository session");
- }
- return repoSession;
- }
-
- /**
- * releaseRepositorySession releases given repository session
- * @param repoSession
- * @throws java.lang.Exception
- */
- public void releaseRepositorySession(RepositoryInstance repoSession) throws Exception {
- if(repoSession != null){
- getClient().releaseRepository(repoSession);
-
- if(logger.isDebugEnabled()){
- logger.debug("releaseRepositorySession() released repository session");
- }
- }
- }
-
- /**
- * retrieveWorkspaceIds retrieves all workspace ids from default repository
- * @param tenantDomain domain representing tenant
- * @return
- * @throws java.lang.Exception
- */
- public Hashtable<String, String> retrieveWorkspaceIds(String tenantDomain) throws Exception {
- RepositoryInstance repoSession = null;
- Hashtable<String, String> workspaceIds = new Hashtable<String, String>();
- try{
- repoSession = getRepositorySession();
- DocumentModel rootDoc = repoSession.getRootDocument();
- DocumentModelList rootChildrenList = repoSession.getChildren(rootDoc.getRef());
- Iterator<DocumentModel> diter = rootChildrenList.iterator();
- while(diter.hasNext()){
- DocumentModel domain = diter.next();
- String domainPath = "/" + tenantDomain;
- if(!domain.getPathAsString().equalsIgnoreCase(domainPath)){
- continue;
-}
- if(logger.isDebugEnabled()){
- logger.debug("domain=" + domain.toString());
- }
- DocumentModelList domainChildrenList = repoSession.getChildren(domain.getRef());
- Iterator<DocumentModel> witer = domainChildrenList.iterator();
- while(witer.hasNext()){
- DocumentModel childNode = witer.next();
- if("Workspaces".equalsIgnoreCase(childNode.getName())){
- DocumentModelList workspaceList = repoSession.getChildren(childNode.getRef());
- Iterator<DocumentModel> wsiter = workspaceList.iterator();
- while(wsiter.hasNext()){
- DocumentModel workspace = wsiter.next();
- if(logger.isDebugEnabled()){
- logger.debug("workspace name=" + workspace.getName() +
- " id=" + workspace.getId());
- }
- workspaceIds.put(workspace.getName().toLowerCase(), workspace.getId());
- }
- }
- }
- }
- }catch(Exception e){
- if(logger.isDebugEnabled()){
- logger.debug("retrieveWorkspaceIds() caught exception ", e);
- }
- throw e;
- }finally{
- if(repoSession != null){
- releaseRepositorySession(repoSession);
- }
- }
- return workspaceIds;
- }
-}
import org.collectionspace.services.config.RepositoryClientConfigType;\r
import org.collectionspace.services.config.tenant.RepositoryDomainType;\r
import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
+\r
import org.nuxeo.ecm.core.NXCore;\r
import org.nuxeo.ecm.core.api.DocumentModel;\r
import org.nuxeo.ecm.core.api.DocumentModelList;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
import org.nuxeo.ecm.core.model.Repository;\r
import org.nuxeo.osgi.application.FrameworkBootstrap;\r
import org.nuxeo.ecm.core.repository.RepositoryDescriptor;\r
this.servletContext = servletContext;\r
this.repositoryClientConfig = repositoryClientConfig;\r
startNuxeoEP(serverRootPath);\r
- client = new NuxeoClientEmbedded();\r
+ client = NuxeoClientEmbedded.getInstance();\r
initialized = true;\r
}\r
}\r
* @param repoSession\r
* @throws java.lang.Exception\r
*/\r
- public void releaseRepositorySession(RepositoryInstance repoSession)\r
+ public void releaseRepositorySession(RepositoryInstanceInterface repoSession)\r
throws Exception {\r
if (repoSession != null) {\r
getClient().releaseRepository(repoSession);\r
* @return RepositoryInstance\r
* @throws java.lang.Exception\r
*/\r
- public RepositoryInstance getRepositorySession(RepositoryDomainType repoDomain) throws Exception {\r
- RepositoryInstance repoSession = getClient().openRepository(repoDomain);\r
+ public RepositoryInstanceInterface getRepositorySession(RepositoryDomainType repoDomain) throws Exception {\r
+ RepositoryInstanceInterface repoSession = getClient().openRepository(repoDomain);\r
\r
if (logger.isDebugEnabled() && repoSession != null) {\r
logger.debug("getRepositorySession() opened repository session");\r
*/\r
public Hashtable<String, String> retrieveWorkspaceIds(RepositoryDomainType repoDomain)\r
throws Exception {\r
- RepositoryInstance repoSession = null;\r
+ RepositoryInstanceInterface repoSession = null;\r
Hashtable<String, String> workspaceIds = new Hashtable<String, String>();\r
try {\r
repoSession = getRepositorySession(repoDomain);\r
+++ /dev/null
-package org.collectionspace.services.nuxeo.client.java;\r
-\r
-import java.io.File;\r
-import java.util.Collection;\r
-import java.util.Hashtable;\r
-import java.util.Iterator;\r
-\r
-import org.collectionspace.services.config.RepositoryClientConfigType;\r
-import org.nuxeo.ecm.core.api.CoreInstance;\r
-import org.nuxeo.ecm.core.api.DocumentModel;\r
-import org.nuxeo.ecm.core.api.DocumentModelList;\r
-import org.nuxeo.ecm.core.api.repository.Repository;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
-import org.nuxeo.ecm.core.api.repository.RepositoryManager;\r
-import org.nuxeo.ecm.core.client.DefaultLoginHandler;\r
-import org.nuxeo.ecm.core.client.NuxeoApp;\r
-import org.nuxeo.ecm.core.client.NuxeoClient;\r
-import org.nuxeo.osgi.application.FrameworkBootstrap;\r
-import org.nuxeo.runtime.api.Framework;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class NuxeoConnectorRemote {\r
- public FrameworkBootstrap fb;\r
- public final static String NUXEO_CLIENT_DIR = "nuxeo-client";\r
- private Logger logger = LoggerFactory.getLogger(NuxeoConnectorRemote.class);\r
- private static final NuxeoConnectorRemote self = new NuxeoConnectorRemote();\r
- private static final String NUXEO_CLIENT_USERNAME = "NUXEO_CLIENT_USERNAME";\r
- private static final String NUXEO_CLIENT_PASSWORD = "NUXEO_CLIENT_PASSWORD";\r
- private NuxeoClient client;\r
- private volatile boolean initialized = false; // use volatile for lazy\r
- // initialization in\r
- // singleton\r
- private RepositoryClientConfigType repositoryClientConfig;\r
-\r
- private NuxeoConnectorRemote() {\r
- }\r
-\r
- public final static NuxeoConnectorRemote getInstance() {\r
- return self;\r
- }\r
-\r
- private String getClientUserName(\r
- RepositoryClientConfigType repositoryClientConfig) {\r
- String username = System.getenv(NUXEO_CLIENT_USERNAME);\r
- if (username == null) {\r
- username = repositoryClientConfig.getUser();\r
- }\r
- return username;\r
- }\r
-\r
- private String getClientPassword(\r
- RepositoryClientConfigType repositoryClientConfig) {\r
- String password = System.getenv(NUXEO_CLIENT_PASSWORD);\r
- if (password == null) {\r
- password = repositoryClientConfig.getPassword();\r
- }\r
- return password;\r
- }\r
-\r
- private void startNuxeoEP() throws Exception {\r
- String nuxeoHome = "nuxeo-client/";\r
- String serverRootDir = System.getProperty("jboss.server.home.dir");\r
- if (serverRootDir == null) {\r
- serverRootDir = "."; // assume server is started from server root,\r
- // e.g. server/cspace\r
- }\r
- File nuxeoHomeDir = new File(serverRootDir + File.separator + nuxeoHome);\r
- logger.info("Loading Nuxeo configuration from: "\r
- + nuxeoHomeDir.getAbsolutePath());\r
- if (nuxeoHomeDir.exists() == false) {\r
- String msg = "Library bundles requried to deploy Nuxeo client not found: "\r
- + " directory named nuxeo-client with bundles does not exist in "\r
- + serverRootDir;\r
- logger.error(msg);\r
- throw new IllegalStateException(msg);\r
- }\r
- fb = new FrameworkBootstrap(NuxeoConnectorRemote.class.getClassLoader(),\r
- nuxeoHomeDir);\r
- fb.initialize();\r
- fb.start();\r
- }\r
-\r
- /**\r
- * release releases resources occupied by Nuxeo remoting client runtime\r
- * \r
- * @throws java.lang.Exception\r
- */\r
- public void release() throws Exception {\r
- if (initialized == true) {\r
- try {\r
- client.tryDisconnect();\r
- } catch (Exception e) {\r
- logger.error("Failed to disconnect Nuxeo connection.", e);\r
- throw e;\r
- }\r
- }\r
- }\r
-\r
- public void initialize(RepositoryClientConfigType repositoryClientConfig)\r
- throws Exception {\r
- if (initialized == false) {\r
- synchronized (this) {\r
- if (initialized == false) {\r
- try {\r
- this.repositoryClientConfig = repositoryClientConfig;\r
- startNuxeoEP();\r
- // client = NuxeoClient.getInstance();\r
- client = new NuxeoClient();\r
- String username = getClientUserName(repositoryClientConfig);\r
- String password = getClientPassword(repositoryClientConfig);\r
- DefaultLoginHandler loginHandler = new DefaultLoginHandler(\r
- username, password);\r
- client.setLoginHandler(loginHandler);\r
- client.tryConnect(repositoryClientConfig.getHost(),\r
- repositoryClientConfig.getPort());\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("initialize(): connection successful port="\r
- + repositoryClientConfig.getPort());\r
- }\r
- initialized = true;\r
- } catch (Exception e) {\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("Caught exception while initializing",\r
- e);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * releaseRepositorySession releases given repository session\r
- * \r
- * @param repoSession\r
- * @throws java.lang.Exception\r
- */\r
- public void releaseRepositorySession(RepositoryInstance repoSession)\r
- throws Exception {\r
- if (repoSession != null) {\r
- getClient().releaseRepository(repoSession);\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("releaseRepositorySession() released repository session");\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * getRepositorySession get session to default repository\r
- * \r
- * @return RepositoryInstance\r
- * @throws java.lang.Exception\r
- */\r
- public RepositoryInstance getRepositorySession() throws Exception {\r
- RepositoryInstance repoSession = getClient().openRepository();\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("getRepositorySession() opened repository session");\r
- }\r
- return repoSession;\r
-\r
- // Repository repository =\r
- // Framework.getService(RepositoryManager.class).getDefaultRepository();\r
- // session = repository.open();\r
-\r
- }\r
-\r
- /**\r
- * getClient get Nuxeo client for accessing Nuxeo services remotely using\r
- * Nuxeo Java (EJB) Remote APIS\r
- * \r
- * @return NuxeoClient\r
- * @throws java.lang.Exception\r
- */\r
- public NuxeoClient getClient() throws Exception {\r
- if (initialized == true) {\r
- if (client.isConnected()) {\r
- client.login();\r
- return client;\r
- } else {\r
- client.forceConnect(repositoryClientConfig.getHost(),\r
- repositoryClientConfig.getPort());\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("getClient(): connection successful port="\r
- + repositoryClientConfig.getPort());\r
- }\r
- return client;\r
- }\r
- }\r
- String msg = "NuxeoConnector is not initialized!";\r
- logger.error(msg);\r
- throw new IllegalStateException(msg);\r
- }\r
-\r
- /**\r
- * retrieveWorkspaceIds retrieves all workspace ids from default repository\r
- * \r
- * @param tenantDomain\r
- * domain representing tenant\r
- * @return\r
- * @throws java.lang.Exception\r
- */\r
- public Hashtable<String, String> retrieveWorkspaceIds(String tenantDomain)\r
- throws Exception {\r
- RepositoryInstance repoSession = null;\r
- Hashtable<String, String> workspaceIds = new Hashtable<String, String>();\r
- try {\r
- repoSession = getRepositorySession();\r
- DocumentModel rootDoc = repoSession.getRootDocument();\r
- DocumentModelList rootChildrenList = repoSession\r
- .getChildren(rootDoc.getRef());\r
- Iterator<DocumentModel> diter = rootChildrenList.iterator();\r
- while (diter.hasNext()) {\r
- DocumentModel domain = diter.next();\r
- String domainPath = "/" + tenantDomain;\r
- if (!domain.getPathAsString().equalsIgnoreCase(domainPath)) {\r
- continue;\r
- }\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("domain=" + domain.toString());\r
- }\r
- DocumentModelList domainChildrenList = repoSession\r
- .getChildren(domain.getRef());\r
- Iterator<DocumentModel> witer = domainChildrenList.iterator();\r
- while (witer.hasNext()) {\r
- DocumentModel childNode = witer.next();\r
- if ("Workspaces".equalsIgnoreCase(childNode.getName())) {\r
- DocumentModelList workspaceList = repoSession\r
- .getChildren(childNode.getRef());\r
- Iterator<DocumentModel> wsiter = workspaceList\r
- .iterator();\r
- while (wsiter.hasNext()) {\r
- DocumentModel workspace = wsiter.next();\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("workspace name="\r
- + workspace.getName() + " id="\r
- + workspace.getId());\r
- }\r
- workspaceIds.put(workspace.getName().toLowerCase(),\r
- workspace.getId());\r
- }\r
- }\r
- }\r
- }\r
- } catch (Exception e) {\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("retrieveWorkspaceIds() caught exception ", e);\r
- }\r
- throw e;\r
- } finally {\r
- if (repoSession != null) {\r
- releaseRepositorySession(repoSession);\r
- }\r
- }\r
- return workspaceIds;\r
- }\r
- \r
- @Deprecated\r
- private void loadBundles() throws Exception {\r
- }\r
- \r
-}\r
boolean releaseRepoSession = false;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
releaseRepoSession = true;
if (hasRefNameUpdate() == true) {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = getRepositoryClient(ctx);
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface repoSession = this.getRepositorySession();
// Update all the relationship records that referred to the old refName
RefNameServiceUtils.updateRefNamesInRelations(ctx, repoClient, repoSession,
--- /dev/null
+package org.collectionspace.services.nuxeo.client.java;
+
+import java.security.Principal;
+
+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.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;
+
+public interface RepositoryInstanceInterface {
+
+ public RepositoryInstance getRepositoryInstance();
+
+ /**
+ * Gets the root document of this repository.
+ *
+ * @return the root document. cannot be null
+ * @throws ClientException
+ * @throws SecurityException
+ */
+ public DocumentModel getRootDocument() throws ClientException;
+
+ /**
+ * Gets the current session id.
+ * <p>
+ * If the client is not connected returns null.
+ *
+ * @return the session id or null if not connected
+ */
+ public String getSessionId();
+
+ /**
+ *
+ * @throws Exception
+ */
+ public void close() throws Exception;
+
+ /**
+ * Returns the repository name against which this core session is bound.
+ *
+ * @return the repository name used currently used as an identifier
+ */
+ public String getRepositoryName();
+
+ /**
+ * Gets the principal that created the client session.
+ *
+ * @return the principal
+ */
+ public Principal getPrincipal();
+
+ public IterableQueryResult queryAndFetch(String query, String queryType,
+ Object... params) throws ClientException;
+
+ public DocumentModelList query(String query, Filter filter, long limit,
+ long offset, boolean countTotal) throws ClientException;
+
+ public DocumentModelList query(String query) throws ClientException;
+
+ /**
+ * Executes the given NXQL query an returns the result.
+ *
+ * @param query the query to execute
+ * @param max number of document to retrieve
+ * @return the query result
+ * @throws ClientException
+ */
+ public DocumentModelList query(String query, int max) throws ClientException;
+
+ /**
+ * Gets a document model given its reference.
+ * <p>
+ * The default schemas are used to populate the returned document model.
+ * Default schemas are configured via the document type manager.
+ * <p>
+ * Any other data model not part of the default schemas will be lazily
+ * loaded as needed.
+ *
+ * @param docRef the document reference
+ * @return the document
+ * @throws ClientException
+ * @throws SecurityException
+ */
+ public DocumentModel getDocument(DocumentRef docRef) throws ClientException;
+
+ public DocumentModel saveDocument(DocumentModel docModel) throws ClientException;
+
+ public void save() throws ClientException;
+
+ /**
+ * Bulk document saving.
+ *
+ * @param docModels the document models that needs to be saved
+ * @throws ClientException
+ */
+ public void saveDocuments(DocumentModel[] docModels) throws ClientException;
+
+ /**
+ * Removes this document and all its children, if any.
+ *
+ * @param docRef the reference to the document to remove
+ * @throws ClientException
+ */
+ public void removeDocument(DocumentRef docRef) throws ClientException;
+
+ /**
+ * Creates a document model using required information.
+ * <p>
+ * Used to fetch initial datamodels from the type definition.
+ * <p>
+ * DocumentModel creation notifies a
+ * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
+ * listener can initialize its content with computed properties.
+ *
+ * @param parentPath
+ * @param id
+ * @param typeName
+ * @return the initial document model
+ * @throws ClientException
+ */
+ public DocumentModel createDocumentModel(String parentPath, String id,
+ String typeName) throws ClientException;
+
+ /**
+ * Creates a document using given document model for initialization.
+ * <p>
+ * The model contains path of the new document, its type and optionally the
+ * initial data models of the document.
+ * <p>
+ *
+ * @param model the document model to use for initialization
+ * @return the created document
+ * @throws ClientException
+ */
+ public DocumentModel createDocument(DocumentModel model) throws ClientException;
+
+ /**
+ * Gets the children of the given parent.
+ *
+ * @param parent the parent reference
+ * @return the children if any, an empty list if no children or null if the
+ * specified parent document is not a folder
+ * @throws ClientException
+ */
+ public DocumentModelList getChildren(DocumentRef parent) throws ClientException;
+
+
+}
--- /dev/null
+package org.collectionspace.services.nuxeo.client.java;
+
+import java.security.Principal;
+
+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.DocumentRef;
+import org.nuxeo.ecm.core.api.Filter;
+import org.nuxeo.ecm.core.api.IterableQueryResult;
+import org.nuxeo.ecm.core.api.NoRollbackOnException;
+import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+
+public class RepositoryInstanceWrapper implements RepositoryInstanceInterface {
+
+ private RepositoryInstance repoSession;
+
+ public RepositoryInstanceWrapper(RepositoryInstance repoSession) {
+ this.repoSession = repoSession;
+ }
+
+ @Override
+ public RepositoryInstance getRepositoryInstance() {
+ return repoSession;
+ }
+
+ @Override
+ public String getSessionId() {
+ return repoSession.getSessionId();
+ }
+
+ @Override
+ public void close() throws Exception {
+ repoSession.close();
+ }
+
+ /**
+ * Gets the root document of this repository.
+ *
+ * @return the root document. cannot be null
+ * @throws ClientException
+ * @throws SecurityException
+ */
+ @Override
+ public DocumentModel getRootDocument() throws ClientException {
+ return repoSession.getRootDocument();
+ }
+
+ /**
+ * Returns the repository name against which this core session is bound.
+ *
+ * @return the repository name used currently used as an identifier
+ */
+ @Override
+ public String getRepositoryName() {
+ return repoSession.getRepositoryName();
+ }
+
+ /**
+ * Gets the principal that created the client session.
+ *
+ * @return the principal
+ */
+ @Override
+ public Principal getPrincipal() {
+ return repoSession.getPrincipal();
+ }
+
+ @Override
+ public IterableQueryResult queryAndFetch(String query, String queryType,
+ Object... params) throws ClientException {
+ return repoSession.queryAndFetch(query, queryType, params);
+ }
+
+ @Override
+ public DocumentModelList query(String query, Filter filter, long limit,
+ long offset, boolean countTotal) throws ClientException {
+ return repoSession.query(query, filter, limit, offset, countTotal);
+ }
+
+ @Override
+ public DocumentModelList query(String query, int max) throws ClientException {
+ return repoSession.query(query, max);
+ }
+
+ @Override
+ public DocumentModelList query(String query) throws ClientException {
+ return repoSession.query(query);
+ }
+
+ /**
+ * Gets a document model given its reference.
+ * <p>
+ * The default schemas are used to populate the returned document model.
+ * Default schemas are configured via the document type manager.
+ * <p>
+ * Any other data model not part of the default schemas will be lazily
+ * loaded as needed.
+ *
+ * @param docRef the document reference
+ * @return the document
+ * @throws ClientException
+ * @throws SecurityException
+ */
+ @NoRollbackOnException
+ @Override
+ public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
+ return repoSession.getDocument(docRef);
+ }
+
+ @Override
+ public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
+ return repoSession.saveDocument(docModel);
+ }
+
+ @Override
+ public void save() throws ClientException {
+ repoSession.save();
+ }
+
+ /**
+ * Bulk document saving.
+ *
+ * @param docModels the document models that needs to be saved
+ * @throws ClientException
+ */
+ @Override
+ public void saveDocuments(DocumentModel[] docModels) throws ClientException {
+ repoSession.saveDocuments(docModels);
+ }
+
+ /**
+ * Removes this document and all its children, if any.
+ *
+ * @param docRef the reference to the document to remove
+ * @throws ClientException
+ */
+ @Override
+ public void removeDocument(DocumentRef docRef) throws ClientException {
+ repoSession.removeDocument(docRef);
+ }
+
+ /**
+ * Creates a document model using required information.
+ * <p>
+ * Used to fetch initial datamodels from the type definition.
+ * <p>
+ * DocumentModel creation notifies a
+ * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
+ * listener can initialize its content with computed properties.
+ *
+ * @param parentPath
+ * @param id
+ * @param typeName
+ * @return the initial document model
+ * @throws ClientException
+ */
+ @Override
+ public DocumentModel createDocumentModel(String parentPath, String id,
+ String typeName) throws ClientException {
+ return repoSession.createDocumentModel(parentPath, id, typeName);
+ }
+
+ /**
+ * Creates a document using given document model for initialization.
+ * <p>
+ * The model contains path of the new document, its type and optionally the
+ * initial data models of the document.
+ * <p>
+ *
+ * @param model the document model to use for initialization
+ * @return the created document
+ * @throws ClientException
+ */
+ @Override
+ public DocumentModel createDocument(DocumentModel model) throws ClientException {
+ return repoSession.createDocument(model);
+ }
+
+ /**
+ * Gets the children of the given parent.
+ *
+ * @param parent the parent reference
+ * @return the children if any, an empty list if no children or null if the
+ * specified parent document is not a folder
+ * @throws ClientException
+ */
+ @NoRollbackOnException
+ @Override
+ public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
+ return repoSession.getChildren(parent);
+ }
+
+
+
+}
import org.collectionspace.services.common.document.DocumentWrapperImpl;
import org.collectionspace.services.common.document.TransactionException;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
+
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.DocumentRef;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.PathRef;
-import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
import org.nuxeo.runtime.transaction.TransactionRuntimeException;
//
* $LastChangedRevision: $ $LastChangedDate: $
*/
public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
-
+
/**
* The logger.
*/
+ " check if the workspace exists in the Nuxeo repository");
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.CREATE);
repoSession = getRepositorySession(ctx);
"RepositoryJavaClient.get: handler is missing");
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface 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);
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.GET);
}
public DocumentWrapper<DocumentModel> getDoc(
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface 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 {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
DocumentWrapper<DocumentModel> wrapDoc = null;
try {
}
public DocumentWrapper<DocumentModel> findDoc(
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String whereClause)
throws DocumentNotFoundException, DocumentException {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String whereClause)
throws DocumentNotFoundException, TransactionException, DocumentException {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
DocumentWrapper<DocumentModel> wrapDoc = null;
try {
* @return the CollectionSpace ID (CSID) of the requested document
*/
@Override
- public String findDocCSID(RepositoryInstance repoSession,
+ public String findDocCSID(RepositoryInstanceInterface repoSession,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String whereClause)
throws DocumentNotFoundException, TransactionException, DocumentException {
String csid = null;
public DocumentWrapper<DocumentModelList> findDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
List<String> docTypes,
String whereClause,
String orderByClause,
public DocumentWrapper<DocumentModelList> findDocs(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
DocumentHandler handler,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
List<String> docTypes)
throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModelList> wrapDoc = null;
String whereClause,
int pageSize, int pageNum, boolean computeTotal)
throws DocumentNotFoundException, TransactionException, DocumentException {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
DocumentWrapper<DocumentModelList> wrapDoc = null;
try {
"RepositoryJavaClient.getAll: handler is missing");
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.GET_ALL);
repoSession = getRepositorySession(ctx);
+ " check if the workspace exists in the Nuxeo repository.");
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.GET_ALL);
repoSession = getRepositorySession(ctx);
public DocumentWrapper<DocumentModel> getDocFromCsid(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
String csid)
throws Exception {
DocumentWrapper<DocumentModel> result = null;
String csid)
throws Exception {
DocumentWrapper<DocumentModel> result = null;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
repoSession = getRepositorySession(ctx);
result = getDocFromCsid(ctx, repoSession, csid);
/*
* See CSPACE-5036 - How to make CMISQL queries from Nuxeo
*/
- private IterableQueryResult makeCMISQLQuery(RepositoryInstance repoSession, String query, QueryContext queryContext) throws DocumentException {
+ private IterableQueryResult makeCMISQLQuery(RepositoryInstanceInterface repoSession, String query, QueryContext queryContext) throws DocumentException {
IterableQueryResult result = null;
// the NuxeoRepository should be constructed only once, then cached
callContext.put(CallContext.USERNAME, repoSession.getPrincipal()
.getName());
NuxeoCmisService cmisService = new NuxeoCmisService(repo,
- callContext, repoSession);
+ callContext, repoSession.getRepositoryInstance());
result = repoSession.queryAndFetch(query, "CMISQL", cmisService);
} catch (ClientException e) {
}
QueryContext queryContext = new QueryContext(ctx, handler);
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface 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(RepositoryInstance repoSession, ServiceContext ctx,
+ private DocumentModelList getFilteredJDBC(RepositoryInstanceInterface repoSession, ServiceContext ctx,
DocumentHandler handler) throws Exception {
DocumentModelList result = new DocumentModelListImpl();
}
- private DocumentModelList getFilteredCMIS(RepositoryInstance repoSession, ServiceContext ctx, DocumentHandler handler, QueryContext queryContext)
+ private DocumentModelList getFilteredCMIS(RepositoryInstanceInterface repoSession, ServiceContext ctx, DocumentHandler handler, QueryContext queryContext)
throws DocumentNotFoundException, DocumentException {
DocumentModelList result = new DocumentModelListImpl();
"RepositoryJavaClient.update: document handler is missing.");
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.UPDATE);
repoSession = getRepositorySession(ctx);
*/
public void saveDocWithoutHandlerProcessing(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
DocumentModel docModel,
boolean fSaveSession)
throws ClientException, DocumentException {
*/
public void saveDocListWithoutHandlerProcessing(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
DocumentModelList docList,
boolean fSaveSession)
throws ClientException, DocumentException {
if (logger.isDebugEnabled()) {
logger.debug("Deleting document with CSID=" + id);
}
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
handler.prepare(Action.DELETE);
repoSession = getRepositorySession(ctx);
@Override
public String createDomain(RepositoryDomainType repositoryDomain) throws Exception {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
String domainId = null;
try {
//
@Override
public String getDomainId(RepositoryDomainType repositoryDomain) throws Exception {
String domainId = null;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
String repoName = repositoryDomain.getRepositoryName();
String domainStorageName = repositoryDomain.getStorageName();
/*
* Returns the workspaces root directory for a given domain.
*/
- private DocumentModel getWorkspacesRoot(RepositoryInstance repoSession,
+ private DocumentModel getWorkspacesRoot(RepositoryInstanceInterface repoSession,
String domainName) throws Exception {
DocumentModel result = null;
*/
@Override
public String createWorkspace(RepositoryDomainType repositoryDomain, String workspaceName) throws Exception {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
String workspaceId = null;
try {
String repoName = repositoryDomain.getRepositoryName();
public String getWorkspaceId(String tenantDomain, String workspaceName) throws Exception {
String workspaceId = null;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
try {
repoSession = getRepositorySession((ServiceContext) null);
DocumentRef docRef = new PathRef(
return workspaceId;
}
- public RepositoryInstance getRepositorySession(ServiceContext ctx) throws Exception {
+ public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx) throws Exception {
return getRepositorySession(ctx, ctx.getRepositoryName());
}
- public RepositoryInstance getRepositorySession(String repoName) throws Exception {
+ public RepositoryInstanceInterface getRepositorySession(String repoName) throws Exception {
return getRepositorySession(null, repoName);
}
* @return the repository session
* @throws Exception the exception
*/
- public RepositoryInstance getRepositorySession(ServiceContext ctx, String repoName) throws Exception {
- RepositoryInstance repoSession = null;
+ public RepositoryInstanceInterface getRepositorySession(ServiceContext ctx, String repoName) throws Exception {
+ RepositoryInstanceInterface 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 = (RepositoryInstance) ctx.getCurrentRepositorySession(); // Look to see if one exists in the context before creating one
+ repoSession = (RepositoryInstanceInterface) 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, RepositoryInstance repoSession) throws TransactionException {
+ public void releaseRepositorySession(ServiceContext ctx, RepositoryInstanceInterface repoSession) throws TransactionException {
try {
NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
// release session
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.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.storage.sql.Binary;
import org.nuxeo.ecm.core.storage.sql.coremodel.SQLBlob;
import org.nuxeo.runtime.api.Framework;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @return
* @throws DocumentException
*/
- public static Document getDocument(RepositoryInstance repoSession, DocumentModel nuxeoDoc)
+ public static Document getDocument(RepositoryInstanceInterface repoSession, DocumentModel nuxeoDoc)
throws DocumentException {
Document doc = null;
DocumentWriter writer = null;
try {
baos = new ByteArrayOutputStream();
//nuxeo io.impl begin
- reader = new SingleDocumentReader(repoSession, nuxeoDoc);
+ reader = new SingleDocumentReader(repoSession.getRepositoryInstance(), nuxeoDoc);
writer = new XMLDocumentWriter(baos);
DocumentPipe pipe = new DocumentPipeImpl();
//nuxeo io.impl end
*
* @throws DocumentException the document exception
*/
- public static Document getDocument(RepositoryInstance repoSession, String csid)
+ public static Document getDocument(RepositoryInstanceInterface repoSession, String csid)
throws DocumentException {
Document result = null;
* @throws ClientException the client exception
*/
public static DocumentModel getWorkspaceModel(
- RepositoryInstance repoSession, String workspaceName)
+ RepositoryInstanceInterface 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(
- RepositoryInstance repoSession, String nuxeoId)
+ RepositoryInstanceInterface repoSession, String nuxeoId)
throws DocumentException {
DocumentModel result = null;
static public DocumentModel getDocFromCsid(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
String csid) throws Exception {
DocumentModel result = null;
return id;
}
- public static boolean documentExists(RepositoryInstance repoSession,
+ public static boolean documentExists(RepositoryInstanceInterface repoSession,
String csid) throws ClientException {
boolean result = false;
--- /dev/null
+/target
+/target
import java.util.HashMap;\r
import java.util.Map;\r
import java.util.TreeSet;\r
+\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.nuxeo.client.java.NuxeoClientEmbedded;\r
import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryInstanceInterface;\r
import org.nuxeo.ecm.core.api.DocumentModel;\r
import org.nuxeo.ecm.core.api.DocumentRef;\r
import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
File file = new File(src);\r
///cspace way of configuring client and auth:\r
NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();\r
- RepositoryInstance repoSession = null;\r
+ RepositoryInstanceInterface repoSession = null;\r
try {\r
repoSession = client.openRepository(repoName, timeOut);\r
if (logger.isDebugEnabled()) {\r
}\r
}\r
\r
- String importTree(RepositoryInstance repoSession, File file, String toPath) throws Exception {\r
+ String importTree(RepositoryInstanceInterface repoSession, File file, String toPath) throws Exception {\r
Exception failed = null;\r
DocumentReader reader = null;\r
DocumentWriter writer = null;\r
logger.info("importTree reading file: " + file + (file != null ? " exists? " + file.exists() : " file param is null"));\r
}\r
reader = new LoggedXMLDirectoryReader(file); //our overload of XMLDirectoryReader.\r
- writer = new DocumentModelWriter(repoSession, toPath, 10);\r
+ writer = new DocumentModelWriter(repoSession.getRepositoryInstance(), toPath, 10);\r
DocumentPipe pipe = new DocumentPipeImpl(10);\r
// pipe.addTransformer(transformer);\r
pipe.setReader(reader);\r
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.RepositoryJavaClientImpl;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
DocumentModel relationDocModel = wrapDoc.getWrappedObject();
String errMsg = ERROR_TERMS_IN_WORKFLOWSTATE + workflowState;
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface repoSession = this.getRepositorySession();
try {
DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL);
DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL);
// Note that this introduces another caching problem...
DocumentModel relationDocModel = wrapDoc.getWrappedObject();
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
- RepositoryInstance repoSession = this.getRepositorySession();
+ RepositoryInstanceInterface repoSession = this.getRepositorySession();
DocumentModel subjectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, SUBJ_DOC_MODEL);
DocumentModel objectDocModel = getSubjectOrObjectDocModel(repoSession, relationDocModel, OBJ_DOC_MODEL);
private final boolean OBJ_DOC_MODEL = false;
private DocumentModel getSubjectOrObjectDocModel(
- RepositoryInstance repoSession,
+ RepositoryInstanceInterface repoSession,
DocumentModel relationDocModel,
boolean fSubject) throws Exception {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
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.RepositoryJavaClientImpl;
import org.jfree.util.Log;
import org.nuxeo.ecm.core.api.DocumentModel;
InvocationContext invContext,
StringBuffer outMimeType,
StringBuffer outReportFileName) throws Exception {
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
boolean releaseRepoSession = false;
String invocationMode = invContext.getMode();
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.RepositoryJavaClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
List<String> serviceGroupNames) throws Exception {
CommonList commonList = new CommonList();
AbstractCommonList list = (AbstractCommonList)commonList;
- RepositoryInstance repoSession = null;
+ RepositoryInstanceInterface repoSession = null;
boolean releaseRepoSession = false;
try {