. Tree Navigator performance improvement

- explicit txns around multiple nodeservice calls and internal (permission check free) nodeservice to retrieve node names
 - 25% improvement to retrieving node lists
. Permission code hotspot tuning and nodeservice methods ACL configuration tuning

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4960 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-01-29 18:42:30 +00:00
parent 200ff43d6e
commit c68cf150b4
3 changed files with 148 additions and 80 deletions

View File

@@ -8,6 +8,7 @@ import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import javax.transaction.UserTransaction;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
@@ -47,6 +48,7 @@ public class NavigatorPluginBean implements IContextListener
protected NodeRef previouslySelectedNode; protected NodeRef previouslySelectedNode;
private NodeService nodeService; private NodeService nodeService;
private NodeService internalNodeService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private static final Log logger = LogFactory.getLog(NavigatorPluginBean.class); private static final Log logger = LogFactory.getLog(NavigatorPluginBean.class);
@@ -69,6 +71,12 @@ public class NavigatorPluginBean implements IContextListener
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter out = context.getResponseWriter(); ResponseWriter out = context.getResponseWriter();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
Map params = context.getExternalContext().getRequestParameterMap(); Map params = context.getExternalContext().getRequestParameterMap();
String nodeRefStr = (String)params.get("nodeRef"); String nodeRefStr = (String)params.get("nodeRef");
String area = (String)params.get("area"); String area = (String)params.get("area");
@@ -118,6 +126,14 @@ public class NavigatorPluginBean implements IContextListener
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("returning XML: " + xml.toString()); logger.debug("returning XML: " + xml.toString());
} }
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
} }
/** /**
@@ -263,6 +279,12 @@ public class NavigatorPluginBean implements IContextListener
this.companyHomeRootNodes = new ArrayList<TreeNode>(); this.companyHomeRootNodes = new ArrayList<TreeNode>();
this.companyHomeNodes = new HashMap<String, TreeNode>(); this.companyHomeNodes = new HashMap<String, TreeNode>();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
// query for the child nodes of company home // query for the child nodes of company home
NodeRef root = new NodeRef(Repository.getStoreRef(), NodeRef root = new NodeRef(Repository.getStoreRef(),
Application.getCompanyRootId()); Application.getCompanyRootId());
@@ -280,6 +302,13 @@ public class NavigatorPluginBean implements IContextListener
this.companyHomeNodes.put(node.getNodeRef(), node); this.companyHomeNodes.put(node.getNodeRef(), node);
} }
} }
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
} }
return this.companyHomeRootNodes; return this.companyHomeRootNodes;
@@ -301,6 +330,12 @@ public class NavigatorPluginBean implements IContextListener
this.myHomeRootNodes = new ArrayList<TreeNode>(); this.myHomeRootNodes = new ArrayList<TreeNode>();
this.myHomeNodes = new HashMap<String, TreeNode>(); this.myHomeNodes = new HashMap<String, TreeNode>();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
// query for the child nodes of the user's home // query for the child nodes of the user's home
NodeRef root = new NodeRef(Repository.getStoreRef(), NodeRef root = new NodeRef(Repository.getStoreRef(),
Application.getCurrentUser(FacesContext.getCurrentInstance()).getHomeSpaceId()); Application.getCurrentUser(FacesContext.getCurrentInstance()).getHomeSpaceId());
@@ -318,6 +353,13 @@ public class NavigatorPluginBean implements IContextListener
this.myHomeNodes.put(node.getNodeRef(), node); this.myHomeNodes.put(node.getNodeRef(), node);
} }
} }
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
} }
return this.myHomeRootNodes; return this.myHomeRootNodes;
@@ -339,6 +381,12 @@ public class NavigatorPluginBean implements IContextListener
this.guestHomeRootNodes = new ArrayList<TreeNode>(); this.guestHomeRootNodes = new ArrayList<TreeNode>();
this.guestHomeNodes = new HashMap<String, TreeNode>(); this.guestHomeNodes = new HashMap<String, TreeNode>();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
// query for the child nodes of the guest home space // query for the child nodes of the guest home space
NavigationBean navBean = getNavigationBean(); NavigationBean navBean = getNavigationBean();
if (navBean != null) if (navBean != null)
@@ -359,6 +407,13 @@ public class NavigatorPluginBean implements IContextListener
} }
} }
} }
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
} }
return this.guestHomeRootNodes; return this.guestHomeRootNodes;
@@ -372,6 +427,14 @@ public class NavigatorPluginBean implements IContextListener
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* @param internalNodeService The internalNodeService to set.
*/
public void setInternalNodeService(NodeService internalNodeService)
{
this.internalNodeService = internalNodeService;
}
/** /**
* @param dictionaryService The DictionaryService to set. * @param dictionaryService The DictionaryService to set.
*/ */
@@ -554,8 +617,8 @@ public class NavigatorPluginBean implements IContextListener
protected TreeNode createTreeNode(NodeRef nodeRef) protected TreeNode createTreeNode(NodeRef nodeRef)
{ {
TreeNode node = new TreeNode(nodeRef.toString(), TreeNode node = new TreeNode(nodeRef.toString(),
Repository.getNameForNode(this.nodeService, nodeRef), Repository.getNameForNode(this.internalNodeService, nodeRef),
(String)this.nodeService.getProperty(nodeRef, ApplicationModel.PROP_ICON)); (String)this.internalNodeService.getProperty(nodeRef, ApplicationModel.PROP_ICON));
return node; return node;
} }
@@ -568,7 +631,7 @@ public class NavigatorPluginBean implements IContextListener
protected NavigationBean getNavigationBean() protected NavigationBean getNavigationBean()
{ {
return (NavigationBean)FacesHelper.getManagedBean( return (NavigationBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "NavigationBean"); FacesContext.getCurrentInstance(), NavigationBean.BEAN_NAME);
} }
/** /**
@@ -579,7 +642,7 @@ public class NavigatorPluginBean implements IContextListener
protected BrowseBean getBrowseBean() protected BrowseBean getBrowseBean()
{ {
return (BrowseBean)FacesHelper.getManagedBean( return (BrowseBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "BrowseBean"); FacesContext.getCurrentInstance(), BrowseBean.BEAN_NAME);
} }
/** /**

View File

@@ -3129,6 +3129,10 @@
<property-name>nodeService</property-name> <property-name>nodeService</property-name>
<value>#{NodeService}</value> <value>#{NodeService}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>internalNodeService</property-name>
<value>#{nodeService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>dictionaryService</property-name> <property-name>dictionaryService</property-name>
<value>#{DictionaryService}</value> <value>#{DictionaryService}</value>

View File

@@ -435,12 +435,13 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl
.pager .pager
{ {
padding: 5px 3px 4px 3px; padding: 4px 2px 3px 2px;
border: 1px dotted #cccccc; border: 1px dotted #cccccc;
} }
.pager img .pager img
{ {
margin-top:2px;
vertical-align: -20%; vertical-align: -20%;
} }