chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r935546 - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/...
Date Mon, 19 Apr 2010 12:49:41 GMT
Author: fmui
Date: Mon Apr 19 12:49:41 2010
New Revision: 935546

URL: http://svn.apache.org/viewvc?rev=935546&view=rev
Log:
added convenience code that generates object infos

Added:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java
Removed:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfosImpl.java
Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/CmisService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareServiceFactory.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/CmisService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/CmisService.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/CmisService.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/api/server/CmisService.java
Mon Apr 19 12:49:41 2010
@@ -59,7 +59,7 @@ public interface CmisService extends Rep
 	 * 
 	 * Only AtomPub requests will require object infos.
 	 */
-	ObjectInfo getObjectInfo(String objectId);
+	ObjectInfo getObjectInfo(String repositoryId, String objectId);
 
 	/**
 	 * Signals that this object will not be used anymore and resources can

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
Mon Apr 19 12:49:41 2010
@@ -1,6 +1,8 @@
 package org.apache.chemistry.opencmis.commons.impl.server;
 
 import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -18,15 +20,24 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.api.ObjectList;
 import org.apache.chemistry.opencmis.commons.api.ObjectParentData;
 import org.apache.chemistry.opencmis.commons.api.Properties;
+import org.apache.chemistry.opencmis.commons.api.PropertyBoolean;
 import org.apache.chemistry.opencmis.commons.api.PropertyData;
+import org.apache.chemistry.opencmis.commons.api.PropertyDateTime;
+import org.apache.chemistry.opencmis.commons.api.PropertyId;
+import org.apache.chemistry.opencmis.commons.api.PropertyInteger;
+import org.apache.chemistry.opencmis.commons.api.PropertyString;
 import org.apache.chemistry.opencmis.commons.api.RenditionData;
+import org.apache.chemistry.opencmis.commons.api.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.api.RepositoryInfo;
 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.CmisService;
 import org.apache.chemistry.opencmis.commons.api.server.ObjectInfo;
+import org.apache.chemistry.opencmis.commons.api.server.RenditionInfo;
 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -39,6 +50,7 @@ import org.apache.chemistry.opencmis.com
 public abstract class AbstractCmisService implements CmisService {
 
 	private Map<String, ObjectInfo> objectInfoMap;
+	private boolean addObjectInfos = true;
 
 	// --- repository service ---
 
@@ -828,27 +840,266 @@ public abstract class AbstractCmisServic
 
 	// --- server specific ---
 
-	public ObjectInfo getObjectInfo(String objectId) {
+	/**
+	 * Returns the object info map.
+	 */
+	private Map<String, ObjectInfo> getObjectInfoMap() {
 		if (objectInfoMap == null) {
-			return null;
+			objectInfoMap = new HashMap<String, ObjectInfo>();
+		}
+
+		return objectInfoMap;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * <p>
+	 * <b>Implementation Hints:</b>
+	 * <ul>
+	 * <li>Bindings: AtomPub</li>
+	 * <li>If the object info is not found, the object info will be assembled.
+	 * To do that the repository info, the object, the object parent, the object
+	 * history and the base type definitions will be fetched. If you want to
+	 * change this behavior, override this method.</li>
+	 * </ul>
+	 */
+	public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
+		objectInfoMap = getObjectInfoMap();
+
+		ObjectInfo info = objectInfoMap.get(objectId);
+		if (info == null) {
+			// object info has not been found -> create one
+			ObjectInfoImpl infoImpl = new ObjectInfoImpl();
+
+			try {
+				// switch off object info collection to avoid side effects
+				addObjectInfos = false;
+
+				// get the object
+				ObjectData object = getObject(repositoryId, objectId, null, Boolean.TRUE, IncludeRelationships.BOTH,
+						"*", Boolean.TRUE, Boolean.FALSE, null);
+
+				// if the object has no properties, stop here
+				if (object.getProperties() == null || object.getProperties().getProperties() == null)
{
+					throw new Exception("No properties!");
+				}
+
+				// get the repository info
+				RepositoryInfo repositoryInfo = getRepositoryInfo(repositoryId, null);
+
+				// general properties
+				infoImpl.setObject(object);
+				infoImpl.setId(object.getId());
+				infoImpl.setName(getStringProperty(object, PropertyIds.NAME));
+				infoImpl.setCreatedBy(getStringProperty(object, PropertyIds.CREATED_BY));
+				infoImpl.setCreationDate(getDateTimeProperty(object, PropertyIds.CREATED_BY));
+				infoImpl.setLastModificationDate(getDateTimeProperty(object, PropertyIds.LAST_MODIFICATION_DATE));
+				infoImpl.setTypeId(getIdProperty(object, PropertyIds.OBJECT_TYPE_ID));
+				infoImpl.setBaseType(object.getBaseTypeId());
+
+				// versioning
+				infoImpl.setIsCurrentVersion(object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT);
+				infoImpl.setWorkingCopyId(null);
+				infoImpl.setWorkingCopyOriginalId(null);
+
+				infoImpl.setVersionSeriesId(getStringProperty(object, PropertyIds.VERSION_SERIES_ID));
+				if (infoImpl.getVersionSeriesId() != null) {
+					Boolean isLatest = getBooleanProperty(object, PropertyIds.IS_LATEST_VERSION);
+					infoImpl.setIsCurrentVersion(isLatest == null ? true : isLatest.booleanValue());
+
+					Boolean isCheckedOut = getBooleanProperty(object, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+					if (isCheckedOut != null && isCheckedOut.booleanValue()) {
+						infoImpl.setWorkingCopyId(getIdProperty(object, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID));
+
+						// get latest version
+						List<ObjectData> versions = getAllVersions(repositoryId, objectId, infoImpl
+								.getVersionSeriesId(), PropertyIds.OBJECT_ID, Boolean.FALSE, null);
+						if (versions != null && versions.size() > 0) {
+							infoImpl.setWorkingCopyOriginalId(versions.get(0).getId());
+						}
+					}
+				}
+
+				// content
+				String fileName = getStringProperty(object, PropertyIds.CONTENT_STREAM_FILE_NAME);
+				String mimeType = getStringProperty(object, PropertyIds.CONTENT_STREAM_MIME_TYPE);
+				String streamId = getStringProperty(object, PropertyIds.CONTENT_STREAM_ID);
+				BigInteger length = getIntegerProperty(object, PropertyIds.CONTENT_STREAM_LENGTH);
+				boolean hasContent = fileName != null || mimeType != null || streamId != null || length
!= null;
+				if (hasContent) {
+					infoImpl.setHasContent(hasContent);
+					infoImpl.setContentType(mimeType);
+					infoImpl.setFileName(fileName);
+				} else {
+					infoImpl.setHasContent(false);
+					infoImpl.setContentType(null);
+					infoImpl.setFileName(null);
+				}
+
+				// parent
+				List<ObjectParentData> parents = getObjectParents(repositoryId, objectId, PropertyIds.OBJECT_ID,
+						Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
+				infoImpl.setHasParent(parents.size() > 0);
+
+				// policies and relationships
+				infoImpl.setSupportsRelationships(false);
+				infoImpl.setSupportsPolicies(false);
+
+				TypeDefinitionList baseTypesList = getTypeChildren(repositoryId, null, Boolean.FALSE,
BigInteger
+						.valueOf(4), BigInteger.ZERO, null);
+				for (TypeDefinition type : baseTypesList.getList()) {
+					if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(type.getId())) {
+						infoImpl.setSupportsRelationships(true);
+					} else if (BaseTypeId.CMIS_POLICY.value().equals(type.getId())) {
+						infoImpl.setSupportsPolicies(true);
+					}
+				}
+
+				// renditions
+				infoImpl.setRenditionInfos(null);
+
+				List<RenditionData> renditions = object.getRenditions();
+				if (renditions != null && renditions.size() > 0) {
+					List<RenditionInfo> renditionInfos = new ArrayList<RenditionInfo>();
+
+					for (RenditionData rendition : renditions) {
+						RenditionInfoImpl renditionInfo = new RenditionInfoImpl();
+						renditionInfo.setId(rendition.getStreamId());
+						renditionInfo.setKind(rendition.getKind());
+						renditionInfo.setContentType(rendition.getMimeType());
+						renditionInfo.setTitle(rendition.getTitle());
+						renditionInfo.setLength(rendition.getBigLength());
+
+						renditionInfos.add(renditionInfo);
+					}
+
+					infoImpl.setRenditionInfos(renditionInfos);
+				}
+
+				// relationships
+				infoImpl.setRelationshipSourceIds(null);
+				infoImpl.setRelationshipTargetIds(null);
+
+				List<ObjectData> relationships = object.getRelationships();
+				if (relationships != null && relationships.size() > 0) {
+					List<String> sourceIds = new ArrayList<String>();
+					List<String> targetIds = new ArrayList<String>();
+
+					for (ObjectData relationship : relationships) {
+						String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
+						String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
+
+						if (object.getId().equals(sourceId)) {
+							sourceIds.add(relationship.getId());
+						}
+						if (object.getId().equals(targetId)) {
+							targetIds.add(relationship.getId());
+						}
+					}
+
+					if (sourceIds.size() > 0) {
+						infoImpl.setRelationshipSourceIds(sourceIds);
+					}
+					if (targetIds.size() > 0) {
+						infoImpl.setRelationshipTargetIds(targetIds);
+					}
+				}
+
+				// global settings
+				infoImpl.setHasAcl(false);
+				infoImpl.setSupportsDescendants(false);
+				infoImpl.setSupportsFolderTree(false);
+
+				RepositoryCapabilities capabilities = repositoryInfo.getCapabilities();
+				if (capabilities != null) {
+					infoImpl.setHasAcl(capabilities.getAclCapability() == CapabilityAcl.DISCOVER
+							|| capabilities.getAclCapability() == CapabilityAcl.MANAGE);
+					if (object.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
+						infoImpl.setSupportsDescendants(Boolean.TRUE.equals(capabilities.isGetDescendantsSupported()));
+						infoImpl.setSupportsFolderTree(Boolean.TRUE.equals(capabilities.isGetFolderTreeSupported()));
+					}
+				}
+
+				// switch on object info collection
+				addObjectInfos = true;
+
+				// add object info
+				addObjectInfo(infoImpl);
+				info = infoImpl;
+			} catch (Exception e) {
+				info = null;
+			} finally {
+				addObjectInfos = true;
+			}
 		}
 
-		return objectInfoMap.get(objectId);
+		return info;
 	}
 
 	/**
 	 * Adds an object info.
 	 */
 	public void addObjectInfo(ObjectInfo objectInfo) {
-		if (objectInfoMap == null) {
-			objectInfoMap = new HashMap<String, ObjectInfo>();
+		if (!addObjectInfos) {
+			return;
 		}
 
 		if (objectInfo != null && objectInfo.getId() != null) {
-			objectInfoMap.put(objectInfo.getId(), objectInfo);
+			getObjectInfoMap().put(objectInfo.getId(), objectInfo);
 		}
 	}
 
+	/**
+	 * Clears the object info map.
+	 */
+	public void clearObjectInfos() {
+		objectInfoMap = null;
+	}
+
 	public void close() {
+		clearObjectInfos();
+	}
+
+	// --- helpers ---
+
+	private String getStringProperty(ObjectData object, String name) {
+		PropertyData<?> property = object.getProperties().getProperties().get(name);
+		if (property instanceof PropertyString) {
+			return ((PropertyString) property).getFirstValue();
+		}
+		return null;
+	}
+
+	private String getIdProperty(ObjectData object, String name) {
+		PropertyData<?> property = object.getProperties().getProperties().get(name);
+		if (property instanceof PropertyId) {
+			return ((PropertyId) property).getFirstValue();
+		}
+		return null;
+	}
+
+	private GregorianCalendar getDateTimeProperty(ObjectData object, String name) {
+		PropertyData<?> property = object.getProperties().getProperties().get(name);
+		if (property instanceof PropertyDateTime) {
+			return ((PropertyDateTime) property).getFirstValue();
+		}
+		return null;
+	}
+
+	private Boolean getBooleanProperty(ObjectData object, String name) {
+		PropertyData<?> property = object.getProperties().getProperties().get(name);
+		if (property instanceof PropertyBoolean) {
+			return ((PropertyBoolean) property).getFirstValue();
+		}
+		return null;
+	}
+
+	private BigInteger getIntegerProperty(ObjectData object, String name) {
+		PropertyData<?> property = object.getProperties().getProperties().get(name);
+		if (property instanceof PropertyInteger) {
+			return ((PropertyInteger) property).getFirstValue();
+		}
+		return null;
 	}
 }

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java?rev=935546&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java
(added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java
Mon Apr 19 12:49:41 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.commons.impl.server;
+
+import java.math.BigInteger;
+
+import org.apache.chemistry.opencmis.commons.api.server.RenditionInfo;
+
+/**
+ * Implementation of the {@link RenditionInfo} interface.
+ */
+public class RenditionInfoImpl implements RenditionInfo {
+
+	private String id;
+	private String contentType;
+	private String kind;
+	private String title;
+	private BigInteger length;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getContenType() {
+		return contentType;
+	}
+
+	public void setContentType(String contentType) {
+		this.contentType = contentType;
+	}
+
+	public String getKind() {
+		return kind;
+	}
+
+	public void setKind(String kind) {
+		this.kind = kind;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public BigInteger getLength() {
+		return length;
+	}
+
+	public void setLength(BigInteger length) {
+		this.length = length;
+	}
+}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareService.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareService.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareService.java
Mon Apr 19 12:49:41 2010
@@ -34,8 +34,8 @@ import org.apache.chemistry.opencmis.com
  */
 public class FileShareService extends AbstractCmisService {
 
-	private ThreadLocal<CallContext> threadLocalCallContext = new ThreadLocal<CallContext>();
 	private RepositoryMap repositoryMap;
+	private CallContext context;
 
 	/**
 	 * Constructor.
@@ -44,36 +44,25 @@ public class FileShareService extends Ab
 		this.repositoryMap = repositoryMap;
 	}
 
-	// --- thread locals ---
+	// --- context ---
 
-	public void setThreadCallContext(CallContext context) {
-		threadLocalCallContext.set(context);
+	public void setCallContext(CallContext context) {
+		this.context = context;
 	}
 
-	public CallContext getThreadCallContext() {
-		return threadLocalCallContext.get();
-	}
-
-	public void removeThreadCallContext() {
-		threadLocalCallContext.remove();
+	public CallContext getCallContext() {
+		return context;
 	}
 
 	public FileShareRepository getRepository() {
-		return repositoryMap.getRepository(getThreadCallContext().getRepositoryId());
-	}
-
-	// --- life cycle ---
-
-	@Override
-	public void close() {
-		removeThreadCallContext();
+		return repositoryMap.getRepository(getCallContext().getRepositoryId());
 	}
 
 	// --- repository service ---
 
 	@Override
 	public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
-		return getRepository().getRepositoryInfo(getThreadCallContext());
+		return getRepository().getRepositoryInfo(getCallContext());
 	}
 
 	@Override
@@ -81,7 +70,7 @@ public class FileShareService extends Ab
 		List<RepositoryInfo> result = new ArrayList<RepositoryInfo>();
 
 		for (FileShareRepository fsr : repositoryMap.getRepositories()) {
-			result.add(fsr.getRepositoryInfo(getThreadCallContext()));
+			result.add(fsr.getRepositoryInfo(getCallContext()));
 		}
 
 		return result;
@@ -90,19 +79,19 @@ public class FileShareService extends Ab
 	@Override
 	public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
 			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
-		return getRepository().getTypesChildren(getThreadCallContext(), typeId, includePropertyDefinitions,
maxItems,
+		return getRepository().getTypesChildren(getCallContext(), typeId, includePropertyDefinitions,
maxItems,
 				skipCount);
 	}
 
 	@Override
 	public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData
extension) {
-		return getRepository().getTypeDefinition(getThreadCallContext(), typeId);
+		return getRepository().getTypeDefinition(getCallContext(), typeId);
 	}
 
 	@Override
 	public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String
typeId, BigInteger depth,
 			Boolean includePropertyDefinitions, ExtensionsData extension) {
-		return getRepository().getTypesDescendants(getThreadCallContext(), typeId, depth, includePropertyDefinitions);
+		return getRepository().getTypesDescendants(getCallContext(), typeId, depth, includePropertyDefinitions);
 	}
 
 	// --- navigation service ---
@@ -111,7 +100,7 @@ public class FileShareService extends Ab
 	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 getRepository().getChildren(getThreadCallContext(), folderId, filter, includeAllowableActions,
+		return getRepository().getChildren(getCallContext(), folderId, filter, includeAllowableActions,
 				includePathSegment, maxItems, skipCount, null);
 	}
 
@@ -119,20 +108,20 @@ public class FileShareService extends Ab
 	public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId,
BigInteger depth,
 			String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
 			String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
-		return getRepository().getDescendants(getThreadCallContext(), folderId, depth, filter,
includeAllowableActions,
+		return getRepository().getDescendants(getCallContext(), folderId, depth, filter, includeAllowableActions,
 				includePathSegment, null, false);
 	}
 
 	@Override
 	public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData
extension) {
-		return getRepository().getFolderParent(getThreadCallContext(), folderId, filter, null);
+		return getRepository().getFolderParent(getCallContext(), folderId, filter, null);
 	}
 
 	@Override
 	public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId,
BigInteger depth,
 			String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
 			String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
-		return getRepository().getDescendants(getThreadCallContext(), folderId, depth, filter,
includeAllowableActions,
+		return getRepository().getDescendants(getCallContext(), folderId, depth, filter, includeAllowableActions,
 				includePathSegment, null, true);
 	}
 
@@ -140,7 +129,7 @@ public class FileShareService extends Ab
 	public List<ObjectParentData> getObjectParents(String repositoryId, String objectId,
String filter,
 			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
 			Boolean includeRelativePathSegment, ExtensionsData extension) {
-		return getRepository().getObjectParents(getThreadCallContext(), objectId, filter, includeAllowableActions,
+		return getRepository().getObjectParents(getCallContext(), objectId, filter, includeAllowableActions,
 				includeRelativePathSegment, null);
 	}
 
@@ -162,7 +151,7 @@ public class FileShareService extends Ab
 	@Override
 	public String create(String repositoryId, Properties properties, String folderId, ContentStream
contentStream,
 			VersioningState versioningState, List<String> policies, ExtensionsData extension)
{
-		ObjectData object = getRepository().create(getThreadCallContext(), properties, folderId,
contentStream,
+		ObjectData object = getRepository().create(getCallContext(), properties, folderId, contentStream,
 				versioningState, null);
 
 		return object.getId();
@@ -172,72 +161,70 @@ public class FileShareService extends Ab
 	public String createDocument(String repositoryId, Properties properties, String folderId,
 			ContentStream contentStream, VersioningState versioningState, List<String> policies,
Acl addAces,
 			Acl removeAces, ExtensionsData extension) {
-		return getRepository().createDocument(getThreadCallContext(), properties, folderId, contentStream,
-				versioningState);
+		return getRepository().createDocument(getCallContext(), properties, folderId, contentStream,
versioningState);
 	}
 
 	@Override
 	public String createDocumentFromSource(String repositoryId, String sourceId, Properties
properties,
 			String folderId, VersioningState versioningState, List<String> policies, Acl addAces,
Acl removeAces,
 			ExtensionsData extension) {
-		return getRepository().createDocumentFromSource(getThreadCallContext(), sourceId, properties,
folderId,
+		return getRepository().createDocumentFromSource(getCallContext(), sourceId, properties,
folderId,
 				versioningState);
 	}
 
 	@Override
 	public String createFolder(String repositoryId, Properties properties, String folderId,
List<String> policies,
 			Acl addAces, Acl removeAces, ExtensionsData extension) {
-		return getRepository().createFolder(getThreadCallContext(), properties, folderId);
+		return getRepository().createFolder(getCallContext(), properties, folderId);
 	}
 
 	@Override
 	public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String>
changeToken,
 			ExtensionsData extension) {
-		getRepository().setContentStream(getThreadCallContext(), objectId, true, null);
+		getRepository().setContentStream(getCallContext(), objectId, true, null);
 	}
 
 	@Override
 	public void deleteObjectOrCancelCheckOut(String repositoryId, String objectId, Boolean allVersions,
 			ExtensionsData extension) {
-		getRepository().deleteObject(getThreadCallContext(), objectId);
+		getRepository().deleteObject(getCallContext(), objectId);
 	}
 
 	@Override
 	public FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
 			UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
-		return getRepository().deleteTree(getThreadCallContext(), folderId, continueOnFailure);
+		return getRepository().deleteTree(getCallContext(), folderId, continueOnFailure);
 	}
 
 	@Override
 	public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData
extension) {
-		return getRepository().getAllowableActions(getThreadCallContext(), objectId);
+		return getRepository().getAllowableActions(getCallContext(), objectId);
 	}
 
 	@Override
 	public ContentStream getContentStream(String repositoryId, String objectId, String streamId,
BigInteger offset,
 			BigInteger length, ExtensionsData extension) {
-		return getRepository().getContentStream(getThreadCallContext(), objectId, offset, length);
+		return getRepository().getContentStream(getCallContext(), objectId, offset, length);
 	}
 
 	@Override
 	public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean
includeAllowableActions,
 			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
 			Boolean includeAcl, ExtensionsData extension) {
-		return getRepository().getObject(getThreadCallContext(), objectId, filter, includeAllowableActions,
includeAcl,
-				null);
+		return getRepository().getObject(getCallContext(), objectId, filter, includeAllowableActions,
includeAcl, null);
 	}
 
 	@Override
 	public ObjectData getObjectByPath(String repositoryId, String path, String filter, Boolean
includeAllowableActions,
 			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
 			Boolean includeAcl, ExtensionsData extension) {
-		return getRepository().getObjectByPath(getThreadCallContext(), path, filter, includeAllowableActions,
-				includeAcl, null);
+		return getRepository().getObjectByPath(getCallContext(), path, filter, includeAllowableActions,
includeAcl,
+				null);
 	}
 
 	@Override
 	public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData
extension) {
-		ObjectData object = getRepository().getObject(getThreadCallContext(), objectId, filter,
false, false, null);
+		ObjectData object = getRepository().getObject(getCallContext(), objectId, filter, false,
false, null);
 		return object.getProperties();
 	}
 
@@ -250,19 +237,19 @@ public class FileShareService extends Ab
 	@Override
 	public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId,
String sourceFolderId,
 			ExtensionsData extension) {
-		getRepository().moveObject(getThreadCallContext(), objectId, targetFolderId, null);
+		getRepository().moveObject(getCallContext(), objectId, targetFolderId, null);
 	}
 
 	@Override
 	public void setContentStream(String repositoryId, Holder<String> objectId, Boolean
overwriteFlag,
 			Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension)
{
-		getRepository().setContentStream(getThreadCallContext(), objectId, overwriteFlag, contentStream);
+		getRepository().setContentStream(getCallContext(), objectId, overwriteFlag, contentStream);
 	}
 
 	@Override
 	public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String>
changeToken,
 			Properties properties, ExtensionsData extension) {
-		getRepository().updateProperties(getThreadCallContext(), objectId, properties, null);
+		getRepository().updateProperties(getCallContext(), objectId, properties, null);
 	}
 
 	// --- versioning service ---
@@ -270,7 +257,7 @@ public class FileShareService extends Ab
 	@Override
 	public List<ObjectData> getAllVersions(String repositoryId, String objectId, String
versionSeriesId, String filter,
 			Boolean includeAllowableActions, ExtensionsData extension) {
-		ObjectData theVersion = getRepository().getObject(getThreadCallContext(), versionSeriesId,
filter,
+		ObjectData theVersion = getRepository().getObject(getCallContext(), versionSeriesId, filter,
 				includeAllowableActions, false, null);
 
 		return Collections.singletonList(theVersion);
@@ -280,15 +267,14 @@ public class FileShareService extends Ab
 	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)
{
-		return getRepository().getObject(getThreadCallContext(), versionSeriesId, filter, includeAllowableActions,
+		return getRepository().getObject(getCallContext(), versionSeriesId, filter, includeAllowableActions,
 				includeAcl, null);
 	}
 
 	@Override
 	public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String
versionSeriesId,
 			Boolean major, String filter, ExtensionsData extension) {
-		ObjectData object = getRepository().getObject(getThreadCallContext(), versionSeriesId,
filter, false, false,
-				null);
+		ObjectData object = getRepository().getObject(getCallContext(), versionSeriesId, filter,
false, false, null);
 
 		return object.getProperties();
 	}
@@ -297,6 +283,6 @@ public class FileShareService extends Ab
 
 	@Override
 	public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData
extension) {
-		return getRepository().getAcl(getThreadCallContext(), objectId);
+		return getRepository().getAcl(getCallContext(), objectId);
 	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareServiceFactory.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareServiceFactory.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareServiceFactory.java
Mon Apr 19 12:49:41 2010
@@ -40,8 +40,7 @@ public class FileShareServiceFactory ext
 	private RepositoryMap repositoryMap;
 	private TypeManager typeManager;
 
-	private FileShareService fileShareService;
-	private CmisService wrapperService;
+	private ThreadLocal<CmisServiceWrapper<FileShareService>> threadLocalService
= new ThreadLocal<CmisServiceWrapper<FileShareService>>();
 
 	public FileShareServiceFactory() {
 	}
@@ -52,17 +51,25 @@ public class FileShareServiceFactory ext
 		typeManager = new TypeManager();
 
 		readConfiguration(parameters);
+	}
 
-		// create service object and wrapper
-		fileShareService = new FileShareService(repositoryMap);
-		wrapperService = new CmisServiceWrapper(fileShareService, DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES,
-				DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);
+	@Override
+	public void destroy() {
+		threadLocalService = null;
 	}
 
 	@Override
 	public CmisService getService(CallContext context) {
 		repositoryMap.getAuthenticatedRepository(context, context.getRepositoryId());
-		fileShareService.setThreadCallContext(context);
+
+		CmisServiceWrapper<FileShareService> wrapperService = threadLocalService.get();
+		if (wrapperService == null) {
+			wrapperService = new CmisServiceWrapper<FileShareService>(new FileShareService(repositoryMap),
+					DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);
+			threadLocalService.set(wrapperService);
+		}
+
+		wrapperService.getWrappedService().setCallContext(context);
 
 		return wrapperService;
 	}

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
Mon Apr 19 12:49:41 2010
@@ -36,7 +36,7 @@ import org.apache.commons.logging.LogFac
 /**
  * Service wrapper.
  */
-public class CmisServiceWrapper implements CmisService {
+public class CmisServiceWrapper<T extends CmisService> implements CmisService {
 
 	public static final BigInteger MINUS_ONE = BigInteger.valueOf(-1);
 
@@ -48,12 +48,12 @@ public class CmisServiceWrapper implemen
 	private BigInteger defaultMaxItems = null;
 	private BigInteger defaultDepth = MINUS_ONE;
 
-	private CmisService service;
+	private T service;
 
 	/**
 	 * Constructor.
 	 */
-	public CmisServiceWrapper(CmisService service, BigInteger defaultTypesMaxItems, BigInteger
defaultTypesDepth,
+	public CmisServiceWrapper(T service, BigInteger defaultTypesMaxItems, BigInteger defaultTypesDepth,
 			BigInteger defaultMaxItems, BigInteger defaultDepth) {
 		if (service == null) {
 			throw new IllegalArgumentException("Service must be set!");
@@ -400,8 +400,12 @@ public class CmisServiceWrapper implemen
 
 	// --- service operations ---
 
-	public ObjectInfo getObjectInfo(String objectId) {
-		return service.getObjectInfo(objectId);
+	public T getWrappedService() {
+		return service;
+	}
+
+	public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
+		return service.getObjectInfo(repositoryId, objectId);
 	}
 
 	public void close() {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java?rev=935546&r1=935545&r2=935546&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java
Mon Apr 19 12:49:41 2010
@@ -44,7 +44,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
-import org.apache.chemistry.opencmis.commons.impl.server.RenditionInfosImpl;
+import org.apache.chemistry.opencmis.commons.impl.server.RenditionInfoImpl;
 import org.apache.chemistry.opencmis.server.spi.CmisNavigationService;
 import org.apache.chemistry.opencmis.server.spi.CmisObjectService;
 import org.apache.chemistry.opencmis.server.spi.CmisRepositoryService;
@@ -444,7 +444,7 @@ public class ObjectInfoHelper {
 			return null;
 
 		List<RenditionInfo> rendInfos = new ArrayList<RenditionInfo>(renditions.size());
-		RenditionInfosImpl ri = new RenditionInfosImpl();
+		RenditionInfoImpl ri = new RenditionInfoImpl();
 		for (RenditionData rd : renditions) {
 			ri.setContentType(rd.getMimeType());
 			ri.setId(rd.getStreamId());



Mime
View raw message