chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r1030044 - in /incubator/chemistry/cmislib/trunk/src: cmislib/model.py tests/cmislibtest.py
Date Tue, 02 Nov 2010 13:58:30 GMT
Author: jpotts
Date: Tue Nov  2 13:58:30 2010
New Revision: 1030044

URL: http://svn.apache.org/viewvc?rev=1030044&view=rev
Log:
Applied patch CMIS-256

Modified:
    incubator/chemistry/cmislib/trunk/src/cmislib/model.py
    incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py

Modified: incubator/chemistry/cmislib/trunk/src/cmislib/model.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/cmislib/model.py?rev=1030044&r1=1030043&r2=1030044&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/cmislib/model.py (original)
+++ incubator/chemistry/cmislib/trunk/src/cmislib/model.py Tue Nov  2 13:58:30 2010
@@ -1690,8 +1690,6 @@ class CmisObject(object):
 
     def getObjectParents(self):
         """
-        This has not yet been implemented.
-
         See CMIS specification document 2.2.3.5 getObjectParents
 
         The following optional arguments are not supported:
@@ -1701,9 +1699,20 @@ class CmisObject(object):
          - includeAllowableActions
          - includeRelativePathSegment
         """
+        # get the appropriate 'up' link
+        parentUrl = self._getLink(UP_REL)
 
-        # TODO To be implemented
-        raise NotImplementedError
+        if parentUrl == None:
+            raise NotSupportedException('Root folder does not support getObjectParents')
+
+        # invoke the URL
+        result = self._cmisClient.get(parentUrl)
+
+        if type(result) == HTTPError:
+            raise CmisException(result.code)
+
+        # return the result set
+        return ResultSet(self._cmisClient, self._repository, result)
 
     def getAllowableActions(self):
 

Modified: incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py?rev=1030044&r1=1030043&r2=1030044&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py (original)
+++ incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py Tue Nov  2 13:58:30 2010
@@ -23,7 +23,8 @@ from cmislib.model import CmisClient, AC
 from cmislib.exceptions import \
                           ObjectNotFoundException, \
                           PermissionDeniedException, \
-                          CmisException
+                          CmisException, \
+                          NotSupportedException
 from cmislib import messages
 import os
 from time import sleep, time
@@ -1050,6 +1051,17 @@ class DocumentTest(CmisTestBase):
 #                self.assertEquals('false',
 #                             rs.getResults().values()[count].getProperties()['cmis:isLatestVersion'])
 
+    def testGetObjectParents(self):
+        '''Gets all object parents of an CmisObject'''
+        childFolder = self._testFolder.createFolder('parentTest')
+        parentFolder = childFolder.getObjectParents().getResults()[0]
+        self.assertEquals(self._testFolder.getObjectId(), parentFolder.getObjectId())
+
+    def testGetObjectParentsWithinRootFolder(self):
+        '''Gets all object parents of a root folder'''
+        rootFolder = self._repo.getRootFolder()
+        self.assertRaises(NotSupportedException, rootFolder.getObjectParents)
+
 
 class TypeTest(unittest.TestCase):
 



Mime
View raw message