public function moveObject($repositoryId, $objectId, $changeToken = '', $targetFolderId, $sourceFolderId = null) { // The $sourceFolderId parameter SHALL be specified if the Repository supports the optional 'unfiling' capability if (is_null($sourceFolderId)) { $RepositoryService = new CMISRepositoryService(); $info = $RepositoryService->getRepositoryInfo($repositoryId); $capabilities = $info->getCapabilities(); // check for unfiling capability // NOTE this is only required once/if KnowledgeTree allows the source folder id to be optional, // but it is required for CMIS specification compliance. if ($capabilities->hasCapabilityUnfiling() === 'true') { throw new RuntimeException('The source folder id MUST be supplied when unfiling is supported.'); } } // Attempt to decode $objectId, use as is if not detected as encoded $tmpObjectId = $objectId; $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $typeId); if ($tmpTypeId != 'Unknown') { $objectId = $tmpObjectId; } $targetFolderId = CMISUtil::decodeObjectId($targetFolderId); // check type id of object against allowed child types for destination folder $CMISFolder = new CMISFolderObject($targetFolderId, $this->ktapi); $allowed = $CMISFolder->getProperty('AllowedChildObjectTypeIds'); if (!is_array($allowed) || !in_array($typeId, $allowed)) { throw new ConstraintViolationException('Parent folder may not hold objects of this type (' . $typeId . ')'); } // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). $exists = CMISUtil::contentExists($typeId, $objectId, $this->ktapi); if (!$exists) { throw new updateConflictException('Unable to move the object as it cannot be found.'); } // TODO add reasons and sig data // attempt to move object if ($typeId == 'Folder') { $response = $this->ktapi->move_folder($objectId, $targetFolderId, $reason, $sig_username, $sig_password); } else { if ($typeId == 'Document') { $response = $this->ktapi->move_document($objectId, $targetFolderId, $reason, null, null, $sig_username, $sig_password); } else { $response['status_code'] = 1; $response['message'] = 'The object type could not be determined.'; } } // if failed, throw StorageException if ($response['status_code'] != 0) { throw new StorageException('The repository was unable to move the object: ' . $response['message']); } }