chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r935906 [2/2] - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main...
Date Tue, 20 Apr 2010 13:28:25 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -36,7 +36,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.server.spi.CmisRepositoryService;
 
-public class InMemoryRepositoryServiceImpl extends AbstractServiceImpl implements CmisRepositoryService {
+public class InMemoryRepositoryServiceImpl extends InMemoryAbstractServiceImpl  implements CmisRepositoryService  {
 
 	public InMemoryRepositoryServiceImpl(StoreManager storeManager) {
 		super(storeManager);
@@ -44,10 +44,6 @@ public class InMemoryRepositoryServiceIm
 
 	public RepositoryInfo getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
 
-		// Attach the CallContext to a thread local context that can be accessed
-		// from everywhere
-		RuntimeContext.attachCfg(context);
-
 		RepositoryInfo repoInfo = getRepositoryInfoFromStoreManager(repositoryId);
 
 		return repoInfo;
@@ -55,118 +51,90 @@ public class InMemoryRepositoryServiceIm
 
 	public List<RepositoryInfo> getRepositoryInfos(CallContext context, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			List<RepositoryInfo> res = new ArrayList<RepositoryInfo>();
-			List<String> repIds = fStoreManager.getAllRepositoryIds();
-			for (String repId : repIds) {
-				res.add(fStoreManager.getRepositoryInfo(repId));
-			}
-			return res;
-		} finally {
-			RuntimeContext.remove();
+
+		List<RepositoryInfo> res = new ArrayList<RepositoryInfo>();
+		List<String> repIds = fStoreManager.getAllRepositoryIds();
+		for (String repId : repIds) {
+			res.add(fStoreManager.getRepositoryInfo(repId));
 		}
+		return res;
 	}
 
 	public TypeDefinitionList getTypeChildren(CallContext context, String repositoryId, String typeId,
 			Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			getRepositoryInfoFromStoreManager(repositoryId); // just to check if
-																// repository
-																// exists
-
-			int skip = skipCount == null ? 0 : skipCount.intValue();
-			int max = maxItems == null ? -1 : maxItems.intValue();
-
-			TypeDefinitionListImpl result = new TypeDefinitionListImpl();
-			List<TypeDefinitionContainer> children;
-			if (typeId == null) {
-				// spec says that base types must be returned in this case
-				children = fStoreManager.getRootTypes(repositoryId);
-			} else {
-				children = getTypeDescendants(context, repositoryId, typeId, BigInteger.valueOf(1),
-						includePropertyDefinitions, null);
-			}
-			result.setNumItems(BigInteger.valueOf(children.size()));
-			result.setHasMoreItems(children.size() > max - skip);
-			List<TypeDefinition> childrenTypes = new ArrayList<TypeDefinition>();
-			ListIterator<TypeDefinitionContainer> it = children.listIterator(skip);
-			if (max < 0)
-				max = children.size();
-			for (int i = skip; i < max + skip && it.hasNext(); i++)
-				childrenTypes.add(it.next().getTypeDefinition());
-
-			result.setList(childrenTypes);
-			return result;
-		} finally {
-			RuntimeContext.remove();
+
+		getRepositoryInfoFromStoreManager(repositoryId); // just to check if
+		// repository
+		// exists
+
+		int skip = skipCount == null ? 0 : skipCount.intValue();
+		int max = maxItems == null ? -1 : maxItems.intValue();
+
+		TypeDefinitionListImpl result = new TypeDefinitionListImpl();
+		List<TypeDefinitionContainer> children;
+		if (typeId == null) {
+			// spec says that base types must be returned in this case
+			children = fStoreManager.getRootTypes(repositoryId);
+		} else {
+			children = getTypeDescendants(context, repositoryId, typeId, BigInteger.valueOf(1),
+					includePropertyDefinitions, null);
 		}
+		result.setNumItems(BigInteger.valueOf(children.size()));
+		result.setHasMoreItems(children.size() > max - skip);
+		List<TypeDefinition> childrenTypes = new ArrayList<TypeDefinition>();
+		ListIterator<TypeDefinitionContainer> it = children.listIterator(skip);
+		if (max < 0)
+			max = children.size();
+		for (int i = skip; i < max + skip && it.hasNext(); i++)
+			childrenTypes.add(it.next().getTypeDefinition());
+
+		result.setList(childrenTypes);
+		return result;
 	}
 
 	public TypeDefinition getTypeDefinition(CallContext context, String repositoryId, String typeId,
 			ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			getRepositoryInfoFromStoreManager(repositoryId); // just to check if
-																// repository
-																// exists
-
-			TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId);
-			if (tc != null) {
-				return tc.getTypeDefinition();
-			} else
-				throw new CmisObjectNotFoundException("unknown type id: " + typeId);
-		} finally {
-			RuntimeContext.remove();
-		}
+
+		getRepositoryInfoFromStoreManager(repositoryId); // just to check if
+		// repository
+		// exists
+
+		TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId);
+		if (tc != null) {
+			return tc.getTypeDefinition();
+		} else
+			throw new CmisObjectNotFoundException("unknown type id: " + typeId);
 	}
 
 	public List<TypeDefinitionContainer> getTypeDescendants(CallContext context, String repositoryId, String typeId,
 			BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			getRepositoryInfoFromStoreManager(repositoryId); // just to check if
-																// repository
-																// exists
-
-			if (depth != null && depth.intValue() == 0)
-				throw new CmisInvalidArgumentException("depth == 0 is illegal in getTypeDescendants");
-
-			List<TypeDefinitionContainer> result = null;
-			if (typeId == null) {
-				// spec says that depth must be ignored in this case
-				Collection<TypeDefinitionContainer> tmp = fStoreManager.getTypeDefinitionList(repositoryId,
-						includePropertyDefinitions);
-				result = new ArrayList<TypeDefinitionContainer>(tmp);
-			} else {
-				TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId,
-						includePropertyDefinitions, depth == null ? -1 : depth.intValue());
-				if (tc == null)
-					throw new CmisInvalidArgumentException("unknown type id: " + typeId);
-				else
-					result = tc.getChildren();
-			}
-
-			return result;
-		} finally {
-			RuntimeContext.remove();
+
+		getRepositoryInfoFromStoreManager(repositoryId); // just to check if
+		// repository
+		// exists
+
+		if (depth != null && depth.intValue() == 0)
+			throw new CmisInvalidArgumentException("depth == 0 is illegal in getTypeDescendants");
+
+		List<TypeDefinitionContainer> result = null;
+		if (typeId == null) {
+			// spec says that depth must be ignored in this case
+			Collection<TypeDefinitionContainer> tmp = fStoreManager.getTypeDefinitionList(repositoryId,
+					includePropertyDefinitions);
+			result = new ArrayList<TypeDefinitionContainer>(tmp);
+		} else {
+			TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId,
+					includePropertyDefinitions, depth == null ? -1 : depth.intValue());
+			if (tc == null)
+				throw new CmisInvalidArgumentException("unknown type id: " + typeId);
+			else
+				result = tc.getChildren();
 		}
