Commit ae59d347e8dbcc17f8059f5c63cfe8743c65cd3f

Authored by Paul Barrett
1 parent 93e7ad70

Update CMIS Move Document

Story ID:2295472. Update KT CMIS implementation to 1.0 compliance

Committed by: Paul Barrett
lib/api/ktcmis/ktObjectService.inc.php
@@ -200,16 +200,16 @@ class KTObjectService extends KTCMISBase { @@ -200,16 +200,16 @@ class KTObjectService extends KTCMISBase {
200 /** 200 /**
201 * Moves a fileable object from one folder to another. 201 * Moves a fileable object from one folder to another.
202 * 202 *
203 - * @param object $repositoryId  
204 - * @param object $objectId  
205 - * @param object $changeToken [optional]  
206 - * @param object $targetFolderId  
207 - * @param object $sourceFolderId [optional] 203 + * @param string $repositoryId
  204 + * @param string $objectId
  205 + * @param string $targetFolderId
  206 + * @param string $sourceFolderId
  207 + * @return string $objectId
208 */ 208 */
209 - public function moveObject($repositoryId, $objectId, $changeToken = '', $targetFolderId, $sourceFolderId = null) 209 + public function moveObject($repositoryId, $objectId, $targetFolderId, $sourceFolderId)
210 { 210 {
211 try { 211 try {
212 - $this->ObjectService->moveObject($repositoryId, $objectId, $changeToken, $targetFolderId, $sourceFolderId); 212 + $this->ObjectService->moveObject($repositoryId, $objectId, $targetFolderId, $sourceFolderId);
213 } 213 }
214 catch (Exception $e) 214 catch (Exception $e)
215 { 215 {
lib/api/ktcmis/services/CMISNavigationService.inc.php
@@ -98,7 +98,7 @@ class CMISNavigationService { @@ -98,7 +98,7 @@ class CMISNavigationService {
98 // if this is not a folder, cannot get children 98 // if this is not a folder, cannot get children
99 $folderId = CMISUtil::decodeObjectId($folderId, $type); 99 $folderId = CMISUtil::decodeObjectId($folderId, $type);
100 100
101 - if ($type != 'Folder') { 101 + if ($type != 'cmis:folder') {
102 throw new invalidArgumentException('The specified object is not a folder'); 102 throw new invalidArgumentException('The specified object is not a folder');
103 } 103 }
104 104
@@ -149,7 +149,7 @@ class CMISNavigationService { @@ -149,7 +149,7 @@ class CMISNavigationService {
149 // if this is not a folder, cannot get descendants 149 // if this is not a folder, cannot get descendants
150 $folderId = CMISUtil::decodeObjectId($folderId, $type); 150 $folderId = CMISUtil::decodeObjectId($folderId, $type);
151 151
152 - if ($type != 'Folder') { 152 + if ($type != 'cmis:folder') {
153 throw new InvalidArgumentException('The supplied object is not a folder, unable to return descendants'); 153 throw new InvalidArgumentException('The supplied object is not a folder, unable to return descendants');
154 } 154 }
155 155
@@ -195,7 +195,7 @@ class CMISNavigationService { @@ -195,7 +195,7 @@ class CMISNavigationService {
195 // if this is not a folder, cannot get folder parent :) 195 // if this is not a folder, cannot get folder parent :)
196 $folderId = CMISUtil::decodeObjectId($folderId, $type); 196 $folderId = CMISUtil::decodeObjectId($folderId, $type);
197 // NOTE this will quite possibly break the webservices 197 // NOTE this will quite possibly break the webservices
198 - if ($type != 'Folder') 198 + if ($type != 'cmis:folder')
199 { 199 {
200 return $ancestry; 200 return $ancestry;
201 } 201 }
@@ -257,12 +257,12 @@ class CMISNavigationService { @@ -257,12 +257,12 @@ class CMISNavigationService {
257 // TODO - what about other types? only implementing folders and documents at the moment so ignore for now 257 // TODO - what about other types? only implementing folders and documents at the moment so ignore for now
258 switch($typeId) 258 switch($typeId)
259 { 259 {
260 - case 'Document': 260 + case 'cmis:document':
261 $document = $this->ktapi->get_document_by_id($objectId); 261 $document = $this->ktapi->get_document_by_id($objectId);
262 $parent = $document->ktapi_folder; 262 $parent = $document->ktapi_folder;
263 $ancestry[] = $parent; 263 $ancestry[] = $parent;
264 break; 264 break;
265 - case 'Folder': 265 + case 'cmis:folder':
266 $folder = $this->ktapi->get_folder_by_id($objectId); 266 $folder = $this->ktapi->get_folder_by_id($objectId);
267 $parent = $this->ktapi->get_folder_by_id($folder->get_parent_folder_id()); 267 $parent = $this->ktapi->get_folder_by_id($folder->get_parent_folder_id());
268 $ancestry[] = $parent; 268 $ancestry[] = $parent;
lib/api/ktcmis/services/CMISObjectService.inc.php
@@ -88,7 +88,7 @@ class CMISObjectService { @@ -88,7 +88,7 @@ class CMISObjectService {
88 // Attempt to decode $folderId, use as is if not detected as encoded 88 // Attempt to decode $folderId, use as is if not detected as encoded
89 $tmpObjectId = $folderId; 89 $tmpObjectId = $folderId;
90 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId); 90 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId);
91 - if ($tmpTypeId != 'Unknown') 91 + if ($tmpTypeId != 'unknown')
92 $folderId = $tmpObjectId; 92 $folderId = $tmpObjectId;
93 93
94 // if parent folder is not allowed to hold this type, throw exception 94 // if parent folder is not allowed to hold this type, throw exception
@@ -325,7 +325,7 @@ class CMISObjectService { @@ -325,7 +325,7 @@ class CMISObjectService {
325 // Attempt to decode $folderId, use as is if not detected as encoded 325 // Attempt to decode $folderId, use as is if not detected as encoded
326 $tmpObjectId = $folderId; 326 $tmpObjectId = $folderId;
327 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId); 327 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId);
328 - if ($tmpTypeId != 'Unknown') 328 + if ($tmpTypeId != 'unknown')
329 $folderId = $tmpObjectId; 329 $folderId = $tmpObjectId;
330 330
331 // if parent folder is not allowed to hold this type, throw exception 331 // if parent folder is not allowed to hold this type, throw exception
@@ -368,16 +368,16 @@ class CMISObjectService { @@ -368,16 +368,16 @@ class CMISObjectService {
368 $properties = array(); 368 $properties = array();
369 $objectId = CMISUtil::decodeObjectId($objectId, $typeId); 369 $objectId = CMISUtil::decodeObjectId($objectId, $typeId);
370 370
371 - if ($typeId == 'Unknown') { 371 + if ($typeId == 'unknown') {
372 throw new ObjectNotFoundException('The type of the requested object could not be determined'); 372 throw new ObjectNotFoundException('The type of the requested object could not be determined');
373 } 373 }
374 374
375 switch($typeId) 375 switch($typeId)
376 { 376 {
377 - case 'Document': 377 + case 'cmis:document':
378 $CMISObject = new CMISDocumentObject($objectId, $this->ktapi, $repository->getRepositoryURI()); 378 $CMISObject = new CMISDocumentObject($objectId, $this->ktapi, $repository->getRepositoryURI());
379 break; 379 break;
380 - case 'Folder': 380 + case 'cmis:folder':
381 $CMISObject = new CMISFolderObject($objectId, $this->ktapi, $repository->getRepositoryURI()); 381 $CMISObject = new CMISFolderObject($objectId, $this->ktapi, $repository->getRepositoryURI());
382 break; 382 break;
383 } 383 }
@@ -409,15 +409,15 @@ class CMISObjectService { @@ -409,15 +409,15 @@ class CMISObjectService {
409 $contentStream = null; 409 $contentStream = null;
410 410
411 // decode $objectId 411 // decode $objectId
412 - $objectId = CMISUtil::decodeObjectId($objectId, $typeId); 412 + $objectId = CMISUtil::decodeObjectId($objectId, $typeId, $className);
413 413
414 // unknown object type? 414 // unknown object type?
415 - if ($typeId == 'Unknown') { 415 + if ($typeId == 'unknown') {
416 throw new ObjectNotFoundException('The type of the requested object could not be determined'); 416 throw new ObjectNotFoundException('The type of the requested object could not be determined');
417 } 417 }
418 418
419 // fetch type definition of supplied object type 419 // fetch type definition of supplied object type
420 - $objectClass = 'CMIS' . $typeId . 'Object'; 420 + $objectClass = 'CMIS' . $className . 'Object';
421 $CMISObject = new $objectClass($objectId, $this->ktapi); 421 $CMISObject = new $objectClass($objectId, $this->ktapi);
422 422
423 // if content stream is not allowed for this object type definition, or the specified object does not have 423 // if content stream is not allowed for this object type definition, or the specified object does not have
@@ -444,37 +444,32 @@ class CMISObjectService { @@ -444,37 +444,32 @@ class CMISObjectService {
444 /** 444 /**
445 * Moves a fileable object from one folder to another. 445 * Moves a fileable object from one folder to another.
446 * 446 *
447 - * @param object $repositoryId  
448 - * @param object $objectId  
449 - * @param object $changeToken [optional]  
450 - * @param object $targetFolderId  
451 - * @param object $sourceFolderId [optional] 447 + * @param string $repositoryId
  448 + * @param string $objectId
  449 + * @param string $targetFolderId
  450 + * @param string $sourceFolderId
  451 + * @return string $objectId
452 */ 452 */
453 // TODO versioningException: The repository MAY throw this exception if the object is a non-current Document Version. 453 // TODO versioningException: The repository MAY throw this exception if the object is a non-current Document Version.
454 - // TODO check whether object is in fact fileable? not strictly needed, but possibly should be here.  
455 - public function moveObject($repositoryId, $objectId, $changeToken = '', $targetFolderId, $sourceFolderId = null) 454 + // TODO check whether object is in fact fileable? perhaps not strictly needed, but possibly should be here.
  455 + public function moveObject($repositoryId, $objectId, $targetFolderId, $sourceFolderId)
456 { 456 {
457 - // The $sourceFolderId parameter SHALL be specified if the Repository supports the optional 'unfiling' capability  
458 - if (is_null($sourceFolderId))  
459 - {  
460 - $RepositoryService = new CMISRepositoryService();  
461 - $info = $RepositoryService->getRepositoryInfo($repositoryId);  
462 - $capabilities = $info->getCapabilities();  
463 - // check for unfiling capability  
464 - // NOTE this is only required once/if KnowledgeTree allows the source folder id to be optional,  
465 - // but it is required for CMIS specification compliance.  
466 - if ($capabilities->hasCapabilityUnfiling() === 'true') {  
467 - throw new RuntimeException('The source folder id MUST be supplied when unfiling is supported.');  
468 - }  
469 - }  
470 -  
471 - // Attempt to decode $objectId, use as is if not detected as encoded 457 + // attempt to decode $objectId, use as is if not detected as encoded
472 $tmpObjectId = $objectId; 458 $tmpObjectId = $objectId;
473 - $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $typeId);  
474 - if ($tmpTypeId != 'Unknown') $objectId = $tmpObjectId; 459 + $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $typeId, $className);
  460 + if ($tmpTypeId != 'unknown') $objectId = $tmpObjectId;
  461 +
  462 + $objectClass = 'CMIS' . $className . 'Object';
  463 + $CMISObject = new $objectClass($objectId, $this->ktapi);
475 464
476 $targetFolderId = CMISUtil::decodeObjectId($targetFolderId); 465 $targetFolderId = CMISUtil::decodeObjectId($targetFolderId);
477 466
  467 + // check the $sourceFolderId parameter - if empty or does not match (at least one) parent of the specified object,
  468 + // throw exception
  469 + if (empty($sourceFolderId) || $CMISObject->getProperty('parentId') != $sourceFolderId) {
  470 + throw new InvalidArgumentException('The source folder id is invalid');
  471 + }
  472 +
478 // check type id of object against allowed child types for destination folder 473 // check type id of object against allowed child types for destination folder
479 $CMISFolder = new CMISFolderObject($targetFolderId, $this->ktapi); 474 $CMISFolder = new CMISFolderObject($targetFolderId, $this->ktapi);
480 $allowed = $CMISFolder->getProperty('allowedChildObjectTypeIds'); 475 $allowed = $CMISFolder->getProperty('allowedChildObjectTypeIds');
@@ -490,21 +485,26 @@ class CMISObjectService { @@ -490,21 +485,26 @@ class CMISObjectService {
490 485
491 // TODO add reasons and sig data 486 // TODO add reasons and sig data
492 // attempt to move object 487 // attempt to move object
493 - if ($typeId == 'Folder') { 488 + if ($typeId == 'cmis:folder') {
494 $response = $this->ktapi->move_folder($objectId, $targetFolderId, $reason, $sig_username, $sig_password); 489 $response = $this->ktapi->move_folder($objectId, $targetFolderId, $reason, $sig_username, $sig_password);
495 } 490 }
496 - else if ($typeId == 'Document') { 491 + else if ($typeId == 'cmis:document') {
497 $response = $this->ktapi->move_document($objectId, $targetFolderId, $reason, null, null, $sig_username, $sig_password); 492 $response = $this->ktapi->move_document($objectId, $targetFolderId, $reason, null, null, $sig_username, $sig_password);
498 } 493 }
499 else { 494 else {
500 $response['status_code'] = 1; 495 $response['status_code'] = 1;
501 $response['message'] = 'The object type could not be determined.'; 496 $response['message'] = 'The object type could not be determined.';
502 } 497 }
  498 +
  499 + // TODO The repository may throw a NameConstrainViolationException if there is a name conflict (determined by KTAPI)
  500 + // or may choose a name which does not conflict
503 501
504 // if failed, throw StorageException 502 // if failed, throw StorageException
505 if ($response['status_code'] != 0) { 503 if ($response['status_code'] != 0) {
506 throw new StorageException('The repository was unable to move the object: ' . $response['message']); 504 throw new StorageException('The repository was unable to move the object: ' . $response['message']);
507 - } 505 + }
  506 +
  507 + return CMISUtil::encodeObjectId($objectId, $typeId);
508 } 508 }
509 509
510 /** 510 /**
@@ -524,14 +524,14 @@ class CMISObjectService { @@ -524,14 +524,14 @@ class CMISObjectService {
524 // TODO this should probably be a function, it is now used in two places... 524 // TODO this should probably be a function, it is now used in two places...
525 // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository). 525 // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository).
526 $exists = true; 526 $exists = true;
527 - if ($typeId == 'Folder') 527 + if ($typeId == 'cmis:folder')
528 { 528 {
529 $object = $this->ktapi->get_folder_by_id($objectId); 529 $object = $this->ktapi->get_folder_by_id($objectId);
530 if (PEAR::isError($object)) { 530 if (PEAR::isError($object)) {
531 $exists = false; 531 $exists = false;
532 } 532 }
533 } 533 }
534 - else if ($typeId == 'Document') 534 + else if ($typeId == 'cmis:document')
535 { 535 {
536 $object = $this->ktapi->get_document_by_id($objectId); 536 $object = $this->ktapi->get_document_by_id($objectId);
537 if (PEAR::isError($object)) { 537 if (PEAR::isError($object)) {
@@ -548,7 +548,7 @@ class CMISObjectService { @@ -548,7 +548,7 @@ class CMISObjectService {
548 } 548 }
549 global $default; 549 global $default;
550 // throw ConstraintViolationException if method is invoked on a Folder object that contains one or more objects 550 // throw ConstraintViolationException if method is invoked on a Folder object that contains one or more objects
551 - if ($typeId == 'Folder') 551 + if ($typeId == 'cmis:folder')
552 { 552 {
553 $folderContent = $object->get_listing(); 553 $folderContent = $object->get_listing();
554 if (!PEAR::isError($folderContent)) 554 if (!PEAR::isError($folderContent))
@@ -563,7 +563,7 @@ class CMISObjectService { @@ -563,7 +563,7 @@ class CMISObjectService {
563 // TODO add the electronic signature capability 563 // TODO add the electronic signature capability
564 $result = $this->ktapi->delete_folder($objectId, $reason, $sig_username, $sig_password); 564 $result = $this->ktapi->delete_folder($objectId, $reason, $sig_username, $sig_password);
565 } 565 }
566 - else if ($typeId == 'Document') 566 + else if ($typeId == 'cmis:document')
567 { 567 {
568 // NOTE KnowledgeTree does not support deleting of individual versions and will always delete all versions 568 // NOTE KnowledgeTree does not support deleting of individual versions and will always delete all versions
569 // Throw an exception instead if individual version requested for delete 569 // Throw an exception instead if individual version requested for delete
@@ -625,7 +625,7 @@ class CMISObjectService { @@ -625,7 +625,7 @@ class CMISObjectService {
625 625
626 // throw updateConflictException if the operation is attempting to update an object that is no longer current 626 // throw updateConflictException if the operation is attempting to update an object that is no longer current
627 // (as determined by the repository) 627 // (as determined by the repository)
628 - if ($typeId == 'Folder') { 628 + if ($typeId == 'cmis:folder') {
629 $object = $this->ktapi->get_folder_by_id($folderId); 629 $object = $this->ktapi->get_folder_by_id($folderId);
630 if (PEAR::isError($object)) { 630 if (PEAR::isError($object)) {
631 throw new updateConflictException('Unable to delete the object as it cannot be found.'); 631 throw new updateConflictException('Unable to delete the object as it cannot be found.');
@@ -652,10 +652,10 @@ class CMISObjectService { @@ -652,10 +652,10 @@ class CMISObjectService {
652 foreach($folderContents as $folderObject) 652 foreach($folderContents as $folderObject)
653 { 653 {
654 if ($folderObject['item_type'] == 'F') { 654 if ($folderObject['item_type'] == 'F') {
655 - $type = 'Folder'; 655 + $type = 'cmis:folder';
656 } 656 }
657 else if ($folderObject['item_type'] == 'D') { 657 else if ($folderObject['item_type'] == 'D') {
658 - $type = 'Document'; 658 + $type = 'cmis:document';
659 } 659 }
660 660
661 $failedToDelete[] = CMISUtil::encodeObjectId($type, $folderObject['id']); 661 $failedToDelete[] = CMISUtil::encodeObjectId($type, $folderObject['id']);
@@ -697,7 +697,7 @@ class CMISObjectService { @@ -697,7 +697,7 @@ class CMISObjectService {
697 // Attempt to decode $documentId, use as is if not detected as encoded 697 // Attempt to decode $documentId, use as is if not detected as encoded
698 $tmpObjectId = $documentId; 698 $tmpObjectId = $documentId;
699 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId); 699 $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId);
700 - if ($tmpTypeId != 'Unknown') 700 + if ($tmpTypeId != 'unknown')
701 $documentId = $tmpObjectId; 701 $documentId = $tmpObjectId;
702 702
703 // TODO deal with other types except documents 703 // TODO deal with other types except documents
@@ -715,8 +715,7 @@ class CMISObjectService { @@ -715,8 +715,7 @@ class CMISObjectService {
715 } 715 }
716 716
717 $csFileName = $CMISDocument->getProperty('contentStreamFilename'); 717 $csFileName = $CMISDocument->getProperty('contentStreamFilename');
718 - if (!empty($csFileName) && (!$overwriteFlag))  
719 - { 718 + if (!empty($csFileName) && (!$overwriteFlag)) {
720 throw new ContentAlreadyExistsException('Unable to overwrite existing content stream'); 719 throw new ContentAlreadyExistsException('Unable to overwrite existing content stream');
721 } 720 }
722 721
@@ -724,8 +723,7 @@ class CMISObjectService { @@ -724,8 +723,7 @@ class CMISObjectService {
724 // update the document content from this temporary file as per usual 723 // update the document content from this temporary file as per usual
725 // TODO Use checkin_document_with_metadata instead if metadata content submitted || update metadata separately? 724 // TODO Use checkin_document_with_metadata instead if metadata content submitted || update metadata separately?
726 $response = $this->ktapi->checkin_document($documentId, $csFileName, 'CMIS setContentStream action', $tempfilename, false); 725 $response = $this->ktapi->checkin_document($documentId, $csFileName, 'CMIS setContentStream action', $tempfilename, false);
727 - if ($response['status_code'] != 0)  
728 - { 726 + if ($response['status_code'] != 0) {
729 throw new StorageException('Unable to update the content stream. ' . $response['message']); 727 throw new StorageException('Unable to update the content stream. ' . $response['message']);
730 } 728 }
731 // else 729 // else
lib/api/ktcmis/util/CMISUtil.inc.php
@@ -97,11 +97,11 @@ class CMISUtil { @@ -97,11 +97,11 @@ class CMISUtil {
97 * @param string &$typeId 97 * @param string &$typeId
98 * @return string $objectId 98 * @return string $objectId
99 */ 99 */
100 - static public function decodeObjectId($objectId, &$typeId = null) 100 + static public function decodeObjectId($objectId, &$typeId = null, &$className = '')
101 { 101 {
102 if (!is_string($objectId)) 102 if (!is_string($objectId))
103 { 103 {
104 - $typeId = 'Unknown'; 104 + $typeId = 'unknown';
105 return null; 105 return null;
106 } 106 }
107 107
@@ -123,7 +123,7 @@ class CMISUtil { @@ -123,7 +123,7 @@ class CMISUtil {
123 // method of doing this. 123 // method of doing this.
124 // meantime this minor hack will get things working for the existing system structure, as the root 124 // meantime this minor hack will get things working for the existing system structure, as the root
125 // folder should always be id 1. 125 // folder should always be id 1.
126 - $typeId = 'Folder'; 126 + $typeId = 'cmis:folder';
127 return '1'; 127 return '1';
128 } 128 }
129 129
@@ -134,13 +134,15 @@ class CMISUtil { @@ -134,13 +134,15 @@ class CMISUtil {
134 switch($type) 134 switch($type)
135 { 135 {
136 case 'D': 136 case 'D':
137 - $typeId = 'Document'; 137 + $typeId = 'cmis:document';
  138 + $className = 'Document';
138 break; 139 break;
139 case 'F': 140 case 'F':
140 - $typeId = 'Folder'; 141 + $typeId = 'cmis:folder';
  142 + $className = 'Folder';
141 break; 143 break;
142 default: 144 default:
143 - $typeId = 'Unknown'; 145 + $typeId = 'unknown';
144 break; 146 break;
145 } 147 }
146 148
@@ -498,14 +500,14 @@ class CMISUtil { @@ -498,14 +500,14 @@ class CMISUtil {
498 public function contentExists($typeId, $objectId, &$ktapi) 500 public function contentExists($typeId, $objectId, &$ktapi)
499 { 501 {
500 $exists = true; 502 $exists = true;
501 - if ($typeId == 'Folder') 503 + if ($typeId == 'cmis:folder')
502 { 504 {
503 $object = $ktapi->get_folder_by_id($objectId); 505 $object = $ktapi->get_folder_by_id($objectId);
504 if (PEAR::isError($object)) { 506 if (PEAR::isError($object)) {
505 $exists = false; 507 $exists = false;
506 } 508 }
507 } 509 }
508 - else if ($typeId == 'Document') 510 + else if ($typeId == 'cmis:document')
509 { 511 {
510 $object = $ktapi->get_document_by_id($objectId); 512 $object = $ktapi->get_document_by_id($objectId);
511 if (PEAR::isError($object)) { 513 if (PEAR::isError($object)) {
@@ -567,10 +569,10 @@ class CMISUtil { @@ -567,10 +569,10 @@ class CMISUtil {
567 /** 569 /**
568 * Checks for the root folder 570 * Checks for the root folder
569 * 571 *
570 - * @param unknown_type $repositoryId  
571 - * @param unknown_type $folderId  
572 - * @param unknown_type $ktapi  
573 - * @return unknown 572 + * @param string $repositoryId
  573 + * @param string $folderId
  574 + * @param object $ktapi
  575 + * @return boolean
574 */ 576 */
575 static public function isRootFolder($repositoryId, $folderId, &$ktapi) 577 static public function isRootFolder($repositoryId, $folderId, &$ktapi)
576 { 578 {
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
@@ -150,24 +150,23 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { @@ -150,24 +150,23 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service {
150 // document action create will have a content tag <atom:content> or <content> containing base64 encoding of the document 150 // document action create will have a content tag <atom:content> or <content> containing base64 encoding of the document
151 // move action will have an existing id supplied as a parameter - not sure how this works yet as the CMIS clients we are 151 // move action will have an existing id supplied as a parameter - not sure how this works yet as the CMIS clients we are
152 // testing don't support move functionality at this time (2009/07/23) and so we are presuming the following format: 152 // testing don't support move functionality at this time (2009/07/23) and so we are presuming the following format:
153 - // /folder/<folderId>/children/<objectId> 153 + // /folder/<folderId>/<sourceFolderId>/<objectId>
154 // also possible that there will be an existing ObjectId property, try to cater for both until we know how it really works 154 // also possible that there will be an existing ObjectId property, try to cater for both until we know how it really works
  155 + // NOTE this also applies to the source folder id, see above
155 156
156 // check for existing object id as parameter in url 157 // check for existing object id as parameter in url
157 - if (isset($this->params[2]))  
158 - { 158 + // if sourceFolderId parameter is submitted, this is a move
  159 + if (isset($this->params[1])) {
159 $action = 'move'; 160 $action = 'move';
160 - $objectId = $this->params[2]; 161 + $sourceFolderId = $this->params[1];
161 } 162 }
162 163
163 // get object properties - todo send through original properties array and not modified version 164 // get object properties - todo send through original properties array and not modified version
164 - $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); 165 + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisObjectProperties($this->rawContent);
165 $properties = array('name' => $title, 'summary' => $summary, 'objectTypeId' => $cmisObjectProperties['cmis:objectTypeId']); 166 $properties = array('name' => $title, 'summary' => $summary, 'objectTypeId' => $cmisObjectProperties['cmis:objectTypeId']);
166 167
167 // check for existing object id as property of submitted object data 168 // check for existing object id as property of submitted object data
168 - if (!empty($cmisObjectProperties['cmis:objectId']))  
169 - {  
170 - $action = 'move'; 169 + if (!empty($cmisObjectProperties['cmis:objectId'])) {
171 $objectId = $cmisObjectProperties['cmis:objectId']; 170 $objectId = $cmisObjectProperties['cmis:objectId'];
172 } 171 }
173 172
@@ -210,7 +209,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { @@ -210,7 +209,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service {
210 $newObjectId = $newObjectId['results']; 209 $newObjectId = $newObjectId['results'];
211 // check if returned Object Id is a valid CMIS Object Id 210 // check if returned Object Id is a valid CMIS Object Id
212 CMISUtil::decodeObjectId($newObjectId, $typeId); 211 CMISUtil::decodeObjectId($newObjectId, $typeId);
213 - if ($typeId != 'Unknown') { 212 + if ($typeId != 'unknown') {
214 $success = true; 213 $success = true;
215 } 214 }
216 else { 215 else {
@@ -223,7 +222,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service { @@ -223,7 +222,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service {
223 } 222 }
224 else if ($action == 'move') 223 else if ($action == 'move')
225 { 224 {
226 - $response = $ObjectService->moveObject($repositoryId, $objectId, '', $folderId); 225 + $response = $ObjectService->moveObject($repositoryId, $objectId, $folderId, $sourceFolderId);
227 226
228 if ($response['status_code'] == 0) { 227 if ($response['status_code'] == 0) {
229 $success = true; 228 $success = true;
@@ -523,7 +522,7 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service { @@ -523,7 +522,7 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service {
523 $ObjectService = new KTObjectService(KT_cmis_atom_service_helper::getKt()); 522 $ObjectService = new KTObjectService(KT_cmis_atom_service_helper::getKt());
524 523
525 // get object properties 524 // get object properties
526 - $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); 525 + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisObjectProperties($this->rawContent);
527 526
528 // check for content stream 527 // check for content stream
529 $content = KT_cmis_atom_service_helper::getCmisContent($this->rawContent); 528 $content = KT_cmis_atom_service_helper::getCmisContent($this->rawContent);
@@ -635,7 +634,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { @@ -635,7 +634,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service {
635 $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt()); 634 $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt());
636 $ObjectService = new KTObjectService(KT_cmis_atom_service_helper::getKt()); 635 $ObjectService = new KTObjectService(KT_cmis_atom_service_helper::getKt());
637 636
638 - $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->rawContent); 637 + $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisObjectProperties($this->rawContent);
639 638
640 // check for existing object id as property of submitted object data 639 // check for existing object id as property of submitted object data
641 if (empty($cmisObjectProperties['cmis:objectId'])) 640 if (empty($cmisObjectProperties['cmis:objectId']))
webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
@@ -530,7 +530,7 @@ class KT_cmis_atom_service_helper { @@ -530,7 +530,7 @@ class KT_cmis_atom_service_helper {
530 return CMISUtil::encodeObjectId(FOLDER, $folderId); 530 return CMISUtil::encodeObjectId(FOLDER, $folderId);
531 } 531 }
532 532
533 - static public function getCmisProperties(&$xml) 533 + static public function getCmisObjectProperties(&$xml)
534 { 534 {
535 $xmlReader = new XMLReader(); 535 $xmlReader = new XMLReader();
536 $xmlReader->XML($xml); 536 $xmlReader->XML($xml);