Example #1
0
 /**
  * Returns the path of the folder.
  *
  * @return string the absolute folder path
  */
 public function getPath()
 {
     $path = $this->getPropertyValue(PropertyIds::PATH);
     // if the path property isn't set, get it
     if ($path === null) {
         $objectData = $this->getBinding()->getObjectService()->getObject($this->getRepositoryId(), $this->getId(), $this->getPropertyQueryName(PropertyIds::PATH), false, IncludeRelationships::cast(IncludeRelationships::NONE), Constants::RENDITION_NONE, false, false);
         if ($objectData !== null && $objectData->getProperties() !== null && $objectData->getProperties()->getProperties() !== null) {
             $objectProperties = $objectData->getProperties()->getProperties();
             if (isset($objectProperties[PropertyIds::PATH]) && $objectProperties[PropertyIds::PATH] instanceof PropertyString) {
                 $path = $objectProperties[PropertyIds::PATH]->getFirstValue();
             }
         }
     }
     // we still don't know the path ... it's not a CMIS compliant repository
     if ($path === null) {
         throw new CmisRuntimeException('Repository didn\'t return ' . PropertyIds::PATH . '!');
     }
     return $path;
 }
 /**
  * Data provider for query
  *
  * @return array
  */
 public function queryDataProvider()
 {
     return array(array(Url::createFromUrl(self::BROWSER_URL_TEST . '?cmisaction=query&statement=SELECT%20*%20FROM%20cmis:document' . '&searchAllVersions=true&includeRelationships=none&renditionFilter=foo:bar' . '&includeAllowableActions=true&maxItems=99&skipCount=0&dateTimeFormat=simple'), 'repositoryId', 'SELECT * FROM cmis:document', true, IncludeRelationships::cast(IncludeRelationships::NONE), 'foo:bar', true, 99, 0), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?cmisaction=query&statement=SELECT%20*%20FROM%20cmis:document' . '&searchAllVersions=false&includeRelationships=both&renditionFilter=foo:bar' . '&includeAllowableActions=false&skipCount=99&dateTimeFormat=simple'), 'repositoryId', 'SELECT * FROM cmis:document', false, IncludeRelationships::cast(IncludeRelationships::BOTH), 'foo:bar', false, null, 99), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?cmisaction=query&statement=SELECT%20*%20FROM%20cmis:document' . '&searchAllVersions=false&renditionFilter=foo:bar' . '&includeAllowableActions=false&skipCount=99&dateTimeFormat=simple'), 'repositoryId', 'SELECT * FROM cmis:document', false, null, 'foo:bar', false, 0, 99));
 }