+
+		return result;
 	}
 
 	private RepositoryInfo getRepositoryInfoFromStoreManager(String repositoryId) {

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java?rev=935906&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java Tue Apr 20 13:28:25 2010
@@ -0,0 +1,555 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.apache.chemistry.opencmis.inmemory.server;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.api.Acl;
+import org.apache.chemistry.opencmis.commons.api.AllowableActions;
+import org.apache.chemistry.opencmis.commons.api.BindingsObjectFactory;
+import org.apache.chemistry.opencmis.commons.api.ContentStream;
+import org.apache.chemistry.opencmis.commons.api.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.api.FailedToDeleteData;
+import org.apache.chemistry.opencmis.commons.api.Holder;
+import org.apache.chemistry.opencmis.commons.api.NavigationService;
+import org.apache.chemistry.opencmis.commons.api.ObjectData;
+import org.apache.chemistry.opencmis.commons.api.ObjectInFolderContainer;
+import org.apache.chemistry.opencmis.commons.api.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.api.ObjectList;
+import org.apache.chemistry.opencmis.commons.api.ObjectParentData;
+import org.apache.chemistry.opencmis.commons.api.ObjectService;
+import org.apache.chemistry.opencmis.commons.api.Properties;
+import org.apache.chemistry.opencmis.commons.api.RenditionData;
+import org.apache.chemistry.opencmis.commons.api.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.api.RepositoryService;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.api.server.CallContext;
+import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
+import org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService;
+import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
+import org.apache.chemistry.opencmis.inmemory.clientprovider.NavigationServiceImpl;
+import org.apache.chemistry.opencmis.inmemory.clientprovider.ObjectServiceImpl;
+import org.apache.chemistry.opencmis.inmemory.clientprovider.RepositoryServiceImpl;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerFactory;
+import org.apache.chemistry.opencmis.inmemory.storedobj.impl.StoreManagerImpl;
+import org.apache.chemistry.opencmis.server.support.DiscoveryServiceWrapper;
+import org.apache.chemistry.opencmis.server.support.NavigationServiceWrapper;
+import org.apache.chemistry.opencmis.server.support.ObjectServiceWrapper;
+import org.apache.chemistry.opencmis.server.support.RepositoryServiceWrapper;
+import org.apache.chemistry.opencmis.server.support.VersioningServiceWrapper;
+import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class InMemoryService  extends AbstractCmisService {
+
+	private static final Log LOG = LogFactory.getLog(InMemoryService.class.getName());
+
+	private StoreManager fStoreManager; // singleton root of everything
+
+	private InMemoryRepositoryServiceImpl fRepSvc;
+	private InMemoryObjectServiceImpl fObjSvc;
+	private InMemoryNavigationServiceImpl fNavSvc;
+	private InMemoryVersioningServiceImpl fVerSvc;
+	private InMemoryDiscoveryServiceImpl fDisSvc;
+	private InMemoryMultiFilingServiceImpl fMultiSvc;
+
+	public StoreManager getStoreManager() {
+		return fStoreManager;
+	}
+
+	public InMemoryService(Map<String, String> parameters) {
+
+		// initialize in-memory management
+		String repositoryClassName = (String) parameters.get(ConfigConstants.REPOSITORY_CLASS);
+		if (null == repositoryClassName)
+			repositoryClassName = StoreManagerImpl.class.getName();
+
+		if (null == fStoreManager)
+			fStoreManager = StoreManagerFactory.createInstance(repositoryClassName);
+
+		String repositoryId = parameters.get(ConfigConstants.REPOSITORY_ID);
+
+		List<String> allAvailableRepositories = fStoreManager.getAllRepositoryIds();
+
+		// init existing repositories
+		for (String existingRepId : allAvailableRepositories)
+			fStoreManager.initRepository(existingRepId);
+
+		// create repository if configured as a startup parameter
+		if (null != repositoryId) {
+			if (allAvailableRepositories.contains(repositoryId))
+				LOG.warn("Repostory " + repositoryId + " already exists and will not be created.");
+			else {
+				String typeCreatorClassName = parameters.get(ConfigConstants.TYPE_CREATOR_CLASS);
+				fStoreManager.createAndInitRepository(repositoryId, typeCreatorClassName);
+			}
+		}
+
+		// With some special configuration settings fill the repository with
+		// some documents and folders
+		// if is empty
+		if (!allAvailableRepositories.contains(repositoryId))
+			fillRepositoryIfConfigured(parameters, repositoryId);
+
+		
+		fRepSvc = new InMemoryRepositoryServiceImpl(fStoreManager);
+		fNavSvc = new InMemoryNavigationServiceImpl(fStoreManager);
+		fObjSvc = new InMemoryObjectServiceImpl(fStoreManager);
+		fVerSvc = new InMemoryVersioningServiceImpl(fStoreManager, fObjSvc);
+		fDisSvc = new InMemoryDiscoveryServiceImpl(fStoreManager, fRepSvc, fNavSvc);
+	    fMultiSvc = new InMemoryMultiFilingServiceImpl(fStoreManager);
+
+	}
+	
+
+	// --- repository service ---
+
+	@Override
+	public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
+		return fRepSvc.getRepositoryInfos(null, extension);
+	}
+
+	public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
+		return fRepSvc.getRepositoryInfo(null, repositoryId, extension);
+	}
+
+	public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		return fRepSvc.getTypeChildren(null, repositoryId, typeId, includePropertyDefinitions, maxItems, skipCount, extension);
+	}
+
+	public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
+		return fRepSvc.getTypeDefinition(null, repositoryId, typeId, extension);
+	}
+
+	public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
+			Boolean includePropertyDefinitions, ExtensionsData extension) {
+		return fRepSvc.getTypeDescendants(null, repositoryId, typeId, depth, includePropertyDefinitions, extension);
+	}
+
+	// --- navigation service ---
+
+	public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		return fNavSvc.getCheckedOutDocs(null, repositoryId, folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension, null);
+	}
+
+	public ObjectInFolderList getChildren(String repositoryId, String folderId, String filter, String orderBy,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		return fNavSvc.getChildren(null, repositoryId, folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, extension, null);
+	}
+
+	public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
+			String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
+//		List<ObjectInFolderContainer> res =  super.getDescendants(repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension);
+		return fNavSvc.getDescendants(null, repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension, null);
+//		return res;
+	}
+
+	public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
+//		ObjectData res =  super.getFolderParent(repositoryId, folderId, filter, extension);
+		return fNavSvc.getFolderParent(null, repositoryId, folderId, filter, extension, null);
+//		return res;
+	}
+
+	public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
+			String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
+//		List<ObjectInFolderContainer> res = super.getFolderTree(repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension);
+		return fNavSvc.getFolderTree(null, repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension, null);
+//		return res;
+	}
+
+	public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			Boolean includeRelativePathSegment, ExtensionsData extension) {
+		return fNavSvc.getObjectParents(null, repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, extension, null);
+	}
+
+	// --- object service ---
+
+	public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
+			VersioningState versioningState, List<String> policies, ExtensionsData extension) {
+//		super.create(repositoryId, properties, folderId, contentStream, versioningState, policies, extension);
+		ObjectData od = fObjSvc.create(null, repositoryId, properties, folderId, contentStream, versioningState, policies, extension, null);
+		return od.getId();
+
+	}
+
+	public String createDocument(String repositoryId, Properties properties, String folderId,
+			ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
+			Acl removeAces, ExtensionsData extension) {
+//		super.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
+		return fObjSvc.createDocument(null, repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
+	}
+
+	public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
+			String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
+			ExtensionsData extension) {
+//		super.createDocumentFromSource(repositoryId, sourceId, properties, folderId, versioningState, policies, addAces, removeAces, extension);
+		return fObjSvc.createDocumentFromSource(null, repositoryId, sourceId, properties, folderId, versioningState, policies, addAces, removeAces, extension);
+	}
+
+	public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
+			Acl addAces, Acl removeAces, ExtensionsData extension) {
+//		super.createFolder(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+		return fObjSvc.createFolder(null, repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+	}
+
+	public String createPolicy(String repositoryId, Properties properties, String folderId, List<String> policies,
+			Acl addAces, Acl removeAces, ExtensionsData extension) {
+//		super.createPolicy(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+		return fObjSvc.createPolicy(null, repositoryId, properties, folderId, policies, addAces, removeAces, extension);
+	}
+
+	public String createRelationship(String repositoryId, Properties properties, List<String> policies, Acl addAces,
+			Acl removeAces, ExtensionsData extension) {
+//		super.createRelationship(repositoryId, properties, policies, addAces, removeAces, extension);
+		return fObjSvc.createRelationship(null, repositoryId, properties, policies, addAces, removeAces, extension);
+	}
+
+	public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
+			ExtensionsData extension) {
+//		super.deleteContentStream(repositoryId, objectId, changeToken, extension);
+		fObjSvc.deleteContentStream(null, repositoryId, objectId, changeToken, extension);
+	}
+
+	public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension) {
+//		super.deleteObject(repositoryId, objectId, allVersions, extension);
+		fObjSvc.deleteObjectOrCancelCheckOut(null, repositoryId, objectId, allVersions, extension);
+	}
+
+	public void deleteObjectOrCancelCheckOut(String repositoryId, String objectId, Boolean allVersions,
+			ExtensionsData extension) {
+//		super.deleteObjectOrCancelCheckOut(repositoryId, objectId, allVersions, extension);
+		fObjSvc.deleteObjectOrCancelCheckOut(null, repositoryId, objectId, allVersions, extension);
+	}
+
+	public FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
+			UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
+//		super.deleteTree(repositoryId, folderId, allVersions, unfileObjects, continueOnFailure, extension);
+		return fObjSvc.deleteTree(null, repositoryId, folderId, allVersions, unfileObjects, continueOnFailure, extension);
+	}
+
+	public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
+//		super.getAllowableActions(repositoryId, objectId, extension);
+		return fObjSvc.getAllowableActions(null, repositoryId, objectId, extension);
+	}
+
+	public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
+			BigInteger length, ExtensionsData extension) {
+//		super.getContentStream(repositoryId, objectId, streamId, offset, length, extension);
+		return fObjSvc.getContentStream(null, repositoryId, objectId, streamId, offset, length, extension);
+	}
+
+	public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
+			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
+			Boolean includeAcl, ExtensionsData extension) {
+		return fObjSvc.getObject(null, repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension, null);
+	}
+
+	public ObjectData getObjectByPath(String repositoryId, String path, String filter, Boolean includeAllowableActions,
+			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
+			Boolean includeAcl, ExtensionsData extension) {
+//		super.getObjectByPath(repositoryId, path, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
+		return fObjSvc.getObjectByPath(null, repositoryId, path, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension, null);
+	}
+
+	public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
+//		super.getProperties(repositoryId, objectId, filter, extension);
+		return fObjSvc.getProperties(null, repositoryId, objectId, filter, extension);
+	}
+
+	public List<RenditionData> getRenditions(String repositoryId, String objectId, String renditionFilter,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+//		super.getRenditions(repositoryId, objectId, renditionFilter, maxItems, skipCount, extension);
+		return fObjSvc.getRenditions(null, repositoryId, objectId, renditionFilter, maxItems, skipCount, extension);		
+	}
+
+	public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
+			ExtensionsData extension) {
+//		super.moveObject(repositoryId, objectId, targetFolderId, sourceFolderId, extension);
+		fObjSvc.moveObject(null, repositoryId, objectId, targetFolderId, sourceFolderId, extension, null);
+	}
+
+	public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
+			Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
+//		super.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
+		fObjSvc.setContentStream(null, repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
+	}
+
+	public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
+			Properties properties, ExtensionsData extension) {
+//		super.updateProperties(repositoryId, objectId, changeToken, properties, extension);
+		fObjSvc.updateProperties(null, repositoryId, objectId, changeToken, properties, null, extension, null);
+	}
+
+	// --- versioning service ---
+
+	public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
+//		super.cancelCheckOut(repositoryId, objectId, extension);
+		fVerSvc.cancelCheckOut(null, repositoryId, objectId, extension);
+	}
+
+	public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
+			ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
+			ExtensionsData extension) {
+//		super.checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment, policies, addAces, removeAces, extension);
+		fVerSvc.checkIn(null, repositoryId, objectId, major, properties, contentStream, checkinComment, policies, addAces, removeAces, extension, null);
+	}
+
+	public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
+			Holder<Boolean> contentCopied) {
+//		super.checkOut(repositoryId, objectId, extension, contentCopied);
+		fVerSvc.checkOut(null, repositoryId, objectId, extension, contentCopied, null);
+	}
+
+	public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
+			Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
+//		super.getObjectOfLatestVersion(repositoryId, objectId, versionSeriesId, major, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
+		return fVerSvc.getObjectOfLatestVersion(null, repositoryId, versionSeriesId, major, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension, null);
+	}
+
+	public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
+			Boolean major, String filter, ExtensionsData extension) {
+//		super.getPropertiesOfLatestVersion(repositoryId, objectId, versionSeriesId, major, filter, extension);
+		return fVerSvc.getPropertiesOfLatestVersion(null, repositoryId, versionSeriesId, major, filter, extension);
+	}
+
+	public List<ObjectData> getAllVersions(String repositoryId, String objectId, String versionSeriesId, String filter,
+			Boolean includeAllowableActions, ExtensionsData extension) {
+//		super.getAllVersions(repositoryId, objectId, versionSeriesId, filter, includeAllowableActions, extension);
+		return fVerSvc.getAllVersions(null, repositoryId, versionSeriesId, filter, includeAllowableActions, extension, null);
+	}
+
+	// --- discovery service ---
+
+	public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
+			String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
+		return super.getContentChanges(repositoryId, changeLogToken, includeProperties, filter, includePolicyIds, includeAcl, maxItems, extension);
+	}
+
+	public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		return super.query(repositoryId, statement, searchAllVersions, includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension);
+	}
+
+	// --- multi filing service ---
+
+	public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
+			ExtensionsData extension) {
+//		super.addObjectToFolder(repositoryId, objectId, folderId, allVersions, extension);
+		fMultiSvc.addObjectToFolder(null, repositoryId, objectId, folderId, allVersions, extension, null);
+	}
+
+	public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
+//		super.removeObjectFromFolder(repositoryId, objectId, folderId, extension);
+		fMultiSvc.removeObjectFromFolder(null, repositoryId, objectId, folderId, extension, null);
+	}
+
+	// --- relationship service ---
+
+	public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
+			RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		return super.getObjectRelationships(repositoryId, objectId, includeSubRelationshipTypes, relationshipDirection, typeId, filter, includeAllowableActions, maxItems, skipCount, extension);
+	}
+
+	// --- ACL service ---
+
+	public Acl applyAcl(String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
+		return super.applyAcl(repositoryId, objectId, aces, aclPropagation);
+	}
+
+	public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
+			AclPropagation aclPropagation, ExtensionsData extension) {
+		return super.applyAcl(repositoryId, objectId, addAces, removeAces, aclPropagation, extension);
+	}
+
+	public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
+		return super.getAcl(repositoryId, objectId, onlyBasicPermissions, extension);
+	}
+
+	// --- policy service ---
+
+	public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+		super.applyPolicy(repositoryId, policyId, objectId, extension);
+	}
+
+	public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
+			ExtensionsData extension) {
+		return super.getAppliedPolicies(repositoryId, objectId, filter, extension);
+	}
+
+	public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+		super.removePolicy(repositoryId, policyId, objectId, extension);
+	}
+
+	////////////////
+    //	
+	private void fillRepositoryIfConfigured(Map<String, String> parameters, String repositoryId) {
+		class DummyCallContext implements CallContext {
+
+			public String get(String key) {
+				return null;
+			}
+
+			public String getBinding() {
+				return null;
+			}
+
+			public boolean isObjectInfoRequired() {
+				return false;
+			}
+
+			public String getRepositoryId() {
+				return null;
+			}
+
+			public String getLocale() {
+				return null;
+			}
+
+			public String getPassword() {
+				return null;
+			}
+
+			public String getUsername() {
+				return null;
+			}
+		}
+
+		String doFillRepositoryStr = parameters.get(ConfigConstants.USE_REPOSITORY_FILER);
+		boolean doFillRepository = doFillRepositoryStr == null ? false : Boolean.parseBoolean(doFillRepositoryStr);
+
+		if (!doFillRepository)
+			return;
+
+		BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
+		NavigationService navSvc = new NavigationServiceImpl(fNavSvc);
+		ObjectService objSvc = new ObjectServiceImpl(fObjSvc);
+		RepositoryService repSvc = new RepositoryServiceImpl(fRepSvc);
+
+		String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
+		int levels = 1;
+		if (null != levelsStr)
+			levels = Integer.parseInt(levelsStr);
+
+		String docsPerLevelStr = parameters.get(ConfigConstants.FILLER_DOCS_PER_FOLDER);
+		int docsPerLevel = 1;
+		if (null != docsPerLevelStr)
+			docsPerLevel = Integer.parseInt(docsPerLevelStr);
+
+		String childrenPerLevelStr = parameters.get(ConfigConstants.FILLER_FOLDERS_PER_FOLDER);
+		int childrenPerLevel = 2;
+		if (null != childrenPerLevelStr)
+			childrenPerLevel = Integer.parseInt(childrenPerLevelStr);
+
+		String documentTypeId = parameters.get(ConfigConstants.FILLER_DOCUMENT_TYPE_ID);
+		if (null == documentTypeId)
+			documentTypeId = BaseTypeId.CMIS_DOCUMENT.value();
+
+		String folderTypeId = parameters.get(ConfigConstants.FILLER_FOLDER_TYPE_ID);
+		if (null == folderTypeId)
+			folderTypeId = BaseTypeId.CMIS_FOLDER.value();
+
+		int contentSizeKB = 0;
+		String contentSizeKBStr = parameters.get(ConfigConstants.FILLER_CONTENT_SIZE);
+		if (null != contentSizeKBStr)
+			contentSizeKB = Integer.parseInt(contentSizeKBStr);
+
+		// Create a hierarchy of folders and fill it with some documents
+		ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repositoryId);
+
+		gen.setNumberOfDocumentsToCreatePerFolder(docsPerLevel);
+
+		// Set the type id for all created documents:
+		gen.setDocumentTypeId(documentTypeId);
+
+		// Set the type id for all created folders:
+		gen.setFolderTypeId(folderTypeId);
+
+		// Set contentSize
+		gen.setContentSizeInKB(contentSizeKB);
+
+		// set properties that need to be filled
+		// set the properties the generator should fill with values for
+		// documents:
+		// Note: must be valid properties in configured document and folder type
+
+		List<String> propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_DOCUMENT_PROPERTY);
+		if (null != propsToSet)
+			gen.setDocumentPropertiesToGenerate(propsToSet);
+
+		propsToSet = readPropertiesToSetFromConfig(parameters, ConfigConstants.FILLER_FOLDER_PROPERTY);
+		if (null != propsToSet)
+			gen.setFolderPropertiesToGenerate(propsToSet);
+
+		// Simulate a runtime context with configuration parameters
+		// Attach the CallContext to a thread local context that can be accessed
+		// from everywhere
+		RuntimeContext.attachCfg(new DummyCallContext());
+
+		// Build the tree
+		RepositoryInfo rep = repSvc.getRepositoryInfo(repositoryId, null);
+		String rootFolderId = rep.getRootFolderId();
+
+		try {
+			gen.createFolderHierachy(levels, childrenPerLevel, rootFolderId);
+			// Dump the tree
+			gen.dumpFolder(rootFolderId, "*");
+		} catch (Exception e) {
+			LOG.error("Could not create folder hierarchy with documents. " + e);
+			e.printStackTrace();
+		}
+
+	}
+
+	private List<String> readPropertiesToSetFromConfig(Map<String, String> parameters, String keyPrefix) {
+		List<String> propsToSet = new ArrayList<String>();
+		for (int i = 0;; ++i) {
+			String propertyKey = keyPrefix + Integer.toString(i);
+			String propertyToAdd = parameters.get(propertyKey);
+			if (null == propertyToAdd)
+				break;
+			else
+				propsToSet.add(propertyToAdd);
+		}
+		return propsToSet;
+	}
+
+}

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java?rev=935906&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java Tue Apr 20 13:28:25 2010
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.apache.chemistry.opencmis.inmemory.server;
+
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.api.server.CallContext;
+import org.apache.chemistry.opencmis.commons.api.server.CmisService;
+import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
+import org.apache.chemistry.opencmis.inmemory.ConfigConstants;
+import org.apache.chemistry.opencmis.server.support.CmisServiceWrapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class InMemoryServiceFactoryImpl extends AbstractServiceFactory {
+
+	private static final Log LOG = LogFactory.getLog(InMemoryServiceFactoryImpl.class.getName());
+	private static final BigInteger DEFAULT_MAX_ITEMS_OBJECTS = BigInteger.valueOf(1000);
+	private static final BigInteger DEFAULT_MAX_ITEMS_TYPES = BigInteger.valueOf(100);
+	private static final BigInteger DEFAULT_DEPTH_OBJECTS = BigInteger.valueOf(2);
+	private static final BigInteger DEFAULT_DEPTH_TYPES = BigInteger.valueOf(-1);
+	private static CallContext OVERRIDE_CTX;
+
+	private InMemoryService inMemoryService;
+	private CmisService wrapperService;
+	private boolean fUseOverrideCtx = false;
+	
+	@Override
+	public void init(Map<String, String> parameters) {
+		LOG.info("Initializing in-memory repository...");
+
+
+		inMemoryService = new InMemoryService(parameters);
+		wrapperService = new CmisServiceWrapper(inMemoryService, DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES,
+				DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);
+		String overrideCtx = parameters.get(ConfigConstants.OVERRIDE_CALL_CONTEXT);
+		if (null != overrideCtx)
+			fUseOverrideCtx = true;
+
+		LOG.info("...initialized in-memory repository.");
+	}
+
+	public static void setOverrideCallContext(CallContext ctx) {
+		OVERRIDE_CTX = ctx;
+	}
+	
+	@Override
+	public CmisService getService(CallContext context) {
+		try {
+			LOG.debug("start getService()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			// Some unit tests set their own context. So if we find one then we use
+			// this one and ignore the provided one. Otherwise we set a new context.
+			if (fUseOverrideCtx && null != OVERRIDE_CTX) {
+				RuntimeContext.attachCfg(OVERRIDE_CTX);
+			} else {
+				RuntimeContext.attachCfg(context);				
+			}
+			LOG.debug("stop getService()");
+			return inMemoryService; //wrapperService;
+			
+		} finally {
+//			RuntimeContext.remove();
+		}
+	}
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -46,12 +46,12 @@ import org.apache.chemistry.opencmis.ser
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryVersioningServiceImpl extends AbstractServiceImpl implements CmisVersioningService {
+public class InMemoryVersioningServiceImpl extends InMemoryAbstractServiceImpl implements CmisVersioningService {
 
 	private static final Log LOG = LogFactory.getLog(InMemoryVersioningServiceImpl.class.getName());
 
 	InMemoryObjectServiceImpl fObjectService; // real implementation of the
-												// service
+	// service
 	AtomLinkInfoProvider fAtomLinkProvider;
 
 	public InMemoryVersioningServiceImpl(StoreManager storeManager, InMemoryObjectServiceImpl objectService) {
@@ -62,136 +62,104 @@ public class InMemoryVersioningServiceIm
 
 	public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-			VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
-
-			verDoc.cancelCheckOut(user);
-		} finally {
-			RuntimeContext.remove();
-		}
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
+		String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
+		VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
+
+		verDoc.cancelCheckOut(user);
 	}
 
 	public ObjectData checkIn(CallContext context, String repositoryId, Holder<String> objectId, Boolean major,
 			Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
 			Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+		String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
+		VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
 
-			StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-			VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
+		DocumentVersion pwc = verDoc.getPwc();
 
-			DocumentVersion pwc = verDoc.getPwc();
+		if (null != contentStream)
+			pwc.setContent(contentStream, false);
 
-			if (null != contentStream)
-				pwc.setContent(contentStream, false);
+		if (null != properties && null != properties.getProperties())
+			pwc.setCustomProperties(properties.getProperties());
 
-			if (null != properties && null != properties.getProperties())
-				pwc.setCustomProperties(properties.getProperties());
+		verDoc.checkIn(major, checkinComment, user);
 
-			verDoc.checkIn(major, checkinComment, user);
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
 
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false, IncludeRelationships.NONE,
+				null, false, false, extension);
 
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-					IncludeRelationships.NONE, null, false, false, extension);
-
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+		return od;
 	}
 
 	public ObjectData checkOut(CallContext context, String repositoryId, Holder<String> objectId,
 			ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-			TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
-			if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
-				throw new CmisNotSupportedException("Only documents can be checked-out.");
-			else if (!((DocumentTypeDefinition) typeDef).isVersionable())
-				throw new CmisNotSupportedException("Object can't be checked-out, type is not versionable.");
-
-			checkIsVersionableObject(so);
-
-			VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
-
-			ContentStream content = null;
-
-			if (so instanceof DocumentVersion) {
-				// get document the version is contained in to c
-				content = ((DocumentVersion) so).getContent(0, -1);
-			} else {
-				content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
-			}
-
-			if (verDoc.isCheckedOut())
-				throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
-
-			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-			checkHasUser(user);
-
-			DocumentVersion pwc = verDoc.checkOut(content, user);
-			objectId.setValue(pwc.getId()); // return the id of the created pwc
-
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-					IncludeRelationships.NONE, null, false, false, extension);
-
-			return od;
-		} finally {
-			RuntimeContext.remove();
+		StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+		TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
+		if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
+			throw new CmisNotSupportedException("Only documents can be checked-out.");
+		else if (!((DocumentTypeDefinition) typeDef).isVersionable())
+			throw new CmisNotSupportedException("Object can't be checked-out, type is not versionable.");
+
+		checkIsVersionableObject(so);
+
+		VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
+
+		ContentStream content = null;
+
+		if (so instanceof DocumentVersion) {
+			// get document the version is contained in to c
+			content = ((DocumentVersion) so).getContent(0, -1);
+		} else {
+			content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
 		}
+
+		if (verDoc.isCheckedOut())
+			throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
+
+		String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
+		checkHasUser(user);
+
+		DocumentVersion pwc = verDoc.checkOut(content, user);
+		objectId.setValue(pwc.getId()); // return the id of the created pwc
+
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false, IncludeRelationships.NONE,
+				null, false, false, extension);
+
+		return od;
 	}
 
 	public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String versionSeriesId,
 			String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
 
