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; }
/** * Retrieves a list of child types for the supplied type * * NOTE this currently returns a hard coded empty list, since we do not currently support child types * TODO make dynamic if/when we support checking for child types (we don't actually need to support child types themselves) * * @param string $type * @return string CMIS AtomPub feed */ private function getTypeChildrenFeed() { //Create a new response feed // $baseURI=NULL,$title=NULL,$link=NULL,$updated=NULL,$author=NULL,$id=NULL $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); $feed->newField('title', 'Child Types of ' . ucwords($this->params[0]), $feed); $feed->newField('id', $this->params[0] . '-children', $feed); // TODO fetch child types - to be implemented when we support child types in the API // links $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel', 'first')); $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . 'type/' . $this->params[0] . '/' . $this->params[1] . '?pageNo=1&pageSize=0')); $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed')); $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel', 'last')); // TODO set page number correctly - to be done when we support paging the the API $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . 'type/' . $this->params[0] . '/' . $this->params[1] . '?pageNo=1&pageSize=0')); $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed')); $feed->newField('updated', KT_cmis_atom_service_helper::formatDatestamp(), $feed); $feed->newField('cmis:hasMoreItems', 'false', $feed); return $feed; }
/** * 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); }
/** * Get the KT singleton instance * * @return object */ public static function getKt() { if (!isset(self::$kt)) { self::$kt = new KTAPI(); self::$kt->get_active_session(session_id()); } return self::$kt; }