Commit a0f1d97fe1fa9d896363ae950d2b24dce78632bd
1 parent
a620abd9
Story ID: 778712. Updated AtomPub response for POST. Removed unneeded inherited …
…class. Removed no longer needed over-ridden functionality. Committed by: Paul Barrett
Showing
7 changed files
with
226 additions
and
405 deletions
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| @@ -43,22 +43,11 @@ include_once 'KT_cmis_atom_service_helper.inc.php'; | @@ -43,22 +43,11 @@ include_once 'KT_cmis_atom_service_helper.inc.php'; | ||
| 43 | * Returns children, descendants (up to arbitrary depth) or detail for a particular folder | 43 | * Returns children, descendants (up to arbitrary depth) or detail for a particular folder |
| 44 | * | 44 | * |
| 45 | */ | 45 | */ |
| 46 | -class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | 46 | +class KT_cmis_atom_service_folder extends KT_atom_service { |
| 47 | 47 | ||
| 48 | public function GET_action() | 48 | public function GET_action() |
| 49 | { | 49 | { |
| 50 | $RepositoryService = new RepositoryService(); | 50 | $RepositoryService = new RepositoryService(); |
| 51 | -// try { | ||
| 52 | -// $RepositoryService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 53 | -// } | ||
| 54 | -// catch (Exception $e) | ||
| 55 | -// { | ||
| 56 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 57 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 58 | -// $this->responseFeed = $feed; | ||
| 59 | -// return null; | ||
| 60 | -// } | ||
| 61 | - | ||
| 62 | $repositories = $RepositoryService->getRepositories(); | 51 | $repositories = $RepositoryService->getRepositories(); |
| 63 | $repositoryId = $repositories[0]['repositoryId']; | 52 | $repositoryId = $repositories[0]['repositoryId']; |
| 64 | 53 | ||
| @@ -80,56 +69,19 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -80,56 +69,19 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 80 | { | 69 | { |
| 81 | $folderId = $this->params[0]; | 70 | $folderId = $this->params[0]; |
| 82 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); | 71 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); |
| 83 | - | ||
| 84 | -// try { | ||
| 85 | -// $ObjectService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 86 | -// } | ||
| 87 | -// catch (Exception $e) | ||
| 88 | -// { | ||
| 89 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 90 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 91 | -// $this->responseFeed = $feed; | ||
| 92 | -// return null; | ||
| 93 | -// } | ||
| 94 | - | ||
| 95 | $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false); | 72 | $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false); |
| 96 | $folderName = $cmisEntry['properties']['Name']['value']; | 73 | $folderName = $cmisEntry['properties']['Name']['value']; |
| 97 | - // $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $newObjectId, $cmisEntry['properties']['Name']['value']); | ||
| 98 | } | 74 | } |
| 99 | 75 | ||
| 100 | if (!empty($this->params[1]) && (($this->params[1] == 'children') || ($this->params[1] == 'descendants'))) | 76 | if (!empty($this->params[1]) && (($this->params[1] == 'children') || ($this->params[1] == 'descendants'))) |
| 101 | { | 77 | { |
| 102 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); | 78 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); |
| 103 | - | ||
| 104 | -// try { | ||
| 105 | -// $NavigationService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 106 | -// } | ||
| 107 | -// catch (Exception $e) | ||
| 108 | -// { | ||
| 109 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 110 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 111 | -// $this->responseFeed = $feed; | ||
| 112 | -// return null; | ||
| 113 | -// } | ||
| 114 | - | ||
| 115 | $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $folderName, $this->params[1]); | 79 | $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $folderName, $this->params[1]); |
| 116 | } | 80 | } |
| 117 | else | 81 | else |
| 118 | { | 82 | { |
| 119 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); | 83 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); |
| 120 | - | ||
| 121 | -// try { | ||
| 122 | -// $ObjectService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 123 | -// } | ||
| 124 | -// catch (Exception $e) | ||
| 125 | -// { | ||
| 126 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 127 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 128 | -// $this->responseFeed = $feed; | ||
| 129 | -// return null; | ||
| 130 | -// } | ||
| 131 | - | ||
| 132 | - $feed = $this->getFolderFeed($ObjectService, $repositoryId, $folderId); | 84 | + $feed = KT_cmis_atom_service_helper::getObjectFeed($ObjectService, $repositoryId, $folderId); |
| 133 | } | 85 | } |
| 134 | 86 | ||
| 135 | //Expose the responseFeed | 87 | //Expose the responseFeed |
| @@ -139,18 +91,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -139,18 +91,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 139 | public function POST_action() | 91 | public function POST_action() |
| 140 | { | 92 | { |
| 141 | $RepositoryService = new RepositoryService(); | 93 | $RepositoryService = new RepositoryService(); |
| 142 | - | ||
| 143 | -// try { | ||
| 144 | -// $RepositoryService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 145 | -// } | ||
| 146 | -// catch (Exception $e) | ||
| 147 | -// { | ||
| 148 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 149 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 150 | -// $this->responseFeed = $feed; | ||
| 151 | -// return null; | ||
| 152 | -// } | ||
| 153 | - | ||
| 154 | $repositories = $RepositoryService->getRepositories(); | 94 | $repositories = $RepositoryService->getRepositories(); |
| 155 | $repositoryId = $repositories[0]['repositoryId']; | 95 | $repositoryId = $repositories[0]['repositoryId']; |
| 156 | 96 | ||
| @@ -168,70 +108,32 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -168,70 +108,32 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 168 | else | 108 | else |
| 169 | $type = 'document'; | 109 | $type = 'document'; |
| 170 | 110 | ||
| 171 | - // TODO what if mime-type is incorrect? CMISSpaces appears to be sending text/plain on an executable file. | ||
| 172 | - // perhaps because the content is text/plain once base64 encoded? | ||
| 173 | - // How to determine the actual content type? | ||
| 174 | - /* | ||
| 175 | - * <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901"> | ||
| 176 | - * <atom:title>setup.txt</atom:title> | ||
| 177 | - * <atom:summary>setup.txt</atom:summary> | ||
| 178 | - * <atom:content type="text/plain">dGhpcyBiZSBzb21lIHRlc3QgY29udGVudCBmb3IgYSBkb2N1bWVudCwgeWVzPw==</atom:content> | ||
| 179 | - * <cmis:object> | ||
| 180 | - * <cmis:properties> | ||
| 181 | - * <cmis:propertyString cmis:name="ObjectTypeId"><cmis:value>document</cmis:value></cmis:propertyString> | ||
| 182 | - * </cmis:properties> | ||
| 183 | - * </cmis:object> | ||
| 184 | - * </atom:entry> | ||
| 185 | - */ | ||
| 186 | - | ||
| 187 | $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object'] | 111 | $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object'] |
| 188 | [0]['@children']['cmis:properties'] | 112 | [0]['@children']['cmis:properties'] |
| 189 | [0]['@children']); | 113 | [0]['@children']); |
| 190 | 114 | ||
| 191 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); | 115 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); |
| 192 | 116 | ||
| 193 | -// try { | ||
| 194 | -// $ObjectService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 195 | -// } | ||
| 196 | -// catch (Exception $e) | ||
| 197 | -// { | ||
| 198 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 199 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 200 | -// $this->responseFeed = $feed; | ||
| 201 | -// return null; | ||
| 202 | -// } | ||
| 203 | - | ||
| 204 | if ($type == 'folder') | 117 | if ($type == 'folder') |
| 205 | $newObjectId = $ObjectService->createFolder($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId); | 118 | $newObjectId = $ObjectService->createFolder($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId); |
| 206 | else | 119 | else |
| 207 | $newObjectId = $ObjectService->createDocument($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId, $content); | 120 | $newObjectId = $ObjectService->createDocument($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId, $content); |
| 208 | 121 | ||
| 209 | // check if returned Object Id is a valid CMIS Object Id | 122 | // check if returned Object Id is a valid CMIS Object Id |
| 210 | - $dummy = CMISUtil::decodeObjectId($newObjectId, $typeId); | 123 | + CMISUtil::decodeObjectId($newObjectId, $typeId); |
| 124 | + | ||
| 211 | if ($typeId != 'Unknown') | 125 | if ($typeId != 'Unknown') |
| 212 | { | 126 | { |
| 213 | $this->setStatus(self::STATUS_CREATED); | 127 | $this->setStatus(self::STATUS_CREATED); |
| 214 | if ($type == 'folder') | 128 | if ($type == 'folder') |
| 215 | { | 129 | { |
| 216 | - $feed = $this->getFolderFeed($ObjectService, $repositoryId, $newObjectId); | 130 | + $feed = KT_cmis_atom_service_helper::getObjectFeed($ObjectService, $repositoryId, $newObjectId, 'POST'); |
| 217 | } | 131 | } |
| 218 | else | 132 | else |
| 219 | { | 133 | { |
| 220 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); | 134 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); |
| 221 | - | ||
| 222 | -// try { | ||
| 223 | -// $NavigationService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 224 | -// } | ||
| 225 | -// catch (Exception $e) | ||
| 226 | -// { | ||
| 227 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 228 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 229 | -// $this->responseFeed = $feed; | ||
| 230 | -// return null; | ||
| 231 | -// } | ||
| 232 | - | ||
| 233 | $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false); | 135 | $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false); |
| 234 | - $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $cmisEntry['properties']['Name']['value']); | 136 | + $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $cmisEntry['properties']['Name']['value'], 'POST'); |
| 235 | } | 137 | } |
| 236 | } | 138 | } |
| 237 | else | 139 | else |
| @@ -268,23 +170,30 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -268,23 +170,30 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 268 | } | 170 | } |
| 269 | 171 | ||
| 270 | // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL | 172 | // $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, null); | ||
| 272 | -// 'urn:uuid:' . $folderId . '-' . $feedType); | ||
| 273 | - | 173 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 174 | + $workspace = $feed->getWorkspace(); | ||
| 175 | + | ||
| 176 | + $feed->newField('title', $folderName . ' ' . ucwords($feedType), $feed); | ||
| 177 | + | ||
| 274 | // TODO dynamic? | 178 | // TODO dynamic? |
| 275 | $feedElement = $feed->newField('author'); | 179 | $feedElement = $feed->newField('author'); |
| 276 | $element = $feed->newField('name', 'System', $feedElement); | 180 | $element = $feed->newField('name', 'System', $feedElement); |
| 277 | $feed->appendChild($feedElement); | 181 | $feed->appendChild($feedElement); |
| 278 | 182 | ||
| 279 | // id | 183 | // id |
| 280 | - $feed->appendChild($feed->newElement('id', 'urn:uuid:' . $folderId . '-' . $feedType)); | 184 | + $feed->newField('id', 'urn:uuid:' . $folderId . '-' . $feedType, $feed); |
| 281 | 185 | ||
| 282 | // TODO get actual most recent update time, only use current if no other available | 186 | // TODO get actual most recent update time, only use current if no other available |
| 283 | - $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp())); | ||
| 284 | - | 187 | + $feed->newField('updated', KT_cmis_atom_service_helper::formatDatestamp(), $feed); |
| 188 | + | ||
| 285 | $link = $feed->newElement('link'); | 189 | $link = $feed->newElement('link'); |
| 286 | - $link->appendChild($feed->newAttr('rel','source')); | ||
| 287 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $folderId)); | 190 | + $link->appendChild($feed->newAttr('rel', 'self')); |
| 191 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/folder/' . $folderId . '/' . $feedType)); | ||
| 192 | + $feed->appendChild($link); | ||
| 193 | + | ||
| 194 | + $link = $feed->newElement('link'); | ||
| 195 | + $link->appendChild($feed->newAttr('rel', 'source')); | ||
| 196 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/folder/' . $folderId)); | ||
| 288 | $feed->appendChild($link); | 197 | $feed->appendChild($link); |
| 289 | 198 | ||
| 290 | foreach($entries as $cmisEntry) | 199 | foreach($entries as $cmisEntry) |
| @@ -292,7 +201,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -292,7 +201,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 292 | KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); | 201 | KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); |
| 293 | 202 | ||
| 294 | // after each entry, add app:edited tag | 203 | // after each entry, add app:edited tag |
| 295 | - $feed->appendChild($feed->newElement('app:edited', KT_cmis_atom_service_helper::formatDatestamp())); | 204 | + $feed->newField('app:edited', KT_cmis_atom_service_helper::formatDatestamp(), $feed); |
| 296 | } | 205 | } |
| 297 | 206 | ||
| 298 | // <cmis:hasMoreItems>false</cmis:hasMoreItems> | 207 | // <cmis:hasMoreItems>false</cmis:hasMoreItems> |
| @@ -304,29 +213,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -304,29 +213,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 304 | return $feed; | 213 | return $feed; |
| 305 | } | 214 | } |
| 306 | 215 | ||
| 307 | - /** | ||
| 308 | - * Retrieves data about a specific folder | ||
| 309 | - * | ||
| 310 | - * @param object $ObjectService The CMIS service | ||
| 311 | - * @param string $repositoryId | ||
| 312 | - * @param string $folderId | ||
| 313 | - * @return string CMIS AtomPub feed | ||
| 314 | - */ | ||
| 315 | - private function getFolderFeed($ObjectService, $repositoryId, $folderId) | ||
| 316 | - { | ||
| 317 | - $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false); | ||
| 318 | - | ||
| 319 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, $cmisEntry['properties']['ObjectTypeId']['value'], null, null, null, | ||
| 320 | - 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value']); | ||
| 321 | - | ||
| 322 | - KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName); | ||
| 323 | - // // <cmis:hasMoreItems>false</cmis:hasMoreItems> | ||
| 324 | - // // global $folderFeed; | ||
| 325 | - // // $outputs = | ||
| 326 | - | ||
| 327 | - return $feed; | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | } | 216 | } |
| 331 | 217 | ||
| 332 | /** | 218 | /** |
| @@ -335,24 +221,11 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | @@ -335,24 +221,11 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { | ||
| 335 | * Returns a list of supported object types | 221 | * Returns a list of supported object types |
| 336 | * | 222 | * |
| 337 | */ | 223 | */ |
| 338 | -class KT_cmis_atom_service_types extends KT_cmis_atom_service { | 224 | +class KT_cmis_atom_service_types extends KT_atom_service { |
| 339 | 225 | ||
| 340 | public function GET_action() | 226 | public function GET_action() |
| 341 | { | 227 | { |
| 342 | $RepositoryService = new RepositoryService(); | 228 | $RepositoryService = new RepositoryService(); |
| 343 | - | ||
| 344 | -// try { | ||
| 345 | -// $RepositoryService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 346 | -// } | ||
| 347 | -// catch (Exception $e) | ||
| 348 | -// { | ||
| 349 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 350 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 351 | -// $this->responseFeed = $feed; | ||
| 352 | -// return null; | ||
| 353 | -// } | ||
| 354 | - | ||
| 355 | - // fetch repository id | ||
| 356 | $repositories = $RepositoryService->getRepositories(); | 229 | $repositories = $RepositoryService->getRepositories(); |
| 357 | $repositoryId = $repositories[0]['repositoryId']; | 230 | $repositoryId = $repositories[0]['repositoryId']; |
| 358 | 231 | ||
| @@ -372,23 +245,12 @@ class KT_cmis_atom_service_types extends KT_cmis_atom_service { | @@ -372,23 +245,12 @@ class KT_cmis_atom_service_types extends KT_cmis_atom_service { | ||
| 372 | * Returns the type defintion for the selected type | 245 | * Returns the type defintion for the selected type |
| 373 | * | 246 | * |
| 374 | */ | 247 | */ |
| 375 | -class KT_cmis_atom_service_type extends KT_cmis_atom_service { | 248 | +class KT_cmis_atom_service_type extends KT_atom_service { |
| 376 | 249 | ||
| 377 | public function GET_action() | 250 | public function GET_action() |
| 378 | { | 251 | { |
| 379 | $RepositoryService = new RepositoryService(); | 252 | $RepositoryService = new RepositoryService(); |
| 380 | 253 | ||
| 381 | -// try { | ||
| 382 | -// $RepositoryService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 383 | -// } | ||
| 384 | -// catch (Exception $e) | ||
| 385 | -// { | ||
| 386 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 387 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 388 | -// $this->responseFeed = $feed; | ||
| 389 | -// return null; | ||
| 390 | -// } | ||
| 391 | - | ||
| 392 | // fetch repository id | 254 | // fetch repository id |
| 393 | $repositories = $RepositoryService->getRepositories(); | 255 | $repositories = $RepositoryService->getRepositories(); |
| 394 | $repositoryId = $repositories[0]['repositoryId']; | 256 | $repositoryId = $repositories[0]['repositoryId']; |
| @@ -425,14 +287,14 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | @@ -425,14 +287,14 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | ||
| 425 | */ | 287 | */ |
| 426 | private function getTypeChildrenFeed() | 288 | private function getTypeChildrenFeed() |
| 427 | { | 289 | { |
| 428 | - //Create a new response feed | ||
| 429 | - // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL | ||
| 430 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Child Types of ' . ucwords($this->params[0]), null, null, null, | ||
| 431 | - $this->params[0] . '-children'); | 290 | + //Create a new response feed |
| 291 | + // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL | ||
| 292 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | ||
| 432 | 293 | ||
| 433 | - // TODO actually fetch child types - to be implemented when we support child types in the API | 294 | + $feed->newField('title', 'Child Types of ' . ucwords($this->params[0]), $feed); |
| 295 | + $feed->newField('id', $this->params[0] . '-children', $feed); | ||
| 434 | 296 | ||
| 435 | - // id | 297 | + // TODO fetch child types - to be implemented when we support child types in the API |
| 436 | 298 | ||
| 437 | // links | 299 | // links |
| 438 | $link = $feed->newElement('link'); | 300 | $link = $feed->newElement('link'); |
| @@ -446,24 +308,9 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | @@ -446,24 +308,9 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | ||
| 446 | $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . 'type/' . $this->params[0] . '/' . $this->params[1] . '?pageNo=1&pageSize=0')); | 308 | $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . 'type/' . $this->params[0] . '/' . $this->params[1] . '?pageNo=1&pageSize=0')); |
| 447 | $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed')); | 309 | $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed')); |
| 448 | 310 | ||
| 449 | - // TODO actual dynamic listing, currently we have no objects with which to test | ||
| 450 | - | ||
| 451 | - // TODO | ||
| 452 | - // <updated>2009-06-23T13:40:32.786+02:00</updated> | ||
| 453 | - // <cmis:hasMoreItems>false</cmis:hasMoreItems> | ||
| 454 | -/* | ||
| 455 | - // TODO need to create this dynamically now, will no longer work with static output | ||
| 456 | - $output = '<?xml version="1.0" encoding="UTF-8"?> | ||
| 457 | - <feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901"> | ||
| 458 | - <id>urn:uuid:type-' . $type . '-children</id> | ||
| 459 | - <link rel="self" href="' . CMIS_APP_BASE_URI . 'type/document/children"/> | ||
| 460 | - <link rel="first" href="' . CMIS_APP_BASE_URI . 'type/document/children?pageNo=1&pageSize=0&guest=" type="application/atom+xml;type=feed"/> | ||
| 461 | - <link rel="last" href="' . CMIS_APP_BASE_URI . 'type/document/children?pageNo=1&pageSize=0&guest=" type="application/atom+xml;type=feed"/> | ||
| 462 | - <title>Child types of ' . $type . '</title> | ||
| 463 | - <updated>2009-06-23T13:40:32.786+02:00</updated> | ||
| 464 | - <cmis:hasMoreItems>false</cmis:hasMoreItems> | ||
| 465 | - </feed>'; | ||
| 466 | -*/ | 311 | + $feed->newField('updated', KT_cmis_atom_service_helper::formatDatestamp(), $feed); |
| 312 | + $feed->newField('cmis:hasMoreItems', 'false', $feed); | ||
| 313 | + | ||
| 467 | return $feed; | 314 | return $feed; |
| 468 | } | 315 | } |
| 469 | 316 | ||
| @@ -476,31 +323,22 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | @@ -476,31 +323,22 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service { | ||
| 476 | * | 323 | * |
| 477 | */ | 324 | */ |
| 478 | // NOTE this is always an empty document, underlying API code still to be implemented | 325 | // NOTE this is always an empty document, underlying API code still to be implemented |
| 479 | -class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | 326 | +class KT_cmis_atom_service_checkedout extends KT_atom_service { |
| 480 | 327 | ||
| 481 | public function GET_action() | 328 | public function GET_action() |
| 482 | { | 329 | { |
| 483 | $RepositoryService = new RepositoryService(); | 330 | $RepositoryService = new RepositoryService(); |
| 484 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); | 331 | $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt()); |
| 485 | 332 | ||
| 486 | -// try { | ||
| 487 | -// $NavigationService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 488 | -// } | ||
| 489 | -// catch (Exception $e) | ||
| 490 | -// { | ||
| 491 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 492 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 493 | -// $this->responseFeed = $feed; | ||
| 494 | -// return null; | ||
| 495 | -// } | ||
| 496 | - | ||
| 497 | $repositories = $RepositoryService->getRepositories(); | 333 | $repositories = $RepositoryService->getRepositories(); |
| 498 | $repositoryId = $repositories[0]['repositoryId']; | 334 | $repositoryId = $repositories[0]['repositoryId']; |
| 499 | 335 | ||
| 500 | $checkedout = $NavigationService->getCheckedoutDocs($repositoryId); | 336 | $checkedout = $NavigationService->getCheckedoutDocs($repositoryId); |
| 501 | 337 | ||
| 502 | //Create a new response feed | 338 | //Create a new response feed |
| 503 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Checked out Documents'); | 339 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 340 | + | ||
| 341 | + $feed->newField('title', 'Checked out Documents', $feed); | ||
| 504 | 342 | ||
| 505 | // TODO dynamic? | 343 | // TODO dynamic? |
| 506 | $feedElement = $feed->newField('author'); | 344 | $feedElement = $feed->newField('author'); |
| @@ -546,40 +384,28 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | @@ -546,40 +384,28 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 546 | * Returns detail on a particular document | 384 | * Returns detail on a particular document |
| 547 | * | 385 | * |
| 548 | */ | 386 | */ |
| 549 | -class KT_cmis_atom_service_document extends KT_cmis_atom_service { | 387 | +class KT_cmis_atom_service_document extends KT_atom_service { |
| 550 | 388 | ||
| 551 | public function GET_action() | 389 | public function GET_action() |
| 552 | { | 390 | { |
| 553 | $RepositoryService = new RepositoryService(); | 391 | $RepositoryService = new RepositoryService(); |
| 554 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); | 392 | $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); |
| 555 | 393 | ||
| 556 | -// try { | ||
| 557 | -// $ObjectService->startSession(self::$authData['username'], self::$authData['password']); | ||
| 558 | -// } | ||
| 559 | -// catch (Exception $e) | ||
| 560 | -// { | ||
| 561 | -// $this->headers[] = 'WWW-Authenticate: Basic realm="KnowledgeTree Secure Area"'; | ||
| 562 | -// $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_NOT_AUTHENTICATED, $e->getMessage()); | ||
| 563 | -// $this->responseFeed = $feed; | ||
| 564 | -// return null; | ||
| 565 | -// } | ||
| 566 | - | ||
| 567 | $repositories = $RepositoryService->getRepositories(); | 394 | $repositories = $RepositoryService->getRepositories(); |
| 568 | $repositoryId = $repositories[0]['repositoryId']; | 395 | $repositoryId = $repositories[0]['repositoryId']; |
| 569 | 396 | ||
| 570 | $cmisEntry = $ObjectService->getProperties($repositoryId, $this->params[0], false, false); | 397 | $cmisEntry = $ObjectService->getProperties($repositoryId, $this->params[0], false, false); |
| 571 | 398 | ||
| 572 | //Create a new response feed | 399 | //Create a new response feed |
| 573 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, $cmisEntry['properties']['ObjectTypeId']['value'], null, null, null, | ||
| 574 | - 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value']); | 400 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 401 | + | ||
| 402 | + $feed->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $feed); | ||
| 403 | + $feed->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $feed); ; | ||
| 575 | 404 | ||
| 576 | KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $cmisEntry['properties']['ParentId']['value']); | 405 | KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $cmisEntry['properties']['ParentId']['value']); |
| 577 | 406 | ||
| 578 | // <cmis:hasMoreItems>false</cmis:hasMoreItems> | 407 | // <cmis:hasMoreItems>false</cmis:hasMoreItems> |
| 579 | 408 | ||
| 580 | - // global $docFeed; | ||
| 581 | - // $output = $docFeed; | ||
| 582 | - | ||
| 583 | //Expose the responseFeed | 409 | //Expose the responseFeed |
| 584 | $this->responseFeed=$feed; | 410 | $this->responseFeed=$feed; |
| 585 | } | 411 | } |
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
| @@ -5,104 +5,117 @@ class KT_cmis_atom_service_helper { | @@ -5,104 +5,117 @@ class KT_cmis_atom_service_helper { | ||
| 5 | protected static $kt = null; | 5 | protected static $kt = null; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | + * Retrieves data about a specific folder OR document within a folder | ||
| 9 | + * | ||
| 10 | + * @param object $ObjectService The CMIS service | ||
| 11 | + * @param string $repositoryId | ||
| 12 | + * @param string $folderId | ||
| 13 | + * @return string CMIS AtomPub feed | ||
| 14 | + */ | ||
| 15 | + static public function getObjectFeed($ObjectService, $repositoryId, $objectId, $method = 'GET') | ||
| 16 | + { | ||
| 17 | + $cmisEntry = $ObjectService->getProperties($repositoryId, $objectId, false, false); | ||
| 18 | + | ||
| 19 | + if ($method == 'GET') { | ||
| 20 | + $response = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | ||
| 21 | + $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); | ||
| 22 | + $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); | ||
| 23 | + } | ||
| 24 | + else if ($method == 'POST') { | ||
| 25 | + $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $folderName); | ||
| 29 | + | ||
| 30 | + if ($method == 'GET') { | ||
| 31 | + $response->newField('cmis:hasMoreItems', 'false', $response); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + return $response; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 8 | * Creates an AtomPub entry for a CMIS entry and adds it to the supplied feed | 38 | * Creates an AtomPub entry for a CMIS entry and adds it to the supplied feed |
| 9 | * | 39 | * |
| 10 | * @param object $feed The feed to which we add the entry | 40 | * @param object $feed The feed to which we add the entry |
| 11 | * @param array $cmisEntry The entry data | 41 | * @param array $cmisEntry The entry data |
| 12 | * @param string $parent The parent folder | 42 | * @param string $parent The parent folder |
| 13 | */ | 43 | */ |
| 14 | - static public function createObjectEntry(&$feed, $cmisEntry, $parent, $path) | 44 | + static public function createObjectEntry(&$response, $cmisEntry, $parent, $method = 'POST') |
| 15 | { | 45 | { |
| 46 | + $workspace = $response->getWorkspace(); | ||
| 47 | + | ||
| 16 | // create entry | 48 | // create entry |
| 17 | - $entry = $feed->newEntry(); | 49 | + $entry = $response->newEntry(); |
| 50 | + | ||
| 51 | + if ($method == 'POST') | ||
| 52 | + { | ||
| 53 | + // append attributes | ||
| 54 | + $entry->appendChild($response->newAttr('xmlns', 'http://www.w3.org/2005/Atom')); | ||
| 55 | + $entry->appendChild($response->newAttr('xmlns:app', 'http://www.w3.org/2007/app')); | ||
| 56 | + $entry->appendChild($response->newAttr('xmlns:cmis', 'http://docs.oasis-open.org/ns/cmis/core/200901')); | ||
| 57 | + } | ||
| 18 | 58 | ||
| 19 | // TODO dynamic actual creator name | 59 | // TODO dynamic actual creator name |
| 20 | - $feedElement = $feed->newField('author'); | ||
| 21 | - $element = $feed->newField('name', 'admin', $feedElement); | ||
| 22 | - $entry->appendChild($feedElement); | 60 | + $responseElement = $response->newField('author'); |
| 61 | + $element = $response->newField('name', 'admin', $responseElement); | ||
| 62 | + $entry->appendChild($responseElement); | ||
| 23 | 63 | ||
| 24 | // content & id tags | 64 | // content & id tags |
| 25 | $id = $cmisEntry['properties']['ObjectId']['value']; | 65 | $id = $cmisEntry['properties']['ObjectId']['value']; |
| 26 | - $entry->appendChild($feed->newField('content', $id)); | ||
| 27 | - $feed->newField('id', 'urn:uuid:' . $id, $entry); | ||
| 28 | - | ||
| 29 | - // links | ||
| 30 | - /* | ||
| 31 | -<link rel="allowableactions" href="http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/66f02c27-379e-4782-a0c4-b12f2d5bc543/permissions"/> | ||
| 32 | -<link rel="relationships" href="http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/66f02c27-379e-4782-a0c4-b12f2d5bc543/rels"/> | ||
| 33 | -<link rel="parents" href="http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/66f02c27-379e-4782-a0c4-b12f2d5bc543/parent"/> | ||
| 34 | - | ||
| 35 | - */ | ||
| 36 | - // | ||
| 37 | - | ||
| 38 | - /* | ||
| 39 | -<cmis:propertyUri cmis:name="Uri"/> | ||
| 40 | -<cmis:propertyId cmis:name="AllowedChildObjectTypeIds"/> | ||
| 41 | -<cmis:propertyString cmis:name="CreatedBy"><cmis:value>System</cmis:value></cmis:propertyString> | ||
| 42 | -<cmis:propertyDateTime cmis:name="CreationDate"><cmis:value>2009-07-13T13:59:20.724+02:00</cmis:value></cmis:propertyDateTime> | ||
| 43 | -<cmis:propertyString cmis:name="ChangeToken"/> | ||
| 44 | -<cmis:propertyString cmis:name="LastModifiedBy"><cmis:value>System</cmis:value></cmis:propertyString> | ||
| 45 | -<cmis:propertyId cmis:name="ObjectTypeId"><cmis:value>folder</cmis:value></cmis:propertyId> | ||
| 46 | - | ||
| 47 | -<cmis:propertyId cmis:name="ObjectId"><cmis:value>workspace://SpacesStore/b30ea6e5-1e3f-4133-82f4-172bc240a9a2</cmis:value></cmis:propertyId> | ||
| 48 | - */ | 66 | + $entry->appendChild($response->newField('content', $id)); |
| 67 | + $response->newField('id', 'urn:uuid:' . $id, $entry); | ||
| 49 | 68 | ||
| 50 | $type = strtolower($cmisEntry['properties']['ObjectTypeId']['value']); | 69 | $type = strtolower($cmisEntry['properties']['ObjectTypeId']['value']); |
| 51 | 70 | ||
| 52 | - $link = $feed->newElement('link'); | ||
| 53 | - $link->appendChild($feed->newAttr('rel','self')); | ||
| 54 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); | 71 | + // links |
| 72 | + $link = $response->newElement('link'); | ||
| 73 | + $link->appendChild($response->newAttr('rel','self')); | ||
| 74 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); | ||
| 55 | $entry->appendChild($link); | 75 | $entry->appendChild($link); |
| 56 | 76 | ||
| 57 | - $link = $feed->newElement('link'); | ||
| 58 | - $link->appendChild($feed->newAttr('rel','edit')); | ||
| 59 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); | 77 | + $link = $response->newElement('link'); |
| 78 | + $link->appendChild($response->newAttr('rel','edit')); | ||
| 79 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ObjectId']['value'])); | ||
| 60 | $entry->appendChild($link); | 80 | $entry->appendChild($link); |
| 61 | 81 | ||
| 62 | // according to spec this MUST be present, but spec says that links for function which are not supported | 82 | // according to spec this MUST be present, but spec says that links for function which are not supported |
| 63 | // do not need to be present, so unsure for the moment | 83 | // do not need to be present, so unsure for the moment |
| 64 | - $link = $feed->newElement('link'); | ||
| 65 | - $link->appendChild($feed->newAttr('rel', 'allowableactions')); | ||
| 66 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' | 84 | + $link = $response->newElement('link'); |
| 85 | + $link->appendChild($response->newAttr('rel', 'allowableactions')); | ||
| 86 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' | ||
| 67 | . $cmisEntry['properties']['ObjectId']['value'] . '/permissions')); | 87 | . $cmisEntry['properties']['ObjectId']['value'] . '/permissions')); |
| 68 | $entry->appendChild($link); | 88 | $entry->appendChild($link); |
| 69 | 89 | ||
| 70 | // according to spec this MUST be present, but spec says that links for function which are not supported | 90 | // 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 | 91 | // 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 . '/' | 92 | + $link = $response->newElement('link'); |
| 93 | + $link->appendChild($response->newAttr('rel', 'relationships')); | ||
| 94 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' | ||
| 75 | . $cmisEntry['properties']['ObjectId']['value'] . '/rels')); | 95 | . $cmisEntry['properties']['ObjectId']['value'] . '/rels')); |
| 76 | $entry->appendChild($link); | 96 | $entry->appendChild($link); |
| 77 | 97 | ||
| 78 | // TODO check parent link is correct, fix if needed | 98 | // TODO check parent link is correct, fix if needed |
| 79 | // TODO leave out if at root folder | 99 | // 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/' | 100 | + $link = $response->newElement('link'); |
| 101 | + $link->appendChild($response->newAttr('rel', 'parents')); | ||
| 102 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/folder/' | ||
| 83 | . $cmisEntry['properties']['ObjectId']['value'] . '/parent')); | 103 | . $cmisEntry['properties']['ObjectId']['value'] . '/parent')); |
| 84 | $entry->appendChild($link); | 104 | $entry->appendChild($link); |
| 85 | 105 | ||
| 86 | // Folder/Document specific links | 106 | // Folder/Document specific links |
| 87 | if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') | 107 | if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') |
| 88 | { | 108 | { |
| 89 | - // no longer valid, remove... | ||
| 90 | -// // TODO check parent link is correct, fix if needed | ||
| 91 | -// $link = $feed->newElement('link'); | ||
| 92 | -// $link->appendChild($feed->newAttr('rel','folderparent')); | ||
| 93 | -// $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $cmisEntry['properties']['ParentId']['value'])); | ||
| 94 | -// $entry->appendChild($link); | ||
| 95 | - | ||
| 96 | - $link = $feed->newElement('link'); | ||
| 97 | - $link->appendChild($feed->newAttr('rel','children')); | ||
| 98 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' | 109 | + $link = $response->newElement('link'); |
| 110 | + $link->appendChild($response->newAttr('rel','children')); | ||
| 111 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' | ||
| 99 | . $type | 112 | . $type |
| 100 | . '/' . $cmisEntry['properties']['ObjectId']['value'] | 113 | . '/' . $cmisEntry['properties']['ObjectId']['value'] |
| 101 | . '/children')); | 114 | . '/children')); |
| 102 | $entry->appendChild($link); | 115 | $entry->appendChild($link); |
| 103 | - $link = $feed->newElement('link'); | ||
| 104 | - $link->appendChild($feed->newAttr('rel','descendants')); | ||
| 105 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' | 116 | + $link = $response->newElement('link'); |
| 117 | + $link->appendChild($response->newAttr('rel','descendants')); | ||
| 118 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' | ||
| 106 | . $type | 119 | . $type |
| 107 | . '/' . $cmisEntry['properties']['ObjectId']['value'] | 120 | . '/' . $cmisEntry['properties']['ObjectId']['value'] |
| 108 | . '/descendants')); | 121 | . '/descendants')); |
| @@ -112,25 +125,25 @@ class KT_cmis_atom_service_helper { | @@ -112,25 +125,25 @@ class KT_cmis_atom_service_helper { | ||
| 112 | { | 125 | { |
| 113 | // according to spec this MUST be present, but spec says that links for function which are not supported | 126 | // according to spec this MUST be present, but spec says that links for function which are not supported |
| 114 | // do not need to be present, so unsure for the moment | 127 | // do not need to be present, so unsure for the moment |
| 115 | -// $link = $feed->newElement('link'); | ||
| 116 | -// $link->appendChild($feed->newAttr('rel', 'allversions')); | ||
| 117 | -// $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | 128 | +// $link = $response->newElement('link'); |
| 129 | +// $link->appendChild($response->newAttr('rel', 'allversions')); | ||
| 130 | +// $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | ||
| 118 | // $entry->appendChild($link); | 131 | // $entry->appendChild($link); |
| 119 | 132 | ||
| 120 | // according to spec this MUST be present, but spec says that links for function which are not supported | 133 | // according to spec this MUST be present, but spec says that links for function which are not supported |
| 121 | // do not need to be present, so unsure for the moment | 134 | // do not need to be present, so unsure for the moment |
| 122 | -// $link = $feed->newElement('link'); | ||
| 123 | -// $link->appendChild($feed->newAttr('rel', 'latestversion')); | ||
| 124 | -// $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | 135 | +// $link = $response->newElement('link'); |
| 136 | +// $link->appendChild($response->newAttr('rel', 'latestversion')); | ||
| 137 | +// $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | ||
| 125 | // $entry->appendChild($link); | 138 | // $entry->appendChild($link); |
| 126 | 139 | ||
| 127 | // if there is a content stream, this link MUST be present | 140 | // if there is a content stream, this link MUST be present |
| 128 | // not sure yet where it must point... | 141 | // not sure yet where it must point... |
| 129 | if (!empty($cmisEntry['properties']['ContentStreamLength']['value'])) | 142 | if (!empty($cmisEntry['properties']['ContentStreamLength']['value'])) |
| 130 | { | 143 | { |
| 131 | - $link = $feed->newElement('link'); | ||
| 132 | - $link->appendChild($feed->newAttr('rel', 'stream')); | ||
| 133 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' | 144 | + $link = $response->newElement('link'); |
| 145 | + $link->appendChild($response->newAttr('rel', 'stream')); | ||
| 146 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' | ||
| 134 | . $cmisEntry['properties']['ObjectId']['value'])); | 147 | . $cmisEntry['properties']['ObjectId']['value'])); |
| 135 | $entry->appendChild($link); | 148 | $entry->appendChild($link); |
| 136 | } | 149 | } |
| @@ -138,47 +151,47 @@ class KT_cmis_atom_service_helper { | @@ -138,47 +151,47 @@ class KT_cmis_atom_service_helper { | ||
| 138 | // if the document is checked out and this is NOT the PWC, this link MUST be present | 151 | // if the document is checked out and this is NOT the PWC, this link MUST be present |
| 139 | // if (!empty($cmisEntry['properties']['ContentStreamLength']['value'])) | 152 | // if (!empty($cmisEntry['properties']['ContentStreamLength']['value'])) |
| 140 | // { | 153 | // { |
| 141 | -// $link = $feed->newElement('link'); | ||
| 142 | -// $link->appendChild($feed->newAttr('rel', 'stream')); | ||
| 143 | -// $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | 154 | +// $link = $response->newElement('link'); |
| 155 | +// $link->appendChild($response->newAttr('rel', 'stream')); | ||
| 156 | +// $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | ||
| 144 | // $entry->appendChild($link); | 157 | // $entry->appendChild($link); |
| 145 | // } | 158 | // } |
| 146 | } | 159 | } |
| 147 | 160 | ||
| 148 | - $link = $feed->newElement('link'); | ||
| 149 | - $link->appendChild($feed->newAttr('rel','type')); | ||
| 150 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/type/' . $type)); | 161 | + $link = $response->newElement('link'); |
| 162 | + $link->appendChild($response->newAttr('rel','type')); | ||
| 163 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . $type)); | ||
| 151 | $entry->appendChild($link); | 164 | $entry->appendChild($link); |
| 152 | 165 | ||
| 153 | - $link = $feed->newElement('link'); | ||
| 154 | - $link->appendChild($feed->newAttr('rel','repository')); | ||
| 155 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . '/servicedocument')); | 166 | + $link = $response->newElement('link'); |
| 167 | + $link->appendChild($response->newAttr('rel','repository')); | ||
| 168 | + $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . '/servicedocument')); | ||
| 156 | $entry->appendChild($link); | 169 | $entry->appendChild($link); |
| 157 | 170 | ||
| 158 | // according to spec this MUST be present, but spec says that links for function which are not supported | 171 | // according to spec this MUST be present, but spec says that links for function which are not supported |
| 159 | // do not need to be present, so unsure for the moment - policies are being abandoned, or so I thought... | 172 | // do not need to be present, so unsure for the moment - policies are being abandoned, or so I thought... |
| 160 | -// $link = $feed->newElement('link'); | ||
| 161 | -// $link->appendChild($feed->newAttr('rel', 'policies')); | ||
| 162 | -// $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | 173 | +// $link = $response->newElement('link'); |
| 174 | +// $link->appendChild($response->newAttr('rel', 'policies')); | ||
| 175 | +// $link->appendChild($response->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/' . $type . '/' . $cmisEntry['properties']['ParentId']['value'])); | ||
| 163 | // $entry->appendChild($link); | 176 | // $entry->appendChild($link); |
| 164 | // end links | 177 | // end links |
| 165 | 178 | ||
| 166 | // TODO proper date | 179 | // TODO proper date |
| 167 | - $entry->appendChild($feed->newField('published', self::formatDatestamp())); | ||
| 168 | - $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value'])); | ||
| 169 | - $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value'])); | ||
| 170 | - $entry->appendChild($feed->newField('updated', self::formatDatestamp())); | 180 | + $entry->appendChild($response->newField('published', self::formatDatestamp())); |
| 181 | + $entry->appendChild($response->newElement('summary', $cmisEntry['properties']['Name']['value'])); | ||
| 182 | + $entry->appendChild($response->newElement('title', $cmisEntry['properties']['Name']['value'])); | ||
| 183 | + $entry->appendChild($response->newField('updated', self::formatDatestamp())); | ||
| 171 | 184 | ||
| 172 | // main CMIS entry | 185 | // main CMIS entry |
| 173 | - $objectElement = $feed->newElement('cmis:object'); | ||
| 174 | - $propertiesElement = $feed->newElement('cmis:properties'); | 186 | + $objectElement = $response->newElement('cmis:object'); |
| 187 | + $propertiesElement = $response->newElement('cmis:properties'); | ||
| 175 | 188 | ||
| 176 | foreach($cmisEntry['properties'] as $propertyName => $property) | 189 | foreach($cmisEntry['properties'] as $propertyName => $property) |
| 177 | { | 190 | { |
| 178 | - $propElement = $feed->newElement('cmis:' . $property['type']); | ||
| 179 | - $propElement->appendChild($feed->newAttr('cmis:name', $propertyName)); | 191 | + $propElement = $response->newElement('cmis:' . $property['type']); |
| 192 | + $propElement->appendChild($response->newAttr('cmis:name', $propertyName)); | ||
| 180 | if (!empty($property['value'])) { | 193 | if (!empty($property['value'])) { |
| 181 | - $feed->newField('cmis:value', CMISUtil::boolToString($property['value']), $propElement); | 194 | + $response->newField('cmis:value', CMISUtil::boolToString($property['value']), $propElement); |
| 182 | } | 195 | } |
| 183 | $propertiesElement->appendChild($propElement); | 196 | $propertiesElement->appendChild($propElement); |
| 184 | } | 197 | } |
| @@ -187,7 +200,11 @@ class KT_cmis_atom_service_helper { | @@ -187,7 +200,11 @@ class KT_cmis_atom_service_helper { | ||
| 187 | $entry->appendChild($objectElement); | 200 | $entry->appendChild($objectElement); |
| 188 | 201 | ||
| 189 | // after every entry, append a cmis:terminator tag | 202 | // after every entry, append a cmis:terminator tag |
| 190 | - $entry->appendChild($feed->newElement('cmis:terminator')); | 203 | + $entry->appendChild($response->newElement('cmis:terminator')); |
| 204 | + | ||
| 205 | + if ($method == 'POST') { | ||
| 206 | + $entry->appendChild($response->newElement('app:edited', self::formatDatestamp())); | ||
| 207 | + } | ||
| 191 | } | 208 | } |
| 192 | 209 | ||
| 193 | /** | 210 | /** |
| @@ -216,7 +233,11 @@ class KT_cmis_atom_service_helper { | @@ -216,7 +233,11 @@ class KT_cmis_atom_service_helper { | ||
| 216 | } | 233 | } |
| 217 | 234 | ||
| 218 | //Create a new response feed | 235 | //Create a new response feed |
| 219 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, $typesHeading, null, null, null, 'urn:uuid:' . $typesString); | 236 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 237 | + $workspace = $feed->getWorkspace(); | ||
| 238 | + | ||
| 239 | + $feed->newField('title', $typesHeading, $feed); | ||
| 240 | + $feed->newField('id', 'urn:uuid:' . $typesString, $feed); | ||
| 220 | 241 | ||
| 221 | // TODO set page number correctly - to be done when we support paging the the API | 242 | // TODO set page number correctly - to be done when we support paging the the API |
| 222 | 243 | ||
| @@ -234,7 +255,7 @@ class KT_cmis_atom_service_helper { | @@ -234,7 +255,7 @@ class KT_cmis_atom_service_helper { | ||
| 234 | /* | 255 | /* |
| 235 | $link = $feed->newElement('link'); | 256 | $link = $feed->newElement('link'); |
| 236 | $link->appendChild($feed->newAttr('rel','source')); | 257 | $link->appendChild($feed->newAttr('rel','source')); |
| 237 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/type/' . strtolower($type['typeId']))); | 258 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); |
| 238 | $feed->appendChild($link); | 259 | $feed->appendChild($link); |
| 239 | */ | 260 | */ |
| 240 | 261 | ||
| @@ -251,11 +272,7 @@ class KT_cmis_atom_service_helper { | @@ -251,11 +272,7 @@ class KT_cmis_atom_service_helper { | ||
| 251 | $feedElement = $feed->newField('content', $type['typeId']); | 272 | $feedElement = $feed->newField('content', $type['typeId']); |
| 252 | $entry->appendChild($feedElement); | 273 | $entry->appendChild($feedElement); |
| 253 | 274 | ||
| 254 | - // hack, force to lower case | ||
| 255 | - $type['typeId'] = strtolower($type['typeId']); | ||
| 256 | - | ||
| 257 | - // NOTE should this be strtolower? thought so but maybe not always, Alfresco is not consistent... | ||
| 258 | - $feed->newId('urn:uuid:type-' . strtolower($type['typeId']), $entry); | 275 | + $feed->newField('id', 'urn:uuid:type-' . $type['typeId'], $feed); |
| 259 | 276 | ||
| 260 | // TODO add parents link when not selecting a base type. | 277 | // TODO add parents link when not selecting a base type. |
| 261 | // TODO add children link when type has children | 278 | // TODO add children link when type has children |
| @@ -265,14 +282,14 @@ class KT_cmis_atom_service_helper { | @@ -265,14 +282,14 @@ class KT_cmis_atom_service_helper { | ||
| 265 | // links | 282 | // links |
| 266 | $link = $feed->newElement('link'); | 283 | $link = $feed->newElement('link'); |
| 267 | $link->appendChild($feed->newAttr('rel','self')); | 284 | $link->appendChild($feed->newAttr('rel','self')); |
| 268 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/type/' . strtolower($type['typeId']))); | 285 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); |
| 269 | $entry->appendChild($link); | 286 | $entry->appendChild($link); |
| 270 | // TODO type link MUST point to base type | 287 | // TODO type link MUST point to base type |
| 271 | // KnowledgeTree currently only supports base types so this is not important | 288 | // KnowledgeTree currently only supports base types so this is not important |
| 272 | // at the present time as it will always point at the base type. | 289 | // at the present time as it will always point at the base type. |
| 273 | $link = $feed->newElement('link'); | 290 | $link = $feed->newElement('link'); |
| 274 | $link->appendChild($feed->newAttr('rel','type')); | 291 | $link->appendChild($feed->newAttr('rel','type')); |
| 275 | - $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/type/' . strtolower($type['typeId']))); | 292 | + $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); |
| 276 | $entry->appendChild($link); | 293 | $entry->appendChild($link); |
| 277 | $link = $feed->newElement('link'); | 294 | $link = $feed->newElement('link'); |
| 278 | $link->appendChild($feed->newAttr('rel','repository')); | 295 | $link->appendChild($feed->newAttr('rel','repository')); |
| @@ -302,7 +319,9 @@ class KT_cmis_atom_service_helper { | @@ -302,7 +319,9 @@ class KT_cmis_atom_service_helper { | ||
| 302 | static public function getErrorFeed(&$service, $status, $message) | 319 | static public function getErrorFeed(&$service, $status, $message) |
| 303 | { | 320 | { |
| 304 | $service->setStatus($status); | 321 | $service->setStatus($status); |
| 305 | - $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Error: ' . $status); | 322 | + $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 323 | + | ||
| 324 | + $feed->newField('title', 'Error: ' . $status, $feed); | ||
| 306 | $entry = $feed->newEntry(); | 325 | $entry = $feed->newEntry(); |
| 307 | $feed->newField('error', $message, $entry); | 326 | $feed->newField('error', $message, $entry); |
| 308 | 327 |
webservice/atompub/cmis/index.php
| @@ -55,8 +55,9 @@ define('CMIS_ATOM_LIB_FOLDER', trim(KT_ATOM_LIB_FOLDER, '/') . '/cmis/'); | @@ -55,8 +55,9 @@ define('CMIS_ATOM_LIB_FOLDER', trim(KT_ATOM_LIB_FOLDER, '/') . '/cmis/'); | ||
| 55 | * Includes | 55 | * Includes |
| 56 | */ | 56 | */ |
| 57 | include_once(KT_ATOM_LIB_FOLDER.'XMLns2array.inc.php'); | 57 | include_once(KT_ATOM_LIB_FOLDER.'XMLns2array.inc.php'); |
| 58 | +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_baseDoc.inc.php'); | ||
| 58 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_server.inc.php'); | 59 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_server.inc.php'); |
| 59 | -include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_baseDoc.inc.php'); | 60 | +include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_response.inc.php'); //Containing the response feed class allowing easy atom feed generation |
| 60 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation | 61 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation |
| 61 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation | 62 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation |
| 62 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_service.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation | 63 | include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_service.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation |
webservice/classes/atompub/cmis/KT_cmis_atom_response.inc.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_response.inc.php'); | ||
| 4 | + | ||
| 5 | +class KT_cmis_atom_response extends KT_atom_response { | ||
| 6 | + | ||
| 7 | + static protected $workspace = null; | ||
| 8 | + | ||
| 9 | + public function __construct($baseURI = null) | ||
| 10 | + { | ||
| 11 | + parent::__construct(); | ||
| 12 | + | ||
| 13 | + // require the workspace for creating links within responses | ||
| 14 | + $queryArray = split('/', trim($_SERVER['QUERY_STRING'], '/')); | ||
| 15 | + $this->workspace = strtolower(trim($queryArray[0])); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + function getWorkspace() | ||
| 19 | + { | ||
| 20 | + return $this->workspace; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + // TODO try to get rid of this function | ||
| 24 | + function appendChild($element) | ||
| 25 | + { | ||
| 26 | + $this->feed->appendChild($element); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +class KT_cmis_atom_Response_GET extends KT_cmis_atom_response{} | ||
| 32 | +class KT_cmis_atom_Response_PUT extends KT_cmis_atom_response{} | ||
| 33 | +class KT_cmis_atom_Response_POST extends KT_cmis_atom_response{} | ||
| 34 | +class KT_cmis_atom_Response_DELETE extends KT_cmis_atom_response{} | ||
| 35 | + | ||
| 36 | +?> | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
webservice/classes/atompub/cmis/KT_cmis_atom_responseFeed.inc.php
| @@ -5,27 +5,42 @@ include_once(KT_ATOM_LIB_FOLDER.'KT_atom_responseFeed.inc.php'); | @@ -5,27 +5,42 @@ include_once(KT_ATOM_LIB_FOLDER.'KT_atom_responseFeed.inc.php'); | ||
| 5 | class KT_cmis_atom_responseFeed extends KT_atom_responseFeed { | 5 | class KT_cmis_atom_responseFeed extends KT_atom_responseFeed { |
| 6 | 6 | ||
| 7 | // override and extend as needed | 7 | // override and extend as needed |
| 8 | - | ||
| 9 | - public $workspace = null; | ||
| 10 | 8 | ||
| 11 | - public function __construct($baseURI = NULL, $title = NULL, $link = NULL, $updated = NULL, $author = NULL, $id = NULL) | 9 | + static protected $workspace = null; |
| 10 | + | ||
| 11 | + /** | ||
| 12 | + * Overridden constructor to allow easy adding of additional header attributes | ||
| 13 | + * | ||
| 14 | + * @param string $baseURI | ||
| 15 | + */ | ||
| 16 | + public function __construct($baseURI = null) | ||
| 12 | { | 17 | { |
| 18 | + parent::__construct($baseURI); | ||
| 19 | + | ||
| 20 | + // append additional tags | ||
| 21 | + $this->feed->appendChild($this->newAttr('xmlns:app', 'http://www.w3.org/2007/app')); | ||
| 22 | + $this->feed->appendChild($this->newAttr('xmlns:cmis', 'http://docs.oasis-open.org/ns/cmis/core/200901')); | ||
| 23 | + | ||
| 24 | + // require the workspace for creating links within responses | ||
| 13 | $queryArray = split('/', trim($_SERVER['QUERY_STRING'], '/')); | 25 | $queryArray = split('/', trim($_SERVER['QUERY_STRING'], '/')); |
| 14 | $this->workspace = strtolower(trim($queryArray[0])); | 26 | $this->workspace = strtolower(trim($queryArray[0])); |
| 15 | - $this->id = $id; | ||
| 16 | - $this->title = $title; | ||
| 17 | - | ||
| 18 | - parent::__construct($baseURI, $title, $link, $updated, $author, $id); | ||
| 19 | } | 27 | } |
| 20 | 28 | ||
| 21 | - protected function constructHeader() | 29 | + function getWorkspace() |
| 22 | { | 30 | { |
| 23 | - $feed = $this->newElement('feed'); | ||
| 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')); | ||
| 26 | - $feed->appendChild($this->newAttr('xmlns:cmis','http://docs.oasis-open.org/ns/cmis/core/200901')); | ||
| 27 | - $this->feed = &$feed; | 31 | + return $this->workspace; |
| 32 | + } | ||
| 28 | 33 | ||
| 34 | + // TODO try to get rid of this function | ||
| 35 | + function appendChild($element) | ||
| 36 | + { | ||
| 37 | + $this->feed->appendChild($element); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + // this is ALL going away...adjust all calling code... | ||
| 41 | + /* | ||
| 42 | + protected function constructHeader() | ||
| 43 | + { | ||
| 29 | if (!is_null($this->id)) | 44 | if (!is_null($this->id)) |
| 30 | { | 45 | { |
| 31 | $this->newId($this->id, $this->feed); | 46 | $this->newId($this->id, $this->feed); |
| @@ -67,43 +82,8 @@ class KT_cmis_atom_responseFeed extends KT_atom_responseFeed { | @@ -67,43 +82,8 @@ class KT_cmis_atom_responseFeed extends KT_atom_responseFeed { | ||
| 67 | 82 | ||
| 68 | return $field; | 83 | return $field; |
| 69 | } | 84 | } |
| 70 | - | ||
| 71 | - function appendChild($element) | ||
| 72 | - { | ||
| 73 | - $this->feed->appendChild($element); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - /* | ||
| 77 | - public function &newEntry() | ||
| 78 | - { | ||
| 79 | - $entry = $this->newElement('entry'); | ||
| 80 | - $this->feed->appendChild($entry); | ||
| 81 | - return $entry; | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - public function &newId($id, $entry = null) | ||
| 85 | - { | ||
| 86 | - $id = $this->newElement('id', $id); | ||
| 87 | - if(isset($entry))$entry->appendChild($id); | ||
| 88 | - return $id; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - public function &newField($name = NULL, $value = NULL, &$entry = NULL) | ||
| 92 | - { | ||
| 93 | - $append = false; | ||
| 94 | - | ||
| 95 | - if(func_num_args() > 3) | ||
| 96 | - { | ||
| 97 | - $append = ((func_get_arg(3) === true) ? true : false); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - $field = $this->newElement('cmis:' . $name,$value); | ||
| 101 | - | ||
| 102 | - if (isset($entry)) $entry->appendChild($field); | ||
| 103 | - else if ($append) $this->feed->appendChild($field); | ||
| 104 | - | ||
| 105 | - return $field; | ||
| 106 | - } | 85 | +\ |
| 86 | + * | ||
| 107 | */ | 87 | */ |
| 108 | 88 | ||
| 109 | } | 89 | } |
webservice/classes/atompub/cmis/KT_cmis_atom_server.inc.php
| @@ -120,26 +120,6 @@ class KT_cmis_atom_server extends KT_atom_server { | @@ -120,26 +120,6 @@ class KT_cmis_atom_server extends KT_atom_server { | ||
| 120 | return false; | 120 | return false; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | -// // TODO we probably want this version in the base class for auth purposes | ||
| 124 | -// public function render() | ||
| 125 | -// { | ||
| 126 | -// ob_end_clean(); | ||
| 127 | -//// // possible additional headers, e.g. basic auth request | ||
| 128 | -//// // FIXME this won't work with the service document as no service object exists | ||
| 129 | -//// if (!is_null($this->serviceObject)) | ||
| 130 | -//// { | ||
| 131 | -//// $headers = $this->serviceObject->getHeaders(); | ||
| 132 | -//// foreach ($headers as $header) | ||
| 133 | -//// { | ||
| 134 | -//// header($header); | ||
| 135 | -//// } | ||
| 136 | -//// } | ||
| 137 | -// | ||
| 138 | -// // TODO header: application/atom+xml for service doc? is how Alfresco does it but is it needed? | ||
| 139 | -// header('Content-type: text/xml'); | ||
| 140 | -// echo $this->output; | ||
| 141 | -// } | ||
| 142 | - | ||
| 143 | } | 123 | } |
| 144 | 124 | ||
| 145 | ?> | 125 | ?> |
| 146 | \ No newline at end of file | 126 | \ No newline at end of file |
webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
| @@ -6,26 +6,5 @@ class KT_cmis_atom_service extends KT_atom_service { | @@ -6,26 +6,5 @@ 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 | - static protected $authData = array(); | ||
| 10 | - | ||
| 11 | - protected function parseHeaders() | ||
| 12 | - { | ||
| 13 | - parent::parseHeaders(); | ||
| 14 | - // attempt to fetch auth info from supplied headers | ||
| 15 | - if (!empty($this->headers['Authorization'])) | ||
| 16 | - { | ||
| 17 | - $auth = base64_decode(preg_replace('/Basic */', '', $this->headers['Authorization'])); | ||
| 18 | - $authData = explode(':', $auth); | ||
| 19 | - self::$authData['username'] = $authData[0]; | ||
| 20 | - self::$authData['password'] = $authData[1]; | ||
| 21 | - } | ||
| 22 | - // if failed, attempt to fetch from $_SERVER array instead | ||
| 23 | - else if (isset($_SERVER['PHP_AUTH_USER'])) | ||
| 24 | - { | ||
| 25 | - self::$authData['username'] = $_SERVER['PHP_AUTH_USER']; | ||
| 26 | - self::$authData['password'] = $_SERVER['PHP_AUTH_PW']; | ||
| 27 | - } | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | } | 9 | } |
| 31 | ?> | 10 | ?> |
| 32 | \ No newline at end of file | 11 | \ No newline at end of file |