Commit 53ab10ed1c6ecdb1ce1dfeb86c3ae414773ff18e
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
9 changed files
with
153 additions
and
16 deletions
lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php
| @@ -73,7 +73,8 @@ class CMISDocumentPropertyCollection extends CMISPropertyCollection { | @@ -73,7 +73,8 @@ class CMISDocumentPropertyCollection extends CMISPropertyCollection { | ||
| 73 | 'ContentStreamUri' => 'propertyUri', | 73 | 'ContentStreamUri' => 'propertyUri', |
| 74 | 'IsVersionSeriesCheckedOut' => 'propertyBoolean', | 74 | 'IsVersionSeriesCheckedOut' => 'propertyBoolean', |
| 75 | 'VersionSeriesCheckedOutBy' => 'propertyString', | 75 | 'VersionSeriesCheckedOutBy' => 'propertyString', |
| 76 | - 'VersionSeriesCheckedOutId' => 'propertyId')); | 76 | + 'VersionSeriesCheckedOutId' => 'propertyId', |
| 77 | + 'VersionLabel' => 'propertyString')); | ||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | } | 80 | } |
lib/api/ktcmis/classes/CMISPropertyCollection.inc.php
| @@ -62,7 +62,7 @@ abstract class CMISPropertyCollection { | @@ -62,7 +62,7 @@ abstract class CMISPropertyCollection { | ||
| 62 | self::$propertyTypes = array('ObjectId' => 'propertyId', | 62 | self::$propertyTypes = array('ObjectId' => 'propertyId', |
| 63 | 'Author' => 'propertyString', | 63 | 'Author' => 'propertyString', |
| 64 | 'BaseType' => 'propertyString', | 64 | 'BaseType' => 'propertyString', |
| 65 | - 'ObjectTypeId' => 'propertyString', | 65 | + 'ObjectTypeId' => 'propertyId', |
| 66 | 'CreatedBy' => 'propertyString', | 66 | 'CreatedBy' => 'propertyString', |
| 67 | 'CreationDate' => 'propertyDateTime', | 67 | 'CreationDate' => 'propertyDateTime', |
| 68 | 'LastModifiedBy' => 'propertyString', | 68 | 'LastModifiedBy' => 'propertyString', |
lib/api/ktcmis/ktcmis.inc.php
| @@ -861,6 +861,37 @@ class KTVersioningService extends KTCMISBase { | @@ -861,6 +861,37 @@ class KTVersioningService extends KTCMISBase { | ||
| 861 | 'results' => (!empty($result) ? $result : 'Document Checkout Cancelled') | 861 | 'results' => (!empty($result) ? $result : 'Document Checkout Cancelled') |
| 862 | ); | 862 | ); |
| 863 | } | 863 | } |
| 864 | + | ||
| 865 | + /** | ||
| 866 | + * Checks in a checked out document | ||
| 867 | + * | ||
| 868 | + * @param string $repositoryId | ||
| 869 | + * @param string $documentId | ||
| 870 | + * @param boolean $major | ||
| 871 | + * @param string $changeToken [optional] | ||
| 872 | + * @param array $properties [optional] | ||
| 873 | + * @param contentStream $contentStream [optional] | ||
| 874 | + * @param string $checkinComment [optional] | ||
| 875 | + * @return string $documentId | ||
| 876 | + */ | ||
| 877 | + public function checkIn($repositoryId, $documentId, $major, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') | ||
| 878 | + { | ||
| 879 | + try { | ||
| 880 | + $result = $this->VersioningService->checkIn($repositoryId, $documentId, $major, $changeToken, $properties, $contentStream, $checkinComment); | ||
| 881 | + } | ||
| 882 | + catch (Exception $e) | ||
| 883 | + { | ||
| 884 | + return array( | ||
| 885 | + "status_code" => 1, | ||
| 886 | + "message" => $e->getMessage() | ||
| 887 | + ); | ||
| 888 | + } | ||
| 889 | + | ||
| 890 | + return array( | ||
| 891 | + 'status_code' => 0, | ||
| 892 | + 'results' => (!empty($result) ? $result : 'Document Checked In Successfully') | ||
| 893 | + ); | ||
| 894 | + } | ||
| 864 | 895 | ||
| 865 | } | 896 | } |
| 866 | 897 |
lib/api/ktcmis/services/CMISNavigationService.inc.php
| @@ -268,6 +268,8 @@ class CMISNavigationService { | @@ -268,6 +268,8 @@ class CMISNavigationService { | ||
| 268 | foreach($results as $document) | 268 | foreach($results as $document) |
| 269 | { | 269 | { |
| 270 | $CMISDocument = new CMISDocumentObject($document->getId(), $this->ktapi); | 270 | $CMISDocument = new CMISDocumentObject($document->getId(), $this->ktapi); |
| 271 | + // set version label property - possibly belongs in document class | ||
| 272 | + $CMISDocument->setProperty('VersionLabel', $CMISDocument->getProperty('VersionSeriesCheckedOutId')); | ||
| 271 | $checkedout[] = $CMISDocument->getProperties(); | 273 | $checkedout[] = $CMISDocument->getProperties(); |
| 272 | } | 274 | } |
| 273 | 275 |
lib/api/ktcmis/services/CMISVersioningService.inc.php
| @@ -169,6 +169,46 @@ class CMISVersioningService { | @@ -169,6 +169,46 @@ class CMISVersioningService { | ||
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | + /** | ||
| 173 | + * Checks in a checked out document | ||
| 174 | + * | ||
| 175 | + * @param string $repositoryId | ||
| 176 | + * @param string $documentId | ||
| 177 | + * @param boolean $major | ||
| 178 | + * @param string $changeToken [optional] | ||
| 179 | + * @param array $properties [optional] | ||
| 180 | + * @param contentStream $contentStream [optional] | ||
| 181 | + * @param string $checkinComment [optional] | ||
| 182 | + * @return string $documentId | ||
| 183 | + */ | ||
| 184 | + // TODO Exceptions: | ||
| 185 | + // โข ConstraintViolationException - SHALL throw if o The Documentโs Object-Type definitionโs versionable attribute is FALSE. | ||
| 186 | + // โข storageException - MAY throw | ||
| 187 | + // โข streamNotSupportedException - The Repository SHALL throw this exception if the Object-Type definition specified by the typeId | ||
| 188 | + // parameterโs โcontentStreamAllowedโ attribute is set to โnot allowedโ and a contentStream input | ||
| 189 | + // parameter is provided. | ||
| 190 | + // โข updateConflictException - MAY throw | ||
| 191 | + // โข versioningException - The repository MAY throw this exception if the object is a non-current Document Version | ||
| 192 | + public function checkIn($repositoryId, $documentId, $major, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') | ||
| 193 | + { | ||
| 194 | + $documentId = CMISUtil::decodeObjectId($documentId, $typeId); | ||
| 195 | + | ||
| 196 | + // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). | ||
| 197 | + try { | ||
| 198 | + $pwc = new CMISDocumentObject($documentId, $this->ktapi); | ||
| 199 | + } | ||
| 200 | + catch (exception $e) { | ||
| 201 | + throw new UpdateConflictException($e->getMessage()); | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + // throw exception if the object is not versionable | ||
| 205 | + if (!$pwc->getAttribute('versionable')) { | ||
| 206 | + throw new ConstraintViolationException('This document is not versionable and may not be checked in'); | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + return $documentId; | ||
| 210 | + } | ||
| 211 | + | ||
| 172 | } | 212 | } |
| 173 | 213 | ||
| 174 | ?> | 214 | ?> |
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 { | @@ -446,7 +446,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 446 | $repositoryId = $repositories[0]['repositoryId']; | 446 | $repositoryId = $repositories[0]['repositoryId']; |
| 447 | 447 | ||
| 448 | $checkedout = $NavigationService->getCheckedOutDocs($repositoryId); | 448 | $checkedout = $NavigationService->getCheckedOutDocs($repositoryId); |
| 449 | - | 449 | +//print_r($checkedout);exit; |
| 450 | //Create a new response feed | 450 | //Create a new response feed |
| 451 | $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | 451 | $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 452 | $workspace = $feed->getWorkspace(); | 452 | $workspace = $feed->getWorkspace(); |
| @@ -483,7 +483,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | @@ -483,7 +483,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 483 | 483 | ||
| 484 | foreach($checkedout as $cmisEntry) | 484 | foreach($checkedout as $cmisEntry) |
| 485 | { | 485 | { |
| 486 | - KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); | 486 | + KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName, true); |
| 487 | 487 | ||
| 488 | // // after each entry, add app:edited tag | 488 | // // after each entry, add app:edited tag |
| 489 | // $feed->newField('app:edited', KT_cmis_atom_service_helper::formatDatestamp(), $feed); | 489 | // $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 { | @@ -506,7 +506,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 506 | 506 | ||
| 507 | $repositories = $RepositoryService->getRepositories(); | 507 | $repositories = $RepositoryService->getRepositories(); |
| 508 | $repositoryId = $repositories[0]['repositoryId']; | 508 | $repositoryId = $repositories[0]['repositoryId']; |
| 509 | - | 509 | + |
| 510 | $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']); | 510 | $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']); |
| 511 | 511 | ||
| 512 | // check for existing object id as property of submitted object data | 512 | // 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 { | @@ -646,6 +646,8 @@ class KT_cmis_atom_service_document extends KT_cmis_atom_service { | ||
| 646 | } | 646 | } |
| 647 | 647 | ||
| 648 | class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { | 648 | class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { |
| 649 | + | ||
| 650 | + protected $serviceType = 'PWC'; | ||
| 649 | 651 | ||
| 650 | /** | 652 | /** |
| 651 | * Deals with GET actions for Private Working Copies. | 653 | * Deals with GET actions for Private Working Copies. |
| @@ -703,6 +705,29 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { | @@ -703,6 +705,29 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { | ||
| 703 | $this->responseFeed = null; | 705 | $this->responseFeed = null; |
| 704 | } | 706 | } |
| 705 | 707 | ||
| 708 | + public function PUT_action() | ||
| 709 | + { | ||
| 710 | + // call the checkin function | ||
| 711 | + $RepositoryService = new RepositoryService(); | ||
| 712 | + $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); | ||
| 713 | + | ||
| 714 | + $repositories = $RepositoryService->getRepositories(); | ||
| 715 | + $repositoryId = $repositories[0]['repositoryId']; | ||
| 716 | + | ||
| 717 | + $response = $VersioningService->checkIn($repositoryId, $this->params[0]); | ||
| 718 | + | ||
| 719 | + if (PEAR::isError($response)) | ||
| 720 | + { | ||
| 721 | + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response->getMessage()); | ||
| 722 | + //Expose the responseFeed | ||
| 723 | + $this->responseFeed = $feed; | ||
| 724 | + return null; | ||
| 725 | + } | ||
| 726 | + | ||
| 727 | + $this->setStatus(self::STATUS_NO_CONTENT); | ||
| 728 | + $this->responseFeed = null; | ||
| 729 | + } | ||
| 730 | + | ||
| 706 | } | 731 | } |
| 707 | 732 | ||
| 708 | ?> | 733 | ?> |
| 709 | \ No newline at end of file | 734 | \ No newline at end of file |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| @@ -14,6 +14,7 @@ class KT_cmis_atom_service_helper { | @@ -14,6 +14,7 @@ class KT_cmis_atom_service_helper { | ||
| 14 | */ | 14 | */ |
| 15 | static public function getObjectFeed(&$service, $ObjectService, $repositoryId, $objectId, $method = 'GET') | 15 | static public function getObjectFeed(&$service, $ObjectService, $repositoryId, $objectId, $method = 'GET') |
| 16 | { | 16 | { |
| 17 | + $serviceType = $service->getServiceType(); | ||
| 17 | $response = $ObjectService->getProperties($repositoryId, $objectId, false, false); | 18 | $response = $ObjectService->getProperties($repositoryId, $objectId, false, false); |
| 18 | 19 | ||
| 19 | if (PEAR::isError($response)) { | 20 | if (PEAR::isError($response)) { |
| @@ -22,18 +23,24 @@ class KT_cmis_atom_service_helper { | @@ -22,18 +23,24 @@ class KT_cmis_atom_service_helper { | ||
| 22 | 23 | ||
| 23 | $cmisEntry = $response; | 24 | $cmisEntry = $response; |
| 24 | $response = null; | 25 | $response = null; |
| 25 | - | ||
| 26 | - if ($method == 'GET') { | 26 | + |
| 27 | + // POST/PWC responses only send back an entry, not a feed | ||
| 28 | + if (($serviceType == 'PWC') || ($method == 'POST')) { | ||
| 29 | + if ($method == 'POST') { | ||
| 30 | + $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); | ||
| 31 | + } | ||
| 32 | + else { | ||
| 33 | + $response = new KT_cmis_atom_response_GET(CMIS_APP_BASE_URI); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + else if ($method == 'GET') { | ||
| 27 | $response = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | 37 | $response = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 28 | $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); | 38 | $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); |
| 29 | $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); | 39 | $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); |
| 30 | } | 40 | } |
| 31 | - // POST responses only send back an entry, not a feed | ||
| 32 | - else if ($method == 'POST') { | ||
| 33 | - $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); | ||
| 34 | - } | ||
| 35 | 41 | ||
| 36 | - KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $cmisEntry['properties']['ParentId']['value'], $method); | 42 | + if ($serviceType == 'PWC') $pwc = true; else $pwc = false; |
| 43 | + KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $cmisEntry['properties']['ParentId']['value'], $pwc, $method); | ||
| 37 | 44 | ||
| 38 | // Don't think this should be here...only one item so why would we need to say there are no more? | 45 | // Don't think this should be here...only one item so why would we need to say there are no more? |
| 39 | /*if ($method == 'GET') { | 46 | /*if ($method == 'GET') { |
| @@ -50,7 +57,7 @@ class KT_cmis_atom_service_helper { | @@ -50,7 +57,7 @@ class KT_cmis_atom_service_helper { | ||
| 50 | * @param array $cmisEntry The entry data | 57 | * @param array $cmisEntry The entry data |
| 51 | * @param string $parent The parent folder | 58 | * @param string $parent The parent folder |
| 52 | */ | 59 | */ |
| 53 | - static public function createObjectEntry(&$response, $cmisEntry, $parent, $method = 'GET') | 60 | + static public function createObjectEntry(&$response, $cmisEntry, $parent, $pwc = false, $method = 'GET') |
| 54 | { | 61 | { |
| 55 | $workspace = $response->getWorkspace(); | 62 | $workspace = $response->getWorkspace(); |
| 56 | $type = strtolower($cmisEntry['properties']['ObjectTypeId']['value']); | 63 | $type = strtolower($cmisEntry['properties']['ObjectTypeId']['value']); |
| @@ -58,7 +65,8 @@ class KT_cmis_atom_service_helper { | @@ -58,7 +65,8 @@ class KT_cmis_atom_service_helper { | ||
| 58 | // create entry | 65 | // create entry |
| 59 | $entry = $response->newEntry(); | 66 | $entry = $response->newEntry(); |
| 60 | 67 | ||
| 61 | - if ($method == 'POST') | 68 | + // FIXME this maybe belongs in the response feed class only how? |
| 69 | + if (($method == 'POST') || $pwc) | ||
| 62 | { | 70 | { |
| 63 | // append attributes | 71 | // append attributes |
| 64 | $entry->appendChild($response->newAttr('xmlns', 'http://www.w3.org/2005/Atom')); | 72 | $entry->appendChild($response->newAttr('xmlns', 'http://www.w3.org/2005/Atom')); |
| @@ -89,7 +97,7 @@ class KT_cmis_atom_service_helper { | @@ -89,7 +97,7 @@ class KT_cmis_atom_service_helper { | ||
| 89 | // links | 97 | // links |
| 90 | $link = $response->newElement('link'); | 98 | $link = $response->newElement('link'); |
| 91 | $link->appendChild($response->newAttr('rel', 'self')); | 99 | $link->appendChild($response->newAttr('rel', 'self')); |
| 92 | - $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); | 100 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . (!$pwc ? $type : 'pwc') . '/' . $cmisEntry['properties']['ObjectId']['value'])); |
| 93 | $entry->appendChild($link); | 101 | $entry->appendChild($link); |
| 94 | 102 | ||
| 95 | $link = $response->newElement('link'); | 103 | $link = $response->newElement('link'); |
webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
| @@ -6,8 +6,9 @@ class KT_cmis_atom_service extends KT_atom_service { | @@ -6,8 +6,9 @@ class KT_cmis_atom_service extends KT_atom_service { | ||
| 6 | 6 | ||
| 7 | // override and extend as needed | 7 | // override and extend as needed |
| 8 | 8 | ||
| 9 | + protected $serviceType = null; | ||
| 9 | protected $contentDownload = false; | 10 | protected $contentDownload = false; |
| 10 | - | 11 | + |
| 11 | public public function isContentDownload() | 12 | public public function isContentDownload() |
| 12 | { | 13 | { |
| 13 | return $this->contentDownload; | 14 | return $this->contentDownload; |
| @@ -23,6 +24,11 @@ class KT_cmis_atom_service extends KT_atom_service { | @@ -23,6 +24,11 @@ class KT_cmis_atom_service extends KT_atom_service { | ||
| 23 | return $this->output; | 24 | return $this->output; |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | + public function getServiceType() | ||
| 28 | + { | ||
| 29 | + return $this->serviceType; | ||
| 30 | + } | ||
| 31 | + | ||
| 26 | protected function setHeader($header = null, $value = null) | 32 | protected function setHeader($header = null, $value = null) |
| 27 | { | 33 | { |
| 28 | if ($header) header($header . ': ' . $value); | 34 | if ($header) header($header . ': ' . $value); |
webservice/classes/atompub/cmis/VersioningService.inc.php
| @@ -72,6 +72,30 @@ class VersioningService extends KTVersioningService { | @@ -72,6 +72,30 @@ class VersioningService extends KTVersioningService { | ||
| 72 | return new PEAR_Error($result['message']); | 72 | return new PEAR_Error($result['message']); |
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * Checks in a checked out document | ||
| 78 | + * | ||
| 79 | + * @param string $repositoryId | ||
| 80 | + * @param string $documentId | ||
| 81 | + * @param boolean $major | ||
| 82 | + * @param string $changeToken [optional] | ||
| 83 | + * @param array $properties [optional] | ||
| 84 | + * @param contentStream $contentStream [optional] | ||
| 85 | + * @param string $checkinComment [optional] | ||
| 86 | + * @return string $documentId | ||
| 87 | + */ | ||
| 88 | + public function checkIn($repositoryId, $documentId, $major, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '') | ||
| 89 | + { | ||
| 90 | + $result = parent::checkIn($repositoryId, $documentId, $major, $changeToken, $properties, $contentStream, $checkinComment); | ||
| 91 | + | ||
| 92 | + if ($result['status_code'] == 0) { | ||
| 93 | + return $result['results']; | ||
| 94 | + } | ||
| 95 | + else { | ||
| 96 | + return new PEAR_Error($result['message']); | ||
| 97 | + } | ||
| 98 | + } | ||
| 75 | 99 | ||
| 76 | } | 100 | } |
| 77 | 101 |