chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r935906 [1/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
Author: jens
Date: Tue Apr 20 13:28:25 2010
New Revision: 935906

URL: http://svn.apache.org/viewvc?rev=935906&view=rev
Log:
Prepare In-Memory for new server interfaces

Added:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyObjectIT.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.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/ConfigConstants.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/ConfigConstants.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java Tue Apr 20 13:28:25 2010
@@ -23,6 +23,7 @@ public class ConfigConstants {
 	public static final String TYPE_CREATOR_CLASS = "InMemoryServer.TypesCreatorClass";
 	public static final String REPOSITORY_INFO_CREATOR_CLASS = "InMemoryServer.RepositoryInfoCreatorClass";
 	public static final String REPOSITORY_CLASS = "InMemoryServer.Class";
+	public static final String OVERRIDE_CALL_CONTEXT = "InMemoryServer.OverrideCallContext";
 
 	// Helper constants that allow to fill a repository with data on
 	// initialization

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.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/InMemoryAbstractServiceImpl.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/InMemoryAbstractServiceImpl.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -0,0 +1,171 @@
+/*
+ * 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 org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.api.Properties;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
+
+/**
+ * Common functionality for all service implementations
+ * 
+ * @author Jens
+ * 
+ */
+public class InMemoryAbstractServiceImpl {
+
+	protected StoreManager fStoreManager;
+
+	protected InMemoryAbstractServiceImpl(StoreManager storeManager) {
+		fStoreManager = storeManager;
+	}
+
+	/**
+	 * check if repository is known and that object exists. To avoid later calls
+	 * to again retrieve the object from the id return the retrieved object for
+	 * later use.
+	 * 
+	 * @param repositoryId
+	 *            repository id
+	 * @param objectId
+	 *            object id
+	 * @return object for objectId
+	 */
+	protected StoredObject checkStandardParameters(String repositoryId, String objectId) {
+
+		ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+
+		if (objStore == null)
+			throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId);
+
+		StoredObject so = objStore.getObjectById(objectId);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		return so;
+	}
+
+	protected StoredObject checkExistingObjectId(ObjectStore objStore, String objectId) {
+
+		StoredObject so = objStore.getObjectById(objectId);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		return so;
+	}
+
+	protected void checkRepositoryId(String repositoryId) {
+		ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
+
+		if (objStore == null)
+			throw new CmisObjectNotFoundException("Unknown repository id: " + repositoryId);
+	}
+
+	protected TypeDefinition getTypeDefinition(String repositoryId, Properties properties) {
+		String typeId = (String) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue();
+		TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
+		if (typeDefC == null)
+			throw new RuntimeException("Cannot create object, a type with id " + typeId + " is unknown");
+
+		return typeDefC.getTypeDefinition();
+	}
+
+	protected TypeDefinition getTypeDefinition(String repositoryId, StoredObject obj) {
+
+		TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, obj.getTypeId());
+		return typeDefC.getTypeDefinition();
+	}
+
+	/**
+	 * We allow checkin, cancel, checkout operations on a single version as well
+	 * as on a version series This method returns the versioned document
+	 * (version series) in each case
+	 * 
+	 * @param value
+	 *            version or version series id of a document
+	 * @return version series id
+	 */
+	protected VersionedDocument getVersionedDocumentOfObjectId(StoredObject so) {
+
+		VersionedDocument verDoc;
+		if (so instanceof DocumentVersion) {
+			// get document the version is contained in to c
+			verDoc = ((DocumentVersion) so).getParentDocument();
+		} else {
+			verDoc = (VersionedDocument) so;
+		}
+
+		return verDoc;
+	}
+
+	protected VersionedDocument testIsNotCheckedOutBySomeoneElse(StoredObject so, String user) {
+		checkIsVersionableObject(so);
+		VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
+		if (verDoc.isCheckedOut())
+			testCheckedOutByCurrentUser(user, verDoc);
+
+		return verDoc;
+	}
+
+	protected VersionedDocument testHasProperCheckedOutStatus(StoredObject so, String user) {
+
+		checkIsVersionableObject(so);
+		VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
+
+		checkHasUser(user);
+
+		testIsCheckedOut(verDoc);
+		testCheckedOutByCurrentUser(user, verDoc);
+
+		return verDoc;
+	}
+
+	protected void checkIsVersionableObject(StoredObject so) {
+		if (!(so instanceof VersionedDocument || so instanceof DocumentVersion))
+			throw new RuntimeException(
+					"Object is of a versionable type but not instance of VersionedDocument or DocumentVersion.");
+	}
+
+	protected void checkHasUser(String user) {
+		if (null == user || user.length() == 0)
+			throw new CmisUpdateConflictException("Object can't be checked-in, no user is given.");
+	}
+
+	protected void testCheckedOutByCurrentUser(String user, VersionedDocument verDoc) {
+		if (!user.equals(verDoc.getCheckedOutBy()))
+			throw new CmisUpdateConflictException("Object can't be checked-in, user " + verDoc.getCheckedOutBy()
+					+ " has checked out the document.");
+	}
+
+	protected void testIsCheckedOut(VersionedDocument verDoc) {
+		if (!verDoc.isCheckedOut())
+			throw new CmisUpdateConflictException("Canot check-in: Document " + verDoc.getId() + " is not checked out.");
+	}
+
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.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/InMemoryDiscoveryServiceImpl.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/InMemoryDiscoveryServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -37,6 +37,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
 import org.apache.chemistry.opencmis.server.spi.CmisDiscoveryService;
+import org.apache.chemistry.opencmis.server.spi.CmisRepositoryService;
 import org.apache.chemistry.opencmis.server.spi.ObjectInfoHolder;
 
 public class InMemoryDiscoveryServiceImpl implements CmisDiscoveryService {
@@ -60,11 +61,6 @@ public class InMemoryDiscoveryServiceImp
 			BigInteger maxItems, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 		// dummy implementation using hard coded values
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
 			RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
 			String rootFolderId = rep.getRootFolderId();
 
@@ -85,9 +81,6 @@ public class InMemoryDiscoveryServiceImp
 			// additional information:
 			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList);
 			return objList;
-		} finally {
-			RuntimeContext.remove();
-		}
 	}
 
 	private void convertList(List<ObjectData> lod, ObjectInFolderContainer obj) {
@@ -111,11 +104,6 @@ public class InMemoryDiscoveryServiceImp
 			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
 		// dummy implementation using hard coded values
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
 			// use descendants of root folder as result
 			RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
 			String rootFolderId = rep.getRootFolderId();
@@ -133,9 +121,6 @@ public class InMemoryDiscoveryServiceImp
 			objList.setNumItems(BigInteger.valueOf(lod.size()));
 
 			return objList;
-		} finally {
-			RuntimeContext.remove();
-		}
 	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.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/InMemoryMultiFilingServiceImpl.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/InMemoryMultiFilingServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -35,7 +35,7 @@ import org.apache.chemistry.opencmis.ser
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryMultiFilingServiceImpl extends AbstractServiceImpl implements CmisMultiFilingService {
+public class InMemoryMultiFilingServiceImpl extends InMemoryAbstractServiceImpl implements CmisMultiFilingService{
 
 	private static final Log LOG = LogFactory.getLog(InMemoryMultiFilingServiceImpl.class.getName());
 
@@ -49,70 +49,55 @@ public class InMemoryMultiFilingServiceI
 	public ObjectData addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId,
 			Boolean allVersions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("Begin addObjectToFolder()");
+		LOG.debug("Begin addObjectToFolder()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject[] so2 = checkParams(repositoryId, objectId, folderId);
-			if (allVersions != null && allVersions.booleanValue() == false)
-				throw new CmisNotSupportedException(
-						"Cannot add object to folder, version specific filing is not supported.");
-			StoredObject so = so2[0];
-			StoredObject folder = so2[1];
-			checkObjects(so, folder);
-
-			Folder newParent = (Folder) folder;
-			MultiFiling obj = (MultiFiling) so;
-			obj.addParent(newParent);
-
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
-
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-					IncludeRelationships.NONE, null, false, false, extension);
-
-			LOG.debug("End addObjectToFolder()");
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+		StoredObject[] so2 = checkParams(repositoryId, objectId, folderId);
+		if (allVersions != null && allVersions.booleanValue() == false)
+			throw new CmisNotSupportedException(
+					"Cannot add object to folder, version specific filing is not supported.");
+		StoredObject so = so2[0];
+		StoredObject folder = so2[1];
+		checkObjects(so, folder);
+
+		Folder newParent = (Folder) folder;
+		MultiFiling obj = (MultiFiling) so;
+		obj.addParent(newParent);
+
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
+
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
+				IncludeRelationships.NONE, null, false, false, extension);
+
+		LOG.debug("End addObjectToFolder()");
+		return od;
 	}
 
 	public ObjectData removeObjectFromFolder(CallContext context, String repositoryId, String objectId,
 			String folderId, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("Begin removeObjectFromFolder()");
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-			StoredObject folder = checkExistingObjectId(objectStore, folderId);
-
-			checkObjects(so, folder);
-			Folder parent = (Folder) folder;
-			MultiFiling obj = (MultiFiling) so;
-			obj.removeParent(parent);
-
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
-
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-					IncludeRelationships.NONE, null, false, false, extension);
-
-			LOG.debug("End removeObjectFromFolder()");
-
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("Begin removeObjectFromFolder()");
+
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		StoredObject folder = checkExistingObjectId(objectStore, folderId);
+
+		checkObjects(so, folder);
+		Folder parent = (Folder) folder;
+		MultiFiling obj = (MultiFiling) so;
+		obj.removeParent(parent);
+
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
+
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
+				IncludeRelationships.NONE, null, false, false, extension);
+
+		LOG.debug("End removeObjectFromFolder()");
+
+		return od;
 	}
 
 	private StoredObject[] checkParams(String repositoryId, String objectId, String folderId) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.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/InMemoryNavigationServiceImpl.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/InMemoryNavigationServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -57,11 +57,12 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.server.spi.CmisNavigationService;
