mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
REPO-1110 - Apply patch provided in ALF-21632 (FreeMarker performance improvement)
ALF-21632 - FreeMarker API node.childByNamePath can be very slow git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@132431 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,15 +25,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.template;
|
package org.alfresco.repo.template;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special Map that executes an XPath against the parent Node as part of the get()
|
* A special Map that executes an XPath against the parent Node as part of the get()
|
||||||
@@ -60,8 +64,37 @@ public class NamePathResultsMap extends BasePathResultsMap
|
|||||||
public Object get(Object key)
|
public Object get(Object key)
|
||||||
{
|
{
|
||||||
String path = key.toString();
|
String path = key.toString();
|
||||||
|
final StringTokenizer t = new StringTokenizer(path, "/");
|
||||||
|
|
||||||
|
// optimization
|
||||||
|
if (this.services.getDictionaryService().isSubClass(parent.getType(), org.alfresco.model.ContentModel.TYPE_FOLDER))
|
||||||
|
{
|
||||||
|
NodeRef result = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef doWork() throws Exception
|
||||||
|
{
|
||||||
|
NodeRef child = parent.nodeRef;
|
||||||
|
while (t.hasMoreTokens() && child != null)
|
||||||
|
{
|
||||||
|
String name = t.nextToken();
|
||||||
|
child = services.getNodeService().getChildByName(child, org.alfresco.model.ContentModel.ASSOC_CONTAINS, name);
|
||||||
|
}
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
|
// final node must be accessible to the user via the usual ACL permission checks
|
||||||
|
if (result != null
|
||||||
|
&& services.getPublicServiceAccessService().hasAccess("NodeService", "getProperties", result) != AccessStatus.ALLOWED)
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (result != null ? new TemplateNode(result, this.services, this.parent.getImageResolver()) : null);
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder xpath = new StringBuilder(path.length() << 1);
|
StringBuilder xpath = new StringBuilder(path.length() << 1);
|
||||||
StringTokenizer t = new StringTokenizer(path, "/");
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
QueryParameterDefinition[] params = new QueryParameterDefinition[t.countTokens()];
|
QueryParameterDefinition[] params = new QueryParameterDefinition[t.countTokens()];
|
||||||
DataTypeDefinition ddText =
|
DataTypeDefinition ddText =
|
||||||
|
Reference in New Issue
Block a user