diff --git a/ktatompub/services/cmis/ObjectFeed.inc.php b/ktatompub/services/cmis/ObjectFeed.inc.php
new file mode 100644
index 0000000..461695d
--- /dev/null
+++ b/ktatompub/services/cmis/ObjectFeed.inc.php
@@ -0,0 +1,87 @@
+newEntry();
+ $feed->newId('urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'] . '-'
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry);
+
+ /*
+
+
+
+ */
+
+ // links
+// $link = $feed->newElement('link');
+// $link->appendChild($feed->newAttr('rel','self'));
+// $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
+// . '/' . $cmisEntry['properties']['ObjectId']['value']));
+// $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-parent'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent));
+ $entry->appendChild($link);
+
+ if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder')
+ {
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-folderparent'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent));
+ $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-children'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['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_BASE_URI
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
+ . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/descendants'));
+ $entry->appendChild($link);
+ }
+
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-type'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'type/' . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])));
+ $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-repository'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'repository'));
+ $entry->appendChild($link);
+ // end links
+
+ $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value']));
+ $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value']));
+
+ // main CMIS entry
+ $objectElement = $feed->newElement('cmis:object');
+ $propertiesElement = $feed->newElement('cmis:properties');
+ // D2
+
+ foreach($cmisEntry['properties'] as $propertyName => $property)
+ {
+ $propElement = $feed->newElement('cmis:' . $property['type']);
+ $propElement->appendChild($feed->newAttr('cmis:name', $propertyName));
+ $feed->newField('value', CMISUtil::boolToString($property['value']), $propElement);
+ $propertiesElement->appendChild($propElement);
+ }
+
+ $objectElement->appendChild($propertiesElement);
+ $entry->appendChild($objectElement);
+ }
+
+}
+
+?>
diff --git a/ktatompub/services/cmis/document.inc.php b/ktatompub/services/cmis/document.inc.php
index 75de987..046dbb8 100644
--- a/ktatompub/services/cmis/document.inc.php
+++ b/ktatompub/services/cmis/document.inc.php
@@ -4,20 +4,9 @@
* Document access/management functions for CMIS AtomPub
* Output returned as an AtomPub feed
*/
+include 'services/cmis/ObjectFeed.inc.php';
-include 'services/cmis/RepositoryService.inc.php';
-include 'services/cmis/ObjectService.inc.php';
-
-$RepositoryService = new RepositoryService();
-$repositories = $RepositoryService->getRepositories();
-$repositoryId = $repositories[0]['repositoryId'];
-
-$ObjectService = new ObjectService();
-$ObjectService->startSession($username, $password);
-
-$output = CMISDocumentFeed::getDocumentFeed($ObjectService, $repositoryId, $query[2]);
-
-class CMISDocumentFeed {
+class CMISDocumentFeed extends CMISObjectFeed {
/**
* Retrieves data about a specific document
@@ -29,6 +18,17 @@ class CMISDocumentFeed {
*/
static public function getDocumentFeed($ObjectService, $repositoryId, $documentId)
{
+ $cmisEntry = $ObjectService->getProperties($repositoryId, $documentId, false, false);
+
+ $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, $cmisEntry['properties']['ObjectTypeId']['value'], null, null, null,
+ 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value']);
+
+ CMISDocumentFeed::createEntry($feed, $cmisEntry, $cmisEntry['properties']['ParentId']['value']);
+
+ // false
+
+ $output = $feed->getAPPdoc();
+
// $documentData = $ObjectService->getProperties($repositoryId, $documentId, false, false);
//
// $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, 'Root Folder Children', null, null, null,
@@ -88,7 +88,7 @@ class CMISDocumentFeed {
// // false
//
// $output = $feed->getAPPdoc();
- $output = '
+ $outputs = '
admin
@@ -142,4 +142,16 @@ class CMISDocumentFeed {
}
+include 'services/cmis/RepositoryService.inc.php';
+include 'services/cmis/ObjectService.inc.php';
+
+$RepositoryService = new RepositoryService();
+$repositories = $RepositoryService->getRepositories();
+$repositoryId = $repositories[0]['repositoryId'];
+
+$ObjectService = new ObjectService();
+$ObjectService->startSession($username, $password);
+
+$output = CMISDocumentFeed::getDocumentFeed($ObjectService, $repositoryId, $query[2]);
+
?>
diff --git a/ktatompub/services/cmis/folder.inc.php b/ktatompub/services/cmis/folder.inc.php
index 337317b..c817f94 100644
--- a/ktatompub/services/cmis/folder.inc.php
+++ b/ktatompub/services/cmis/folder.inc.php
@@ -5,30 +5,9 @@
* Output returned as an AtomPub feed
*/
-include 'services/cmis/RepositoryService.inc.php';
-include 'services/cmis/NavigationService.inc.php';
-include 'services/cmis/ObjectService.inc.php';
+include 'services/cmis/ObjectFeed.inc.php';
-$RepositoryService = new RepositoryService();
-$repositories = $RepositoryService->getRepositories();
-$repositoryId = $repositories[0]['repositoryId'];
-
-if (isset($query[3]) && (($query[3] == 'children') || ($query[3] == 'descendants')))
-{
- $NavigationService = new NavigationService();
- $NavigationService->startSession($username, $password);
-
- $output = CMISFolderFeed::getFolderChildrenFeed($NavigationService, $repositoryId, $query[2], $query[3]);
-}
-else
-{
- $ObjectService = new ObjectService();
- $ObjectService->startSession($username, $password);
-
- $output = CMISFolderFeed::getFolderFeed($ObjectService, $repositoryId, $query[2]);
-}
-
-class CMISFolderFeed {
+class CMISFolderFeed extends CMISObjectFeed {
/**
* Retrieves children/descendants of the specified folder
@@ -55,7 +34,7 @@ class CMISFolderFeed {
}
$feed = new KTCMISAPPFeed(KT_APP_BASE_URI, $folderName . ' Children', null, null, null,
- 'urn:' . $cmisEntry['properties']['ObjectId']['value'] . '-children');
+ 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'] . '-children');
foreach($entries as $cmisEntry)
{
@@ -501,86 +480,29 @@ class CMISFolderFeed {
return $output;
}
- /**
- * Creates an AtomPub entry for a CMIS entry and adds it to the supplied feed
- *
- * @param object $feed The feed to which we add the entry
- * @param array $cmisEntry The entry data
- * @param string $parent The parent folder
- */
- function createEntry(&$feed, $cmisEntry, $parent)
- {
- $entry = $feed->newEntry();
- $feed->newId('urn:' . $cmisEntry['properties']['ObjectId']['value'] . '-'
- . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry);
+}
- /*
-
-
-
- */
-
- // links
-// $link = $feed->newElement('link');
-// $link->appendChild($feed->newAttr('rel','self'));
-// $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
-// . '/' . $cmisEntry['properties']['ObjectId']['value']));
-// $entry->appendChild($link);
- $link = $feed->newElement('link');
- $link->appendChild($feed->newAttr('rel','cmis-parent'));
- $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent));
- $entry->appendChild($link);
-
- if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder')
- {
- $link = $feed->newElement('link');
- $link->appendChild($feed->newAttr('rel','cmis-folderparent'));
- $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent));
- $entry->appendChild($link);
- $link = $feed->newElement('link');
- $link->appendChild($feed->newAttr('rel','cmis-children'));
- $link->appendChild($feed->newAttr('href', CMIS_BASE_URI
- . strtolower($cmisEntry['properties']['ObjectTypeId']['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_BASE_URI
- . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
- . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/descendants'));
- $entry->appendChild($link);
- }
+include 'services/cmis/RepositoryService.inc.php';
+include 'services/cmis/NavigationService.inc.php';
+include 'services/cmis/ObjectService.inc.php';
- $link = $feed->newElement('link');
- $link->appendChild($feed->newAttr('rel','cmis-type'));
- $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'type/' . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])));
- $entry->appendChild($link);
- $link = $feed->newElement('link');
- $link->appendChild($feed->newAttr('rel','cmis-repository'));
- $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'repository'));
- $entry->appendChild($link);
- // end links
-
- $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value']));
- $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value']));
-
- // main CMIS entry
- $objectElement = $feed->newElement('cmis:object');
- $propertiesElement = $feed->newElement('cmis:properties');
- // D2
-
- foreach($cmisEntry['properties'] as $propertyName => $property)
- {
- $propElement = $feed->newElement('cmis:' . $property['type']);
- $propElement->appendChild($feed->newAttr('cmis:name', $propertyName));
- $feed->newField('value', CMISUtil::boolToString($property['value']), $propElement);
- $propertiesElement->appendChild($propElement);
- }
+$RepositoryService = new RepositoryService();
+$repositories = $RepositoryService->getRepositories();
+$repositoryId = $repositories[0]['repositoryId'];
- $objectElement->appendChild($propertiesElement);
- $entry->appendChild($objectElement);
- }
+if (isset($query[3]) && (($query[3] == 'children') || ($query[3] == 'descendants')))
+{
+ $NavigationService = new NavigationService();
+ $NavigationService->startSession($username, $password);
+
+ $output = CMISFolderFeed::getFolderChildrenFeed($NavigationService, $repositoryId, $query[2], $query[3]);
+}
+else
+{
+ $ObjectService = new ObjectService();
+ $ObjectService->startSession($username, $password);
+ $output = CMISFolderFeed::getFolderFeed($ObjectService, $repositoryId, $query[2]);
}
?>
diff --git a/ktatompub/services/cmis/index.php b/ktatompub/services/cmis/index.php
index dd09035..bd8acc5 100644
--- a/ktatompub/services/cmis/index.php
+++ b/ktatompub/services/cmis/index.php
@@ -32,7 +32,7 @@ switch($arg)
include('services/cmis/checkedout.inc.php');
break;
case 'document':
- include('services/cmis/folder.inc.php');
+ include('services/cmis/document.inc.php');
break;
case 'folder':
include('services/cmis/folder.inc.php');
diff --git a/lib/api/ktcmis/ktcmis.inc.php b/lib/api/ktcmis/ktcmis.inc.php
index a39183d..c13464a 100644
--- a/lib/api/ktcmis/ktcmis.inc.php
+++ b/lib/api/ktcmis/ktcmis.inc.php
@@ -372,6 +372,12 @@ class KTObjectService extends KTCMISBase {
// instantiate underlying CMIS service
$this->ObjectService = new CMISObjectService();
}
+
+ public function startSession($username, $password)
+ {
+ parent::startSession($username, $password);
+ $this->ObjectService->setInterface($this->ktapi);
+ }
/**
* Gets the properties for the selected object
@@ -387,7 +393,7 @@ class KTObjectService extends KTCMISBase {
public function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
$returnVersion = false, $filter = '')
{
- $propertiesResult = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships);
+ $propertyCollection = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships);
if (PEAR::isError($propertiesResult))
{
@@ -397,17 +403,7 @@ class KTObjectService extends KTCMISBase {
);
}
- // will need to convert to array format, so:
- $propertyCollection['objectId'] = $propertiesResult->getValue('objectId');
- $propertyCollection['URI'] = $propertiesResult->getValue('URI');
- $propertyCollection['typeId'] = $propertiesResult->getValue('typeId');
- $propertyCollection['createdBy'] = $propertiesResult->getValue('createdBy');
- $propertyCollection['creationDate'] = $propertiesResult->getValue('creationDate');
- $propertyCollection['lastModifiedBy'] = $propertiesResult->getValue('lastModifiedBy');
- $propertyCollection['lastModificationDate'] = $propertiesResult->getValue('lastModificationDate');
- $propertyCollection['changeToken'] = $propertiesResult->getValue('changeToken');
-
- $properties = array(array('properties' => $propertyCollection, 'child' => null));
+ $properties = CMISUtil::createObjectPropertiesEntry($propertyCollection);
return array(
"status_code" => 0,
diff --git a/lib/api/ktcmis/services/CMISObjectService.inc.php b/lib/api/ktcmis/services/CMISObjectService.inc.php
index 2448a46..710f2c3 100644
--- a/lib/api/ktcmis/services/CMISObjectService.inc.php
+++ b/lib/api/ktcmis/services/CMISObjectService.inc.php
@@ -11,10 +11,15 @@ class CMISObjectService {
protected $ktapi;
-// function CMISObjectService(&$ktapi)
-// {
-// $this->ktapi = $ktapi;
-// }
+ /**
+ * Sets the interface to be used to query the repository
+ *
+ * @param object $ktapi The KnowledgeTree API interface
+ */
+ function setInterface(&$ktapi)
+ {
+ $this->ktapi = $ktapi;
+ }
/**
* Fetches the properties for the specified object
diff --git a/lib/api/ktcmis/util/CMISUtil.inc.php b/lib/api/ktcmis/util/CMISUtil.inc.php
index 4dd9a07..0cbfc21 100644
--- a/lib/api/ktcmis/util/CMISUtil.inc.php
+++ b/lib/api/ktcmis/util/CMISUtil.inc.php
@@ -221,43 +221,57 @@ class CMISUtil {
$object = $entry['object'];
$properties = $object->getProperties();
- // TODO additional properties to be returned
- $hierarchy[$key]['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'),
- 'value' => $properties->getValue('ObjectId'));
- $hierarchy[$key]['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'),
- 'value' => $properties->getValue('BaseType'));
- $hierarchy[$key]['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'),
- 'value' => $properties->getValue('ObjectTypeId'));
- $hierarchy[$key]['properties']['Name'] = array('type' => $properties->getFieldType('Name'),
- 'value' => $properties->getValue('Name'));
- $hierarchy[$key]['Author'] = array('value' => $properties->getValue('Author'));
- if (strtolower($properties->getValue('ObjectTypeId')) == 'folder')
- {
- $hierarchy[$key]['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'),
- 'value' => CMISUtil::encodeObjectId('Folder',
- $properties->getValue('ParentId')));
- } else {
- $hierarchy[$key]['properties']['ContentStreamLength'] = array('type' => $properties->getFieldType('ContentStreamLength'),
- 'value' => $properties->getValue('ContentStreamLength'));
- $hierarchy[$key]['properties']['ContentStreamMimeType'] = array('type' => $properties->getFieldType('ContentStreamMimeType'),
- 'value' => $properties->getValue('ContentStreamMimeType'));
- }
- // if we have found a child/parent with one or more children/parents, recurse into the child/parent object
- if (count($entry['items']) > 0)
- {
- $hierarchy[$key][$linkText] = CMISUtil::decodeObjectHierarchy($entry['items'], $linkText);
- }
- // NOTE may need to set a null value here in case webservices don't like it unset
- // so we'll set it just in case...
- else
- {
- $hierarchy[$key][$linkText] = null;
- }
+ $hierarchy[$key] = CMISUtil::createObjectPropertiesEntry($properties);
}
return $hierarchy;
}
+ static function createObjectPropertiesEntry($properties)
+ {
+ $object = array();
+
+ // TODO additional properties to be returned
+ $object['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'),
+ 'value' => $properties->getValue('ObjectId'));
+ $object['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'),
+ 'value' => $properties->getValue('BaseType'));
+ $object['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'),
+ 'value' => $properties->getValue('ObjectTypeId'));
+ $object['properties']['Name'] = array('type' => $properties->getFieldType('Name'),
+ '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')));
+ }
+ // TODO should check for content stream data before filling these in
+ else //if ()
+ {
+ $object['properties']['ContentStreamLength'] = array('type' => $properties->getFieldType('ContentStreamLength'),
+ 'value' => $properties->getValue('ContentStreamLength'));
+ $object['properties']['ContentStreamMimeType'] = array('type' => $properties->getFieldType('ContentStreamMimeType'),
+ 'value' => $properties->getValue('ContentStreamMimeType'));
+ }
+
+ // if we have found a child/parent with one or more children/parents, recurse into the child/parent object
+ if (count($entry['items']) > 0)
+ {
+ $object[$linkText] = CMISUtil::decodeObjectHierarchy($entry['items'], $linkText);
+ }
+ // NOTE may need to set a null value here in case webservices don't like it unset
+ // so we'll set it just in case...
+ else
+ {
+ $object[$linkText] = null;
+ }
+
+ return $object;
+ }
+
/**
* This function takes a class object and converts it to an array structure
* via var_export (which returns a useable PHP string for creating the object from array content)