<?php // initialise ktapi instance KT_cmis_atom_service_helper::$ktapi = KT_cmis_atom_service_helper::getKt(); class KT_cmis_atom_service_helper { public static $ktapi = null; public static $repositoryId = null; /** * Helper function to set internal repository id * * @param object $RepositoryService */ public static function setRepositoryId(&$RepositoryService = null) { if (is_null($RepositoryService)) { $RepositoryService = new RepositoryService(); } $repositories = $RepositoryService->getRepositories(); // TODO handle multiple repositories self::$repositoryId = $repositories[0]['repositoryId']; } /** * Helper function to fetch internal repository id * * Calls set function automatically, use $set = false to prevent this and return the current setting, if any * * NOTE the function will automatically call the setRepositoryId function if no previous repository id was set * * @param object $RepositoryService * @param boolean $RepositoryService
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; }
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; }