Commit 9f69bab52764bb92617d9f1711b548e20f18ce6b
1 parent
717e2613
AtomPub code for CMIS checkout
StoryID: 1093055. CMIS Checkout In Progress Committed by: Paul Barrett Reviewed by: Jarrett Jordaan
Showing
3 changed files
with
114 additions
and
6 deletions
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| ... | ... | @@ -136,9 +136,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { |
| 136 | 136 | $objectId = $this->params[2]; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object'] | |
| 140 | - [0]['@children']['cmis:properties'] | |
| 141 | - [0]['@children']); | |
| 139 | + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object']); | |
| 142 | 140 | |
| 143 | 141 | // check for existing object id as property of submitted object data |
| 144 | 142 | if (!empty($cmisObjectProperties['ObjectId'])) |
| ... | ... | @@ -487,6 +485,85 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { |
| 487 | 485 | //Expose the responseFeed |
| 488 | 486 | $this->responseFeed = $feed; |
| 489 | 487 | } |
| 488 | + | |
| 489 | + public function POST_action() | |
| 490 | + { | |
| 491 | + $RepositoryService = new RepositoryService(); | |
| 492 | + $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); | |
| 493 | + $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); | |
| 494 | + | |
| 495 | + $repositories = $RepositoryService->getRepositories(); | |
| 496 | + $repositoryId = $repositories[0]['repositoryId']; | |
| 497 | + | |
| 498 | + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object']); | |
| 499 | + | |
| 500 | + // check for existing object id as property of submitted object data | |
| 501 | + if (empty($cmisObjectProperties['ObjectId'])) | |
| 502 | + { | |
| 503 | + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout'); | |
| 504 | + //Expose the responseFeed | |
| 505 | + $this->responseFeed = $feed; | |
| 506 | + return null; | |
| 507 | + } | |
| 508 | + | |
| 509 | + $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['ObjectId']); | |
| 510 | + | |
| 511 | + if (PEAR::isError($response)) | |
| 512 | + { | |
| 513 | + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout'); | |
| 514 | + //Expose the responseFeed | |
| 515 | + $this->responseFeed = $feed; | |
| 516 | + return null; | |
| 517 | + } | |
| 518 | + | |
| 519 | + $this->setStatus(self::STATUS_CREATED); | |
| 520 | + $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $cmisObjectProperties['ObjectId'], 'POST'); | |
| 521 | +// $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $newObjectId, 'POST'); | |
| 522 | + | |
| 523 | + //Expose the responseFeed | |
| 524 | + $this->responseFeed = $feed; | |
| 525 | + | |
| 526 | +// $checkedout = $NavigationService->getCheckedoutDocs($repositoryId); | |
| 527 | +// | |
| 528 | +// //Create a new response feed | |
| 529 | +// $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | |
| 530 | +// | |
| 531 | +// $feed->newField('title', 'Checked out Documents', $feed); | |
| 532 | +// | |
| 533 | +// // TODO dynamic? | |
| 534 | +// $feedElement = $feed->newField('author'); | |
| 535 | +// $element = $feed->newField('name', 'admin', $feedElement); | |
| 536 | +// $feed->appendChild($feedElement); | |
| 537 | +// | |
| 538 | +// $feed->appendChild($feed->newElement('id', 'urn:uuid:checkedout')); | |
| 539 | +// | |
| 540 | +// // TODO get actual most recent update time, only use current if no other available | |
| 541 | +// $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp())); | |
| 542 | +// | |
| 543 | +// foreach($checkedout as $document) | |
| 544 | +// { | |
| 545 | +// $entry = $feed->newEntry(); | |
| 546 | +// $objectElement = $feed->newElement('cmis:object'); | |
| 547 | +// $propertiesElement = $feed->newElement('cmis:properties'); | |
| 548 | +// | |
| 549 | +// foreach($cmisEntry['properties'] as $propertyName => $property) | |
| 550 | +// { | |
| 551 | +// $propElement = $feed->newElement('cmis:' . $property['type']); | |
| 552 | +// $propElement->appendChild($feed->newAttr('cmis:name', $propertyName)); | |
| 553 | +// $feed->newField('cmis:value', CMISUtil::boolToString($property['value']), $propElement); | |
| 554 | +// $propertiesElement->appendChild($propElement); | |
| 555 | +// } | |
| 556 | +// | |
| 557 | +// $objectElement->appendChild($propertiesElement); | |
| 558 | +// $entry->appendChild($objectElement); | |
| 559 | +// } | |
| 560 | +// | |
| 561 | +// $entry = null; | |
| 562 | +// $feed->newField('cmis:hasMoreItems', 'false', $entry, true); | |
| 563 | +// | |
| 564 | +// //Expose the responseFeed | |
| 565 | +// $this->responseFeed = $feed; | |
| 566 | + } | |
| 490 | 567 | |
| 491 | 568 | } |
| 492 | 569 | ... | ... |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| ... | ... | @@ -28,6 +28,7 @@ class KT_cmis_atom_service_helper { |
| 28 | 28 | $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); |
| 29 | 29 | $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); |
| 30 | 30 | } |
| 31 | + // POST responses only send back an entry, not a feed | |
| 31 | 32 | else if ($method == 'POST') { |
| 32 | 33 | $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); |
| 33 | 34 | } |
| ... | ... | @@ -414,11 +415,20 @@ class KT_cmis_atom_service_helper { |
| 414 | 415 | { |
| 415 | 416 | $properties = array(); |
| 416 | 417 | |
| 417 | - foreach($xmlArray as $cmisPropertyDefinition) | |
| 418 | + foreach($xmlArray as $xmlElement) | |
| 418 | 419 | { |
| 419 | - foreach($cmisPropertyDefinition as $propertyType => $propertyDefinition) | |
| 420 | + foreach($xmlElement['@children'] as $key => $childElement) | |
| 420 | 421 | { |
| 421 | - $properties[$propertyDefinition['@attributes']['cmis:name']] = $propertyDefinition['@children']['cmis:value'][0]['@value']; | |
| 422 | + if ($key == 'cmis:properties') | |
| 423 | + { | |
| 424 | + foreach($childElement[0]['@children'] as $cmisPropertyDefinition) | |
| 425 | + { | |
| 426 | + foreach($cmisPropertyDefinition as $propertyType => $propertyDefinition) | |
| 427 | + { | |
| 428 | + $properties[$propertyDefinition['@attributes']['cmis:name']] = $propertyDefinition['@children']['cmis:value'][0]['@value']; | |
| 429 | + } | |
| 430 | + } | |
| 431 | + } | |
| 422 | 432 | } |
| 423 | 433 | } |
| 424 | 434 | ... | ... |
webservice/classes/atompub/cmis/VersioningService.inc.php
| ... | ... | @@ -27,6 +27,27 @@ class VersioningService extends KTVersioningService { |
| 27 | 27 | return new PEAR_Error($result['message']); |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Checks out a document and creates the PWC (Private Working Copy) which will represent the checked out document | |
| 33 | + * | |
| 34 | + * @param string $repositoryId | |
| 35 | + * @param string $documentId | |
| 36 | + * @param string $changeToken [optional] | |
| 37 | + * @return array results | |
| 38 | + */ | |
| 39 | + // TODO set up delivery of content stream? or is that up to the CMIS client? | |
| 40 | + public function checkOut($repositoryId, $documentId, $changeToken = '') | |
| 41 | + { | |
| 42 | + $result = parent::checkOut($repositoryId, $documentId, $changeToken); | |
| 43 | + | |
| 44 | + if ($result['status_code'] == 0) { | |
| 45 | + return $result['results']; | |
| 46 | + } | |
| 47 | + else { | |
| 48 | + return new PEAR_Error($result['message']); | |
| 49 | + } | |
| 50 | + } | |
| 30 | 51 | |
| 31 | 52 | } |
| 32 | 53 | ... | ... |