+import org.apache.chemistry.opencmis.server.spi.CmisRepositoryService;
 import org.apache.chemistry.opencmis.server.spi.ObjectInfoHolder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryNavigationServiceImpl extends AbstractServiceImpl implements CmisNavigationService {
+public class InMemoryNavigationServiceImpl extends InMemoryAbstractServiceImpl implements CmisNavigationService {
 
 	private static Log LOG = LogFactory.getLog(InMemoryNavigationServiceImpl.class);
 
@@ -77,51 +78,43 @@ public class InMemoryNavigationServiceIm
 			String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension,
 			ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			ObjectListImpl res = new ObjectListImpl();
-			List<ObjectData> odList = new ArrayList<ObjectData>();
-
-			LOG.debug("start getCheckedOutDocs()");
-			if (null != folderId)
-				checkStandardParameters(repositoryId, folderId);
-			else
-				checkRepositoryId(repositoryId);
+		ObjectListImpl res = new ObjectListImpl();
+		List<ObjectData> odList = new ArrayList<ObjectData>();
 
-			if (null == folderId) {
-				List<VersionedDocument> checkedOuts = fStoreManager.getObjectStore(repositoryId)
-						.getCheckedOutDocuments(orderBy);
-				for (VersionedDocument checkedOut : checkedOuts) {
-					ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, checkedOut, filter,
-							includeAllowableActions, includeRelationships, renditionFilter, false, false, extension);
-					fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, checkedOut, objectInfos);
-					odList.add(od);
-				}
-			} else {
-				ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
-						includeAllowableActions, includeRelationships, renditionFilter, false, -1, -1, false,
-						objectInfos);
-				for (ObjectInFolderData child : children.getObjects()) {
-					ObjectData obj = child.getObject();
-					StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
-					LOG.info("Checked out: children:" + obj.getId());
-					if (so instanceof DocumentVersion && ((DocumentVersion) so).getParentDocument().isCheckedOut()) {
-						odList.add(obj);
-						fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-					}
+		LOG.debug("start getCheckedOutDocs()");
+		if (null != folderId)
+			checkStandardParameters(repositoryId, folderId);
+		else
+			checkRepositoryId(repositoryId);
+
+		if (null == folderId) {
+			List<VersionedDocument> checkedOuts = fStoreManager.getObjectStore(repositoryId)
+			.getCheckedOutDocuments(orderBy);
+			for (VersionedDocument checkedOut : checkedOuts) {
+				ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, checkedOut, filter,
+						includeAllowableActions, includeRelationships, renditionFilter, false, false, extension);
+				fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, checkedOut, objectInfos);
+				odList.add(od);
+			}
+		} else {
+			ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
+					includeAllowableActions, includeRelationships, renditionFilter, false, -1, -1, false,
+					objectInfos);
+			for (ObjectInFolderData child : children.getObjects()) {
+				ObjectData obj = child.getObject();
+				StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
+				LOG.info("Checked out: children:" + obj.getId());
+				if (so instanceof DocumentVersion && ((DocumentVersion) so).getParentDocument().isCheckedOut()) {
+					odList.add(obj);
+					fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
 				}
 			}
-			res.setObjects(odList);
-			res.setNumItems(BigInteger.valueOf(odList.size()));
-
-			LOG.debug("end getCheckedOutDocs()");
-			return res;
-		} finally {
-			RuntimeContext.remove();
 		}