-			StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+		if (!(so instanceof VersionedDocument))
+			throw new RuntimeException("Object is not instance of a VersionedDocument (version series)");
 
-			if (!(so instanceof VersionedDocument))
-				throw new RuntimeException("Object is not instance of a VersionedDocument (version series)");
-
-			VersionedDocument verDoc = (VersionedDocument) so;
-			List<ObjectData> res = new ArrayList<ObjectData>();
-			List<DocumentVersion> versions = verDoc.getAllVersions();
-			for (DocumentVersion version : versions) {
-				ObjectData objData = getObject(context, repositoryId, version.getId(), filter, includeAllowableActions,
-						extension, objectInfos);
-				res.add(objData);
-			}
-
-			// provide information for Atom links for version series:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			return res;
-		} finally {
-			RuntimeContext.remove();
+		VersionedDocument verDoc = (VersionedDocument) so;
+		List<ObjectData> res = new ArrayList<ObjectData>();
+		List<DocumentVersion> versions = verDoc.getAllVersions();
+		for (DocumentVersion version : versions) {
+			ObjectData objData = getObject(context, repositoryId, version.getId(), filter, includeAllowableActions,
+					extension, objectInfos);
+			res.add(objData);
 		}
+
+		// provide information for Atom links for version series:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		return res;
 	}
 
 	public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
