You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2010/03/31 22:28:17 UTC
svn commit: r929708 - in
/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory:
server/ storedobj/api/ storedobj/impl/
Author: jens
Date: Wed Mar 31 20:28:17 2010
New Revision: 929708
URL: http://svn.apache.org/viewvc?rev=929708&view=rev
Log:
minor cleanup of in-memory dependencies
Modified:
incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java
incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java?rev=929708&r1=929707&r2=929708&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/server/InMemoryRepositoryServiceImpl.java Wed Mar 31 20:28:17 2010
@@ -30,8 +30,6 @@ import org.apache.opencmis.commons.api.T
import org.apache.opencmis.commons.api.TypeDefinitionList;
import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
-import org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
-import org.apache.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
import org.apache.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
import org.apache.opencmis.commons.provider.RepositoryInfoData;
import org.apache.opencmis.inmemory.storedobj.api.StoreManager;
@@ -150,36 +148,17 @@ public class InMemoryRepositoryServiceIm
List<TypeDefinitionContainer> result = null;
if (typeId == null) {
// spec says that depth must be ignored in this case
- Collection<TypeDefinitionContainer> typeColl = fStoreManager
- .getTypeDefinitionList(repositoryId);
- result = new ArrayList<TypeDefinitionContainer>(typeColl);
- if (!includePropertyDefinitions) {
- // copy list and omit properties
- for (TypeDefinitionContainer c : result) {
- AbstractTypeDefinition td = ((AbstractTypeDefinition) c.getTypeDefinition()).clone();
- TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td);
- tdc.setChildren(c.getChildren());
- td.setPropertyDefinitions(null);
- }
- }
+ Collection<TypeDefinitionContainer> tmp = fStoreManager.getTypeDefinitionList(repositoryId,
+ includePropertyDefinitions);
+ result = new ArrayList<TypeDefinitionContainer> (tmp);
}
else {
- TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId);
- if (tc != null) {
- if (null == depth || depth.intValue() == -1) {
- result = tc.getChildren();
- if (!includePropertyDefinitions)
- cloneTypeList(depth.intValue() - 1, false, result);
- }
- else if (depth.intValue() == 0 || depth.intValue() < -1)
- throw new CmisInvalidArgumentException("illegal depth value: " + depth.intValue());
- else {
- result = tc.getChildren();
- cloneTypeList(depth.intValue() - 1, includePropertyDefinitions, result);
- }
- }
- else
+ TypeDefinitionContainer tc = fStoreManager.getTypeById(repositoryId, typeId,
+ includePropertyDefinitions, depth==null ? -1 : depth.intValue());
+ if (tc == null)
throw new CmisInvalidArgumentException("unknown type id: " + typeId);
+ else
+ result = tc.getChildren();
}
return result;
@@ -189,34 +168,6 @@ public class InMemoryRepositoryServiceIm
}
}
- /**
- * traverse tree and replace each need node with a clone. remove properties on clone if requested,
- * cut children of clone if depth is exceeded.
- *
- * @param depth
- * @param types
- */
- private void cloneTypeList(int depth, boolean includePropertyDefinitions,
- List<TypeDefinitionContainer> types) {
-
- ListIterator<TypeDefinitionContainer> it = types.listIterator();
- while (it.hasNext()) {
- TypeDefinitionContainer tdc = it.next();
- AbstractTypeDefinition td = ((AbstractTypeDefinition) tdc.getTypeDefinition()).clone();
- if (!includePropertyDefinitions)
- td.setPropertyDefinitions(null);
- TypeDefinitionContainerImpl tdcClone = new TypeDefinitionContainerImpl(td);
- if (depth > 0) {
- ArrayList<TypeDefinitionContainer> children = new ArrayList<TypeDefinitionContainer>(tdc
- .getChildren().size());
- children.addAll(tdc.getChildren());
- tdcClone.setChildren(children);
- cloneTypeList(depth - 1, includePropertyDefinitions, children);
- }
- it.set(tdcClone);
- }
- }
-
private RepositoryInfoData getRepositoryInfoFromStoreManager(String repositoryId) {
RepositoryInfoData repoInfo = fStoreManager.getRepositoryInfo(repositoryId);
if (null == repoInfo || !repoInfo.getRepositoryId().equals(repositoryId)) {
Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java?rev=929708&r1=929707&r2=929708&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/api/StoreManager.java Wed Mar 31 20:28:17 2010
@@ -78,10 +78,13 @@ public interface StoreManager {
* retrieve a list with all type definitions.
* @param repositoryId
* id of repository
+ * @param includePropertyDefinitions
+ * indicates whether to include property definitions in returned type
* @return
* map with type definition
*/
- Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId);
+ Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId,
+ boolean includePropertyDefinitions);
/**
* Retrieve a type definition for a give repository and type id
@@ -96,6 +99,24 @@ public interface StoreManager {
TypeDefinitionContainer getTypeById(String repositoryId, String typeId);
/**
+ * Retrieve a type definition for a give repository and type id with or
+ * without property definitions and limited to depth in hierarchy
+ *
+ * @param repositoryId
+ * id of repository
+ * @param typeId
+ * id of type definition
+ * @param includePropertyDefinitions
+ * indicates whether to include property definitions in returned type
+ * @param depth
+ * limit depth of type hierarchy in return (-1 means unlimited)
+ * @return
+ * type definition
+ */
+ TypeDefinitionContainer getTypeById(String repositoryId, String typeId,
+ boolean includePropertyDefinitions, int depth);
+
+ /**
* Retrieve a factory to create CMIS data structures used as containers
*
* @return
Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=929708&r1=929707&r2=929708&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Wed Mar 31 20:28:17 2010
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
@@ -33,9 +34,12 @@ import org.apache.opencmis.commons.enums
import org.apache.opencmis.commons.enums.CapabilityJoin;
import org.apache.opencmis.commons.enums.CapabilityQuery;
import org.apache.opencmis.commons.enums.CapabilityRendition;
+import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
import org.apache.opencmis.commons.impl.dataobjects.ProviderObjectFactoryImpl;
import org.apache.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesDataImpl;
import org.apache.opencmis.commons.impl.dataobjects.RepositoryInfoDataImpl;
+import org.apache.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
import org.apache.opencmis.commons.provider.ProviderObjectFactory;
import org.apache.opencmis.commons.provider.RepositoryInfoData;
import org.apache.opencmis.inmemory.RepositoryInfoCreator;
@@ -113,14 +117,53 @@ public class StoreManagerImpl implements
if (null == typeManager)
throw new RuntimeException("Unknown repository " + repositoryId);
- return typeManager.getTypeById(typeId);
+ return typeManager.getTypeById(typeId);
}
- public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId) {
+ public TypeDefinitionContainer getTypeById(String repositoryId, String typeId,
+ boolean includePropertyDefinitions, int depth) {
TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
if (null == typeManager)
throw new RuntimeException("Unknown repository " + repositoryId);
- return typeManager.getTypeDefinitionList();
+
+ TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
+ List<TypeDefinitionContainer> result = null;
+
+ if (tc != null) {
+ if (depth == -1) {
+ result = tc.getChildren();
+ if (!includePropertyDefinitions)
+ cloneTypeList(depth - 1, false, result);
+ }
+ else if (depth == 0 || depth < -1)
+ throw new CmisInvalidArgumentException("illegal depth value: " + depth);
+ else {
+ result = tc.getChildren();
+ cloneTypeList(depth - 1, includePropertyDefinitions, result);
+ }
+ }
+ return tc;
+ }
+
+ public Collection<TypeDefinitionContainer> getTypeDefinitionList(String repositoryId, boolean includePropertyDefinitions) {
+ Collection<TypeDefinitionContainer> result;
+ TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+ if (null == typeManager)
+ throw new RuntimeException("Unknown repository " + repositoryId);
+ Collection<TypeDefinitionContainer> typeColl = typeManager.getTypeDefinitionList();
+ if (includePropertyDefinitions) {
+ result = typeColl;
+ } else {
+ result = new ArrayList<TypeDefinitionContainer>(typeColl);
+ // copy list and omit properties
+ for (TypeDefinitionContainer c : result) {
+ AbstractTypeDefinition td = ((AbstractTypeDefinition) c.getTypeDefinition()).clone();
+ TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td);
+ tdc.setChildren(c.getChildren());
+ td.setPropertyDefinitions(null);
+ }
+ }
+ return result;
}
public Map<String, TypeDefinitionContainer> getTypeDefinitionMap(String repositoryId) {
@@ -146,19 +189,6 @@ public class StoreManagerImpl implements
return repoInfo;
}
- private void initTypeSystem(String repositoryId, String typeCreatorClassName) {
-
- List<TypeDefinition> typeDefs = null;
- TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
- if (null == typeManager)
- throw new RuntimeException("Unknown repository " + repositoryId);
-
- if (null != typeCreatorClassName)
- typeDefs = initTypeSystem(typeCreatorClassName);
-
- typeManager.initTypeSystem(typeDefs);
- }
-
public void clearTypeSystem(String repositoryId) {
TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
if (null == typeManager)
@@ -206,6 +236,57 @@ public class StoreManagerImpl implements
}
}
+ public List<TypeDefinition> initTypeSystem(String typeCreatorClassName) {
+
+ List<TypeDefinition> typesList = null;
+
+ if (typeCreatorClassName != null) {
+ Object obj = null;
+ TypeCreator typeCreator = null;
+
+ try {
+ obj = Class.forName(typeCreatorClassName).newInstance();
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException(
+ "Illegal class to create type system, must implement TypeCreator interface.", e);
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException(
+ "Illegal class to create type system, must implement TypeCreator interface.", e);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(
+ "Illegal class to create type system, must implement TypeCreator interface.", e);
+ }
+
+ if (obj instanceof TypeCreator)
+ typeCreator = (TypeCreator) obj;
+ else
+ throw new RuntimeException(
+ "Illegal class to create type system, must implement TypeCreator interface.");
+
+ // retrieve the list of available types from the configured class.
+ // test
+ typesList = typeCreator.createTypesList();
+ }
+
+ return typesList;
+ }
+
+ private void initTypeSystem(String repositoryId, String typeCreatorClassName) {
+
+ List<TypeDefinition> typeDefs = null;
+ TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
+ if (null == typeManager)
+ throw new RuntimeException("Unknown repository " + repositoryId);
+
+ if (null != typeCreatorClassName)
+ typeDefs = initTypeSystem(typeCreatorClassName);
+
+ typeManager.initTypeSystem(typeDefs);
+ }
+
private RepositoryInfoData createDefaultRepositoryInfo(String repositoryId) {
ObjectStore objStore = getObjectStore(repositoryId);
String rootFolderId = objStore.getRootFolder().getId();
@@ -256,42 +337,32 @@ public class StoreManagerImpl implements
return repoInfo;
}
- public List<TypeDefinition> initTypeSystem(String typeCreatorClassName) {
-
- List<TypeDefinition> typesList = null;
-
- if (typeCreatorClassName != null) {
- Object obj = null;
- TypeCreator typeCreator = null;
+ /**
+ * traverse tree and replace each need node with a clone. remove properties on clone if requested,
+ * cut children of clone if depth is exceeded.
+ *
+ * @param depth
+ * @param types
+ */
+ private void cloneTypeList(int depth, boolean includePropertyDefinitions,
+ List<TypeDefinitionContainer> types) {
- try {
- obj = Class.forName(typeCreatorClassName).newInstance();
- }
- catch (InstantiationException e) {
- throw new RuntimeException(
- "Illegal class to create type system, must implement TypeCreator interface.", e);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Illegal class to create type system, must implement TypeCreator interface.", e);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException(
- "Illegal class to create type system, must implement TypeCreator interface.", e);
+ ListIterator<TypeDefinitionContainer> it = types.listIterator();
+ while (it.hasNext()) {
+ TypeDefinitionContainer tdc = it.next();
+ AbstractTypeDefinition td = ((AbstractTypeDefinition) tdc.getTypeDefinition()).clone();
+ if (!includePropertyDefinitions)
+ td.setPropertyDefinitions(null);
+ TypeDefinitionContainerImpl tdcClone = new TypeDefinitionContainerImpl(td);
+ if (depth > 0) {
+ ArrayList<TypeDefinitionContainer> children = new ArrayList<TypeDefinitionContainer>(tdc
+ .getChildren().size());
+ children.addAll(tdc.getChildren());
+ tdcClone.setChildren(children);
+ cloneTypeList(depth - 1, includePropertyDefinitions, children);
}
-
- if (obj instanceof TypeCreator)
- typeCreator = (TypeCreator) obj;
- else
- throw new RuntimeException(
- "Illegal class to create type system, must implement TypeCreator interface.");
-
- // retrieve the list of available types from the configured class.
- // test
- typesList = typeCreator.createTypesList();
+ it.set(tdcClone);
}
-
- return typesList;
}
-
+
}