diff --git a/lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php b/lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php index a35bda3..0a19724 100644 --- a/lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php +++ b/lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php @@ -73,7 +73,8 @@ class CMISDocumentPropertyCollection extends CMISPropertyCollection { 'ContentStreamUri' => 'propertyUri', 'IsVersionSeriesCheckedOut' => 'propertyBoolean', 'VersionSeriesCheckedOutBy' => 'propertyString', - 'VersionSeriesCheckedOutId' => 'propertyId')); + 'VersionSeriesCheckedOutId' => 'propertyId', + 'VersionLabel' => 'propertyString')); } } diff --git a/lib/api/ktcmis/classes/CMISPropertyCollection.inc.php b/lib/api/ktcmis/classes/CMISPropertyCollection.inc.php index 6536b6b..3ab27e4 100644 --- a/lib/api/ktcmis/classes/CMISPropertyCollection.inc.php +++ b/lib/api/ktcmis/classes/CMISPropertyCollection.inc.php @@ -62,7 +62,7 @@ abstract class CMISPropertyCollection { self::$propertyTypes = array('ObjectId' => 'propertyId', 'Author' => 'propertyString', 'BaseType' => 'propertyString', - 'ObjectTypeId' => 'propertyString', + 'ObjectTypeId' => 'propertyId', 'CreatedBy' => 'propertyString', 'CreationDate' => 'propertyDateTime', 'LastModifiedBy' => 'propertyString', diff --git a/lib/api/ktcmis/ktcmis.inc.php b/lib/api/ktcmis/ktcmis.inc.php index 8b55f8d..d59fb5b 100644 --- a/lib/api/ktcmis/ktcmis.inc.php +++ b/lib/api/ktcmis/ktcmis.inc.php @@ -861,6 +861,37 @@ class KTVersioningService extends KTCMISBase { 'results' => (!empty($result) ? $result : 'Document Checkout Cancelled') ); } + + /** + * 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, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') + { + try { + $result = $this->VersioningService->checkIn($repositoryId, $documentId, $major, $changeToken, $properties, $contentStream, $checkinComment); + } + catch (Exception $e) + { + return array( + "status_code" => 1, + "message" => $e->getMessage() + ); + } + + return array( + 'status_code' => 0, + 'results' => (!empty($result) ? $result : 'Document Checked In Successfully') + ); + } } diff --git a/lib/api/ktcmis/services/CMISNavigationService.inc.php b/lib/api/ktcmis/services/CMISNavigationService.inc.php index bed27ff..4e00335 100644 --- a/lib/api/ktcmis/services/CMISNavigationService.inc.php +++ b/lib/api/ktcmis/services/CMISNavigationService.inc.php @@ -268,6 +268,8 @@ class CMISNavigationService { foreach($results as $document) { $CMISDocument = new CMISDocumentObject($document->getId(), $this->ktapi); + // set version label property - possibly belongs in document class + $CMISDocument->setProperty('VersionLabel', $CMISDocument->getProperty('VersionSeriesCheckedOutId')); $checkedout[] = $CMISDocument->getProperties(); } diff --git a/lib/api/ktcmis/services/CMISVersioningService.inc.php b/lib/api/ktcmis/services/CMISVersioningService.inc.php index 482515c..345086e 100644 --- a/lib/api/ktcmis/services/CMISVersioningService.inc.php +++ b/lib/api/ktcmis/services/CMISVersioningService.inc.php @@ -169,6 +169,46 @@ class CMISVersioningService { } } + /** + * 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 + */ + // TODO Exceptions: + // • ConstraintViolationException - SHALL throw if o The Document’s Object-Type definition’s versionable attribute is FALSE. + // • storageException - MAY throw + // • streamNotSupportedException - The Repository SHALL throw this exception if the Object-Type definition specified by the typeId + // parameter’s “contentStreamAllowed” attribute is set to “not allowed” and a contentStream input + // parameter is provided. + // • updateConflictException - MAY throw + // • versioningException - The repository MAY throw this exception if the object is a non-current Document Version + public function checkIn($repositoryId, $documentId, $major, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') + { + $documentId = CMISUtil::decodeObjectId($documentId, $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); + } + 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'); + } + + return $documentId; + } + } ?> 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 54cfcbe..ef12863 100644 --- a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php +++ b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php @@ -446,7 +446,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { $repositoryId = $repositories[0]['repositoryId']; $checkedout = $NavigationService->getCheckedOutDocs($repositoryId); - +//print_r($checkedout);exit; //Create a new response feed $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); $workspace = $feed->getWorkspace(); @@ -483,7 +483,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { foreach($checkedout as $cmisEntry) { - KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); + KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName, true); // // after each entry, add app:edited tag // $feed->newField('app:edited', KT_cmis_atom_service_helper::formatDatestamp(), $feed); @@ -506,7 +506,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { $repositories = $RepositoryService->getRepositories(); $repositoryId = $repositories[0]['repositoryId']; - + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']); // check for existing object id as property of submitted object data @@ -646,6 +646,8 @@ class KT_cmis_atom_service_document extends KT_cmis_atom_service { } class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { + + protected $serviceType = 'PWC'; /** * Deals with GET actions for Private Working Copies. @@ -703,6 +705,29 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { $this->responseFeed = null; } + public function PUT_action() + { + // call the checkin function + $RepositoryService = new RepositoryService(); + $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); + + $repositories = $RepositoryService->getRepositories(); + $repositoryId = $repositories[0]['repositoryId']; + + $response = $VersioningService->checkIn($repositoryId, $this->params[0]); + + if (PEAR::isError($response)) + { + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response->getMessage()); + //Expose the responseFeed + $this->responseFeed = $feed; + return null; + } + + $this->setStatus(self::STATUS_NO_CONTENT); + $this->responseFeed = null; + } + } ?> \ No newline at end of file diff --git a/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php b/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php index d57198f..f3007a9 100644 --- a/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php +++ b/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php @@ -14,6 +14,7 @@ class KT_cmis_atom_service_helper { */ static public function getObjectFeed(&$service, $ObjectService, $repositoryId, $objectId, $method = 'GET') { + $serviceType = $service->getServiceType(); $response = $ObjectService->getProperties($repositoryId, $objectId, false, false); if (PEAR::isError($response)) { @@ -22,18 +23,24 @@ class KT_cmis_atom_service_helper { $cmisEntry = $response; $response = null; - - if ($method == 'GET') { + + // POST/PWC responses only send back an entry, not a feed + if (($serviceType == 'PWC') || ($method == 'POST')) { + if ($method == 'POST') { + $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); + } + else { + $response = new KT_cmis_atom_response_GET(CMIS_APP_BASE_URI); + } + } + else if ($method == 'GET') { $response = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); } - // POST responses only send back an entry, not a feed - else if ($method == 'POST') { - $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); - } - KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $cmisEntry['properties']['ParentId']['value'], $method); + if ($serviceType == 'PWC') $pwc = true; else $pwc = false; + KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $cmisEntry['properties']['ParentId']['value'], $pwc, $method); // Don't think this should be here...only one item so why would we need to say there are no more? /*if ($method == 'GET') { @@ -50,7 +57,7 @@ class KT_cmis_atom_service_helper { * @param array $cmisEntry The entry data * @param string $parent The parent folder */ - static public function createObjectEntry(&$response, $cmisEntry, $parent, $method = 'GET') + static public function createObjectEntry(&$response, $cmisEntry, $parent, $pwc = false, $method = 'GET') { $workspace = $response->getWorkspace(); $type = strtolower($cmisEntry['properties']['ObjectTypeId']['value']); @@ -58,7 +65,8 @@ class KT_cmis_atom_service_helper { // create entry $entry = $response->newEntry(); - if ($method == 'POST') + // FIXME this maybe belongs in the response feed class only how? + if (($method == 'POST') || $pwc) { // append attributes $entry->appendChild($response->newAttr('xmlns', 'http://www.w3.org/2005/Atom')); @@ -89,7 +97,7 @@ class KT_cmis_atom_service_helper { // links $link = $response->newElement('link'); $link->appendChild($response->newAttr('rel', 'self')); - $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . (!$pwc ? $type : 'pwc') . '/' . $cmisEntry['properties']['ObjectId']['value'])); $entry->appendChild($link); $link = $response->newElement('link'); diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php index 3266cd1..0b6a44d 100644 --- a/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php +++ b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php @@ -6,8 +6,9 @@ class KT_cmis_atom_service extends KT_atom_service { // override and extend as needed + protected $serviceType = null; protected $contentDownload = false; - + public public function isContentDownload() { return $this->contentDownload; @@ -23,6 +24,11 @@ class KT_cmis_atom_service extends KT_atom_service { return $this->output; } + public function getServiceType() + { + return $this->serviceType; + } + protected function setHeader($header = null, $value = null) { if ($header) header($header . ': ' . $value); diff --git a/webservice/classes/atompub/cmis/VersioningService.inc.php b/webservice/classes/atompub/cmis/VersioningService.inc.php index f7fb909..82cbf4d 100644 --- a/webservice/classes/atompub/cmis/VersioningService.inc.php +++ b/webservice/classes/atompub/cmis/VersioningService.inc.php @@ -72,6 +72,30 @@ class VersioningService extends KTVersioningService { 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, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') + { + $result = parent::checkIn($repositoryId, $documentId, $major, $changeToken, $properties, $contentStream, $checkinComment); + + if ($result['status_code'] == 0) { + return $result['results']; + } + else { + return new PEAR_Error($result['message']); + } + } }