@@ -199,61 +167,45 @@ public class InMemoryVersioningServiceIm
 			String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
 			ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
-			ObjectData objData = null;
-
-			if (so instanceof VersionedDocument) {
-				VersionedDocument verDoc = (VersionedDocument) so;
-				DocumentVersion latestVersion = verDoc.getLatestVersion(major);
-				objData = getObject(context, repositoryId, latestVersion.getId(), filter, includeAllowableActions,
-						extension, objectInfos);
-			} else if (so instanceof Document) {
-				objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions, extension,
-						objectInfos);
-			} else
-				throw new RuntimeException("Object is not instance of a document (version series)");
-
-			// provide information for Atom links for version series:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			return objData;
-		} finally {
-			RuntimeContext.remove();
-		}
+		StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+		ObjectData objData = null;
+
+		if (so instanceof VersionedDocument) {
+			VersionedDocument verDoc = (VersionedDocument) so;
+			DocumentVersion latestVersion = verDoc.getLatestVersion(major);
+			objData = getObject(context, repositoryId, latestVersion.getId(), filter, includeAllowableActions,
+					extension, objectInfos);
+		} else if (so instanceof Document) {
+			objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions, extension,
+					objectInfos);
+		} else
+			throw new RuntimeException("Object is not instance of a document (version series)");
+
+		// provide information for Atom links for version series:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		return objData;
 	}
 
 	public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
 			Boolean major, String filter, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
