Author: fmui
Date: Thu Jan 3 16:28:20 2013
New Revision: 1428454
URL: http://svn.apache.org/viewvc?rev=1428454&view=rev
Log:
Server: added convenience implementation for getTypeDescendants()
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java
Modified:
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/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java?rev=1428454&r1=1428453&r2=1428454&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractCmisService.java
Thu Jan 3 16:28:20 2013
@@ -61,6 +61,7 @@ import org.apache.chemistry.opencmis.com
import
org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
import
org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import
org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
import org.apache.chemistry.opencmis.commons.server.CmisService;
import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
@@ -136,12 +137,61 @@ public abstract class AbstractCmisServic
* <b>Implementation Hints:</b>
* <ul>
* <li>Bindings: AtomPub, Web Services, Browser, Local</li>
- * <li>Implementation is optional.</li>
+ * <li>Implementation is optional. Convenience implementation is
present.</li>
* </ul>
*/
public List<TypeDefinitionContainer> getTypeDescendants(String
repositoryId, String typeId, BigInteger depth,
Boolean includePropertyDefinitions, ExtensionsData extension) {
- throw new CmisNotSupportedException("Not supported!");
+ // check depth
+ int d = (depth == null ? -1 : depth.intValue());
+ if (d == 0) {
+ throw new CmisInvalidArgumentException("Depth must not be 0!");
+ }
+ if (typeId == null) {
+ d = -1;
+ }
+
+ List<TypeDefinitionContainer> result = new
ArrayList<TypeDefinitionContainer>();
+
+ TypeDefinitionList children = getTypeChildren(repositoryId, typeId,
includePropertyDefinitions,
+ BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.ZERO, null);
+
+ if (children != null && children.getList() != null &&
children.getList().size() > 0) {
+ for (TypeDefinition td : children.getList()) {
+ TypeDefinitionContainerImpl tdc = new
TypeDefinitionContainerImpl(td);
+ addTypeChildren(repositoryId, includePropertyDefinitions, (d >
0 ? d - 1 : -1), tdc);
+ result.add(tdc);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Helper method for
+ * {@link #getTypeDescendants(String, String, BigInteger, Boolean,
ExtensionsData)}
+ * .
+ */
+ private void addTypeChildren(String repositoryId, Boolean
includePropertyDefinitions, int depth,
+ TypeDefinitionContainerImpl container) {
+
+ if (depth == 0) {
+ return;
+ }
+
+ TypeDefinitionList children = getTypeChildren(repositoryId,
container.getTypeDefinition().getId(),
+ includePropertyDefinitions,
BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.ZERO, null);
+
+ if (children != null && children.getList() != null &&
children.getList().size() > 0) {
+ List<TypeDefinitionContainer> list = new
ArrayList<TypeDefinitionContainer>();
+ container.setChildren(list);
+
+ for (TypeDefinition td : children.getList()) {
+ TypeDefinitionContainerImpl tdc = new
TypeDefinitionContainerImpl(td);
+ addTypeChildren(repositoryId, includePropertyDefinitions,
(depth > 0 ? depth - 1 : -1), tdc);
+ list.add(tdc);
+ }
+ }
}
/**
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java?rev=1428454&r1=1428453&r2=1428454&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/TypeManager.java
Thu Jan 3 16:28:20 2013
@@ -532,6 +532,9 @@ public class TypeManager {
if (d == 0) {
throw new CmisInvalidArgumentException("Depth must not be 0!");
}
+ if (typeId == null) {
+ d = -1;
+ }
// set property definition flag to default value if not set
boolean ipd = (includePropertyDefinitions == null ? false :
includePropertyDefinitions.booleanValue());