ACE-198 / ACE-202 / ACE-4734: Perf improvements for CMIS (getChildren et al)\n Merge BRANCHES/DEV/HEAD_ACE198_2

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@118887 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2015-12-01 08:49:39 +00:00
parent d07b33bbc4
commit 5ffe135a2e
8 changed files with 163 additions and 143 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -65,7 +65,6 @@ import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.opencmis.mapping.DirectProperty;
import org.alfresco.opencmis.search.CMISQueryOptions;
import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
import org.alfresco.opencmis.search.CMISQueryService;
@@ -1187,15 +1186,15 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
*/
public CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef)
{
return createNodeInfo(nodeRef, null);
return createNodeInfo(nodeRef, null, null, null, true);
}
/**
* Creates an object info object.
*/
public CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef, VersionHistory versionHistory)
public CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef, QName nodeType, Map<QName,Serializable> nodeProps, VersionHistory versionHistory, boolean checkExists)
{
return new CMISNodeInfoImpl(this, nodeRef, versionHistory);
return new CMISNodeInfoImpl(this, nodeRef, nodeType, nodeProps, versionHistory, checkExists);
}
/**
@@ -1394,7 +1393,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
try
{
QName typeQName = nodeService.getType(nodeRef);
return getType(typeQName);
return getOpenCMISDictionaryService().findNodeType(typeQName);
}
catch(InvalidNodeRefException inre)
{
@@ -1402,11 +1401,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
private TypeDefinitionWrapper getType(QName typeQName)
{
return getOpenCMISDictionaryService().findNodeType(typeQName);
}
/**
* Returns the type definition of an association or <code>null</code> if no
* type definition could be found.
@@ -1519,21 +1513,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
/**
* Creates the CMIS object for a node.
*/
public ObjectData createCMISObject(CMISNodeInfo info, FileInfo node, String filter,
boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
boolean includePolicyIds, boolean includeAcl)
{
if (info.getType() == null)
{
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
Properties nodeProps = getNodeProperties(info, node, filter, info.getType());
return createCMISObjectImpl(info, nodeProps, filter, includeAllowableActions, includeRelationships,
renditionFilter, includePolicyIds, includeAcl);
}
public ObjectData createCMISObject(CMISNodeInfo info, String filter, boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds,
boolean includeAcl)
@@ -1543,8 +1522,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
Properties nodeProps = (info.isRelationship() ? getAssocProperties(info, filter) : getNodeProperties(info,
filter));
Properties nodeProps = (info.isRelationship() ? getAssocProperties(info, filter) : getNodeProperties(info, filter));
return createCMISObjectImpl(info, nodeProps, filter, includeAllowableActions, includeRelationships,
renditionFilter, includePolicyIds, includeAcl);
@@ -1629,6 +1607,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// add aspects
List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties()
.getProperties().keySet());
if (!extensions.isEmpty())
{
result.getProperties().setExtensions(
@@ -1888,12 +1867,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private void addAspectProperties(CMISNodeInfo info, String filter, PropertiesImpl result)
{
if(getRequestCmisVersion().equals(CmisVersion.CMIS_1_1))
if (getRequestCmisVersion().equals(CmisVersion.CMIS_1_1))
{
Set<String> propertyIds = new HashSet<String>();
Set<String> propertyIds = new HashSet<>();
Set<String> filterSet = splitFilter(filter);
Set<QName> aspects = nodeService.getAspects(info.getNodeRef());
Set<QName> aspects = info.getNodeAspects();
for (QName aspect : aspects)
{
TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
@@ -1901,7 +1880,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
continue;
}
for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
{
if (propertyIds.contains(propDef.getPropertyId()))
@@ -1909,16 +1888,16 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// skip properties that have already been added
continue;
}
if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
{
// skip properties that are not in the filter
continue;
}
Serializable value = propDef.getPropertyAccessor().getValue(info);
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
// mark property as 'added'
propertyIds.add(propDef.getPropertyId());
}
@@ -1953,46 +1932,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result;
}
public Properties getNodeProperties(CMISNodeInfo info, FileInfo node, String filter, TypeDefinitionWrapper type)
{
PropertiesImpl result = new PropertiesImpl();
Set<String> filterSet = splitFilter(filter);
Map<QName, Serializable> nodeProps = node.getProperties();
for (PropertyDefinitionWrapper propDef : type.getProperties())
{
if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
{
// don't filter the object id
if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
{
// skip properties that are not in the filter
continue;
}
}
Serializable value = null;
CMISPropertyAccessor accessor = propDef.getPropertyAccessor();
if (accessor instanceof DirectProperty)
{
value = nodeProps.get(accessor.getMappedProperty());
}
else
{
value = propDef.getPropertyAccessor().getValue(info);
}
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
}
addAspectProperties(info, filter, result);
return result;
}
public Properties getAssocProperties(CMISNodeInfo info, String filter)
{
PropertiesImpl result = new PropertiesImpl();
@@ -2021,15 +1960,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
/**
* Builds aspect extension.
*/
public List<CmisExtensionElement> getAspectExtensions(CMISNodeInfo info, String filter,
Set<String> alreadySetProperties)
public List<CmisExtensionElement> getAspectExtensions(CMISNodeInfo info, String filter, Set<String> alreadySetProperties)
{
List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
Set<String> propertyIds = new HashSet<String>(alreadySetProperties);
List<CmisExtensionElement> propertyExtensionList = new ArrayList<CmisExtensionElement>();
Set<String> filterSet = splitFilter(filter);
Set<QName> aspects = nodeService.getAspects(info.getNodeRef());
Set<QName> aspects = info.getNodeAspects();
for (QName aspect : aspects)
{
TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
@@ -2037,7 +1975,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
continue;
}
AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect);
Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectProperties = aspectDefinition.getProperties();