Commit 953b76b4c9967d35df41e31dd251b089498eee40

Authored by Paul Barrett
1 parent 110bf5c8

Initial basic CMIS API level folder creation function and interface access point

Committed by:Paul Barrett

Reviewed by: Jarrett Jordaan
lib/api/ktcmis/services/CMISObjectService.inc.php
... ... @@ -60,6 +60,45 @@ class CMISObjectService {
60 60 return $properties;
61 61 }
62 62  
  63 + /**
  64 + * Function to create a folder
  65 + *
  66 + * @param string $repositoryId The repository to which the folder must be added
  67 + * @param string $typeId Object Type id for the folder object being created
  68 + * @param array $properties Array of properties which must be applied to the created folder object
  69 + * @param string $folderId The id of the folder which will be the parent of the created folder object
  70 + * @return string $objectId The id of the created folder object
  71 + */
  72 + // TODO throw ConstraintViolationException if:
  73 + // typeID is not an Object-Type whose baseType is “Folder”.
  74 + // value of any of the properties violates the min/max/required/length constraints
  75 + // specified in the property definition in the Object-Type.
  76 + // typeID is NOT in the list of AllowedChildObjectTypeIds of the parent-folder specified by folderId
  77 + // TODO throw storageException under conditions specified in "specific exceptions" section
  78 + function createFolder($repositoryId, $typeId, $properties, $folderId)
  79 + {
  80 + $objectId = null;
  81 +
  82 + // TODO determine whether this is in fact necessary or if we should require decoding in the calling code
  83 + // Attempt to decode $folderId, use as is if not detected as encoded
  84 + $objectId = $folderId;
  85 + $tmpTypeId = CMISUtil::decodeObjectId($objectId);
  86 + if ($tmpTypeId != 'Unknown')
  87 + $folderId = $objectId;
  88 +
  89 + $response = $this->ktapi->create_folder($folderId, $properties['name'], $sig_username = '', $sig_password = '', $reason = '');
  90 + if ($response['status_code'] != 0)
  91 + {
  92 + // TODO add some error handling here
  93 + }
  94 + else
  95 + {
  96 + $objectId = CMISUtil::encodeObjectId('Folder', $response['results']['id']);
  97 + }
  98 +
  99 + return $objectId;
  100 + }
  101 +
63 102 }
64 103  
65 104 ?>
... ...