chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From richa...@apache.org
Subject svn commit: r1040011 - /incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php
Date Mon, 29 Nov 2010 03:57:36 GMT
Author: richardm
Date: Mon Nov 29 03:57:36 2010
New Revision: 1040011

URL: http://svn.apache.org/viewvc?rev=1040011&view=rev
Log:
CMIS-274 -- Parse allowableActions on objects -- Patch Provided by Patrice Collardez

Modified:
    incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php

Modified: incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php
URL: http://svn.apache.org/viewvc/incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php?rev=1040011&r1=1040010&r2=1040011&view=diff
==============================================================================
--- incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php (original)
+++ incubator/chemistry/phpclient/trunk/cmis_repository_wrapper.php Mon Nov 29 03:57:36 2010
@@ -329,6 +329,26 @@ class CMISRepositoryWrapper
         }
         return $links;
     }
+	static function extractAllowableActions($xmldata)
+    {
+        $doc = new DOMDocument();
+        $doc->loadXML($xmldata);
+        return CMISRepositoryWrapper :: extractAllowableActionsFromNode($doc);
+    }
+    static function extractAllowableActionsFromNode($xmlnode)
+    {
+        $result = array();
+        $allowableActions = $xmlnode->getElementsByTagName("allowableActions");
+        if ($allowableActions->length > 0) {
+            foreach($allowableActions->item(0)->childNodes as $action)
+            {
+                if (isset($action->localName)) {
+                    $result[$action->localName] = (preg_match("/^true$/i", $action->nodeValue)
> 0);
+                }
+            }
+        }
+        return $result;
+    }
     static function extractObject($xmldata)
     {
         $doc = new DOMDocument();
@@ -371,6 +391,7 @@ class CMISRepositoryWrapper
 			$children_doc->appendChild($xnode);
 	        $retval->children = CMISRepositoryWrapper :: extractObjectFeedFromNode($children_doc);
         }
+		$retval->allowableActions = CMISRepositoryWrapper :: extractAllowableActionsFromNode($xmlnode);
         return $retval;
     }
     
@@ -1036,9 +1057,10 @@ xmlns:cmisra="http://docs.oasis-open.org
 
     function getAllowableActions($objectId, $options = array ())
     {
-        // get stripped down version of object (for the links) and then get the allowable
actions?
-        // Low priority -- can get all information when getting object
-        throw Exception("Not Implemented");
+        $myURL = $this->getLink($objectId, LINK_ALLOWABLE_ACTIONS);
+        $ret = $this->doGet($myURL);
+        $result = $this->extractAllowableActions($ret->body);
+        return $result;
     }
 
     function getRenditions($objectId, $options = array (



Mime
View raw message