-			StoredObject latestVersionObject = null;
-
-			if (so instanceof VersionedDocument) {
-				VersionedDocument verDoc = (VersionedDocument) so;
-				latestVersionObject = verDoc.getLatestVersion(major);
-			} else if (so instanceof Document) {
-				latestVersionObject = so;
-			} else
-				throw new RuntimeException("Object is not instance of a document (version series)");
-
-			List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-			Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, latestVersionObject,
-					fStoreManager, requestedIds);
-
-			return props;
-		} finally {
-			RuntimeContext.remove();
-		}
+		StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+		StoredObject latestVersionObject = null;
+
+		if (so instanceof VersionedDocument) {
+			VersionedDocument verDoc = (VersionedDocument) so;
+			latestVersionObject = verDoc.getLatestVersion(major);
+		} else if (so instanceof Document) {
+			latestVersionObject = so;
+		} else
+			throw new RuntimeException("Object is not instance of a document (version series)");
+
+		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+		Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, latestVersionObject,
+				fStoreManager, requestedIds);
+
+		return props;
 	}
 
 	private ObjectData getObject(CallContext context, String repositoryId, String objectId, String filter,

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java Tue Apr 20 13:28:25 2010
@@ -39,6 +39,7 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.clientprovider.CmisInMemoryProvider;
 import org.apache.chemistry.opencmis.inmemory.clientprovider.DummyCallContext;
 import org.apache.chemistry.opencmis.inmemory.server.RuntimeContext;
+import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceFactoryImpl;
 import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -56,18 +57,17 @@ public class AbstractServiceTst /* exten
 	protected MultiFilingService fMultiSvc;
 	protected DummyCallContext fTestCallContext;
 	private String fTypeCreatorClassName;
-	private boolean fUseClientProviderInterface;
+	protected boolean fUseClientProviderInterface;
 
 	public AbstractServiceTst() {
-		// The in-memory server unit tests can either be run directly against
-		// the
-		// service implementation or against a client provider interface. The
-		// client
-		// provider interfaces offers some benefits like type system caching etc
+		// The in-memory server unit tests can either be run directly against the
+		// service implementation or against a clocal binding interface. The local
+		// binding interfaces offers some benefits like type system caching etc.
 		// The default is using the direct implementation. Subclasses may
-		// override
-		// this behavior
-		fUseClientProviderInterface = false;
+		// override this behavior.
+		
+		fUseClientProviderInterface = true;
+		
 		// Init with default types, can be overridden by subclasses:
 		fTypeCreatorClassName = UnitTestTypeSystemCreator.class.getName();
 	}
@@ -81,16 +81,14 @@ public class AbstractServiceTst /* exten
 		// super.setUp();
 		LOG.debug("Initializing InMemory Test with type creator class: " + fTypeCreatorClassName);
 		Map<String, String> parameters = new HashMap<String, String>();
-		parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisBindingFactory.BINDING_SPI_INMEMORY);
-		// attach TypeSystem to the session
-
+		
 		// attach repository info to the session:
 		parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, fTypeCreatorClassName);
 		parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
 
 		// attach repository info to the session:
 		parameters.put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
-
+		
 		// give subclasses a chance to provide additional parameters for special
 		// tests
 		addParameters(parameters);
@@ -101,7 +99,7 @@ public class AbstractServiceTst /* exten
 		RuntimeContext.attachCfg(fTestCallContext);
 
 		if (fUseClientProviderInterface)
-			initializeUsingClientProvider(parameters);
+			initializeUsingLocalBinding(parameters);
 		else
 			initializeDirect(parameters);
 
@@ -334,6 +332,8 @@ public class AbstractServiceTst /* exten
 	 *            in-memory provider
 	 */
 	private void initializeDirect(Map<String, String> parameters) {
+		LOG.info("Initialize unit test using directly the InMemory-classes.");
+
 		CmisInMemoryProvider inMemSpi = new CmisInMemoryProvider(parameters);
 		fRepSvc = inMemSpi.getRepositoryService();
 		fObjSvc = inMemSpi.getObjectService();
@@ -349,19 +349,26 @@ public class AbstractServiceTst /* exten
 	 *            configuration parameters for client provider interface and
 	 *            in-memory provider
 	 */
-	private void initializeUsingClientProvider(Map<String, String> parameters) {
-		CmisBinding provider;
+	private void initializeUsingLocalBinding(Map<String, String> parameters) {
 
-		// get factory and create provider
-		CmisBindingFactory factory = CmisBindingFactory.newInstance();
-		provider = factory.createCmisBinding(parameters);
-		assertNotNull(provider);
-		fFactory = provider.getObjectFactory();
-		fRepSvc = provider.getRepositoryService();
-		fObjSvc = provider.getObjectService();
-		fNavSvc = provider.getNavigationService();
-		fVerSvc = provider.getVersioningService();
-		fMultiSvc = provider.getMultiFilingService();
+		LOG.info("Initialize unit test using the local binding interface.");
+		
+		// add parameters for local binding:
+		parameters.put(SessionParameter.BINDING_SPI_CLASS, SessionParameter.LOCAL_FACTORY);
+		parameters.put(SessionParameter.LOCAL_FACTORY, InMemoryServiceFactoryImpl.class.getName());
+		parameters.put(ConfigConstants.OVERRIDE_CALL_CONTEXT, "true");
+		InMemoryServiceFactoryImpl.setOverrideCallContext(fTestCallContext);
+
+		// get factory and create binding
+		CmisBindingFactory factory = CmisBindingFactory.newInstance();		
+		CmisBinding binding = factory.createCmisLocalBinding(parameters);
+		assertNotNull(binding);
+		fFactory = binding.getObjectFactory();
+		fRepSvc = binding.getRepositoryService();
+		fObjSvc = binding.getObjectService();
+		fNavSvc = binding.getNavigationService();
+		fVerSvc = binding.getVersioningService();
+		fMultiSvc = binding.getMultiFilingService();
 	}
 
 	protected String getStringProperty(ObjectData objData, String propertyKey) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java Tue Apr 20 13:28:25 2010
@@ -18,6 +18,12 @@
  */
 package org.apache.chemistry.opencmis.inmemory;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -52,8 +58,6 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
-import org.apache.chemistry.opencmis.inmemory.RepositoryInfoCreator;
-import org.apache.chemistry.opencmis.inmemory.TypeCreator;
 import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
@@ -63,8 +67,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 /**
  * @author Jens
  */
@@ -473,13 +475,13 @@ public class RepositoryServiceTest exten
 		return repository.getId();
 	}
 
-	private boolean containsTypeById(String typeId, List<TypeDefinitionContainer> types) {
-		for (TypeDefinitionContainer type : types) {
-			if (type.getTypeDefinition().getId().equals(typeId))
-				return true;
-		}
-		return false;
-	}
+//	private boolean containsTypeById(String typeId, List<TypeDefinitionContainer> types) {
+//		for (TypeDefinitionContainer type : types) {
+//			if (type.getTypeDefinition().getId().equals(typeId))
+//				return true;
+//		}
+//		return false;
+//	}
 
 	private boolean containsTypeByIdRecursive(String typeId, List<TypeDefinitionContainer> types) {
 		for (TypeDefinitionContainer type : types) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java Tue Apr 20 13:28:25 2010
@@ -52,6 +52,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
+import org.apache.chemistry.opencmis.inmemory.server.RuntimeContext;
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.commons.logging.Log;

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyObjectIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyObjectIT.java?rev=935906&r1=935905&r2=935906&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyObjectIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyObjectIT.java Tue Apr 20 13:28:25 2010
@@ -67,9 +67,9 @@ public class ReadOnlyObjectIT extends Ab
 		Assert.assertEquals(ObjectType.FOLDER_BASETYPE_ID, folder.getBaseType().getId());
 
 		Assert.assertNotNull(folder.getCreatedBy());
-		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER), folder.getCreatedBy());
+//		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER), folder.getCreatedBy());
 		Assert.assertNotNull(folder.getLastModifiedBy());
-		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER), folder.getLastModifiedBy());
+//		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER), folder.getLastModifiedBy());
 		Assert.assertNotNull(folder.getLastModificationDate());
 		Assert.assertNotNull(folder.getCreationDate());
 



Mime
View raw message