/** * Retrieves data about a specific folder OR document within a folder * * @param object $ObjectService The CMIS service * @param string $repositoryId * @param string $folderId * @return string CMIS AtomPub feed */ public static function getObjectFeed(&$service, $ObjectService, $repositoryId, $objectId, $method = 'GET') { $serviceType = $service->getServiceType(); $response = $ObjectService->getProperties($repositoryId, $objectId, false, false); if (PEAR::isError($response)) { return KT_cmis_atom_service_helper::getErrorFeed($service, KT_cmis_atom_service::STATUS_SERVER_ERROR, $response->getMessage()); } $cmisEntry = $response; $response = null; // POST/PWC responses only send back an entry, not a feed if ($serviceType == 'PWC' || $method == 'POST') { if ($method == 'POST') { $response = new KT_cmis_atom_response_POST(CMIS_APP_BASE_URI); } else { $response = new KT_cmis_atom_response_GET(CMIS_APP_BASE_URI); } } else { if ($method == 'GET') { $response = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); $response->newField('title', $cmisEntry['properties']['ObjectTypeId']['value'], $response); $response->newField('id', 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'], $response); } } if ($serviceType == 'PWC') { $pwc = true; } else { $pwc = false; } KT_cmis_atom_service_helper::createObjectEntry($response, $cmisEntry, $cmisEntry['properties']['ParentId']['value'], $pwc, $method); // Don't think this should be here...only one item so why would we need to say there are no more? /*if ($method == 'GET') { $response->newField('cmis:hasMoreItems', 'false', $response); }*/ return $response; }
public function PUT_action() { // call the checkin function $RepositoryService = new RepositoryService(); $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); $repositories = $RepositoryService->getRepositories(); $repositoryId = $repositories[0]['repositoryId']; $response = $VersioningService->checkIn($repositoryId, $this->params[0]); if (PEAR::isError($response)) { $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response->getMessage()); //Expose the responseFeed $this->responseFeed = $feed; return null; } $this->setStatus(self::STATUS_NO_CONTENT); $this->responseFeed = null; }
/** * Fetches and prepares the document content stream for download/viewing * * @param object $ObjectService * @param string $repositoryId * @return null | nothing */ public static function downloadContentStream(&$service, &$ObjectService, $repositoryId) { $response = $ObjectService->getProperties($repositoryId, $service->params[0], false, false); if (PEAR::isError($response)) { $feed = KT_cmis_atom_service_helper::getErrorFeed($service, KT_cmis_atom_service::STATUS_SERVER_ERROR, $response->getMessage()); $service->responseFeed = $feed; return null; } // TODO also check If-Modified-Since? // $service->headers['If-Modified-Since'] => 2009-07-24 17:16:54 $service->setContentDownload(true); $eTag = md5($response['properties']['LastModificationDate']['value'] . $response['properties']['ContentStreamLength']['value']); if ($service->headers['If-None-Match'] == $eTag) { $service->setStatus(KT_cmis_atom_service::STATUS_NOT_MODIFIED); $service->setContentDownload(false); return null; } $contentStream = $ObjectService->getContentStream($repositoryId, $service->params[0]); // headers specific to output $service->setEtag($eTag); $service->setHeader('Last-Modified', $response['properties']['LastModificationDate']['value']); if (!empty($response['properties']['ContentStreamMimeType']['value'])) { $service->setHeader('Content-type', $response['properties']['ContentStreamMimeType']['value'] . ';charset=utf-8'); } else { $service->setHeader('Content-type', 'text/plain;charset=utf-8'); } $service->setHeader('Content-Disposition', 'attachment;filename="' . $response['properties']['ContentStreamFilename']['value'] . '"'); $service->setHeader('Content-Length', $response['properties']['ContentStreamLength']['value']); $service->setOutput($contentStream); }
public function POST_action() { $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService); $VersioningService = new VersioningService(KT_cmis_atom_service_helper::getKt()); $ObjectService = new ObjectService(KT_cmis_atom_service_helper::getKt()); $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']); // check for existing object id as property of submitted object data if (empty($cmisObjectProperties['ObjectId'])) { $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout'); // Expose the responseFeed $this->responseFeed = $feed; return null; } $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['ObjectId']); if (PEAR::isError($response)) { $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout'); // Expose the responseFeed $this->responseFeed = $feed; return null; } $this->setStatus(self::STATUS_CREATED); $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $cmisObjectProperties['ObjectId'], 'POST'); // Expose the responseFeed $this->responseFeed = $feed; }