Index: cmis_alfresco.utils.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cmis_alfresco/cmis_alfresco.utils.inc,v retrieving revision 1.3.2.1 diff -u -p -r1.3.2.1 cmis_alfresco.utils.inc --- cmis_alfresco.utils.inc 10 Sep 2009 10:24:07 -0000 1.3.2.1 +++ cmis_alfresco.utils.inc 1 Dec 2009 05:30:22 -0000 @@ -16,8 +16,8 @@ function _cmis_alfresco_utils_cmis_versi static $cmis_version; if (empty($cmis_version)) { - $response = cmis_alfresco_invoke_service('/api/repository'); - + $response = cmis_alfresco_invoke_service('/cmis'); + foreach (array('0.5', '0.6') as $test_cmis_version) { $namespaces = cmis_alfresco_utils_get_namespaces($test_cmis_version); $xml = new SimpleXMLElement($response); @@ -94,16 +94,16 @@ function _cmis_alfresco_utils_known_prop function cmis_alfresco_utils_get_CMIS_xml($xml, $xpath = NULL) { try { $cmis_service = new SimpleXMLElement($xml); + + // register the default namespace with our alias 'D' + $namespaces = $cmis_service->getNamespaces(); + isset($namespaces['']) ? $cmis_service->registerXPathNamespace('D', $namespaces['']) : NULL; } catch (Exception $e) { cmis_error_handler('cmis_alfresco_utils_get_CMIS_xml', $e); throw new CMISException(t('Unable to process xml.')); } - foreach (cmis_alfresco_utils_get_namespaces() as $ns => $namespace) { - $cmis_service->registerXPathNamespace($ns, $namespace); - } - if ($xpath) { return $cmis_service->xpath($xpath); } @@ -138,19 +138,19 @@ function cmis_alfresco_objectId($objectI $parts = parse_url($objectId); - if (substr($parts['scheme'], 0, 4) == 'http') { + if (isset($parts['scheme']) && substr($parts['scheme'], 0, 4) == 'http') { // @todo lookup id by path $parts['url'] = $objectId; return $parts; } - if (in_array($parts['scheme'], array ('workspace', 'archive', 'user', 'system', 'avm'))) { + if (isset($parts['scheme']) && in_array($parts['scheme'], array ('workspace', 'archive', 'user', 'system', 'avm'))) { $parts['noderef'] = $objectId; $parts['noderef_url'] = $parts['scheme'] .'/'. $parts['host'] . $parts['path']; return $parts; } - if ($parts['scheme'] == 'urn') { + if (isset($parts['scheme']) && $parts['scheme'] == 'urn') { // Assuming that comes from workspace://SpacesStore/ // @todo Review this assumption $tmp_parts = parse_url($parts['path']); @@ -168,7 +168,7 @@ function cmis_alfresco_objectId($objectI if (substr($parts['path'], -1) == '/') { $parts['path'] = substr_replace($parts['path'], '', -1); } - $response = cmis_alfresco_invoke_service('/api/path/workspace/SpacesStore'. $parts['path']); + $response = cmis_alfresco_invoke_service('/cmis/s/workspace:SpacesStore/i'. $parts['path']); $object_info = cmis_alfresco_utils_get_CMIS_xml($response, '//D:entry'); if (false != $object_info) { return cmis_alfresco_objectId((string) $object_info[0]->id); @@ -191,24 +191,26 @@ function cmis_alfresco_objectId($objectI */ function _cmis_alfresco_getEntries($entries) { $result = array(); + $types = _cmis_alfresco_utils_known_property_types(); + foreach ($entries as $entry) { - $cmis_object = _cmis_alfresco_utils_entry($entry); + $cmis_object = _cmis_alfresco_utils_entry($entry); $cmis_object->properties = array(); - $cmis_element = $entry->children(cmis_alfresco_utils_ns('cmis')); - foreach (_cmis_alfresco_utils_known_property_types() as $type) { - $property_tag = 'property'. $type; - foreach ($cmis_element->object->properties->$property_tag as $property) { - $attrs = $property->attributes(cmis_alfresco_utils_ns('cmis')); - $cmis_object->properties[(string) $attrs->name] = _cmis_alfresco_utils_cast($property->value, $type); + $cmis_properties = $entry->children('cmisra', TRUE)->children('cmis', TRUE)->properties; + + foreach($types as $type) { + $tag = 'property' . $type; + foreach($cmis_properties->$tag as $property) { + $name = str_replace('cmis:', '', (string) $property->attributes() ); + $cmis_object->properties[$name] = _cmis_alfresco_utils_cast($property->value, $type); } } - - $cmis_object->type = $cmis_object->properties['BaseType']; + $cmis_object->type = $cmis_object->properties['baseTypeId']; - if ($cmis_object->type == 'document') { - $cmis_object->size = $cmis_object->properties['ContentStreamLength']; - $cmis_object->contentMimeType = $cmis_object->properties['ContentStreamMimeType']; - $cmis_object->versionSeriesCheckedOutBy = $cmis_object->properties['VersionSeriesCheckedOutBy']; + if ($cmis_object->type == 'cmis:document') { + $cmis_object->size = $cmis_object->properties['contentStreamLength']; + $cmis_object->contentMimeType = $cmis_object->properties['contentStreamMimeType']; + $cmis_object->versionSeriesCheckedOutBy = $cmis_object->properties['versionSeriesCheckedOutBy']; } $result[] = $cmis_object;