chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1153619 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apa...
Date Wed, 03 Aug 2011 19:33:29 GMT
Author: fmui
Date: Wed Aug  3 19:33:28 2011
New Revision: 1153619

URL: http://svn.apache.org/viewvc?rev=1153619&view=rev
Log:
CMIS-412: call getFolderParent() to get the parent of a folder

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java?rev=1153619&r1=1153618&r2=1153619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java
Wed Aug  3 19:33:28 2011
@@ -50,6 +50,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.PropertyId;
 import org.apache.chemistry.opencmis.commons.data.PropertyString;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -356,7 +357,7 @@ public class FolderImpl extends Abstract
             return null;
         }
 
-        List<Folder> parents = super.getParents();
+        List<Folder> parents = getParents();
         if ((parents == null) || (parents.isEmpty())) {
             return null;
         }
@@ -400,6 +401,40 @@ public class FolderImpl extends Abstract
     }
 
     @Override
+    public List<Folder> getParents() {
+        if (isRootFolder()) {
+            return Collections.emptyList();
+        }
+
+        String objectId = getObjectId();
+
+        ObjectData bindingParent = getBinding().getNavigationService().getFolderParent(getRepositoryId(),
objectId,
+                getPropertyQueryName(PropertyIds.OBJECT_ID), null);
+
+        if (bindingParent.getProperties() == null) {
+            // should not happen...
+            throw new CmisRuntimeException("Repository sent invalid data!");
+        }
+
+        // get id property
+        PropertyData<?> idProperty = bindingParent.getProperties().getProperties().get(PropertyIds.OBJECT_ID);
+        if (!(idProperty instanceof PropertyId)) {
+            // the repository sent an object without a valid object id...
+            throw new CmisRuntimeException("Repository sent invalid data! No object id!");
+        }
+
+        // fetch the object and make sure it is a folder
+        ObjectId parentId = getSession().createObjectId((String) idProperty.getFirstValue());
+        CmisObject parentFolder = getSession().getObject(parentId);
+        if (!(parentFolder instanceof Folder)) {
+            // the repository sent an object that is not a folder...
+            throw new CmisRuntimeException("Repository sent invalid data! Object is not a
folder!");
+        }
+
+        return Collections.singletonList((Folder) parentFolder);
+    }
+
+    @Override
     public List<String> getPaths() {
         return Collections.singletonList(getPath());
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java?rev=1153619&r1=1153618&r2=1153619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DataObjectCreator.java
Wed Aug  3 19:33:28 2011
@@ -177,7 +177,7 @@ public class DataObjectCreator {
         	
             ObjectList relationships = spo.getObjectRelationships(false, relationshipDirection,
             		null, null, false, MINUS_ONE, MINUS_ONE, null, user);
-           return relationships.getObjects();
+           return (relationships == null? null : relationships.getObjects());
         }
          return null;
     }



Mime
View raw message