/**
  * Deals with folder service POST actions.
  * This includes creation/moving of both folders and documents.
  */
 public function POST_action()
 {
     $RepositoryService = new RepositoryService();
     $repositories = $RepositoryService->getRepositories();
     $repositoryId = $repositories[0]['repositoryId'];
     // set default action, objectId and typeId
     $action = 'create';
     $objectId = null;
     $typeId = null;
     $folderId = $this->params[0];
     $title = KT_cmis_atom_service_helper::getAtomValues($this->parsedXMLContent['@children'], 'title');
     $summary = KT_cmis_atom_service_helper::getAtomValues($this->parsedXMLContent['@children'], 'summary');
     $properties = array('name' => $title, 'summary' => $summary);
     // determine whether this is a folder or a document action
     // document action create will have a content tag <atom:content> or <content> containing base64 encoding of the document
     // move action will have an existing id supplied as a parameter - not sure how this works yet as the CMIS clients we are
     // testing don't support move functionality at this time (2009/07/23) and so we are presuming the following format:
     // /folder/<folderId>/children/<objectId>
     // also possible that there will be an existing ObjectId property, try to cater for both until we know how it really works
     // check for existing object id as parameter in url
     if (isset($this->params[2])) {
         $action = 'move';
         $objectId = $this->params[2];
     }
     $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object']);
     // check for existing object id as property of submitted object data
     if (!empty($cmisObjectProperties['ObjectId'])) {
         $action = 'move';
         $objectId = $cmisObjectProperties['ObjectId'];
     }
     // TODO there may be more to do for the checking of an existing object.
     //      e.g. verifying that it does indeed exist, and throwing an exception if it does not:
     //      "If the objected property is present but not valid an exception will be thrown" (from CMIS specification)
     // NOTE this exception should be thrown in the service API code and not here.
     // determine type if object is being moved
     if (!is_null($objectId)) {
         CMISUtil::decodeObjectId($objectId, $typeId);
     }
     // now check for content stream
     $content = KT_cmis_atom_service_helper::getAtomValues($this->parsedXMLContent['@children'], 'content');
     // TODO this will possibly need to change somewhat once Relationship Objects come into play.
     if ($action == 'create' && is_null($content) || $typeId == 'Folder') {
         $type = 'folder';
     } else {
         $type = 'document';
     }
     $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt());
     $success = false;
     $error = null;
     if ($action == 'create') {
         if ($type == 'folder') {
             $newObjectId = $ObjectService->createFolder($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId);
         } else {
             $newObjectId = $ObjectService->createDocument($repositoryId, ucwords($cmisObjectProperties['ObjectTypeId']), $properties, $folderId, $content);
         }
         // check if returned Object Id is a valid CMIS Object Id
         CMISUtil::decodeObjectId($newObjectId, $typeId);
         if ($typeId != 'Unknown') {
             $success = true;
         } else {
             $error = $newObjectId['message'];
         }
     } else {
         if ($action == 'move') {
             $response = $ObjectService->moveObject($repositoryId, $objectId, '', $folderId);
             if (!PEAR::isError($response)) {
                 $success = true;
             } else {
                 $error = $response->getMessage();
             }
             // same object as before
             $newObjectId = $objectId;
             $typeId = ucwords($type);
         }
     }
     if ($success) {
         $this->setStatus($action == 'create' ? self::STATUS_CREATED : self::STATUS_UPDATED);
         $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $newObjectId, 'POST');
     } else {
         $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $error);
     }
     //Expose the responseFeed
     $this->responseFeed = $feed;
 }