Commit 5c7d6464e6eb0acd224e03dfbec4c4bf6952bf45
1 parent
c5c0f6f2
Implemented return for CMIS folder parent request
Story ID:1434265. CMIS patch contributions Committed by: Paul Barrett
Showing
3 changed files
with
36 additions
and
11 deletions
lib/api/ktcmis/objecttypes/CMISFolderObject.inc.php
| @@ -72,19 +72,22 @@ class CMISFolderObject extends CMISObject { | @@ -72,19 +72,22 @@ class CMISFolderObject extends CMISObject { | ||
| 72 | 72 | ||
| 73 | if (!is_null($folderId)) | 73 | if (!is_null($folderId)) |
| 74 | { | 74 | { |
| 75 | - $this->get($folderId); | 75 | + try { |
| 76 | + $this->get($folderId); | ||
| 77 | + } | ||
| 78 | + catch (exception $e) { | ||
| 79 | + throw new ObjectNotFoundException($e->getMessage()); | ||
| 80 | + } | ||
| 76 | } | 81 | } |
| 77 | } | 82 | } |
| 78 | 83 | ||
| 79 | private function get($folderId) | 84 | private function get($folderId) |
| 80 | { | 85 | { |
| 81 | $object = $this->ktapi->get_folder_by_id((int)$folderId); | 86 | $object = $this->ktapi->get_folder_by_id((int)$folderId); |
| 82 | - | ||
| 83 | - // error? | ||
| 84 | - if (PEAR::isError($object)) | ||
| 85 | - { | ||
| 86 | - // throw an exception? | ||
| 87 | - return $object; | 87 | + |
| 88 | + // folder does not exist? | ||
| 89 | + if (PEAR::isError($object)) { | ||
| 90 | + throw new ObjectNotFoundException('The folder you are trying to access does not exist or is inaccessible'); | ||
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | // static $allowedChildObjectTypeIds; | 93 | // static $allowedChildObjectTypeIds; |
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| @@ -60,9 +60,10 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -60,9 +60,10 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 60 | $repositoryId = $repositories[0]['repositoryId']; | 60 | $repositoryId = $repositories[0]['repositoryId']; |
| 61 | 61 | ||
| 62 | // TODO implement full path/node separation as with Alfresco - i.e. path requests come in on path/ and node requests come in on node/ | 62 | // TODO implement full path/node separation as with Alfresco - i.e. path requests come in on path/ and node requests come in on node/ |
| 63 | - // path request e.g.: Root Folder/DroppedDocuments | ||
| 64 | - // node request e.g.: F1/children | ||
| 65 | - // node request e.g.: F2 | 63 | + // path request e.g.: path/Root Folder/DroppedDocuments |
| 64 | + // node request e.g.: node/F1/children | ||
| 65 | + // node request e.g.: node/F2/parent | ||
| 66 | + // node request e.g.: node/F2 | ||
| 66 | if (urldecode($this->params[0]) == 'Root Folder') | 67 | if (urldecode($this->params[0]) == 'Root Folder') |
| 67 | { | 68 | { |
| 68 | $folderId = CMISUtil::encodeObjectId('Folder', 1); | 69 | $folderId = CMISUtil::encodeObjectId('Folder', 1); |
| @@ -87,6 +88,26 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -87,6 +88,26 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 87 | 88 | ||
| 88 | $folderName = $response['properties']['Name']['value']; | 89 | $folderName = $response['properties']['Name']['value']; |
| 89 | } | 90 | } |
| 91 | + // NOTE parent changes to parents in later specification | ||
| 92 | + // TODO update when updating to later specification | ||
| 93 | + else if ($this->params[1] == 'parent') | ||
| 94 | + { | ||
| 95 | + // abstract this to be used also by the document service (and the PWC service?) ??? | ||
| 96 | + // alternatively use getFolderParent here makes sense and use getObjectParents when document service? | ||
| 97 | + $folderId = $this->params[0]; | ||
| 98 | + $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); | ||
| 99 | + $response = $NavigationService->getFolderParent($repositoryId, $folderId, false, false, false); | ||
| 100 | + | ||
| 101 | + if (PEAR::isError($response)) { | ||
| 102 | + $feed = KT_cmis_atom_service_helper::getErrorFeed($this, KT_cmis_atom_service::STATUS_SERVER_ERROR, $response->getMessage()); | ||
| 103 | + $this->responseFeed = $feed; | ||
| 104 | + return null; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + // we know that a folder will only have one parent, so we can assume element 0 | ||
| 108 | + $folderId = $response[0]['properties']['ObjectId']['value']; | ||
| 109 | + $folderName = $response[0]['properties']['Name']['value']; | ||
| 110 | + } | ||
| 90 | else { | 111 | else { |
| 91 | $folderId = $this->params[0]; | 112 | $folderId = $this->params[0]; |
| 92 | } | 113 | } |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| @@ -97,7 +97,8 @@ class KT_cmis_atom_service_helper { | @@ -97,7 +97,8 @@ class KT_cmis_atom_service_helper { | ||
| 97 | // links | 97 | // links |
| 98 | $link = $response->newElement('link'); | 98 | $link = $response->newElement('link'); |
| 99 | $link->appendChild($response->newAttr('rel', 'self')); | 99 | $link->appendChild($response->newAttr('rel', 'self')); |
| 100 | - $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . (!$pwc ? $type : 'pwc') . '/' . $cmisEntry['properties']['ObjectId']['value'])); | 100 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . (!$pwc ? $type : 'pwc') . '/' |
| 101 | + . $cmisEntry['properties']['ObjectId']['value'])); | ||
| 101 | $entry->appendChild($link); | 102 | $entry->appendChild($link); |
| 102 | 103 | ||
| 103 | $link = $response->newElement('link'); | 104 | $link = $response->newElement('link'); |