Commit 7e146afce535a3a88a4b757754dbd99aa0d9ba84

Authored by Paul Barrett
1 parent 89bff69a

intermediat commit for CMIS

lib/api/ktcmis/util/CMISUtil.inc.php
@@ -261,36 +261,45 @@ class CMISUtil { @@ -261,36 +261,45 @@ class CMISUtil {
261 // TODO additional properties to be returned 261 // TODO additional properties to be returned
262 $object['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'), 262 $object['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'),
263 'value' => $properties->getValue('BaseType')); 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 'value' => $properties->getValue('Name')); 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 'value' => CMISUtil::encodeObjectId('Folder', 269 'value' => CMISUtil::encodeObjectId('Folder',
278 $properties->getValue('ParentId'))); 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 $object['properties']['CreatedBy'] = array('type' => $properties->getFieldType('CreatedBy'), 279 $object['properties']['CreatedBy'] = array('type' => $properties->getFieldType('CreatedBy'),
287 'value' => $properties->getValue('CreatedBy')); 280 'value' => $properties->getValue('CreatedBy'));
  281 +
  282 + $object['properties']['AllowedChildObjectTypeIds'] = array('type' => $properties->getFieldType('AllowedChildObjectTypeIds'),
  283 + 'value' => $properties->getValue('AllowedChildObjectTypeIds'));
288 284
289 $object['properties']['CreationDate'] = array('type' => $properties->getFieldType('CreationDate'), 285 $object['properties']['CreationDate'] = array('type' => $properties->getFieldType('CreationDate'),
290 'value' => $properties->getValue('CreationDate')); 286 'value' => $properties->getValue('CreationDate'));
291 287
  288 + $object['properties']['LastModifiedBy'] = array('type' => $properties->getFieldType('LastModifiedBy'),
  289 + 'value' => $properties->getValue('LastModifiedBy'));
  290 +
292 $object['properties']['ChangeToken'] = array('type' => $properties->getFieldType('ChangeToken'), 291 $object['properties']['ChangeToken'] = array('type' => $properties->getFieldType('ChangeToken'),
293 'value' => $properties->getValue('ChangeToken')); 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 if (strtolower($properties->getValue('ObjectTypeId')) == 'document') 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,13 +268,16 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service {
268 } 268 }
269 269
270 // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL 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 // TODO dynamic? 274 // TODO dynamic?
275 $feedElement = $feed->newField('author'); 275 $feedElement = $feed->newField('author');
276 $element = $feed->newField('name', 'System', $feedElement); 276 $element = $feed->newField('name', 'System', $feedElement);
277 $feed->appendChild($feedElement); 277 $feed->appendChild($feedElement);
  278 +
  279 + // id
  280 + $feed->appendChild($feed->newElement('id', 'urn:uuid:' . $folderId . '-' . $feedType));