+		res.setObjects(odList);
+		res.setNumItems(BigInteger.valueOf(odList.size()));
+
+		LOG.debug("end getCheckedOutDocs()");
+		return res;
 	}
 
 	public ObjectInFolderList getChildren(CallContext context, String repositoryId, String folderId, String filter,
@@ -129,25 +122,17 @@ public class InMemoryNavigationServiceIm
 			String renditionFilter, Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount,
 			ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getChildren()");
+		LOG.debug("start getChildren()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		checkStandardParameters(repositoryId, folderId);
 
-			checkStandardParameters(repositoryId, folderId);
-
-			int maxItemsInt = maxItems == null ? -1 : maxItems.intValue();
-			int skipCountInt = skipCount == null ? -1 : skipCount.intValue();
-			ObjectInFolderList res = getChildrenIntern(repositoryId, folderId, filter, orderBy,
-					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItemsInt,
-					skipCountInt, false, objectInfos);
-			LOG.debug("stop getChildren()");
-			return res;
-		} finally {
-			RuntimeContext.remove();
-		}
+		int maxItemsInt = maxItems == null ? -1 : maxItems.intValue();
+		int skipCountInt = skipCount == null ? -1 : skipCount.intValue();
+		ObjectInFolderList res = getChildrenIntern(repositoryId, folderId, filter, orderBy,
+				includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItemsInt,
+				skipCountInt, false, objectInfos);
+		LOG.debug("stop getChildren()");
+		return res;
 	}
 
 	public List<ObjectInFolderContainer> getDescendants(CallContext context, String repositoryId, String folderId,
@@ -155,66 +140,50 @@ public class InMemoryNavigationServiceIm
 			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment,
 			ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getDescendants()");
+		LOG.debug("start getDescendants()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		checkStandardParameters(repositoryId, folderId);
 
-			checkStandardParameters(repositoryId, folderId);
+		int levels;
+		if (depth == null)
+			levels = 2; // one of the recommended defaults (should it be
+		// -1?)
+		else if (depth.intValue() == 0)
+			throw new CmisInvalidArgumentException("A zero depth is not allowed for getDescendants().");
+		else
+			levels = depth.intValue();
 
-			int levels;
-			if (depth == null)
-				levels = 2; // one of the recommended defaults (should it be
-							// -1?)
-			else if (depth.intValue() == 0)
-				throw new CmisInvalidArgumentException("A zero depth is not allowed for getDescendants().");
-			else
-				levels = depth.intValue();
+		int level = 0;
+		List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
+				includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
+				false, objectInfos);
 
-			int level = 0;
-			List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
-					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
-					false, objectInfos);
-
-			LOG.debug("stop getDescendants()");
-			return result;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("stop getDescendants()");
+		return result;
 	}
 
 	public ObjectData getFolderParent(CallContext context, String repositoryId, String folderId, String filter,
 			ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getFolderParent()");
+		LOG.debug("start getFolderParent()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, folderId);
-
-			Folder folder = null;
-			if (so instanceof Folder)
-				folder = (Folder) so;
-			else
-				throw new CmisInvalidArgumentException("Can't get folder parent, id does not refer to a folder: "
-						+ folderId);
+		StoredObject so = checkStandardParameters(repositoryId, folderId);
 
-			ObjectData res = getFolderParentIntern(repositoryId, folder, filter, objectInfos);
+		Folder folder = null;
+		if (so instanceof Folder)
+			folder = (Folder) so;
+		else
+			throw new CmisInvalidArgumentException("Can't get folder parent, id does not refer to a folder: "
+					+ folderId);
 
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			LOG.debug("stop getFolderParent()");
-			return res;
-		} finally {
-			RuntimeContext.remove();
-		}
+		ObjectData res = getFolderParentIntern(repositoryId, folder, filter, objectInfos);
+
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		LOG.debug("stop getFolderParent()");
+		return res;
 	}
 
 	public List<ObjectInFolderContainer> getFolderTree(CallContext context, String repositoryId, String folderId,
@@ -222,29 +191,21 @@ public class InMemoryNavigationServiceIm
 			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment,
 			ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getFolderTree()");
+		LOG.debug("start getFolderTree()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		checkStandardParameters(repositoryId, folderId);
 
-			checkStandardParameters(repositoryId, folderId);
+		if (depth != null && depth.intValue() == 0)
+			throw new CmisInvalidArgumentException("A zero depth is not allowed for getFolderTree().");
 
-			if (depth != null && depth.intValue() == 0)
-				throw new CmisInvalidArgumentException("A zero depth is not allowed for getFolderTree().");
+		int levels = depth == null ? 2 : depth.intValue();
+		int level = 0;
+		List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
+				includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
+				true, objectInfos);
 
-			int levels = depth == null ? 2 : depth.intValue();
-			int level = 0;
-			List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
-					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
-					true, objectInfos);
-
-			LOG.debug("stop getFolderTree()");
-			return result;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("stop getFolderTree()");
+		return result;
 	}
 
 	public List<ObjectParentData> getObjectParents(CallContext context, String repositoryId, String objectId,
@@ -252,38 +213,30 @@ public class InMemoryNavigationServiceIm
 			String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension,
 			ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getObjectParents()");
+		LOG.debug("start getObjectParents()");
 
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-
-			// for now we have only folders that have a parent and the in-memory
-			// provider only has one
-			// parent for each object (no multi-filing)
-			List<ObjectParentData> result = null;
-
-			Filing spo = null;
-			if (so instanceof Filing)
-				spo = (Filing) so;
-			else
-				throw new CmisInvalidArgumentException(
-						"Can't get object parent, id does not refer to a folder or document: " + objectId);
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
 
-			result = getObjectParentsIntern(repositoryId, spo, filter, objectInfos);
+		// for now we have only folders that have a parent and the in-memory
+		// provider only has one
+		// parent for each object (no multi-filing)
+		List<ObjectParentData> result = null;
 
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			LOG.debug("stop getObjectParents()");
-			return result;
-		} finally {
-			RuntimeContext.remove();
-		}
+		Filing spo = null;
+		if (so instanceof Filing)
+			spo = (Filing) so;
+		else
+			throw new CmisInvalidArgumentException(
+					"Can't get object parent, id does not refer to a folder or document: " + objectId);
+
+		result = getObjectParentsIntern(repositoryId, spo, filter, objectInfos);
+
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		LOG.debug("stop getObjectParents()");
+		return result;
 	}
 
 	// private helpers
@@ -325,9 +278,9 @@ public class InMemoryNavigationServiceIm
 			}
 			if (renditionFilter != null && renditionFilter.length() > 0) {
 				objectData.setRelationships(null /*
-												 * f.getRenditions(renditionFilter
-												 * )
-												 */);
+				 * f.getRenditions(renditionFilter
+				 * )
+				 */);
 			}
 
 			Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, spo, fStoreManager,
@@ -390,11 +343,11 @@ public class InMemoryNavigationServiceIm
 				parentData.setObject(parent);
 				String path = ((SingleFiling) sop).getPath();
 				int beginIndex = path.lastIndexOf(Filing.PATH_SEPARATOR) + 1; // Note
-																				// :
-																				// if
-																				// /
-																				// not
-																				// found
+				// :
+				// if
+				// /
+				// not
+				// found
 				// results in 0
 				String relPathSeg = path.substring(beginIndex, path.length());
 				parentData.setRelativePathSegment(relPathSeg);
