예제 #1
0
 /**
  * @depends testSetPrincipalIdSetsProperty
  */
 public function testGetPrincipalIdReturnsProperty()
 {
     $principal = new Principal('value');
     $this->assertSame('value', $principal->getId());
 }
 public function testConvertAclConvertsArrayToAclObject()
 {
     $principal = new Principal('anyone');
     $principal->setExtensions($this->cmisExtensionsDummy);
     $ace = new AccessControlEntry($principal, array('cmis:all'));
     $ace->setIsDirect(true);
     $ace->setExtensions($this->cmisExtensionsDummy);
     $acl = new AccessControlList(array($ace));
     $acl->setIsExact(true);
     $acl->setExtensions($this->cmisExtensionsDummy);
     $getObjectResponse = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getObject-response.log');
     $result = $this->jsonConverter->convertAcl($getObjectResponse[JSONConstants::JSON_OBJECT_ACL], $getObjectResponse[JSONConstants::JSON_OBJECT_EXACT_ACL]);
     $this->assertEquals($acl, $result);
     return $result;
 }
예제 #3
0
 /**
  * @param array|null $data
  * @param boolean $isExact
  * @return AccessControlList
  */
 public function convertAcl(array $data = null, $isExact = false)
 {
     if (empty($data)) {
         return null;
     }
     $aces = array();
     if (isset($data[JSONConstants::JSON_ACL_ACES]) && is_array($data[JSONConstants::JSON_ACL_ACES])) {
         foreach ($data[JSONConstants::JSON_ACL_ACES] as $aceData) {
             if (empty($aceData[JSONConstants::JSON_ACE_PRINCIPAL][JSONConstants::JSON_ACE_PRINCIPAL_ID])) {
                 continue;
             }
             $permissions = array();
             if (isset($aceData[JSONConstants::JSON_ACE_PERMISSIONS]) && is_array($aceData[JSONConstants::JSON_ACE_PERMISSIONS])) {
                 foreach ($aceData[JSONConstants::JSON_ACE_PERMISSIONS] as $permissionItem) {
                     if (!empty($permissionItem)) {
                         $permissions[] = $permissionItem;
                     }
                 }
             }
             $principal = new Principal((string) $aceData[JSONConstants::JSON_ACE_PRINCIPAL][JSONConstants::JSON_ACE_PRINCIPAL_ID]);
             $principal->setExtensions($this->convertExtension($aceData[JSONConstants::JSON_ACE_PRINCIPAL], JSONConstants::getAcePrincipalKeys()));
             $ace = new AccessControlEntry($principal, $permissions);
             if (isset($aceData[JSONConstants::JSON_ACE_IS_DIRECT])) {
                 $ace->setIsDirect((bool) $aceData[JSONConstants::JSON_ACE_IS_DIRECT]);
             }
             $ace->setExtensions($this->convertExtension($aceData, JSONConstants::getAceKeys()));
             $aces[] = $ace;
         }
     }
     $acl = new AccessControlList($aces);
     $acl->setIsExact($isExact);
     $acl->setExtensions($this->convertExtension($data, JSONConstants::getAclKeys()));
     return $acl;
 }