public function testConvertAclCapabilitiesConvertsArrayToAclCapabilitiesObject()
 {
     $expectedAclCapabilities = new AclCapabilities();
     $expectedAclCapabilities->setAclPropagation(AclPropagation::cast('objectonly'));
     $expectedAclCapabilities->setSupportedPermissions(SupportedPermissions::cast('basic'));
     $permissionMapping = new PermissionMapping();
     $permissionMapping->setKey('canGetDescendents.Folder');
     $permissionMapping->setPermissions(array('cmis:read'));
     $permissionMapping->setExtensions($this->cmisExtensionsDummy);
     $expectedAclCapabilities->setPermissionMapping(array('canGetDescendents.Folder' => $permissionMapping));
     $permissionDefinition = new PermissionDefinition();
     $permissionDefinition->setId('cmis:read');
     $permissionDefinition->setDescription('Read');
     $permissionDefinition->setExtensions($this->cmisExtensionsDummy);
     $expectedAclCapabilities->setPermissions(array($permissionDefinition));
     $expectedAclCapabilities->setExtensions($this->cmisExtensionsDummy);
     $repositoryInfoArray = current($this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getRepositoryInfo-full-response.log'));
     $result = $this->jsonConverter->convertAclCapabilities($repositoryInfoArray[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES]);
     $this->assertEquals($expectedAclCapabilities, $result);
     return $result;
 }
예제 #2
0
 /**
  * @param array|null $data
  * @return AclCapabilities|null
  */
 public function convertAclCapabilities(array $data = null)
 {
     if (empty($data)) {
         return null;
     }
     $aclCapabilities = new AclCapabilities();
     $aclCapabilities->setSupportedPermissions(SupportedPermissions::cast($data[JSONConstants::JSON_ACLCAP_SUPPORTED_PERMISSIONS]));
     $aclCapabilities->setAclPropagation(AclPropagation::cast($data[JSONConstants::JSON_ACLCAP_ACL_PROPAGATION]));
     if (isset($data[JSONConstants::JSON_ACLCAP_PERMISSIONS]) && is_array($data[JSONConstants::JSON_ACLCAP_PERMISSIONS])) {
         $permissionsData = $data[JSONConstants::JSON_ACLCAP_PERMISSIONS];
         $permissionDefinitionList = array();
         if (is_array($permissionsData)) {
             foreach ($permissionsData as $permissionData) {
                 $permissionDefinition = new PermissionDefinition();
                 $permissionDefinition->setId((string) $permissionData[JSONConstants::JSON_ACLCAP_PERMISSION_PERMISSION]);
                 $permissionDefinition->setDescription((string) $permissionData[JSONConstants::JSON_ACLCAP_PERMISSION_DESCRIPTION]);
                 // handle extensions
                 $permissionDefinition->setExtensions($this->convertExtension($permissionData, JSONConstants::getAclCapabilityPermissionKeys()));
                 $permissionDefinitionList[] = $permissionDefinition;
             }
         }
         $aclCapabilities->setPermissions($permissionDefinitionList);
     }
     if (isset($data[JSONConstants::JSON_ACLCAP_PERMISSION_MAPPING]) && is_array($data[JSONConstants::JSON_ACLCAP_PERMISSION_MAPPING])) {
         $permissionMappingData = $data[JSONConstants::JSON_ACLCAP_PERMISSION_MAPPING];
         $permissionMappingList = array();
         foreach ($permissionMappingData as $permissionMapping) {
             $mapping = new PermissionMapping();
             $key = (string) $permissionMapping[JSONConstants::JSON_ACLCAP_MAPPING_KEY];
             $mapping->setKey($key);
             $permissionList = array();
             if (isset($permissionMapping[JSONConstants::JSON_ACLCAP_MAPPING_PERMISSION]) && is_array($permissionMapping[JSONConstants::JSON_ACLCAP_MAPPING_PERMISSION])) {
                 foreach ($permissionMapping[JSONConstants::JSON_ACLCAP_MAPPING_PERMISSION] as $permission) {
                     if (!empty($permission)) {
                         $permissionList[] = (string) $permission;
                     }
                 }
             }
             $mapping->setPermissions($permissionList);
             $mapping->setExtensions($this->convertExtension($permissionMapping, JSONConstants::getAclCapabilityMappingKeys()));
             $permissionMappingList[$key] = $mapping;
         }
         $aclCapabilities->setPermissionMapping($permissionMappingList);
     }
     // handle extensions
     $aclCapabilities->setExtensions($this->convertExtension($data, JSONConstants::getAclCapabilityKeys()));
     return $aclCapabilities;
 }