@@ -442,7 +395,7 @@ public class InMemoryNavigationServiceIm
 	void copyFilteredProperties(String repositoryId, StoredObject so, String filter, ObjectDataImpl objData) {
 		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
 		Properties props = PropertyCreationHelper
-				.getPropertiesFromObject(repositoryId, so, fStoreManager, requestedIds);
+		.getPropertiesFromObject(repositoryId, so, fStoreManager, requestedIds);
 		objData.setProperties(props);
 	}
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.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/InMemoryObjectServiceImpl.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/InMemoryObjectServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java Tue Apr 20 13:28:25 2010
@@ -70,12 +70,13 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.types.InMemoryRelationshipTypeDefinition;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.server.spi.CmisObjectService;
+import org.apache.chemistry.opencmis.server.spi.CmisRepositoryService;
 import org.apache.chemistry.opencmis.server.spi.ObjectInfoHolder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryObjectServiceImpl extends AbstractServiceImpl implements CmisObjectService {
-	private static final Log LOG = LogFactory.getLog(ServiceFactory.class.getName());
+public class InMemoryObjectServiceImpl extends InMemoryAbstractServiceImpl implements CmisObjectService {
+	private static final Log LOG = LogFactory.getLog(InMemoryServiceFactoryImpl.class.getName());
 
 	AtomLinkInfoProvider fAtomLinkProvider;
 
@@ -88,118 +89,84 @@ public class InMemoryObjectServiceImpl e
 			ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
 			Acl removeAces, ExtensionsData extension) {
 
-		try {
-			LOG.debug("start createDocument()");
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			StoredObject so = createDocumentIntern(repositoryId, properties, folderId, contentStream, versioningState,
-					policies, addAces, removeAces, extension);
-			LOG.debug("stop createDocument()");
-			return so.getId();
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start createDocument()");
+		// Attach the CallContext to a thread local context that can be
+		// accessed from everywhere
+
+		StoredObject so = createDocumentIntern(repositoryId, properties, folderId, contentStream, versioningState,
+				policies, addAces, removeAces, extension);
+		LOG.debug("stop createDocument()");
+		return so.getId();
 	}
 
 	public String createDocumentFromSource(CallContext context, String repositoryId, String sourceId,
 			Properties properties, String folderId, VersioningState versioningState, List<String> policies,
 			Acl addAces, Acl removeAces, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start createDocumentFromSource()");
+		LOG.debug("start createDocumentFromSource()");
 
-			StoredObject so = checkStandardParameters(repositoryId, sourceId);
+		StoredObject so = checkStandardParameters(repositoryId, sourceId);
 
-			ContentStream content = getContentStream(context, repositoryId, sourceId, null, BigInteger.valueOf(-1),
-					BigInteger.valueOf(-1), null);
+		ContentStream content = getContentStream(context, repositoryId, sourceId, null, BigInteger.valueOf(-1),
+				BigInteger.valueOf(-1), null);
 
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + sourceId);
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + sourceId);
 
-			// build properties collection
-			List<String> requestedIds = FilterParser.getRequestedIdsFromFilter("*");
+		// build properties collection
+		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter("*");
 
-			Properties existingProps = PropertyCreationHelper.getPropertiesFromObject(repositoryId, so, fStoreManager,
-					requestedIds);
+		Properties existingProps = PropertyCreationHelper.getPropertiesFromObject(repositoryId, so, fStoreManager,
+				requestedIds);
 
-			PropertiesImpl newPD = new PropertiesImpl();
-			// copy all existing properties
-			for (PropertyData<?> prop : existingProps.getProperties().values()) {
-				newPD.addProperty(prop);
-			}
-			// overwrite all new properties
-			for (PropertyData<?> prop : properties.getProperties().values()) {
-				newPD.addProperty(prop);
-			}
-
-			String res = createDocument(context, repositoryId, newPD, folderId, content, versioningState, policies,
-					addAces, removeAces, null);
-			LOG.debug("stop createDocumentFromSource()");
-			return res;
-		} finally {
-			RuntimeContext.remove();
+		PropertiesImpl newPD = new PropertiesImpl();
+		// copy all existing properties
+		for (PropertyData<?> prop : existingProps.getProperties().values()) {
+			newPD.addProperty(prop);
+		}
+		// overwrite all new properties
+		for (PropertyData<?> prop : properties.getProperties().values()) {
+			newPD.addProperty(prop);
 		}
+
+		String res = createDocument(context, repositoryId, newPD, folderId, content, versioningState, policies,
+				addAces, removeAces, null);
+		LOG.debug("stop createDocumentFromSource()");
+		return res;
 	}
 
 	public String createFolder(CallContext context, String repositoryId, Properties properties, String folderId,
 			List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
-		try {
-			LOG.debug("start createFolder()");
-			RuntimeContext.attachCfg(context);
+		LOG.debug("start createFolder()");
 
-			Folder folder = createFolderIntern(repositoryId, properties, folderId, policies, addAces, removeAces,
-					extension);
-			LOG.debug("stop createFolder()");
-			return folder.getId();
-		} finally {
-			RuntimeContext.remove();
-		}
+		Folder folder = createFolderIntern(repositoryId, properties, folderId, policies, addAces, removeAces,
+				extension);
+		LOG.debug("stop createFolder()");
+		return folder.getId();
 	}
 
 	public String createPolicy(CallContext context, String repositoryId, Properties properties, String folderId,
 			List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			// TODO to be completed if ACLs are implemented
-			LOG.debug("start createPolicy()");
-			checkStandardParameters(repositoryId, folderId);
-			StoredObject so = createPolicyIntern(repositoryId, properties, folderId, policies, addAces, removeAces,
-					extension);
-			LOG.debug("stop createPolicy()");
-			return so == null ? null : so.getId();
-		} finally {
-			RuntimeContext.remove();
-		}
+		// TODO to be completed if ACLs are implemented
+		LOG.debug("start createPolicy()");
+		checkStandardParameters(repositoryId, folderId);
+		StoredObject so = createPolicyIntern(repositoryId, properties, folderId, policies, addAces, removeAces,
+				extension);
+		LOG.debug("stop createPolicy()");
+		return so == null ? null : so.getId();
 	}
 
 	public String createRelationship(CallContext context, String repositoryId, Properties properties,
 			List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			// TODO to be completed if relationships are implemented
-			LOG.debug("start createRelationship()");
-			checkRepositoryId(repositoryId);
-			StoredObject so = createRelationshipIntern(repositoryId, properties, policies, addAces, removeAces,
-					extension);
-			LOG.debug("stop createRelationship()");
-			return so == null ? null : so.getId();
-		} finally {
-			RuntimeContext.remove();
-		}
+		// TODO to be completed if relationships are implemented
+		LOG.debug("start createRelationship()");
+		checkRepositoryId(repositoryId);
+		StoredObject so = createRelationshipIntern(repositoryId, properties, policies, addAces, removeAces,
+				extension);
+		LOG.debug("stop createRelationship()");
+		return so == null ? null : so.getId();
 	}
 
 	/*
@@ -224,536 +191,437 @@ public class InMemoryObjectServiceImpl e
 			ContentStream contentStream, VersioningState versioningState, List<String> policies,
 			ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			if (null == properties || null == properties.getProperties())
-				throw new RuntimeException("Cannot create object, without properties.");
-
-			// Find out what kind of object needs to be created
-			PropertyData<String> pd = (PropertyData<String>) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
-			String typeId = pd == null ? null : pd.getFirstValue();
-			if (null == typeId)
-				throw new RuntimeException(
-						"Cannot create object, without a type (no property with id CMIS_OBJECT_TYPE_ID).");
-
-			TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
-			if (typeDefC == null)
-				throw new RuntimeException("Cannot create object, a type with id " + typeId + " is unknown");
-
-			// check if the given type is a document type
-			BaseTypeId typeBaseId = typeDefC.getTypeDefinition().getBaseTypeId();
-			StoredObject so = null;
-			if (typeBaseId.equals(InMemoryDocumentTypeDefinition.getRootDocumentType().getBaseTypeId())) {
-				so = createDocumentIntern(repositoryId, properties, folderId, contentStream, versioningState, null,
-						null, null, null);
-			} else if (typeBaseId.equals(InMemoryFolderTypeDefinition.getRootFolderType().getBaseTypeId())) {
-				so = createFolderIntern(repositoryId, properties, folderId, null, null, null, null);
-			} else if (typeBaseId.equals(InMemoryPolicyTypeDefinition.getRootPolicyType().getBaseTypeId())) {
-				so = createPolicyIntern(repositoryId, properties, folderId, null, null, null, null);
-			} else if (typeBaseId.equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType().getBaseTypeId())) {
-				so = createRelationshipIntern(repositoryId, properties, null, null, null, null);
-			} else
-				LOG.error("The type contains an unknown base object id, object can't be created");
-
-			// Make a call to getObject to convert the resulting id into an
-			// ObjectData
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-					IncludeRelationships.NONE, null, false, false, extension);
-
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+
+		if (null == properties || null == properties.getProperties())
+			throw new RuntimeException("Cannot create object, without properties.");
+
+		// Find out what kind of object needs to be created
+		PropertyData<String> pd = (PropertyData<String>) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
+		String typeId = pd == null ? null : pd.getFirstValue();
+		if (null == typeId)
+			throw new RuntimeException(
+			"Cannot create object, without a type (no property with id CMIS_OBJECT_TYPE_ID).");
+
+		TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
+		if (typeDefC == null)
+			throw new RuntimeException("Cannot create object, a type with id " + typeId + " is unknown");
+
+		// check if the given type is a document type
+		BaseTypeId typeBaseId = typeDefC.getTypeDefinition().getBaseTypeId();
+		StoredObject so = null;
+		if (typeBaseId.equals(InMemoryDocumentTypeDefinition.getRootDocumentType().getBaseTypeId())) {
+			so = createDocumentIntern(repositoryId, properties, folderId, contentStream, versioningState, null,
+					null, null, null);
+		} else if (typeBaseId.equals(InMemoryFolderTypeDefinition.getRootFolderType().getBaseTypeId())) {
+			so = createFolderIntern(repositoryId, properties, folderId, null, null, null, null);
+		} else if (typeBaseId.equals(InMemoryPolicyTypeDefinition.getRootPolicyType().getBaseTypeId())) {
+			so = createPolicyIntern(repositoryId, properties, folderId, null, null, null, null);
+		} else if (typeBaseId.equals(InMemoryRelationshipTypeDefinition.getRootRelationshipType().getBaseTypeId())) {
+			so = createRelationshipIntern(repositoryId, properties, null, null, null, null);
+		} else
+			LOG.error("The type contains an unknown base object id, object can't be created");
+
+		// Make a call to getObject to convert the resulting id into an
+		// ObjectData
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
+				IncludeRelationships.NONE, null, false, false, extension);
+
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		return od;
 	}
 
 	public void deleteContentStream(CallContext context, String repositoryId, Holder<String> objectId,
 			Holder<String> changeToken, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start deleteContentStream()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
-
-			if (!(so instanceof Content))
-				throw new CmisObjectNotFoundException("Id" + objectId
-						+ " does not refer to a document, but only documents can have content");
-
-			((Content) so).setContent(null, true);
-			LOG.debug("stop deleteContentStream()");
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start deleteContentStream()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		if (!(so instanceof Content))
+			throw new CmisObjectNotFoundException("Id" + objectId
+					+ " does not refer to a document, but only documents can have content");
+
+		((Content) so).setContent(null, true);
+		LOG.debug("stop deleteContentStream()");
 	}
 
 	public void deleteObjectOrCancelCheckOut(CallContext context, String repositoryId, String objectId,
 			Boolean allVersions, ExtensionsData extension) {
 
-		try {
-			LOG.debug("start deleteObject()");
-			checkStandardParameters(repositoryId, objectId);
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-			LOG.info("delete object for id: " + objectId);
-
-			// check if it is the root folder
-			if (objectId.equals(objectStore.getRootFolder().getId()))
-				throw new CmisNotSupportedException("You can't delete a root folder");
-
-			objectStore.deleteObject(objectId);
-			LOG.debug("stop deleteObject()");
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start deleteObject()");
+		checkStandardParameters(repositoryId, objectId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		LOG.info("delete object for id: " + objectId);
+
+		// check if it is the root folder
+		if (objectId.equals(objectStore.getRootFolder().getId()))
+			throw new CmisNotSupportedException("You can't delete a root folder");
+
+		objectStore.deleteObject(objectId);
+		LOG.debug("stop deleteObject()");
 	}
 
 	public FailedToDeleteData deleteTree(CallContext context, String repositoryId, String folderId,
 			Boolean allVersions, UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start deleteTree()");
-			StoredObject so = checkStandardParameters(repositoryId, folderId);
-			List<String> failedToDeleteIds = new ArrayList<String>();
-			FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
-
-			if (null == allVersions)
-				allVersions = true;
-			if (null == unfileObjects)
-				unfileObjects = UnfileObject.DELETE;
-			if (null == continueOnFailure)
-				continueOnFailure = false;
+		LOG.debug("start deleteTree()");
+		StoredObject so = checkStandardParameters(repositoryId, folderId);
+		List<String> failedToDeleteIds = new ArrayList<String>();
+		FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
+
+		if (null == allVersions)
+			allVersions = true;
+		if (null == unfileObjects)
+			unfileObjects = UnfileObject.DELETE;
+		if (null == continueOnFailure)
+			continueOnFailure = false;
 
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
 
-			if (null == so)
-				throw new RuntimeException("Cannot delete object with id  " + folderId + ". Object does not exist.");
+		if (null == so)
+			throw new RuntimeException("Cannot delete object with id  " + folderId + ". Object does not exist.");
 
-			if (!(so instanceof Folder))
-				throw new RuntimeException("deleteTree can only be invoked on a folder, but id " + folderId
-						+ " does not refer to a folder");
-
-			if (unfileObjects == UnfileObject.UNFILE)
-				throw new CmisNotSupportedException("This repository does not support unfile operations.");
-
-			// check if it is the root folder
-			if (folderId.equals(objectStore.getRootFolder().getId()))
-				throw new CmisNotSupportedException("You can't delete a root folder");
-
-			// recursively delete folder
-			deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds);
-
-			result.setIds(failedToDeleteIds);
-			LOG.debug("stop deleteTree()");
-			return result;
-		} finally {
-			RuntimeContext.remove();
-		}
+		if (!(so instanceof Folder))
+			throw new RuntimeException("deleteTree can only be invoked on a folder, but id " + folderId
+					+ " does not refer to a folder");
+
+		if (unfileObjects == UnfileObject.UNFILE)
+			throw new CmisNotSupportedException("This repository does not support unfile operations.");
+
+		// check if it is the root folder
+		if (folderId.equals(objectStore.getRootFolder().getId()))
+			throw new CmisNotSupportedException("You can't delete a root folder");
+
+		// recursively delete folder
+		deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds);
+
+		result.setIds(failedToDeleteIds);
+		LOG.debug("stop deleteTree()");
+		return result;
 	}
 
 	public AllowableActions getAllowableActions(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);
-
-			LOG.debug("start getAllowableActions()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
-
-			AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(objectStore, so);
-			LOG.debug("stop getAllowableActions()");
-			return allowableActions;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start getAllowableActions()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(objectStore, so);
+		LOG.debug("stop getAllowableActions()");
+		return allowableActions;
 	}
 
 	public ContentStream getContentStream(CallContext context, String repositoryId, String objectId, String streamId,
 			BigInteger offset, BigInteger length, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start getContentStream()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
-
-			if (!(so instanceof Content))
-				throw new CmisObjectNotFoundException("Id" + objectId
-						+ " does not refer to a document or version, but only those can have content");
-
-			ContentStream csd = getContentStream(so, streamId, offset, length);
-			LOG.debug("stop getContentStream()");
-			return csd;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start getContentStream()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		if (!(so instanceof Content))
+			throw new CmisObjectNotFoundException("Id" + objectId
+					+ " does not refer to a document or version, but only those can have content");
+
+		ContentStream csd = getContentStream(so, streamId, offset, length);
+		LOG.debug("stop getContentStream()");
+		return csd;
 	}
 
 	public ObjectData getObject(CallContext context, String repositoryId, String objectId, String filter,
 			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
 			Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			LOG.debug("start getObject()");
-
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
+		LOG.debug("start getObject()");
 
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
 
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
 
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, filter, includeAllowableActions,
-					includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, filter, includeAllowableActions,
+				includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
 
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
 
-			LOG.debug("stop getObject()");
+		LOG.debug("stop getObject()");
 
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+		return od;
 	}
 
 	public ObjectData getObjectByPath(CallContext context, String repositoryId, String path, String filter,
 			Boolean includeAllowableActions, IncludeRelationships includeRelationships, 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);
-
-			LOG.debug("start getObjectByPath()");
-			checkRepositoryId(repositoryId);
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-			StoredObject so = objectStore.getObjectByPath(path);
-
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown path: " + path);
-
-			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, filter, includeAllowableActions,
-					includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
-
-			LOG.debug("stop getObjectByPath()");
-
-			// To be able to provide all Atom links in the response we need
-			// additional information:
-			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-			return od;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start getObjectByPath()");
+		checkRepositoryId(repositoryId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		StoredObject so = objectStore.getObjectByPath(path);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown path: " + path);
+
+		ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, filter, includeAllowableActions,
+				includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension);
+
+		LOG.debug("stop getObjectByPath()");
+
+		// To be able to provide all Atom links in the response we need
+		// additional information:
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+		return od;
 	}
 
 	public Properties getProperties(CallContext context, String repositoryId, String objectId, String filter,
 			ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start getProperties()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId);
-
-			if (so == null)
-				throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
-
-			// build properties collection
-			List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-			Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, so, fStoreManager,
-					requestedIds);
-			LOG.debug("stop getProperties()");
-			return props;
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start getProperties()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId);
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + objectId);
+
+		// build properties collection
+		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+		Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, so, fStoreManager,
+				requestedIds);
+		LOG.debug("stop getProperties()");
+		return props;
 	}
 
 	public List<RenditionData> getRenditions(CallContext context, String repositoryId, String objectId,
 			String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			// TODO to be completed if renditions are implemented
-			LOG.debug("start getRenditions()");
-			checkStandardParameters(repositoryId, objectId);
-			LOG.debug("stop getRenditions()");
-			return null;
-		} finally {
-			RuntimeContext.remove();
-		}
+		// TODO to be completed if renditions are implemented
+		LOG.debug("start getRenditions()");
+		checkStandardParameters(repositoryId, objectId);
+		LOG.debug("stop getRenditions()");
+		return null;
 	}
 
 	public ObjectData moveObject(CallContext context, String repositoryId, Holder<String> objectId,
 			String targetFolderId, String sourceFolderId, ExtensionsData extension, ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start moveObject()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-			Folder targetFolder = null;
-			Folder sourceFolder = null;
-			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-			Filing spo = null;
-
-			if (null == so)
-				throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
-			else if (so instanceof Filing)
-				spo = (Filing) so;
-			else
-				throw new CmisInvalidArgumentException("Object must be folder or document: " + objectId.getValue());
+		LOG.debug("start moveObject()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+		Folder targetFolder = null;
+		Folder sourceFolder = null;
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		Filing spo = null;
 
-			StoredObject soTarget = objectStore.getObjectById(targetFolderId);
-			if (null == soTarget)
-				throw new CmisObjectNotFoundException("Unknown target folder: " + targetFolderId);
-			else if (soTarget instanceof Folder)
-				targetFolder = (Folder) soTarget;
-			else
-				throw new CmisNotSupportedException("Destination " + targetFolderId
-						+ " of a move operation must be a folder");
+		if (null == so)
+			throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
+		else if (so instanceof Filing)
+			spo = (Filing) so;
+		else
+			throw new CmisInvalidArgumentException("Object must be folder or document: " + objectId.getValue());
 
-			StoredObject soSource = objectStore.getObjectById(sourceFolderId);
-			if (null == soSource)
-				throw new CmisObjectNotFoundException("Unknown source folder: " + sourceFolderId);
-			else if (soSource instanceof Folder)
-				sourceFolder = (Folder) soSource;
-			else
-				throw new CmisNotSupportedException("Source " + sourceFolderId
-						+ " of a move operation must be a folder");
+		StoredObject soTarget = objectStore.getObjectById(targetFolderId);
+		if (null == soTarget)
+			throw new CmisObjectNotFoundException("Unknown target folder: " + targetFolderId);
+		else if (soTarget instanceof Folder)
+			targetFolder = (Folder) soTarget;
+		else
+			throw new CmisNotSupportedException("Destination " + targetFolderId
+					+ " of a move operation must be a folder");
 
-			boolean foundOldParent = false;
-			for (Folder parent : spo.getParents()) {
-				if (parent.getId().equals(soSource.getId())) {
-					foundOldParent = true;
-					break;
-				}
-			}
-			if (!foundOldParent)
-				throw new CmisNotSupportedException("Cannot move object, source folder " + sourceFolderId
-						+ "is not a parent of object " + objectId.getValue());
+		StoredObject soSource = objectStore.getObjectById(sourceFolderId);
+		if (null == soSource)
+			throw new CmisObjectNotFoundException("Unknown source folder: " + sourceFolderId);
+		else if (soSource instanceof Folder)
+			sourceFolder = (Folder) soSource;
+		else
+			throw new CmisNotSupportedException("Source " + sourceFolderId
+					+ " of a move operation must be a folder");
 
-			if (so instanceof Folder && hasDescendant((Folder) so, targetFolder)) {
-				throw new CmisNotSupportedException("Destination of a move cannot be a subfolder of the source");
+		boolean foundOldParent = false;
+		for (Folder parent : spo.getParents()) {
+			if (parent.getId().equals(soSource.getId())) {
+				foundOldParent = true;
+				break;
 			}
+		}
+		if (!foundOldParent)
+			throw new CmisNotSupportedException("Cannot move object, source folder " + sourceFolderId
+					+ "is not a parent of object " + objectId.getValue());
 
-			spo.move(sourceFolder, targetFolder);
-			objectId.setValue(so.getId());
-			LOG.debug("stop moveObject()");
-
-			// 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();
+		if (so instanceof Folder && hasDescendant((Folder) so, targetFolder)) {
+			throw new CmisNotSupportedException("Destination of a move cannot be a subfolder of the source");
 		}
+
+		spo.move(sourceFolder, targetFolder);
+		objectId.setValue(so.getId());
+		LOG.debug("stop moveObject()");
+
+		// 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 void setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
 			Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start setContentStream()");
-			checkStandardParameters(repositoryId, objectId.getValue());
-
-			ObjectStore folderStore = fStoreManager.getObjectStore(repositoryId);
-			StoredObject so = folderStore.getObjectById(objectId.getValue());
-			Content content;
-
-			if (!(so instanceof Document || so instanceof VersionedDocument || so instanceof DocumentVersion))
-				throw new CmisObjectNotFoundException("Id" + objectId
-						+ " does not refer to a document, but only documents can have content");
-
-			if (so instanceof Document)
-				content = ((Document) so);
-			else if (so instanceof DocumentVersion) {
-				// something that is versionable check the proper status of the
-				// object
-				String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-				testHasProperCheckedOutStatus(so, user);
-				content = (DocumentVersion) so;
-			} else
-				throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
-
-			if (!overwriteFlag && content.getContent(0, -1) != null)
-				throw new CmisConstraintException("cannot overwrite existing content if overwrite flag is not set");
-
-			content.setContent(contentStream, true);
-			LOG.debug("stop setContentStream()");
-		} finally {
-			RuntimeContext.remove();
-		}
+		LOG.debug("start setContentStream()");
+		checkStandardParameters(repositoryId, objectId.getValue());
+
+		ObjectStore folderStore = fStoreManager.getObjectStore(repositoryId);
+		StoredObject so = folderStore.getObjectById(objectId.getValue());
+		Content content;
+
+		if (!(so instanceof Document || so instanceof VersionedDocument || so instanceof DocumentVersion))
+			throw new CmisObjectNotFoundException("Id" + objectId
+					+ " does not refer to a document, but only documents can have content");
+
+		if (so instanceof Document)
+			content = ((Document) so);
+		else if (so instanceof DocumentVersion) {
+			// something that is versionable check the proper status of the
+			// object
+			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
+			testHasProperCheckedOutStatus(so, user);
+			content = (DocumentVersion) so;
+		} else
+			throw new IllegalArgumentException("Content cannot be set on this object (must be document or version)");
+
+		if (!overwriteFlag && content.getContent(0, -1) != null)
+			throw new CmisConstraintException("cannot overwrite existing content if overwrite flag is not set");
+
+		content.setContent(contentStream, true);
+		LOG.debug("stop setContentStream()");
 	}
 
 	public ObjectData updateProperties(CallContext context, String repositoryId, Holder<String> objectId,
 			Holder<String> changeToken, Properties properties, Acl acl, ExtensionsData extension,
 			ObjectInfoHolder objectInfos) {
 
-		try {
-			// Attach the CallContext to a thread local context that can be
-			// accessed from everywhere
-			RuntimeContext.attachCfg(context);
-
-			LOG.debug("start updateProperties()");
-			StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-
-			// Validation
-			TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
-			boolean isCheckedOut = false;
-
-			// if the object is a versionable object it must be checked-out
-			if (so instanceof VersionedDocument || so instanceof DocumentVersion) {
-				String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-				// VersionedDocument verDoc =
-				// testIsNotCheckedOutBySomeoneElse(so, user);
-				testHasProperCheckedOutStatus(so, user);
-				isCheckedOut = true;
-			}
+		LOG.debug("start updateProperties()");
+		StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
 
-			Map<String, PropertyData<?>> oldProperties = so.getProperties();
+		// Validation
+		TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
+		boolean isCheckedOut = false;
 
-			// check properties for validity
-			TypeValidator.validateProperties(typeDef, properties, false);
-
-			if (changeToken != null && changeToken.getValue() != null
-					&& Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue()))
-				throw new CmisUpdateConflictException(" updateProperties failed: outdated changeToken");
-
-			// update properties
-			boolean hasUpdatedName = false;
-			boolean hasUpdatedOtherProps = false;
-
-			for (String key : properties.getProperties().keySet()) {
-				if (key.equals(PropertyIds.NAME))
-					continue; // ignore here
-
-				PropertyData<?> value = properties.getProperties().get(key);
-				PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(key);
-				if (value.getValues() == null || value.getFirstValue() == null) {
-					// delete property
-					// check if a required a property
-					if (propDef.isRequired())
-						throw new CmisConstraintException(
-								"updateProperties failed, following property can't be deleted, because it is required: "
-										+ key);
-					oldProperties.remove(key);
-					hasUpdatedOtherProps = true;
-				} else {
-					if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT) && !isCheckedOut)
-						throw new CmisConstraintException(
-								"updateProperties failed, following property can't be updated, because it is not checked-out: "
-										+ key);
-					else if (!propDef.getUpdatability().equals(Updatability.READWRITE))
-						throw new CmisConstraintException(
-								"updateProperties failed, following property can't be updated, because it is not writable: "
-										+ key);
-					oldProperties.put(key, value);
-					hasUpdatedOtherProps = true;
-				}
+		// if the object is a versionable object it must be checked-out
+		if (so instanceof VersionedDocument || so instanceof DocumentVersion) {
+			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
+			// VersionedDocument verDoc =
+			// testIsNotCheckedOutBySomeoneElse(so, user);
+			testHasProperCheckedOutStatus(so, user);
+			isCheckedOut = true;
+		}
+
+		Map<String, PropertyData<?>> oldProperties = so.getProperties();
+
+		// check properties for validity
+		TypeValidator.validateProperties(typeDef, properties, false);
+
+		if (changeToken != null && changeToken.getValue() != null
+				&& Long.valueOf(so.getChangeToken()) > Long.valueOf(changeToken.getValue()))
+			throw new CmisUpdateConflictException(" updateProperties failed: outdated changeToken");
+
+		// update properties
+		boolean hasUpdatedName = false;
+		boolean hasUpdatedOtherProps = false;
+
+		for (String key : properties.getProperties().keySet()) {
+			if (key.equals(PropertyIds.NAME))
+				continue; // ignore here
+
+			PropertyData<?> value = properties.getProperties().get(key);
+			PropertyDefinition<?> propDef = typeDef.getPropertyDefinitions().get(key);
+			if (value.getValues() == null || value.getFirstValue() == null) {
+				// delete property
+				// check if a required a property
+				if (propDef.isRequired())
+					throw new CmisConstraintException(
+							"updateProperties failed, following property can't be deleted, because it is required: "
+							+ key);
+				oldProperties.remove(key);
+				hasUpdatedOtherProps = true;
+			} else {
+				if (propDef.getUpdatability().equals(Updatability.WHENCHECKEDOUT) && !isCheckedOut)
+					throw new CmisConstraintException(
+							"updateProperties failed, following property can't be updated, because it is not checked-out: "
+							+ key);
+				else if (!propDef.getUpdatability().equals(Updatability.READWRITE))
+					throw new CmisConstraintException(
+							"updateProperties failed, following property can't be updated, because it is not writable: "
+							+ key);
+				oldProperties.put(key, value);
+				hasUpdatedOtherProps = true;
 			}
+		}
 
-			// get name from properties and perform special rename to check if
-			// path
-			// already exists
-			PropertyData<?> pd = properties.getProperties().get(PropertyIds.NAME);
-			if (pd != null && so instanceof Filing) {
-				String newName = (String) pd.getFirstValue();
-				List<Folder> parents = ((Filing) so).getParents();
-				if (so instanceof Folder && parents.isEmpty())
-					throw new CmisConstraintException("updateProperties failed, you cannot rename the root folder");
-				for (Folder parent : parents) {
-					if (parent.hasChild(newName))
-						throw new CmisConstraintException(
-								"updateProperties failed, cannot rename because path already exists.");
-				}
-				so.rename((String) pd.getFirstValue()); // note: this does
-														// persist
-				hasUpdatedName = true;
-			}
+		// get name from properties and perform special rename to check if
+		// path
+		// already exists
+		PropertyData<?> pd = properties.getProperties().get(PropertyIds.NAME);
+		if (pd != null && so instanceof Filing) {
+			String newName = (String) pd.getFirstValue();
+			List<Folder> parents = ((Filing) so).getParents();
+			if (so instanceof Folder && parents.isEmpty())
+				throw new CmisConstraintException("updateProperties failed, you cannot rename the root folder");
+			for (Folder parent : parents) {
+				if (parent.hasChild(newName))
+					throw new CmisConstraintException(
+					"updateProperties failed, cannot rename because path already exists.");
+			}
+			so.rename((String) pd.getFirstValue()); // note: this does
+			// persist
+			hasUpdatedName = true;
+		}
 
-			if (hasUpdatedOtherProps) {
-				// set user, creation date, etc.
-				String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
-
-				if (user == null)
-					user = "unknown";
-				so.updateSystemBasePropertiesWhenModified(properties.getProperties(), user);
-				// set changeToken
-				so.persist();
-			}
+		if (hasUpdatedOtherProps) {
+			// set user, creation date, etc.
+			String user = RuntimeContext.getRuntimeConfigValue(CallContext.USERNAME);
 
-			if (hasUpdatedName || hasUpdatedOtherProps) {
-				objectId.setValue(so.getId()); // might have a new id
-				if (null != changeToken) {
-					String changeTokenVal = so.getChangeToken();
-					LOG.info("updateProperties(), new change token is: " + changeTokenVal);
-					changeToken.setValue(changeTokenVal);
-				}
-			}
+			if (user == null)
+				user = "unknown";
+			so.updateSystemBasePropertiesWhenModified(properties.getProperties(), user);
+			// set changeToken
+			so.persist();
+		}
 
-			if (null != acl) {
-				LOG.warn("Setting ACLs is currently not supported by this implementation, acl is ignored");
-				// if implemented add this call:
-				// fAclService.appyAcl(context, repositoryId, acl, null,
-				// AclPropagation.OBJECTONLY,
-				// extension);
+		if (hasUpdatedName || hasUpdatedOtherProps) {
+			objectId.setValue(so.getId()); // might have a new id
+			if (null != changeToken) {
+				String changeTokenVal = so.getChangeToken();
+				LOG.info("updateProperties(), new change token is: " + changeTokenVal);
+				changeToken.setValue(changeTokenVal);
 			}
+		}
 
-			// 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);
-
-			LOG.debug("stop updateProperties()");
-
-			return od;
-		} finally {
-			RuntimeContext.remove();
+		if (null != acl) {
+			LOG.warn("Setting ACLs is currently not supported by this implementation, acl is ignored");
+			// if implemented add this call:
+			// fAclService.appyAcl(context, repositoryId, acl, null,
+			// AclPropagation.OBJECTONLY,
+			// extension);
 		}
+
+		// 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);
+
+		LOG.debug("stop updateProperties()");
+
+		return od;
 	}
 
 	// ///////////////////////////////////////////////////////
@@ -816,14 +684,14 @@ public class InMemoryObjectServiceImpl e
 			DocumentVersion version = verDoc.addVersion(contentStream, versioningState, user);
 			if (null != folder)
 				folder.addChildDocument(verDoc); // add document to folder and
-													// set parent in doc
+			// set parent in doc
 			else
 				verDoc.persist();
 			version.createSystemBasePropertiesWhenCreated(properties.getProperties(), user);
 			version.setCustomProperties(properties.getProperties());
 			version.persist();
 			so = version; // return the version and not the version series to
-							// caller
+			// caller
 		} else {
 			Document doc = fStoreManager.getObjectStore(repositoryId).createDocument(name);
 			doc.setContent(contentStream, false);
@@ -832,7 +700,7 @@ public class InMemoryObjectServiceImpl e
 			doc.setCustomProperties(properties.getProperties());
 			if (null != folder)
 				folder.addChildDocument(doc); // add document to folder and set
-												// parent in doc
+			// parent in doc
 			else
 				doc.persist();
 			so = doc;



Mime
View raw message