diff --git a/lib/api/ktcmis/config/repositories.xml b/lib/api/ktcmis/config/repositories.xml
index 8f65088..71ed7ad 100644
--- a/lib/api/ktcmis/config/repositories.xml
+++ b/lib/api/ktcmis/config/repositories.xml
@@ -13,7 +13,7 @@
http://127.0.0.1/
0ad7de04-7914-41b1-b5ee-be9f0b626437
- KnowledgeTree
+ KnowledgeTree DMS
self
KnowledgeTree Repository
KnowledgeTree
diff --git a/lib/api/ktcmis/ktcmis.inc.php b/lib/api/ktcmis/ktcmis.inc.php
index 2a40345..88fc291 100644
--- a/lib/api/ktcmis/ktcmis.inc.php
+++ b/lib/api/ktcmis/ktcmis.inc.php
@@ -70,18 +70,23 @@ class KTCMISBase {
// TODO try to pick up existing session if possible, i.e. if the $session value is not empty
public function startSession($username, $password)
{
- if (is_null(self::$session))
+// echo $username." :: ".$password."
";
+ // attempt to recover session if one exists
+ if (!is_null(self::$session) && !PEAR::isError(self::$session))
{
- self::$ktapi = new KTAPI();
- self::$session =& self::$ktapi->start_session($username, $password);
+// echo "ATTEMPT TO RECOVER SESSION: ".print_r(self::$session, true)."
\n";
+ self::$session =& self::$ktapi->get_active_session(self::$session->get_sessionid());
}
- else
+
+ // start new session if no existing session or problem getting existing session (expired, etc...)
+ if (is_null(self::$session) || PEAR::isError(self::$session))
{
- // add session restart code here
- self::$session =& self::$ktapi->get_active_session(self::$session->get_sessionid());
+// echo "ATTEMPT TO START NEW SESSION
\n";
+ self::$ktapi = new KTAPI();
+ self::$session =& self::$ktapi->start_session($username, $password);
}
- //var_dump(self::$ktapi);
+// print_r(self::$ktapi);
return self::$session;
}
@@ -90,6 +95,11 @@ class KTCMISBase {
return self::$ktapi;
}
+ public function getSession()
+ {
+ return self::$session;
+ }
+
// TODO what about destroying sessions? only on logout (which is not offered by the CMIS clients tested so far)
}
diff --git a/lib/api/ktcmis/objecttypes/CMISDocumentObject.inc.php b/lib/api/ktcmis/objecttypes/CMISDocumentObject.inc.php
index cd9024e..6307e30 100644
--- a/lib/api/ktcmis/objecttypes/CMISDocumentObject.inc.php
+++ b/lib/api/ktcmis/objecttypes/CMISDocumentObject.inc.php
@@ -110,6 +110,7 @@ class CMISDocumentObject extends CMISBaseObject {
}
$objectProperties = $object->get_detail();
+// print_r($objectProperties);
$this->_setPropertyInternal('ObjectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['document_id']));
// prevent doubled '/' chars
@@ -131,6 +132,7 @@ class CMISDocumentObject extends CMISBaseObject {
$this->_setPropertyInternal('LastModificationDate', $objectProperties['modified_date']);
$this->_setPropertyInternal('ChangeToken', null);
$this->_setPropertyInternal('Name', $objectProperties['title']);
+ $this->_setPropertyInternal('ParentId', $objectProperties['folder_id']);
$this->_setPropertyInternal('IsImmutable', $objectProperties['is_immutable']);
// NOTE if access to older versions is allowed, this will need to be checked, else just set to yes
// see ktapi::get_document_version_history
diff --git a/lib/api/ktcmis/services/CMISObjectService.inc.php b/lib/api/ktcmis/services/CMISObjectService.inc.php
index 0a7f0e3..0ddab6f 100644
--- a/lib/api/ktcmis/services/CMISObjectService.inc.php
+++ b/lib/api/ktcmis/services/CMISObjectService.inc.php
@@ -262,6 +262,12 @@ class CMISObjectService {
throw new ConstraintViolationException('Parent folder may not hold objects of this type (' . $typeId . ')');
}
+ // TODO if name is blank! throw another exception (check type) - using RuntimeException for now
+ if (trim($properties['name']) == '')
+ {
+ throw new RuntimeException('Refusing to create an un-named folder');
+ }
+
$response = $this->ktapi->create_folder((int)$folderId, $properties['name'], $sig_username = '', $sig_password = '', $reason = '');
if ($response['status_code'] != 0)
{
diff --git a/lib/api/ktcmis/util/CMISUtil.inc.php b/lib/api/ktcmis/util/CMISUtil.inc.php
index 8740f84..8506d54 100644
--- a/lib/api/ktcmis/util/CMISUtil.inc.php
+++ b/lib/api/ktcmis/util/CMISUtil.inc.php
@@ -86,6 +86,12 @@ class CMISUtil {
*/
static public function decodeObjectId($objectId, &$typeId = null)
{
+ if (!is_string($objectId))
+ {
+ $typeId = 'Unknown';
+ return null;
+ }
+
$typeId = null;
preg_match('/(\D)(\d*)/', $objectId, $matches);
@@ -240,14 +246,11 @@ class CMISUtil {
'value' => $properties->getValue('Name'));
$object['Author'] = array('value' => $properties->getValue('Author'));
- if (strtolower($properties->getValue('ObjectTypeId')) == 'folder')
- {
- $object['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'),
- 'value' => CMISUtil::encodeObjectId('Folder',
- $properties->getValue('ParentId')));
- }
+ $object['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'),
+ 'value' => CMISUtil::encodeObjectId('Folder',
+ $properties->getValue('ParentId')));
// TODO should check for content stream data before filling these in
- else //if ()
+ if (strtolower($properties->getValue('ObjectTypeId')) == 'document')
{
$object['properties']['ContentStreamLength'] = array('type' => $properties->getFieldType('ContentStreamLength'),
'value' => $properties->getValue('ContentStreamLength'));
diff --git a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
index f50e48b..dbbacf7 100644
--- a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
+++ b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
@@ -17,14 +17,15 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service
{
public function GET_action()
{
- $username = $password = 'admin';
$RepositoryService = new RepositoryService();
- $RepositoryService->startSession($username, $password);
+ $RepositoryService->startSession(self::$authData['username'], self::$authData['password']);
$repositories = $RepositoryService->getRepositories();
$repositoryId = $repositories[0]['repositoryId'];
-//var_dump($RepositoryService->ktapi);
-// $folderId = $this->getFolderData();
+ // TODO implement full path/node separation as with Alfresco - i.e. path requests come in on path/ and node requests come in on node/
+ // path request e.g.: Root Folder/DroppedDocuments
+ // node request e.g.: F1/children
+ // node request e.g.: F2
if (urldecode($this->params[0]) == 'Root Folder')
{
$folderId = CMISUtil::encodeObjectId('Folder', 1);
@@ -35,35 +36,28 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service
{
$ktapi =& $RepositoryService->getInterface();
$folderId = KT_cmis_atom_service_helper::getFolderId($this->params, $ktapi);
-// echo "DA FOLDER ID IS $folderId
";
}
else
{
$folderId = $this->params[0];
-// // get folder name from id, using the ObjectService methods
-// $ObjectService = new ObjectService();
-//// var_dump($ObjectService->ktapi);
-// $ObjectService->setInterface();
-// $cmisProps = $ObjectService->getProperties($repositoryId, $folderId, false, false);
-//// var_dump($cmisObject);
-//// $props = $cmisObject->getProperties();
-//// var_dump($props);
-// $folderName = $cmisProps['properties']['Name']['value'];
+ $ObjectService = new ObjectService();
+ $ObjectService->startSession(self::$authData['username'], self::$authData['password']);
+ $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false);
+ $folderName = $cmisEntry['properties']['Name']['value'];
+// $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $newObjectId, $cmisEntry['properties']['Name']['value']);
}
- $username = $password = 'admin';
if (!empty($this->params[1]) && (($this->params[1] == 'children') || ($this->params[1] == 'descendants')))
{
$NavigationService = new NavigationService();
- $NavigationService->startSession($username, $password);
+ $NavigationService->startSession(self::$authData['username'], self::$authData['password']);
$feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $folderName, $this->params[1]);
}
else
{
-// echo "UHUHUHUHUH: $folderId
\n";
$ObjectService = new ObjectService();
- $ObjectService->startSession($username, $password);
+ $ObjectService->startSession(self::$authData['username'], self::$authData['password']);
$feed = $this->getFolderFeed($ObjectService, $repositoryId, $folderId);
}
@@ -71,6 +65,84 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service
//Expose the responseFeed
$this->responseFeed = $feed;
}
+
+ public function POST_action()
+ {
+// $username = $password = 'admin';
+ $RepositoryService = new RepositoryService();
+ $RepositoryService->startSession(self::$authData['username'], self::$authData['password']);
+ $repositories = $RepositoryService->getRepositories();
+ $repositoryId = $repositories[0]['repositoryId'];
+
+ $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 create
+ // document create will have a content tag or containing base64 encoding of the document
+ $content = KT_cmis_atom_service_helper::getAtomValues($this->parsedXMLContent['@children'], 'content');
+ if (is_null($content))
+ $type = 'folder';
+ else
+ $type = 'document';
+
+ // TODO what if mime-type is incorrect? CMISSpaces appears to be sending text/plain on an executable file.
+ // perhaps because the content is text/plain once base64 encoded?
+ // How to determine the actual content type?
+ /*
+ *
+ * setup.txt
+ * setup.txt
+ * dGhpcyBiZSBzb21lIHRlc3QgY29udGVudCBmb3IgYSBkb2N1bWVudCwgeWVzPw==
+ *
+ *
+ * document
+ *
+ *
+ *
+ */
+
+ $cmisObjectProperties = KT_cmis_atom_service_helper::getCmisProperties($this->parsedXMLContent['@children']['cmis:object']
+ [0]['@children']['cmis:properties']
+ [0]['@children']);
+
+ $ObjectService = new ObjectService();
+ $ObjectService->startSession(self::$authData['username'], self::$authData['password']);
+ 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
+ $dummy = CMISUtil::decodeObjectId($newObjectId, $typeId);
+ if ($typeId != 'Unknown')
+ {
+ $this->setStatus(self::STATUS_CREATED);
+ if ($type == 'folder')
+ {
+ $feed = $this->getFolderFeed($ObjectService, $repositoryId, $newObjectId);
+ }
+ else
+ {
+ $NavigationService = new NavigationService();
+ $NavigationService->startSession(self::$authData['username'], self::$authData['password']);
+ $cmisEntry = $ObjectService->getProperties($repositoryId, $folderId, false, false);
+ $feed = $this->getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $cmisEntry['properties']['Name']['value']);
+ }
+ }
+ else
+ {
+ $this->setStatus(self::STATUS_SERVER_ERROR);
+ $feed = new KT_cmis_atom_responseFeed(CMIS_APP_BASE_URI, 'Error: ' . self::STATUS_SERVER_ERROR);
+ $entry = $feed->newEntry();
+ $feed->newField('error', $newObjectId['message'], $entry);
+ }
+
+ //Expose the responseFeed
+ $this->responseFeed = $feed;
+ }
/**
* Retrieves children/descendants of the specified folder
@@ -81,7 +153,7 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service
* @param string $feedType children or descendants
* @return string CMIS AtomPub feed
*/
- private function getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $folderName, $feedType)
+ private function getFolderChildrenFeed($NavigationService, $repositoryId, $folderId, $folderName, $feedType = 'children')
{
if ($feedType == 'children')
{
@@ -136,34 +208,6 @@ class KT_cmis_atom_service_folder extends KT_cmis_atom_service
return $feed;
}
-
- // FIXME change how the drupal module works so that we don't need this anymore
- private function getFolderData($query, &$folderName)
- {
- // FIXME really need to to avoid this!
- $ktapi = new KTAPI();
- $ktapi->start_session('admin', 'admin');
-
- $numQ = count($query);
- $numFolders = $numQ-3;
- $folderId = 1;
-
- if ($query[$numQ-1] == 'children' || $query[$numQ-1] == 'descendants')
- {
- $tree = $query[$numQ-1];
- }
-
- $start = 0;
- while($start < $numFolders-1)
- {
- $folderName = urldecode($query[$numQ-$numFolders+$start]);
- $folder = $ktapi->get_folder_by_name($folderName, $folderId);
- $folderId = $folder->get_folderid();
- ++$start;
- }
-
- return CMISUtil::encodeObjectId('Folder', $folderId);
- }
}
/**
@@ -176,11 +220,11 @@ class KT_cmis_atom_service_types extends KT_cmis_atom_service
{
public function GET_action()
{
- $username = $password = 'admin';
+// $username = $password = 'admin';
$RepositoryService = new RepositoryService();
// technically do not need to log in to access this information
// TODO consider requiring authentication even to access basic repository information
- $RepositoryService->startSession($username, $password);
+ $RepositoryService->startSession(self::$authData['username'], self::$authData['password']);
// fetch repository id
$repositories = $RepositoryService->getRepositories();
@@ -205,11 +249,11 @@ class KT_cmis_atom_service_type extends KT_cmis_atom_service
{
public function GET_action()
{
- $username = $password = 'admin';
+// $username = $password = 'admin';
$RepositoryService = new RepositoryService();
// technically do not need to log in to access this information
// TODO consider requiring authentication even to access basic repository information
- $RepositoryService->startSession($username, $password);
+ $RepositoryService->startSession(self::$authData['username'], self::$authData['password']);
// fetch repository id
$repositories = $RepositoryService->getRepositories();
@@ -303,11 +347,11 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service
{
public function GET_action()
{
- $username = $password = 'admin';
+// $username = $password = 'admin';
$RepositoryService = new RepositoryService();
$NavigationService = new NavigationService();
- $NavigationService->startSession($username, $password);
+ $NavigationService->startSession(self::$authData['username'], self::$authData['password']);
$repositories = $RepositoryService->getRepositories();
$repositoryId = $repositories[0]['repositoryId'];
@@ -354,11 +398,11 @@ class KT_cmis_atom_service_document extends KT_cmis_atom_service
{
public function GET_action()
{
- $username = $password = 'admin';
+// $username = $password = 'admin';
$RepositoryService = new RepositoryService();
$ObjectService = new ObjectService();
- $ObjectService->startSession($username, $password);
+ $ObjectService->startSession(self::$authData['username'], self::$authData['password']);
$repositories = $RepositoryService->getRepositories();
$repositoryId = $repositories[0]['repositoryId'];
diff --git a/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php b/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
index 10b9fd0..aa8655d 100644
--- a/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
+++ b/webservice/atompub/cmis/KT_cmis_atom_service_helper.inc.php
@@ -16,20 +16,22 @@ class KT_cmis_atom_service_helper {
// . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry);
// echo $_SERVER['QUERY_STRING']."
\n";
- preg_match('/^\/?[^\/]*\/folder\/(.*)\/[^\/]*\/?$/', trim($_SERVER['QUERY_STRING'], '/'), $matches);
- $path = $matches[1];
- $parent = preg_replace('/\/[^\/]*$/', '', $path);
- // TODO fix path to work on old method, after fixing drupal module to not require extended path
+// preg_match('/^\/?[^\/]*\/folder\/(.*)\/[^\/]*\/?$/', trim($_SERVER['QUERY_STRING'], '/'), $matches);
+// $path = $matches[1];
+// $parent = preg_replace('/\/[^\/]*$/', '', $path);
+// // TODO fix path to work on old method, after fixing drupal module to not require extended path
+//
+// $path = '';
$id = $cmisEntry['properties']['ObjectId']['value'];
$entry = $feed->newEntry();
$feed->newField('id', 'urn:uuid:' . $id, $entry);
-
+// print_r($cmisEntry);
// links
// TODO check parent link is correct, fix if needed
$link = $feed->newElement('link');
$link->appendChild($feed->newAttr('rel','cmis-parent'));
- $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $path));
+ $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $cmisEntry['properties']['ParentId']['value']));
$entry->appendChild($link);
if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder')
@@ -37,20 +39,20 @@ class KT_cmis_atom_service_helper {
// TODO check parent link is correct, fix if needed
$link = $feed->newElement('link');
$link->appendChild($feed->newAttr('rel','cmis-folderparent'));
- $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $path));
+ $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/folder/' . $cmisEntry['properties']['ParentId']['value']));
$entry->appendChild($link);
$link = $feed->newElement('link');
$link->appendChild($feed->newAttr('rel','cmis-children'));
$link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/'
. strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
- . '/' . $path . '/' . rawurlencode($cmisEntry['properties']['Name']['value'])
+ . '/' . $cmisEntry['properties']['ObjectId']['value']
. '/children'));
$entry->appendChild($link);
$link = $feed->newElement('link');
$link->appendChild($feed->newAttr('rel','cmis-descendants'));
$link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $feed->workspace . '/'
. strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
- . '/' . $path . '/' . rawurlencode($cmisEntry['properties']['Name']['value'])
+ . '/' . $cmisEntry['properties']['ObjectId']['value']
. '/descendants'));
$entry->appendChild($link);
}
@@ -164,18 +166,12 @@ class KT_cmis_atom_service_helper {
// TODO make this much more efficient than this messy method
static public function getFolderId($path, &$ktapi)
{
-// static public function getFolderData($query, &$folderName, &$tree)
-// $ktapi = new KTAPI();
-// $ktapi->start_session('admin', 'admin');
-
// lose first item
array_shift($path);
$numQ = count($path);
-// echo $numQ."
";
$numFolders = $numQ;
$folderId = 1;
-// echo $numFolders."
";
$start = 0;
while($start < $numFolders)
@@ -184,10 +180,7 @@ class KT_cmis_atom_service_helper {
// hack to fix drupal url encoding issue
$name = str_replace('%2520', '%20', $name);
-// echo $name."
";
-
$folderName = urldecode($name);
-// echo $folderName."
";
$folder = $ktapi->get_folder_by_name($folderName, $folderId);
$folderId = $folder->get_folderid();
++$start;
@@ -196,6 +189,31 @@ class KT_cmis_atom_service_helper {
return CMISUtil::encodeObjectId('Folder', $folderId);
}
+ static public function getCmisProperties($xmlArray)
+ {
+ $properties = array();
+
+ foreach($xmlArray as $cmisPropertyDefinition)
+ {
+ foreach($cmisPropertyDefinition as $propertyType => $propertyDefinition)
+ {
+ $properties[$propertyDefinition['@attributes']['cmis:name']] = $propertyDefinition['@children']['cmis:value'][0]['@value'];
+ }
+ }
+
+ return $properties;
+ }
+
+ static public function getAtomValues($xmlArray, $tag)
+ {
+ if (!is_null($xmlArray['atom:'.$tag]))
+ return $xmlArray['atom:'.$tag][0]['@value'];
+ else if (!is_null($xmlArray[$tag]))
+ return $xmlArray[$tag][0]['@value'];
+
+ return null;
+ }
+
}
?>
diff --git a/webservice/atompub/cmis/index.php b/webservice/atompub/cmis/index.php
index 2cc1c61..b6c9570 100644
--- a/webservice/atompub/cmis/index.php
+++ b/webservice/atompub/cmis/index.php
@@ -59,6 +59,7 @@ $password = $_SERVER['PHP_AUTH_PW'];
/**
* Includes
*/
+include_once(KT_ATOM_LIB_FOLDER.'XMLns2array.inc.php');
include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_server.inc.php');
include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_baseDoc.inc.php');
include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation
@@ -66,7 +67,6 @@ include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_serviceDoc.inc.php'); /
include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_service.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation
include_once('KT_cmis_atom_server.services.inc.php');
-
//Start the AtomPubProtocol Routing Engine
$APP = new KT_cmis_atom_server();
@@ -91,7 +91,6 @@ $APP->addWorkspaceTag('dms','atom:title',$APP->repositoryInfo['repositoryName'])
* http://ktatompub/{folder/folder2/folder3/}service/param1/param2
*/
// TODO consider a registerServices function which will, dependant on what is requested, register the appropriate services, keep the logic out of the index file
-// FIXME HACK! this should not happen every time, ONLY on a service doc request, except for request specific collection links
$APP->registerService('dms', 'folder', 'KT_cmis_atom_service_folder', 'Root Folder Children Collection',
array(rawurlencode($APP->repositoryInfo['rootFolderId']), 'children'), 'root-children');
$APP->registerService('dms', 'folder', 'KT_cmis_atom_service_folder', 'Root Folder Children Collection',
diff --git a/webservice/classes/atompub/KT_atom_server.inc.php b/webservice/classes/atompub/KT_atom_server.inc.php
index f3c3941..91bb1ca 100644
--- a/webservice/classes/atompub/KT_atom_server.inc.php
+++ b/webservice/classes/atompub/KT_atom_server.inc.php
@@ -21,11 +21,10 @@ class KT_atom_server{
*
*/
public function execute(){
-// $_SERVER['QUERY_STRING'] = urldecode($_SERVER['QUERY_STRING']);
$reqMethod=trim(strtoupper($_SERVER['REQUEST_METHOD']));
$queryArray=split('/',trim($_SERVER['QUERY_STRING'],'/'));
$rawRequest=@file_get_contents('php://input');
-//echo "\n\n".rawurldecode($_SERVER['QUERY_STRING'])."
\n\n";
+
$workspace=strtolower(trim($queryArray[0]));
$serviceName=strtolower(trim($queryArray[1]));
$requestParams=array_slice($queryArray,2);
@@ -33,7 +32,7 @@ class KT_atom_server{
$this->serviceName=$serviceName;
$this->method=$reqMethod;
$this->workspace=$workspace;
-
+
if($workspace=='servicedocument'){
$this->serviceDocument();
return;
diff --git a/webservice/classes/atompub/KT_atom_service.inc.php b/webservice/classes/atompub/KT_atom_service.inc.php
index 0e46afe..d59818c 100644
--- a/webservice/classes/atompub/KT_atom_service.inc.php
+++ b/webservice/classes/atompub/KT_atom_service.inc.php
@@ -1,13 +1,15 @@
responseFeed->render();
}
- protected function xml2array($xml){
- if(class_exists('')){
+ protected function xml2array($xml)
+ {
+ if (trim($xml) == '') return array();
+
+ if(class_exists('XMLns2array'))
+ {
$array=XMLns2array::parse($xml);
- }else{
- $array=json_decode(json_encode(@simplexml_load_string($xml)),true);
+ }
+ else
+ {
+ $array=json_decode(json_encode(@simplexml_load_string($xml)), true);
}
return $array;
}
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
index 26225ab..f136f3d 100644
--- a/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
@@ -6,5 +6,31 @@ class KT_cmis_atom_service extends KT_atom_service {
// override and extend as needed
+ static protected $authData = array();
+
+ protected function parseHeaders()
+ {
+// echo "PARSE HEADERS\n";
+ parent::parseHeaders();
+// echo "CHECKING HEADERS\n";
+// print_r($this->headers);
+// print_r($_SERVER);
+ // attempt to fetch auth info from supplied headers
+ if (!empty($this->headers['Authorization']))
+ {
+ $auth = base64_decode(preg_replace('/Basic */', '', $this->headers['Authorization']));
+ $authData = explode(':', $auth);
+// print_r($authData);
+ self::$authData['username'] = $authData[0];
+ self::$authData['password'] = $authData[1];
+ }
+ // if failed, attempt to fetch from $_SERVER array instead
+ else if (isset($_SERVER['PHP_AUTH_USER']))
+ {
+ self::$authData['username'] = $_SERVER['PHP_AUTH_USER'];
+ self::$authData['password'] = $_SERVER['PHP_AUTH_PW'];
+ }
+ }
+
}
?>
\ No newline at end of file
diff --git a/webservice/classes/atompub/cmis/ObjectService.inc.php b/webservice/classes/atompub/cmis/ObjectService.inc.php
index 728de1f..90171e6 100644
--- a/webservice/classes/atompub/cmis/ObjectService.inc.php
+++ b/webservice/classes/atompub/cmis/ObjectService.inc.php
@@ -32,6 +32,59 @@ class ObjectService extends KTObjectService {
}
}
+ /**
+ * Creates a new folder within the repository
+ *
+ * @param string $repositoryId The repository to which the folder must be added
+ * @param string $typeId Object Type id for the folder object being created
+ * @param array $properties Array of properties which must be applied to the created folder object
+ * @param string $folderId The id of the folder which will be the parent of the created folder object
+ * @return string $objectId The id of the created folder object
+ */
+ function createFolder($repositoryId, $typeId, $properties, $folderId)
+ {
+ $result = parent::createFolder($repositoryId, $typeId, $properties, $folderId);
+
+ if ($result['status_code'] == 0)
+ {
+ return $result['results'];
+ }
+ else
+ {
+ return $result;
+ }
+ }
+
+ /**
+ * Creates a new document within the repository
+ *
+ * @param string $repositoryId The repository to which the document must be added
+ * @param string $typeId Object Type id for the document object being created
+ * @param array $properties Array of properties which must be applied to the created document object
+ * @param string $folderId The id of the folder which will be the parent of the created document object
+ * This parameter is optional IF unfilingCapability is supported
+ * @param contentStream $contentStream optional content stream data
+ * @param string $versioningState optional version state value: checkedout/major/minor
+ * @return string $objectId The id of the created folder object
+ */
+ // TODO throw ConstraintViolationException if:
+ // value of any of the properties violates the min/max/required/length constraints
+ // specified in the property definition in the Object-Type.
+ function createDocument($repositoryId, $typeId, $properties, $folderId = null,
+ $contentStream = null, $versioningState = null)
+ {
+ $result = parent::createDocument($repositoryId, $typeId, $properties, $folderId, $contentStream, $versioningState);
+
+ if ($result['status_code'] == 0)
+ {
+ return $result['results'];
+ }
+ else
+ {
+ return $result;
+ }
+ }
+
}
?>