chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r1758999 - in /chemistry/cmislib/trunk/src: cmislib/browser/binding.py cmislib/messages.py tests/cmislibtest.py
Date Fri, 02 Sep 2016 18:15:08 GMT
Author: jpotts
Date: Fri Sep  2 18:15:08 2016
New Revision: 1758999

URL: http://svn.apache.org/viewvc?rev=1758999&view=rev
Log:
Work-in-progress on change entry support for the cmislib browser binding.

Modified:
    chemistry/cmislib/trunk/src/cmislib/browser/binding.py
    chemistry/cmislib/trunk/src/cmislib/messages.py
    chemistry/cmislib/trunk/src/tests/cmislibtest.py

Modified: chemistry/cmislib/trunk/src/cmislib/browser/binding.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/cmislib/browser/binding.py?rev=1758999&r1=1758998&r2=1758999&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/cmislib/browser/binding.py (original)
+++ chemistry/cmislib/trunk/src/cmislib/browser/binding.py Fri Sep  2 18:15:08 2016
@@ -1238,8 +1238,20 @@ class BrowserRepository(object):
         >>> rs[0].changeTime
         datetime.datetime(2010, 2, 16, 20, 6, 37)
         """
+        if self.getCapabilities()['Changes'] is None:
+            raise NotSupportedException(messages.NO_CHANGE_LOG_SUPPORT)
 
-        pass
+        changesUrl = self.getRootFolderUrl() + "?selector=contentChanges"
+
+        result = self._cmisClient.binding.get(changesUrl,
+                                              self._cmisClient.username,
+                                              self._cmisClient.password,
+                                              **kwargs)
+
+        return BrowserResultSet(self._cmisClient,
+                                self,
+                                data=result,
+                                serializer=ChangeEntrySerializer())
 
     def createDocumentFromString(self,
                                  name,
@@ -2727,7 +2739,7 @@ class BrowserACL(ACL):
                 result[principalId] = ace
         return result
 
-    def addEntry(self, principalId, access, direct):
+    def addEntry(self, principalId, access, direct=True):
 
         """
         Adds an :class:`ACE` entry to the ACL.
@@ -2844,6 +2856,19 @@ class BrowserChangeEntry(ChangeEntry):
     u'updated'
     """
 
+    def __init__(self, cmisClient, repository, data):
+        """Constructor"""
+        self._cmisClient = cmisClient
+        self._repository = repository
+        self._data = data
+        self._properties = {}
+        self._objectId = None
+        self._changeEntryId = None
+        self._changeType = None
+        self._changeTime = None
+        self.logger = logging.getLogger('cmislib.model.ChangeEntry')
+        self.logger.info('Creating an instance of ChangeEntry')
+
     def getId(self):
         """
         Returns the unique ID of the change entry.
@@ -2942,9 +2967,18 @@ class BrowserChangeEntryResultSet(Browse
         """
         Overriding to make it work with a list instead of a dict.
         """
-        # TODO need to implement
-        pass
+        if self._results:
+            return self._results
+
+        if self._data:
+            entries = []
+            for entry in self._data:
+                changeEntry = BrowserChangeEntry(self._cmisClient, self._repository, entry)
+                entries.append(changeEntry)
+
+            self._results = entries
 
+        return self._results
 
 class BrowserRendition(object):
 
@@ -3233,3 +3267,24 @@ class ACLSerializer(object):
             aces.append(entryJSON)
 
         return json.dumps(aces)
+
+class ChangeEntrySerializer(object):
+
+    """
+    Responsible for serializing lists of change entries.
+    """
+
+    def fromJSON(self, client, repo, jsonObj):
+        """Transforms from JSON to the object."""
+        self.logger = logging.getLogger('cmislib.browser.binding.ChangeEntrySerializer')
+        entries = []
+        for obj in jsonObj['objects']:
+            self.logger.debug("Parsing a change entry object")
+            dataObj = obj['object']
+            cmisObject = getSpecializedObject(BrowserChangeEntry(client,
+                                                                 repo,
+                                                                 data=dataObj))
+            self.logger.debug("Parsed a change entry object, appending")
+            entries.append(cmisObject)
+
+        return entries

Modified: chemistry/cmislib/trunk/src/cmislib/messages.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/cmislib/messages.py?rev=1758999&r1=1758998&r2=1758999&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/cmislib/messages.py (original)
+++ chemistry/cmislib/trunk/src/cmislib/messages.py Fri Sep  2 18:15:08 2016
@@ -22,3 +22,4 @@ Common strings.
 """
 NO_ACL_SUPPORT = 'This repository does not support ACLs'
 NO_CHANGE_LOG_SUPPORT = 'This repository does not support change logs'
+NO_CHANGE_OBJECT_SUPPORT = 'This repository does not support change log entries as objects'

Modified: chemistry/cmislib/trunk/src/tests/cmislibtest.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/tests/cmislibtest.py?rev=1758999&r1=1758998&r2=1758999&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/tests/cmislibtest.py (original)
+++ chemistry/cmislib/trunk/src/tests/cmislibtest.py Fri Sep  2 18:15:08 2016
@@ -733,7 +733,8 @@ class ChangeEntryTest(CmisTestBase):
         """Get the content changes and inspect Change Entry props"""
 
         # need to check changes capability
-        if not self._repo.capabilities['Changes']:
+        changeCap = self._repo.capabilities['Changes']
+        if changeCap == 'none':
             print messages.NO_CHANGE_LOG_SUPPORT
             return
 
@@ -751,10 +752,15 @@ class ChangeEntryTest(CmisTestBase):
         """Gets the ACL that is included with a Change Entry."""
 
         # need to check changes capability
-        if not self._repo.capabilities['Changes']:
+        changeCap = self._repo.capabilities['Changes']
+        if changeCap == 'none':
             print messages.NO_CHANGE_LOG_SUPPORT
             return
 
+        if changeCap == 'objectidsonly':
+            print messages.NO_CHANGE_OBJECT_SUPPORT
+            return
+
         # need to check ACL capability
         if not self._repo.capabilities['ACL']:
             print messages.NO_ACL_SUPPORT
@@ -786,10 +792,14 @@ class ChangeEntryTest(CmisTestBase):
 
         # need to check changes capability
         changeCap = self._repo.capabilities['Changes']
-        if not changeCap:
+        if changeCap == 'none':
             print messages.NO_CHANGE_LOG_SUPPORT
             return
 
+        if changeCap == 'objectidsonly':
+            print messages.NO_CHANGE_OBJECT_SUPPORT
+            return
+
         # need to test once without includeProperties set. the objectID should be there
         rs = self._repo.getContentChanges()
         self.assertTrue(len(rs) > 0)



Mime
View raw message