Commit 7e146afce535a3a88a4b757754dbd99aa0d9ba84
1 parent
89bff69a
intermediat commit for CMIS
Showing
4 changed files
with
75 additions
and
64 deletions
lib/api/ktcmis/util/CMISUtil.inc.php
| ... | ... | @@ -261,36 +261,45 @@ class CMISUtil { |
| 261 | 261 | // TODO additional properties to be returned |
| 262 | 262 | $object['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'), |
| 263 | 263 | 'value' => $properties->getValue('BaseType')); |
| 264 | - $object['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'), | |
| 265 | - 'value' => $properties->getValue('ObjectId')); | |
| 266 | - $object['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'), | |
| 267 | - 'value' => $properties->getValue('ObjectTypeId')); | |
| 268 | - $object['properties']['Name'] = array('type' => $properties->getFieldType('Name'), | |
| 264 | + | |
| 265 | + $object['properties']['Name'] = array('type' => $properties->getFieldType('Name'), | |
| 269 | 266 | 'value' => $properties->getValue('Name')); |
| 270 | - // TODO ensure format of date is always correct | |
| 271 | - $object['properties']['LastModificationDate'] = array('type' => $properties->getFieldType('LastModificationDate'), | |
| 272 | - 'value' => $properties->getValue('LastModificationDate')); | |
| 273 | - $object['properties']['Uri'] = array('type' => $properties->getFieldType('Uri'), | |
| 274 | - 'value' => $properties->getValue('Uri')); | |
| 275 | - | |
| 276 | - $object['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'), | |
| 267 | + | |
| 268 | + $object['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'), | |
| 277 | 269 | 'value' => CMISUtil::encodeObjectId('Folder', |
| 278 | 270 | $properties->getValue('ParentId'))); |
| 279 | - | |
| 280 | - $object['properties']['AllowedChildObjectTypeIds'] = array('type' => $properties->getFieldType('AllowedChildObjectTypeIds'), | |
| 281 | - 'value' => $properties->getValue('AllowedChildObjectTypeIds')); | |
| 282 | - | |
| 283 | -// $object['properties']['AllowedChildObjectTypeIds'] = array('type' => $properties->getFieldType('AllowedChildObjectTypeIds'), | |
| 284 | -// 'value' => $properties->getValue('AllowedChildObjectTypeIds')); | |
| 271 | + | |
| 272 | + $object['properties']['Uri'] = array('type' => $properties->getFieldType('Uri'), | |
| 273 | + 'value' => $properties->getValue('Uri')); | |
| 274 | + | |
| 275 | + // TODO ensure format of date is always correct | |
| 276 | + $object['properties']['LastModificationDate'] = array('type' => $properties->getFieldType('LastModificationDate'), | |
| 277 | + 'value' => $properties->getValue('LastModificationDate')); | |
| 285 | 278 | |
| 286 | 279 | $object['properties']['CreatedBy'] = array('type' => $properties->getFieldType('CreatedBy'), |
| 287 | 280 | 'value' => $properties->getValue('CreatedBy')); |
| 281 | + | |
| 282 | + $object['properties']['AllowedChildObjectTypeIds'] = array('type' => $properties->getFieldType('AllowedChildObjectTypeIds'), | |
| 283 | + 'value' => $properties->getValue('AllowedChildObjectTypeIds')); | |
| 288 | 284 | |
| 289 | 285 | $object['properties']['CreationDate'] = array('type' => $properties->getFieldType('CreationDate'), |
| 290 | 286 | 'value' => $properties->getValue('CreationDate')); |
| 291 | 287 | |
| 288 | + $object['properties']['LastModifiedBy'] = array('type' => $properties->getFieldType('LastModifiedBy'), | |
| 289 | + 'value' => $properties->getValue('LastModifiedBy')); | |
| 290 | + | |
| 292 | 291 | $object['properties']['ChangeToken'] = array('type' => $properties->getFieldType('ChangeToken'), |
| 293 | 292 | 'value' => $properties->getValue('ChangeToken')); |
| 293 | + | |
| 294 | + $object['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'), | |
| 295 | + 'value' => $properties->getValue('ObjectTypeId')); | |
| 296 | + | |
| 297 | + $object['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'), | |
| 298 | + 'value' => $properties->getValue('ObjectId')); | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 294 | 303 | |
| 295 | 304 | if (strtolower($properties->getValue('ObjectTypeId')) == 'document') |
| 296 | 305 | { | ... | ... |
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| ... | ... | @@ -268,13 +268,16 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL |
| 271 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, $folderName . ' ' . ucwords($feedType), null, null, null, | |
| 272 | - 'urn:uuid:' . $folderId . '-' . $feedType); | |
| 271 | + $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, $folderName . ' ' . ucwords($feedType), null, null, null, null); | |
| 272 | +// 'urn:uuid:' . $folderId . '-' . $feedType); | |
| 273 | 273 | |
| 274 | 274 | // TODO dynamic? |
| 275 | 275 | $feedElement = $feed->newField('author'); |
| 276 | 276 | $element = $feed->newField('name', 'System', $feedElement); |
| 277 | 277 | $feed->appendChild($feedElement); |
| 278 | + | |
| 279 | + // id | |
| 280 | + $feed->appendChild($feed->newElement('id', 'urn:uuid:' . $folderId . '-' . $feedType)); | |
| 278 | 281 | |
| 279 | 282 | // TODO get actual most recent update time, only use current if no other available |
| 280 | 283 | $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp())); |
| ... | ... | @@ -287,6 +290,9 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { |
| 287 | 290 | foreach($entries as $cmisEntry) |
| 288 | 291 | { |
| 289 | 292 | KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); |
| 293 | + | |
| 294 | + // after each entry, add app:edited tag | |
| 295 | + $feed->appendChild($feed->newElement('app:edited', KT_cmis_atom_service_helper::formatDatestamp())); | |
| 290 | 296 | } |
| 291 | 297 | |
| 292 | 298 | // <cmis:hasMoreItems>false</cmis:hasMoreItems> |
| ... | ... | @@ -494,8 +500,19 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { |
| 494 | 500 | $checkedout = $NavigationService->getCheckedoutDocs($repositoryId); |
| 495 | 501 | |
| 496 | 502 | //Create a new response feed |
| 497 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Checked out Documents', null, null, null, 'urn:uuid:checkedout'); | |
| 503 | + $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Checked out Documents'); | |
| 504 | + | |
| 505 | + // TODO dynamic? | |
| 506 | + $feedElement = $feed->newField('author'); | |
| 507 | + $element = $feed->newField('name', 'admin', $feedElement); | |
| 508 | + $feed->appendChild($feedElement); | |
| 509 | + | |
| 510 | + $feed->appendChild($feed->newElement('id', 'urn:uuid:checkedout')); | |
| 498 | 511 | |
| 512 | + // TODO get actual most recent update time, only use current if no other available | |
| 513 | + $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp())); | |
| 514 | + | |
| 515 | +//'urn:uuid:checkedout' | |
| 499 | 516 | foreach($checkedout as $document) |
| 500 | 517 | { |
| 501 | 518 | $entry = $feed->newEntry(); |
| ... | ... | @@ -515,7 +532,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { |
| 515 | 532 | } |
| 516 | 533 | |
| 517 | 534 | $entry = null; |
| 518 | - $feed->newField('hasMoreItems', 'false', $entry, true); | |
| 535 | + $feed->newField('cmis:hasMoreItems', 'false', $entry, true); | |
| 519 | 536 | |
| 520 | 537 | //Expose the responseFeed |
| 521 | 538 | $this->responseFeed = $feed; | ... | ... |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| ... | ... | @@ -13,33 +13,18 @@ class KT_cmis_atom_service_helper { |
| 13 | 13 | */ |
| 14 | 14 | static public function createObjectEntry(&$feed, $cmisEntry, $parent, $path) |
| 15 | 15 | { |
| 16 | - // TODO next two lots of code (1 commented 1 not) must be replaced with something better | |
| 17 | -// $feed->newId('urn:uuid:' . $cmisEntry['properties']['Name']['value'] . '-' | |
| 18 | -// . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry); | |
| 19 | - | |
| 20 | -// echo $_SERVER['QUERY_STRING']."<BR>\n"; | |
| 21 | -// preg_match('/^\/?[^\/]*\/folder\/(.*)\/[^\/]*\/?$/', trim($_SERVER['QUERY_STRING'], '/'), $matches); | |
| 22 | -// $path = $matches[1]; | |
| 23 | -// $parent = preg_replace('/\/[^\/]*$/', '', $path); | |
| 24 | -// // TODO fix path to work on old method, after fixing drupal module to not require extended path | |
| 25 | -// | |
| 26 | -// $path = ''; | |
| 27 | - | |
| 28 | - $id = $cmisEntry['properties']['ObjectId']['value']; | |
| 16 | + // create entry | |
| 29 | 17 | $entry = $feed->newEntry(); |
| 30 | - $feed->newField('id', 'urn:uuid:' . $id, $entry); | |
| 31 | - | |
| 18 | + | |
| 32 | 19 | // TODO dynamic actual creator name |
| 33 | 20 | $feedElement = $feed->newField('author'); |
| 34 | 21 | $element = $feed->newField('name', 'admin', $feedElement); |
| 35 | 22 | $entry->appendChild($feedElement); |
| 36 | - | |
| 23 | + | |
| 24 | + // content & id tags | |
| 25 | + $id = $cmisEntry['properties']['ObjectId']['value']; | |
| 37 | 26 | $entry->appendChild($feed->newField('content', $id)); |
| 38 | - // TODO proper date | |
| 39 | - $entry->appendChild($feed->newField('published', self::formatDatestamp())); | |
| 40 | - $entry->appendChild($feed->newField('updated', self::formatDatestamp())); | |
| 41 | - | |
| 42 | -// $entry->appendChild($feed->newField('summary', $cmisEntry['properties']['Name']['value'])); | |
| 27 | + $feed->newField('id', 'urn:uuid:' . $id, $entry); | |
| 43 | 28 | |
| 44 | 29 | // links |
| 45 | 30 | /* |
| ... | ... | @@ -73,14 +58,6 @@ class KT_cmis_atom_service_helper { |
| 73 | 58 | $link->appendChild($feed->newAttr('rel','edit')); |
| 74 | 59 | $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); |
| 75 | 60 | $entry->appendChild($link); |
| 76 | - | |
| 77 | - // TODO check parent link is correct, fix if needed | |
| 78 | - // TODO leave out if at root folder | |
| 79 | - $link = $feed->newElement('link'); | |
| 80 | - $link->appendChild($feed->newAttr('rel', 'parents')); | |
| 81 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' | |
| 82 | - . $cmisEntry['properties']['ObjectId']['value'] . '/parent')); | |
| 83 | - $entry->appendChild($link); | |
| 84 | 61 | |
| 85 | 62 | // according to spec this MUST be present, but spec says that links for function which are not supported |
| 86 | 63 | // do not need to be present, so unsure for the moment |
| ... | ... | @@ -90,6 +67,22 @@ class KT_cmis_atom_service_helper { |
| 90 | 67 | . $cmisEntry['properties']['ObjectId']['value'] . '/permissions')); |
| 91 | 68 | $entry->appendChild($link); |
| 92 | 69 | |
| 70 | + // according to spec this MUST be present, but spec says that links for function which are not supported | |
| 71 | + // do not need to be present, so unsure for the moment | |
| 72 | + $link = $feed->newElement('link'); | |
| 73 | + $link->appendChild($feed->newAttr('rel', 'relationships')); | |
| 74 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' | |
| 75 | + . $cmisEntry['properties']['ObjectId']['value'] . '/rels')); | |
| 76 | + $entry->appendChild($link); | |
| 77 | + | |
| 78 | + // TODO check parent link is correct, fix if needed | |
| 79 | + // TODO leave out if at root folder | |
| 80 | + $link = $feed->newElement('link'); | |
| 81 | + $link->appendChild($feed->newAttr('rel', 'parents')); | |
| 82 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' | |
| 83 | + . $cmisEntry['properties']['ObjectId']['value'] . '/parent')); | |
| 84 | + $entry->appendChild($link); | |
| 85 | + | |
| 93 | 86 | // Folder/Document specific links |
| 94 | 87 | if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') |
| 95 | 88 | { |
| ... | ... | @@ -150,17 +143,7 @@ class KT_cmis_atom_service_helper { |
| 150 | 143 | // $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); |
| 151 | 144 | // $entry->appendChild($link); |
| 152 | 145 | // } |
| 153 | - } | |
| 154 | - | |
| 155 | - | |
| 156 | - // according to spec this MUST be present, but spec says that links for function which are not supported | |
| 157 | - // do not need to be present, so unsure for the moment | |
| 158 | - $link = $feed->newElement('link'); | |
| 159 | - $link->appendChild($feed->newAttr('rel', 'relationships')); | |
| 160 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' | |
| 161 | - . $cmisEntry['properties']['ObjectId']['value'] . '/rels')); | |
| 162 | - $entry->appendChild($link); | |
| 163 | - | |
| 146 | + } | |
| 164 | 147 | |
| 165 | 148 | $link = $feed->newElement('link'); |
| 166 | 149 | $link->appendChild($feed->newAttr('rel','type')); |
| ... | ... | @@ -180,8 +163,11 @@ class KT_cmis_atom_service_helper { |
| 180 | 163 | // $entry->appendChild($link); |
| 181 | 164 | // end links |
| 182 | 165 | |
| 166 | + // TODO proper date | |
| 167 | + $entry->appendChild($feed->newField('published', self::formatDatestamp())); | |
| 183 | 168 | $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value'])); |
| 184 | 169 | $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value'])); |
| 170 | + $entry->appendChild($feed->newField('updated', self::formatDatestamp())); | |
| 185 | 171 | |
| 186 | 172 | // main CMIS entry |
| 187 | 173 | $objectElement = $feed->newElement('cmis:object'); | ... | ... |
webservice/classes/atompub/cmis/KT_cmis_atom_responseFeed.inc.php
| ... | ... | @@ -21,9 +21,8 @@ class KT_cmis_atom_responseFeed extends KT_atom_responseFeed { |
| 21 | 21 | protected function constructHeader() |
| 22 | 22 | { |
| 23 | 23 | $feed = $this->newElement('feed'); |
| 24 | -// $feed->appendChild($this->newAttr('xmlns','http://www.w3.org/2007/app')); | |
| 25 | -// $feed->appendChild($this->newAttr('xmlns:atom','http://www.w3.org/2005/Atom')); | |
| 26 | 24 | $feed->appendChild($this->newAttr('xmlns','http://www.w3.org/2005/Atom')); |
| 25 | + $feed->appendChild($this->newAttr('xmlns:app','http://www.w3.org/2007/app')); | |
| 27 | 26 | $feed->appendChild($this->newAttr('xmlns:cmis','http://docs.oasis-open.org/ns/cmis/core/200901')); |
| 28 | 27 | $this->feed = &$feed; |
| 29 | 28 | ... | ... |