diff --git a/lib/api/ktcmis/ktObjectService.inc.php b/lib/api/ktcmis/ktObjectService.inc.php index c0a72ab..4b4abd9 100644 --- a/lib/api/ktcmis/ktObjectService.inc.php +++ b/lib/api/ktcmis/ktObjectService.inc.php @@ -181,12 +181,13 @@ class KTObjectService extends KTCMISBase { * * @param string $repositoryId * @param string $objectId + * @param string $streamId [optional for documents] Specifies the rendition to retrieve if not original document * @return string $contentStream (binary or text data) */ - function getContentStream($repositoryId, $objectId) + function getContentStream($repositoryId, $objectId, $streamId = null) { try { - $contentStream = $this->ObjectService->getContentStream($repositoryId, $objectId); + $contentStream = $this->ObjectService->getContentStream($repositoryId, $objectId, $streamId); } catch (Exception $e) { diff --git a/lib/api/ktcmis/ktVersioningService.inc.php b/lib/api/ktcmis/ktVersioningService.inc.php index 46aea33..0349f77 100644 --- a/lib/api/ktcmis/ktVersioningService.inc.php +++ b/lib/api/ktcmis/ktVersioningService.inc.php @@ -110,15 +110,14 @@ class KTVersioningService extends KTCMISBase { * Checks out a document and creates the PWC (Private Working Copy) which will represent the checked out document * * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] + * @param string $objectId * @return array results */ // TODO set up delivery of content stream? or is that up to the CMIS client? - public function checkOut($repositoryId, $documentId, $changeToken = '') + public function checkOut($repositoryId, $objectId) { try { - $result = $this->VersioningService->checkOut($repositoryId, $documentId, $changeToken); + $result = $this->VersioningService->checkOut($repositoryId, $objectId); } catch (Exception $e) { @@ -138,18 +137,17 @@ class KTVersioningService extends KTCMISBase { * Reverses the effect of a checkout: I.E. deletes the PWC (Private Working Copy) and re-sets the status of the document to "not checked out" * * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] + * @param string $objectId */ // TODO exceptions: // • ConstraintViolationException: The Repository SHALL throw this exception if ANY of the following conditions are met: // o The Document’s Object-Type definition’s versionable attribute is FALSE. // • updateConflictException // • versioningException - public function cancelCheckOut($repositoryId, $documentId, $changeToken = '') + public function cancelCheckOut($repositoryId, $objectId) { try { - $result = $this->VersioningService->cancelCheckOut($repositoryId, $documentId, $changeToken); + $result = $this->VersioningService->cancelCheckOut($repositoryId, $objectId); } catch (Exception $e) { @@ -169,18 +167,22 @@ class KTVersioningService extends KTCMISBase { * Checks in a checked out document * * @param string $repositoryId - * @param string $documentId - * @param boolean $major - * @param string $changeToken [optional] + * @param string $objectId + * @param boolean $major [optional] defaults to true * @param array $properties [optional] * @param contentStream $contentStream [optional] * @param string $checkinComment [optional] - * @return string $documentId + * @param array $policies + * @param array $addACEs + * @param array $removeACEs + * @return string $objectId */ - public function checkIn($repositoryId, $documentId, $major, $contentStream = null, $changeToken = '', $properties = array(), $checkinComment = '') + public function checkIn($repositoryId, $objectId, $major = true, $properties = array(), $contentStream = null, + $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array()) { try { - $result = $this->VersioningService->checkIn($repositoryId, $documentId, $major, $contentStream, $changeToken, $properties, $checkinComment); + $result = $this->VersioningService->checkIn($repositoryId, $objectId, $major, $properties, $contentStream, + $checkinComment, $policies, $addACEs, $removeACEs); } catch (Exception $e) { diff --git a/lib/api/ktcmis/services/CMISObjectService.inc.php b/lib/api/ktcmis/services/CMISObjectService.inc.php index e99b16e..4c54fe6 100644 --- a/lib/api/ktcmis/services/CMISObjectService.inc.php +++ b/lib/api/ktcmis/services/CMISObjectService.inc.php @@ -401,16 +401,16 @@ class CMISObjectService { } /** - * Fetches the content stream data for an object + * Fetches the content stream data for an object, or fetched a rendition stream for a specified rendition * * @param string $repositoryId * @param string $objectId - * @return string $contentStream (binary or text data) + * @param string $streamId [optional for documents] Specifies the rendition to retrieve if not original document + * @return string $contentStream (binary [base64 encoded] or text data) */ - // NOTE streamNotSupportedException: The Repository SHALL throw this exception if the Object-Type definition - // specified by the objectId parameter’s “contentStreamAllowedâ€? attribute is set to “not allowedâ€?. - // - function getContentStream($repositoryId, $objectId) + // NOTE Each CMIS protocol binding MAY provide a way for fetching a sub-range within a content stream, + // in a manner appropriate to that protocol. + function getContentStream($repositoryId, $objectId, $streamId = null) { $contentStream = null; @@ -426,13 +426,11 @@ class CMISObjectService { $objectClass = 'CMIS' . $typeId . 'Object'; $CMISObject = new $objectClass($objectId, $this->ktapi); - // if content stream is not allowed for this object type definition, throw a ConstraintViolationException + // if content stream is not allowed for this object type definition, or the specified object does not have + // a content/rendition stream, throw a ConstraintViolationException if (($CMISObject->getAttribute('contentStreamAllowed') == 'notAllowed')) { - // NOTE spec version 0.61c specifies both a ConstraintViolationException and a StreamNotSupportedException - // for this case. Choosing to throw StreamNotSupportedException until the specification is clarified - // as it is a more specific exception - throw new StreamNotSupportedException('Content Streams are not allowed for this object type'); + throw new ConstraintViolationException('This object does not have a content stream of the requested type'); } // now go on to fetching the content stream diff --git a/lib/api/ktcmis/services/CMISVersioningService.inc.php b/lib/api/ktcmis/services/CMISVersioningService.inc.php index e23beb0..8507255 100644 --- a/lib/api/ktcmis/services/CMISVersioningService.inc.php +++ b/lib/api/ktcmis/services/CMISVersioningService.inc.php @@ -71,54 +71,58 @@ class CMISVersioningService { * Checks out a document and creates the PWC (Private Working Copy) which will represent the checked out document * * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] - * @return string $documentId The id of the PWC object + * @param string $objectId + * @return string $objectId The id of the PWC object * @return boolean $contentCopied TRUE if contentStream is a copy of the document content stream, FALSE if contentStream not set */ - // TODO exceptions: - // • versioningException: The repository MAY throw this exception if the object is a non-current Document Version. // NOTE since we need to return two values, we return one via argument by reference - // since $documentId already exists in the argument list, that was chosen as the "return by reference" value + // since $objectId already exists in the argument list, that was chosen as the "return by reference" value // TODO set up delivery of content stream? or is that up to the CMIS client? - public function checkOut($repositoryId, &$documentId, $changeToken = '') + public function checkOut($repositoryId, &$objectId) { $contentCopied = false; - - $documentId = CMISUtil::decodeObjectId($documentId, $typeId); + + $objectId = CMISUtil::decodeObjectId($objectId, $typeId); // NOTE We are not planning on persisting the PWC beyond the current session, it will be re-created on access of the checked out document // TODO consider persisting in the database? How will this relate to JSR if we are switching to that? // NOTE within the current system it is assumed if a new document metadata version is created that this is the latest version of the document // TODO see if there is an easy way to modify this, else we may not have an easy way to persist PWC objects - + // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). try { - $pwc = new CMISDocumentObject($documentId, $this->ktapi); + $pwc = new CMISDocumentObject($objectId, $this->ktapi); } catch (exception $e) { throw new UpdateConflictException($e->getMessage()); } - + // throw exception if the object is not versionable if (!$pwc->getAttribute('versionable')) { throw new ConstraintViolationException('This document is not versionable and may not be checked out'); } - + + // check that this is the latest version + if ($pwc->getProperty('isLatestVersion') != true) { + throw new VersioningException('The document is not the latest version and cannot be checked out'); + } + // NOTE KTAPI as currently implemented does not give a direct response which indicates if the document is already checked out, // as long as the same user is calling the checkout again, so should we add a check here specifically? // run checkout process - set $download = false (third function argument) as we want to return the document content via the contentStream - $response = $this->ktapi->checkout_document($documentId, 'CMIS Checkout Action', false, $sig_username, $sig_password); + $response = $this->ktapi->checkout_document($objectId, 'CMIS Checkout Action', false, $sig_username, $sig_password); // if there was an error, throw an exception if ($response['status_code'] == 1) { throw new StorageException($response['message']); - }; - + } + // if successful, set $contentCopied = true; unless contentStream is not set - if ($pwc->getProperty('contentStreamFilename') != '') $contentCopied = true; - $documentId = CMISUtil::encodeObjectId(DOCUMENT, $documentId); - + if ($pwc->getProperty('contentStreamFilename') != '') { + $contentCopied = true; + } + $objectId = CMISUtil::encodeObjectId(DOCUMENT, $objectId); + // mark document object as checked out $pwc->setProperty('isVersionSeriesCheckedOut', true); $userName = ''; @@ -127,8 +131,8 @@ class CMISVersioningService { $userName = $user->getName(); } $pwc->setProperty('versionSeriesCheckedOutBy', $userName); - $pwc->setProperty('versionSeriesCheckedOutId', $documentId); - + $pwc->setProperty('versionSeriesCheckedOutId', $objectId); + return $contentCopied; } @@ -136,19 +140,18 @@ class CMISVersioningService { * Reverses the effect of a checkout: I.E. deletes the PWC (Private Working Copy) and re-sets the status of the document to "not checked out" * * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] + * @param string $objectId */ // TODO exceptions: // • versioningException - The repository MAY throw this exception if the object is a non-current Document Version. - public function cancelCheckOut($repositoryId, $documentId, $changeToken = '') + public function cancelCheckOut($repositoryId, $objectId) { - $documentId = CMISUtil::decodeObjectId($documentId, $typeId); + $objectId = CMISUtil::decodeObjectId($objectId, $typeId); /* re-generate PWC object */ // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). try { - $pwc = new CMISDocumentObject($documentId, $this->ktapi); + $pwc = new CMISDocumentObject($objectId, $this->ktapi); } catch (exception $e) { throw new UpdateConflictException($e->getMessage()); @@ -159,10 +162,15 @@ class CMISVersioningService { throw new ConstraintViolationException('This document is not versionable and may not be checked out'); } + // check that this is the latest version + if ($pwc->getProperty('isLatestVersion') != true) { + throw new VersioningException('The document is not the latest version'); + } + // TODO delete PWC - since we are not persisting the PWC this is not necessary at the moment // cancel checkout - $response = $this->ktapi->undo_document_checkout($documentId, 'CMIS Cancel Checkout Action', $sig_username, $sig_password); + $response = $this->ktapi->undo_document_checkout($objectId, 'CMIS Cancel Checkout Action', $sig_username, $sig_password); // if there was any error in cancelling the checkout if ($response['status_code'] == 1) { @@ -174,28 +182,35 @@ class CMISVersioningService { * Checks in a checked out document * * @param string $repositoryId - * @param string $documentId - * @param boolean $major - * @param string $changeToken [optional] + * @param string $objectId + * @param boolean $major [optional] defaults to true * @param array $properties [optional] * @param contentStream $contentStream [optional] * @param string $checkinComment [optional] - * @return string $documentId + * @param array $policies + * @param array $addACEs + * @param array $removeACEs + * @return string $objectId */ - // TODO Exceptions: - // • versioningException - The repository MAY throw this exception if the object is a non-current Document Version - public function checkIn($repositoryId, $documentId, $major, $contentStream = null, $changeToken = '', $properties = array(), $checkinComment = '') + // NOTE For repositories that do NOT support the optional “capabilityPWCUpdatable” capability, the properties + // and contentStream input parameters MUST be provided on the checkIn method for updates to happen as part + // of checkIn. + // NOTE Only those properties whose values are different than the original value of the object need to be submitted. + // NOTE we are not actually doing anything with the properties at this time, only the content stream + // TODO filename changes and anything else supported in web interface, possibly additional supported by CMIS clients + public function checkIn($repositoryId, $objectId, $major = true, $properties = array(), $contentStream = null, + $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array()) { - $documentId = CMISUtil::decodeObjectId($documentId, $typeId); - + $objectId = CMISUtil::decodeObjectId($objectId, $typeId); + // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). try { - $pwc = new CMISDocumentObject($documentId, $this->ktapi); + $pwc = new CMISDocumentObject($objectId, $this->ktapi); } catch (exception $e) { throw new UpdateConflictException($e->getMessage()); } - + // throw exception if the object is not versionable if (!$pwc->getAttribute('versionable')) { throw new ConstraintViolationException('This document is not versionable and may not be checked in'); @@ -209,11 +224,17 @@ class CMISVersioningService { // if we can't get the type definition, then we can't store the content throw new StorageException($e->getMessage()); } - - if (($typeDefinition['attributes']['contentStreamAllowed'] == 'notAllowed') && !empty($contentStream)) { + + // if content stream is required (capabilityPWCUpdatability == false) and no content stream is supplied, + // throw a ConstraintViolationException + if (($typeDefinition['attributes']['contentStreamAllowed'] == 'required') && is_null($contentStream)) { + throw new RuntimeException('This repository requires a content stream for document update on checkin. ' + . 'Refusing to checkin an empty document'); + } + else if (($typeDefinition['attributes']['contentStreamAllowed'] == 'notAllowed') && !empty($contentStream)) { throw new StreamNotSupportedException('Content Streams are not supported'); } - + // check that this is the latest version if ($pwc->getProperty('isLatestVersion') != true) { throw new VersioningException('The document is not the latest version and cannot be checked in'); @@ -221,15 +242,16 @@ class CMISVersioningService { // now do the checkin $tempfilename = CMISUtil::createTemporaryFile($contentStream); - $response = $this->ktapi->checkin_document($documentId, $pwc->getProperty('contentStreamFilename'), $reason, $tempfilename, $major, - $sig_username, $sig_password); - - // if there was any error in cancelling the checkout + $reason = 'CMIS object checkin'; + $response = $this->ktapi->checkin_document($objectId, $pwc->getProperty('contentStreamFilename'), $reason, $tempfilename, $major, + $sig_username, $sig_password); + + // if there was any error checking in if ($response['status_code'] == 1) { throw new RuntimeException('There was an error checking in the document: ' . $response['message']); } - return CMISUtil::encodeObjectId(DOCUMENT, $documentId); + return CMISUtil::encodeObjectId(DOCUMENT, $objectId); } } diff --git a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php index e7d8562..ff7242c 100644 --- a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php +++ b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php @@ -34,7 +34,7 @@ When POSTing an Atom Document, the atom fields take precedence over the CMIS pro include_once CMIS_ATOM_LIB_FOLDER . 'RepositoryService.inc.php'; include_once CMIS_ATOM_LIB_FOLDER . 'NavigationService.inc.php'; include_once CMIS_ATOM_LIB_FOLDER . 'ObjectService.inc.php'; -include_once CMIS_ATOM_LIB_FOLDER . 'VersioningService.inc.php'; +include_once CMIS_API . '/ktVersioningService.inc.php'; include_once 'KT_cmis_atom_service_helper.inc.php'; // TODO consider changing all responses from the webservice layer to return PEAR errors or success results instead of the half/half we have at the moment. @@ -157,6 +157,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { $objectId = $this->params[2]; } + // get object properties - todo send through original properties array and not modified version $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); $properties = array('name' => $title, 'summary' => $summary, 'objectTypeId' => $cmisObjectProperties['cmis:objectTypeId']); @@ -188,7 +189,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); - global $default; $success = false; $error = null; if ($action == 'create') @@ -430,7 +430,7 @@ class KT_cmis_atom_service_document extends KT_cmis_atom_service { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); - $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); + $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); // attempt delete $response = $VersioningService->deleteAllVersions($repositoryId, $this->params[0]); @@ -491,13 +491,12 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); - $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); + $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); $response = $VersioningService->cancelCheckout($repositoryId, $this->params[0]); - if (PEAR::isError($response)) - { - $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response->getMessage()); + if ($response['status_code'] == 1) { + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response['message']); // Expose the responseFeed $this->responseFeed = $feed; return null; @@ -510,45 +509,41 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { public function PUT_action() { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); - - $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); + $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); + + // get object properties + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); // check for content stream - // NOTE this is a hack! will not work with CMISSpaces at least, probably not with any client except RestTest and similar - // where we can manually modify the input - // first we try for an atom content tag - $content = KT_cmis_atom_service_helper::getAtomValues($this->rawContent, 'content'); - if (!empty($content)) { - $contentStream = $content; - } - // not found? try for a regular content tag - else { - $content = KT_cmis_atom_service_helper::findTag('content', $this->parsedXMLContent['@children'], null, false); - $contentStream = $content['@value']; - } - - // if we haven't found it now, the real hack begins - retrieve the EXISTING content and submit this as the contentStream + $content = KT_cmis_atom_service_helper::getCmisContent($this->rawContent); + // NOTE not sure about the text type, will need testing, most content will be base64 + $cmisContent = (isset($content['cmisra:base64']) + ? $content['cmisra:base64'] + : ((isset($content['cmisra:text'])) + ? $content['cmisra:text'] + : null)); + + // if we haven't found it now, the hack begins - retrieve the EXISTING content and submit this as the contentStream // this is needed because KnowledgeTree will not accept a checkin without a content stream but CMISSpaces (and possibly // other CMIS clients are the same, does not send a content stream on checkin nor does it offer the user a method to choose one) // NOTE that if the content is INTENDED to be empty this and all the above checks will FAIL! // FIXME this is horrible, terrible, ugly and bad! - if (empty($contentStream)) { - $contentStream = base64_encode(KT_cmis_atom_service_helper::getContentStream($this, $ObjectService, $repositoryId)); + if (empty($cmisContent)) { + $cmisContent = base64_encode(KT_cmis_atom_service_helper::getContentStream($this, $ObjectService, $repositoryId)); } - // and if we don't have it by now, we give up...but leave the error to be generated by the underlying KnowledgeTree code - + // and if we don't have the content stream by now, we give up...but leave the error to be generated by the underlying KnowledgeTree code // checkin function call // TODO dynamically detect version change type - leaving this for now as the CMIS clients tested do not appear to // offer the choice to the user - perhaps it will turn out that this will come from somewhere else but for now // we assume minor version updates only $major = false; - $response = $VersioningService->checkIn($repositoryId, $this->params[0], $major, $contentStream); - - if (PEAR::isError($response)) - { - $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response->getMessage()); + $checkinComment = ''; + $response = $VersioningService->checkIn($repositoryId, $this->params[0], $major, $cmisObjectProperties, $cmisContent, $checkinComment); + + if ($response['status_code'] == 1) { + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response['message']); // Expose the responseFeed $this->responseFeed = $feed; return null; @@ -630,7 +625,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); - $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); + $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); @@ -646,8 +641,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['cmis:objectId']); - if (PEAR::isError($response)) - { + if ($response['status_code'] == 1) { $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout'); // Expose the responseFeed $this->responseFeed = $feed; diff --git a/webservice/atompub/cmis/index.php b/webservice/atompub/cmis/index.php index 983f2d4..f4601fe 100644 --- a/webservice/atompub/cmis/index.php +++ b/webservice/atompub/cmis/index.php @@ -49,6 +49,7 @@ define('KT_ATOM_LIB_FOLDER', '../../classes/atompub/'); define('CMIS_APP_BASE_URI', trim(KT_APP_BASE_URI, '/')); define('CMIS_APP_SYSTEM_URI', KT_APP_SYSTEM_URI); define('CMIS_ATOM_LIB_FOLDER', trim(KT_ATOM_LIB_FOLDER, '/') . '/cmis/'); +define('CMIS_API', KT_LIB_DIR . '/api/ktcmis'); /** * Check Realm Authentication diff --git a/webservice/classes/atompub/cmis/ObjectService.inc.php b/webservice/classes/atompub/cmis/ObjectService.inc.php index 7a4e46d..886ac60 100644 --- a/webservice/classes/atompub/cmis/ObjectService.inc.php +++ b/webservice/classes/atompub/cmis/ObjectService.inc.php @@ -89,11 +89,12 @@ class ObjectService extends KTObjectService { * * @param string $repositoryId * @param string $objectId + * @param string $streamId [optional for documents] Specifies the rendition to retrieve if not original document * @return string $contentStream (binary or text data) */ - function getContentStream($repositoryId, $objectId) + function getContentStream($repositoryId, $objectId, $streamId = null) { - $result = parent::getContentStream($repositoryId, $objectId); + $result = parent::getContentStream($repositoryId, $objectId, $streamId); if ($result['status_code'] == 0) { return $result['results']; diff --git a/webservice/classes/atompub/cmis/VersioningService.inc.php b/webservice/classes/atompub/cmis/VersioningService.inc.php index 07a953c..4716cb0 100644 --- a/webservice/classes/atompub/cmis/VersioningService.inc.php +++ b/webservice/classes/atompub/cmis/VersioningService.inc.php @@ -27,75 +27,6 @@ class VersioningService extends KTVersioningService { return new PEAR_Error($result['message']); } } - - /** - * Checks out a document and creates the PWC (Private Working Copy) which will represent the checked out document - * - * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] - * @return array results - */ - // TODO set up delivery of content stream? or is that up to the CMIS client? - public function checkOut($repositoryId, $documentId, $changeToken = '') - { - $result = parent::checkOut($repositoryId, $documentId, $changeToken); - - if ($result['status_code'] == 0) { - return $result['results']; - } - else { - return new PEAR_Error($result['message']); - } - } - - /** - * Reverses the effect of a checkout: I.E. deletes the PWC (Private Working Copy) and re-sets the status of the document to "not checked out" - * - * @param string $repositoryId - * @param string $documentId - * @param string $changeToken [optional] - */ - // TODO exceptions: - // • ConstraintViolationException: The Repository SHALL throw this exception if ANY of the following conditions are met: - // o The Document’s Object-Type definition’s versionable attribute is FALSE. - // • updateConflictException - // • versioningException - public function cancelCheckOut($repositoryId, $documentId, $changeToken = '') - { - $result = parent::cancelCheckOut($repositoryId, $documentId, $changeToken); - - if ($result['status_code'] == 0) { - return $result['results']; - } - else { - return new PEAR_Error($result['message']); - } - } - - /** - * Checks in a checked out document - * - * @param string $repositoryId - * @param string $documentId - * @param boolean $major - * @param string $changeToken [optional] - * @param array $properties [optional] - * @param contentStream $contentStream [optional] - * @param string $checkinComment [optional] - * @return string $documentId - */ - public function checkIn($repositoryId, $documentId, $major, $contentStream = null, $changeToken = '', $properties = array(), $checkinComment = '') - { - $result = parent::checkIn($repositoryId, $documentId, $major, $contentStream, $changeToken, $properties, $checkinComment); - - if ($result['status_code'] == 0) { - return $result['results']; - } - else { - return new PEAR_Error($result['message']); - } - } }