repositoryId = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:repositoryId');
$repository->repositoryName = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:repositoryName');
$repository->repositoryDescription = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:repositoryDescription');
$repository->vendorName = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:vendorName');
$repository->productName = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:productName');
$repository->productVersion = cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:productVersion');
$repository->rootFolderId = (string) cmis_utils_CMIS_xml_get_value($repo_info[0], 'cmis:rootFolderId');
}
return $repository;
}
/**
* Implementation of cmisapi_getChildren method
* @param $repositoryId
* @param $folderId
*/
function cmis_alfresco_cmisapi_getChildren($repositoryId, $folderId) {
module_load_include('utils.inc', 'cmis_alfresco');
$folderId = cmis_alfresco_objectId($folderId);
if ($folderId['noderef_url']) {
$url = '/api/node/' . $folderId['noderef_url'];
}
else {
$url = $folderId['url'];
}
$xml = cmis_alfresco_utils_invoke_service($url . '/children');
if (false != $xml) {
return cmis_alfresco_getEntries(cmis_utils_process_CMIS_xml($xml, '//D:entry'));
}
return false;
}
/**
* Implementation of cmisapi_getChildren method
* @param $repositoryId
* @param $folderId
*/
function cmis_alfresco_cmisapi_getObjectParents($repositoryId, $folderId) {
module_load_include('utils.inc', 'cmis_alfresco');
$folderId = cmis_alfresco_objectId($folderId);
if ($folderId['noderef_url']) {
$url = '/api/node/' . $folderId['noderef_url'];
}
else {
$url = $folderId['url'];
}
$xml = cmis_alfresco_utils_invoke_service($url . '/parent');
if (false != $xml) {
return cmis_alfresco_getEntries(cmis_utils_process_CMIS_xml($xml, '//D:entry'));
}
return false;
}
/**
* Implementation of cmisapi_createDocument method
* @param $repositoryId
* @param $objectTypeId
* @param $properties
* @param $folderId
* @param $content
* @param $versioningState
*/
function cmis_alfresco_cmisapi_createDocument($repositoryId, $objectTypeId = 'document', $properties = array (), $folderId = null, $content = null, $versioningState = null) {
module_load_include('utils.inc', 'cmis_alfresco');
$parentFolderId = cmis_alfresco_objectId($folderId);
if (!is_array($parentFolderId) || !array_key_exists('noderef_url', $parentFolderId)) {
drupal_set_message('Unable to find destination folder: ' . $folderId, 'error');
return false;
}
$postvars = '' .
'' .
'' . $properties['title'] . '' .
'' . $properties['summary'] . '' .
'' . base64_encode($content) . '' .
'' .
'' .
'' .
'' . $objectTypeId . '' .
'' .
'' .
'' .
'';
$header[] = 'Content-type: application/atom+xml;type=entry';
$header[] = 'Content-length: ' . strlen($postvars);
$header[] = 'MIME-Version: 1.0';
$xml = cmis_alfresco_utils_invoke_service('/api/node/' . $parentFolderId['noderef_url'] . '/children', 'ticket', $header, 'CUSTOM-POST', $postvars);
$entry = cmis_utils_process_CMIS_xml($xml, '/D:entry');
$entry = $entry[0][0];
$objectId = cmis_alfresco_objectId((string)$entry->id);
return $objectId['noderef'];
}
/**
* Implementation of cmisapi_getProperties method
* @param $repositoryId
* @param $objectId
*/
function cmis_alfresco_cmisapi_getProperties($repositoryId, $objectId) {
module_load_include('utils.inc', 'cmis_alfresco');
$objectId = cmis_alfresco_objectId($objectId);
if ($xml = cmis_alfresco_utils_invoke_service('/api/node/' . $objectId['noderef_url'])) {
if ($entries = cmis_alfresco_getEntries(cmis_utils_process_CMIS_xml($xml, '//D:entry'))) {
return $entries[0];
}
}
watchdog(WATCHDOG_ERROR, 'Unknown objectId ' . $objectId);
return false;
}
/**
* Implemetation of cmisapi_getContentStream method
* @param $repositoryId
* @param $objectId
*/
function cmis_alfresco_cmisapi_getContentStream($repositoryId, $objectId) {
module_load_include('utils.inc', 'cmis_alfresco');
$objectId = cmis_alfresco_objectId($objectId);
return cmis_alfresco_utils_invoke_service('/api/node/content/' . $objectId['noderef_url']);
}
/**
* Implementation of cmisapi_setContentStream method
* @param $repositoryId
* @param $objectId
* @param $overwriteFlag
* @param $content
* @param $properties
*/
function cmis_alfresco_cmisapi_setContentStream($repositoryId, $objectId, $overwriteFlag = true, $content = null, $properties = array ()) {
module_load_include('utils.inc', 'cmis_alfresco');
$postvars = '' .
'' .
'' . $properties['title'] . '' .
'' . $content . '' .
'';
$header[] = 'Content-type: application/atom+xml;type=entry';
$header[] = 'Content-length: ' . strlen($postvars);
$header[] = 'MIME-Version: 1.0';
$objectId = cmis_alfresco_objectId($objectId);
$xml = cmis_alfresco_utils_invoke_service('/api/node/' . $objectId['noderef_url'], 'ticket', $header, 'CUSTOM-PUT', $postvars);
return $xml;
}
/**
* Implementation of cmisapi_query method
* @param $repositoryId
* @param $statement
* @param $searchAllVersions
* @param $includeAllAllowableActions
* @param $includeRelationships
* @param $maxItems
* @param $skipCount
* @return unknown_type
*/
function cmis_alfresco_cmisapi_query($repositoryId, $statement, $searchAllVersions = false, $includeAllAllowableActions = false, $includeRelationships = null, $maxItems = 0, $skipCount = 0) {
module_load_include('utils.inc', 'cmis_alfresco');
$postvars = '' .
'' .
'' . $statement . '' .
'' . $searchAllVersions . '' .
'' . $maxItems . '' .
'' . $maxItems . '' .
'' . $includeAllAllowableActions . '' .
'';
$header[] = 'Content-type: application/cmisquery+xml';
$header[] = 'Content-length: ' . strlen($postvars);
$header[] = 'MIME-Version: 1.0';
$xml = cmis_alfresco_utils_invoke_service('/api/query', 'ticket', $header, 'CUSTOM-POST', $postvars);
if (false != $xml) {
return cmis_alfresco_getEntries(cmis_utils_process_CMIS_xml($xml, '//D:entry'));
}
return false;
}