diff --git a/lib/api/ktcmis/ktVersioningService.inc.php b/lib/api/ktcmis/ktVersioningService.inc.php index 0d940a3..944c391 100644 --- a/lib/api/ktcmis/ktVersioningService.inc.php +++ b/lib/api/ktcmis/ktVersioningService.inc.php @@ -88,23 +88,16 @@ class KTVersioningService extends KTCMISBase { * @return array results */ // TODO set up delivery of content stream? or is that up to the CMIS client? - public function checkOut($repositoryId, $objectId) + public function checkOut($repositoryId, &$objectId) { try { $result = $this->VersioningService->checkOut($repositoryId, $objectId); } - catch (Exception $e) - { - return array( - "status_code" => 1, - "message" => $e->getMessage() - ); + catch (Exception $e) { + throw $e; } - return array( - 'status_code' => 0, - 'results' => (!empty($result) ? $result : 'Document Checked Out') - ); + return $result; } /** @@ -113,28 +106,14 @@ class KTVersioningService extends KTCMISBase { * @param string $repositoryId * @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, $objectId) { try { $result = $this->VersioningService->cancelCheckOut($repositoryId, $objectId); } - catch (Exception $e) - { - return array( - "status_code" => 1, - "message" => $e->getMessage() - ); + catch (Exception $e) { + throw $e; } - - return array( - 'status_code' => 0, - 'results' => (!empty($result) ? $result : 'Document Checkout Cancelled') - ); } /** @@ -155,21 +134,14 @@ class KTVersioningService extends KTCMISBase { $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array()) { try { - $result = $this->VersioningService->checkIn($repositoryId, $objectId, $major, $properties, $contentStream, - $checkinComment, $policies, $addACEs, $removeACEs); + $objectId = $this->VersioningService->checkIn($repositoryId, $objectId, $major, $properties, $contentStream, + $checkinComment, $policies, $addACEs, $removeACEs); } - catch (Exception $e) - { - return array( - "status_code" => 1, - "message" => $e->getMessage() - ); + catch (Exception $e) { + throw $e; } - return array( - 'status_code' => 0, - 'results' => (!empty($result) ? $result : 'Document Checked In Successfully') - ); + return $objectId; } } diff --git a/lib/api/ktcmis/services/CMISVersioningService.inc.php b/lib/api/ktcmis/services/CMISVersioningService.inc.php index fcd1b7d..54a9cfc 100644 --- a/lib/api/ktcmis/services/CMISVersioningService.inc.php +++ b/lib/api/ktcmis/services/CMISVersioningService.inc.php @@ -99,8 +99,6 @@ class CMISVersioningService { * @param string $repositoryId * @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, $objectId) { $objectId = CMISUtil::decodeObjectId($objectId, $typeId); @@ -158,7 +156,6 @@ class CMISVersioningService { public function checkIn($repositoryId, $objectId, $major = true, $properties = array(), $contentStream = null, $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array()) { - $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). 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 0010888..8ab006c 100644 --- a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php +++ b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php @@ -530,12 +530,11 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); - $response = $VersioningService->cancelCheckout($repositoryId, $this->params[0]); - - 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; + try { + $response = $VersioningService->cancelCheckout($repositoryId, $this->params[0]); + } + catch (Exception $e) { + $this->responseFeed = KT_cmis_atom_service_helper::getErrorFeed($this, $this->getStatusCode($e), $e->getMessage()); return null; } @@ -677,15 +676,14 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { return null; } - $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['cmis:objectId']); - - 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; + try { + $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['cmis:objectId']); + } + catch (Exception $e) { + $this->responseFeed = KT_cmis_atom_service_helper::getErrorFeed($this, $this->getStatusCode($e), $e->getMessage()); return null; } - + $this->setStatus(self::STATUS_CREATED); $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $cmisObjectProperties['cmis:objectId'], 'POST');