278 281
279 // TODO get actual most recent update time, only use current if no other available 282 // TODO get actual most recent update time, only use current if no other available
280 $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp())); 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,6 +290,9 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service {
287 foreach($entries as $cmisEntry) 290 foreach($entries as $cmisEntry)
288 { 291 {
289 KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); 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 // <cmis:hasMoreItems>false</cmis:hasMoreItems> 298 // <cmis:hasMoreItems>false</cmis:hasMoreItems>
@@ -494,8 +500,19 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { @@ -494,8 +500,19 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service {
494 $checkedout = $NavigationService->getCheckedoutDocs($repositoryId); 500 $checkedout = $NavigationService->getCheckedoutDocs($repositoryId);
495 501
496 //Create a new response feed 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 foreach($checkedout as $document) 516 foreach($checkedout as $document)
500 { 517 {
501 $entry = $feed->newEntry(); 518 $entry = $feed->newEntry();
@@ -515,7 +532,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { @@ -515,7 +532,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service {
515 } 532 }
516 533
517 $entry = null; 534 $entry = null;
518 - $feed->newField('hasMoreItems', 'false', $entry, true); 535 + $feed->newField('cmis:hasMoreItems', 'false', $entry, true);
519 536
520 //Expose the responseFeed 537 //Expose the responseFeed
521 $this->responseFeed = $feed; 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,33 +13,18 @@ class KT_cmis_atom_service_helper {
13 */ 13 */
14 static public function createObjectEntry(&$feed, $cmisEntry, $parent, $path) 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 $entry = $feed->newEntry(); 17 $entry = $feed->newEntry();
30 - $feed->newField('id', 'urn:uuid:' . $id, $entry);  
31 - 18 +
32 // TODO dynamic actual creator name 19 // TODO dynamic actual creator name
33 $feedElement = $feed->newField('author'); 20 $feedElement = $feed->newField('author');
34 $element = $feed->newField('name', 'admin', $feedElement); 21 $element = $feed->newField('name', 'admin', $feedElement);
35 $entry->appendChild($feedElement); 22 $entry->appendChild($feedElement);
36 - 23 +
  24 + // content & id tags
  25 + $id = $cmisEntry['properties']['ObjectId']['value'];
37 $entry->appendChild($feed->newField('content', $id)); 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 // links 29 // links
45 /* 30 /*
@@ -73,14 +58,6 @@ class KT_cmis_atom_service_helper { @@ -73,14 +58,6 @@ class KT_cmis_atom_service_helper {
73 $link->appendChild($feed->newAttr('rel','edit')); 58 $link->appendChild($feed->newAttr('rel','edit'));
74 $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); 59 $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value']));
75 $entry->appendChild($link); 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 // according to spec this MUST be present, but spec says that links for function which are not supported 62 // according to spec this MUST be present, but spec says that links for function which are not supported
86 // do not need to be present, so unsure for the moment 63 // do not need to be present, so unsure for the moment
@@ -90,6 +67,22 @@ class KT_cmis_atom_service_helper { @@ -90,6 +67,22 @@ class KT_cmis_atom_service_helper {
90 . $cmisEntry['properties']['ObjectId']['value'] . '/permissions')); 67 . $cmisEntry['properties']['ObjectId']['value'] . '/permissions'));
91 $entry->appendChild($link); 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 // Folder/Document specific links 86 // Folder/Document specific links
94 if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') 87 if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder')
95 { 88 {
@@ -150,17 +143,7 @@ class KT_cmis_atom_service_helper { @@ -150,17 +143,7 @@ class KT_cmis_atom_service_helper {
150 // $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); 143 // $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value']));
151 // $entry->appendChild($link); 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 $link = $feed->newElement('link'); 148 $link = $feed->newElement('link');
166 $link->appendChild($feed->newAttr('rel','type')); 149 $link->appendChild($feed->newAttr('rel','type'));
@@ -180,8 +163,11 @@ class KT_cmis_atom_service_helper { @@ -180,8 +163,11 @@ class KT_cmis_atom_service_helper {
180 // $entry->appendChild($link); 163 // $entry->appendChild($link);
181 // end links 164 // end links
182 165
  166 + // TODO proper date
  167 + $entry->appendChild($feed->newField('published', self::formatDatestamp()));
183 $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value'])); 168 $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value']));
184 $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value'])); 169 $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value']));
  170 + $entry->appendChild($feed->newField('updated', self::formatDatestamp()));
185 171
186 // main CMIS entry 172 // main CMIS entry
187 $objectElement = $feed->newElement('cmis:object'); 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,9 +21,8 @@ class KT_cmis_atom_responseFeed extends KT_atom_responseFeed {
21 protected function constructHeader() 21 protected function constructHeader()
22 { 22 {
23 $feed = $this->newElement('feed'); 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 $feed->appendChild($this->newAttr('xmlns','http://www.w3.org/2005/Atom')); 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 $feed->appendChild($this->newAttr('xmlns:cmis','http://docs.oasis-open.org/ns/cmis/core/200901')); 26 $feed->appendChild($this->newAttr('xmlns:cmis','http://docs.oasis-open.org/ns/cmis/core/200901'));
28 $this->feed = &$feed; 27 $this->feed = &$feed;
29 28