Example #3
0
 /**
  * Copies the document manually. The content is streamed from the repository and back.
  *
  * @param ObjectIdInterface|null $targetFolderId the ID of the target folder, <code>null</code> to create an unfiled
  *      document
  * @param array $properties The property values that MUST be applied to the object. This list of properties SHOULD
  *     only contain properties whose values differ from the source document. The array key is the property name
  *     the value is the property value.
  * @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the
  *     newly-created object MUST be. Valid values are:
  *      <code>none</code>
  *          (default, if the object-type is not versionable) The document MUST be created as a non-versionable
  *          document.
  *     <code>checkedout</code>
  *          The document MUST be created in the checked-out state. The checked-out document MAY be
  *          visible to other users.
  *     <code>major</code>
  *          (default, if the object-type is versionable) The document MUST be created as a major version.
  *     <code>minor</code>
  *          The document MUST be created as a minor version.
  * @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document
  *     object.
  * @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either
  *     using the ACL from folderId if specified, or being applied if no folderId is specified.
  * @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object,
  *     either using the ACL from folderId if specified, or being ignored if no folderId is specified.
  * @return ObjectIdInterface The id of the newly-created document.
  * @throws CmisRuntimeException
  */
 protected function copyViaClient(ObjectIdInterface $targetFolderId = null, array $properties = array(), VersioningState $versioningState = null, array $policies = array(), array $addAces = array(), array $removeAces = array())
 {
     $newProperties = array();
     $allPropertiesContext = $this->getSession()->createOperationContext();
     $allPropertiesContext->setFilterString('*');
     $allPropertiesContext->setIncludeAcls(false);
     $allPropertiesContext->setIncludeAllowableActions(false);
     $allPropertiesContext->setIncludePathSegments(false);
     $allPropertiesContext->setIncludePolicies(false);
     $allPropertiesContext->setIncludeRelationships(IncludeRelationships::cast(IncludeRelationships::NONE));
     $allPropertiesContext->setRenditionFilterString(Constants::RENDITION_NONE);
     $allPropertiesDocument = $this->getSession()->getObject($this, $allPropertiesContext);
     if (!$allPropertiesDocument instanceof DocumentInterface) {
         throw new CmisRuntimeException('Returned object is not of expected type DocumentInterface');
     }
     foreach ($allPropertiesDocument->getProperties() as $property) {
         if (Updatability::cast(Updatability::READWRITE)->equals($property->getDefinition()->getUpdatability()) || Updatability::cast(Updatability::ONCREATE)->equals($property->getDefinition()->getUpdatability())) {
             $newProperties[$property->getId()] = $property->isMultiValued() ? $property->getValues() : $property->getFirstValue();
         }
     }
     $newProperties = array_merge($newProperties, $properties);
     $contentStream = $allPropertiesDocument->getContentStream();
     return $this->getSession()->createDocument($newProperties, $targetFolderId, $contentStream, $versioningState, $policies, $addAces, $removeAces);
 }
 public function testGetCacheKeyReturnsStringBasedOnPropertyValues()
 {
     $this->assertSame('0101||none|cmis:none', $this->operationContext->getCacheKey());
     $this->operationContext->setIncludeAcls(true)->setIncludeAllowableActions(false)->setIncludePolicies(true)->setIncludePathSegments(false)->setFilter(array('foo', 'bar'))->setIncludeRelationships(IncludeRelationships::cast(IncludeRelationships::BOTH))->setRenditionFilter(array('baz', 'foo'));
     $this->assertSame('1010|foo,bar,cmis:objectId,cmis:baseTypeId,cmis:objectTypeId|both|baz,foo', $this->operationContext->getCacheKey());
 }
 /**
  * Returns the paths of this object.
  *
  * @return string[] the list of paths of this object or an empty list if this object is unfiled or if this object
  *     is the root folder
  * @throws CmisRuntimeException Throws exception if repository sends invalid data
  */
 public function getPaths()
 {
     $folderType = $this->getSession()->getTypeDefinition((string) BaseTypeId::cast(BaseTypeId::CMIS_FOLDER));
     $propertyDefinition = $folderType->getPropertyDefinition(PropertyIds::PATH);
     $pathQueryName = $propertyDefinition === null ? null : $propertyDefinition->getQueryName();
     // get object paths of the parent folders
     $bindingParents = $this->getBinding()->getNavigationService()->getObjectParents($this->getRepositoryId(), $this->getId(), $pathQueryName, false, IncludeRelationships::cast(IncludeRelationships::NONE), Constants::RENDITION_NONE, true, null);
     $paths = array();
     foreach ($bindingParents as $parent) {
         if ($parent->getObject()->getProperties() === null) {
             // that should never happen but could in case of an faulty repository implementation
             throw new CmisRuntimeException('Repository sent invalid data! No properties given.');
         }
         $parentProperties = $parent->getObject()->getProperties()->getProperties();
         $pathProperty = null;
         if (isset($parentProperties[PropertyIds::PATH])) {
             $pathProperty = $parentProperties[PropertyIds::PATH];
         }
         if (!$pathProperty instanceof PropertyStringInterface) {
             // the repository sent an object without a valid path...
             throw new CmisRuntimeException('Repository sent invalid data! Path is not set!');
         }
         if ($parent->getRelativePathSegment() === null) {
             throw new CmisRuntimeException('Repository sent invalid data! No relative path segement!');
         }
         $folderPath = rtrim((string) $pathProperty->getFirstValue(), '/') . '/';
         $paths[] = $folderPath . $parent->getRelativePathSegment();
     }
     return $paths;
 }
 /**
  * Data provider for getObjectParents
  *
  * @return array
  */
 public function getObjectParentsDataProvider()
 {
     return array(array(Url::createFromUrl(self::BROWSER_URL_TEST . '?filter=filter,123&includeAllowableActions=true' . '&includeRelationships=none&renditionFilter=cmis:none&includeRelativePathSegment=true' . '&succinct=false&dateTimeFormat=simple'), 'repositoryId', 'objectId', 'filter,123', true, IncludeRelationships::cast(IncludeRelationships::NONE), 'cmis:none', true), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?includeAllowableActions=true' . '&renditionFilter=cmis:none&includeRelativePathSegment=false' . '&succinct=false&dateTimeFormat=simple'), 'repositoryId', 'objectId', null, true, null, 'cmis:none', false));
 }
 /**
  * Data provider for getObjectByPath
  *
  * @return array
  */
 public function getObjectByPathDataProvider()
 {
     return array(array(Url::createFromUrl(self::BROWSER_URL_TEST . '?filter=filter,123&includeAllowableActions=true' . '&includeRelationships=none&renditionFilter=foo:bar&includePolicyIds=true&includeACL=true' . '&succinct=false&dateTimeFormat=simple'), 'repositoryId', 'path/toAnObject', 'filter,123', true, IncludeRelationships::cast(IncludeRelationships::NONE), 'foo:bar', true, true), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?includeAllowableActions=false' . '&includeRelationships=both&renditionFilter=foo:bar&includePolicyIds=false&includeACL=false' . '&succinct=false&dateTimeFormat=simple'), 'repositoryId', 'path/toAnObject', null, false, IncludeRelationships::cast(IncludeRelationships::BOTH), 'foo:bar', false, false), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?filter=filter,345&includeAllowableActions=false' . '&renditionFilter=foo:bar&includePolicyIds=false&includeACL=false' . '&succinct=false&dateTimeFormat=simple'), 'repositoryId', 'path/toAnObject', 'filter,345', false, null, 'foo:bar', false, false));
 }
 /**
  * Creates new Operation Context
  */
 public function __construct()
 {
     $this->setRenditionFilter(array());
     $this->includeRelationships = IncludeRelationships::cast(IncludeRelationships::NONE);
 }