Author: chris.laprun(a)jboss.com
Date: 2009-02-26 08:07:23 -0500 (Thu, 26 Feb 2009)
New Revision: 12897
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
Log:
- JBPORTAL-2040:
+ Re-wrote PortalObject.getChild to use container directly instead of going through
ObjectNode.getChildren
to avoid having to retrieve all the children just to get one. This should yield a
massive reduction in DB
requests.
+ Removed unused instances and pages SelectedItems in PortalObjectManagerBean
- Added PortalObjectId.getChildId to efficiently get a child's id from a parent and
use ParameterValidation.
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2009-02-26
11:58:51 UTC (rev 12896)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2009-02-26
13:07:23 UTC (rev 12897)
@@ -411,16 +411,14 @@
{
throw new IllegalArgumentException();
}
- ObjectNode childNode = (ObjectNode)objectNode.getChildren().get(name);
- if (childNode != null)
- {
- PortalObjectImpl childObject = childNode.getObject();
- // Track it
- getAccessedChildren().add(childObject);
-
- //
- return childObject;
+ // use container directly instead of going through children to avoid having to
retrieve all of them just for one
+ // this leads to major perfomance improvement by dramatically reducing the number
of DB requests
+ PortalObject portalObject =
objectNode.getContext().getContainer().getObject(getId().getChildId(name));
+ if (portalObject != null)
+ {
+ getAccessedChildren().add(portalObject);
+ return portalObject;
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2009-02-26
11:58:51 UTC (rev 12896)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2009-02-26
13:07:23 UTC (rev 12897)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
+import org.jboss.portal.common.util.ParameterValidation;
+
import java.io.Serializable;
/**
@@ -60,14 +62,8 @@
*/
public PortalObjectId(String namespace, PortalObjectPath path) throws
IllegalArgumentException
{
- if (namespace == null)
- {
- throw new IllegalArgumentException();
- }
- if (path == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(namespace,
"namespace");
+ ParameterValidation.throwIllegalArgExceptionIfNull(path, "path");
this.namespace = namespace;
this.path = path;
}
@@ -125,10 +121,7 @@
*/
public static PortalObjectId parse(String idValue, PortalObjectPath.Format format)
throws IllegalArgumentException
{
- if (idValue == null)
- {
- throw new IllegalArgumentException("No null id value accepted");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(idValue, "id");
int pos = idValue.indexOf(NAMESPACE_SEPARATOR);
//
@@ -144,6 +137,12 @@
}
}
+ public PortalObjectId getChildId(String name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "child name");
+ return new PortalObjectId(getNamespace(), getPath().getChild(name));
+ }
+
/**
* Parse a portal object id given the namespace and the path string representation.
*
@@ -177,10 +176,7 @@
*/
public String toString(PortalObjectPath.Format format) throws
IllegalArgumentException
{
- if (format == null)
- {
- throw new IllegalArgumentException("No null format accepted");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(format, "format");
//
if (format == PortalObjectPath.LEGACY_FORMAT)
@@ -216,14 +212,8 @@
*/
public static String toString(String namespace, PortalObjectPath path,
PortalObjectPath.Format format) throws IllegalArgumentException
{
- if (namespace == null)
- {
- throw new IllegalArgumentException("No null namespace accepted");
- }
- if (path == null)
- {
- throw new IllegalArgumentException("No null path accepted");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(namespace,
"namespace");
+ ParameterValidation.throwIllegalArgExceptionIfNull(path, "path");
if (namespace.length() > 0)
{
return namespace + NAMESPACE_SEPARATOR + path.toString(format);
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-26
11:58:51 UTC (rev 12896)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-02-26
13:07:23 UTC (rev 12897)
@@ -22,23 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-import javax.faces.model.SelectItem;
-
import org.jboss.portal.core.admin.ui.actions.AddPageAction;
import org.jboss.portal.core.admin.ui.actions.PropertyAction;
import org.jboss.portal.core.admin.ui.common.PageManagerBean;
@@ -49,7 +32,6 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
-import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -67,6 +49,21 @@
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.ThemeService;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+
/** The portal object manager bean. */
public class PortalObjectManagerBean implements Serializable, AddPageAction.Listener
{
@@ -131,12 +128,6 @@
private final AuthorizationBean auth = new PortalObjectAuthorizationBean();
/** . */
- private SelectItem[] instanceItems;
-
- /** . */
- private SelectItem[] portalPageItems;
-
- /** . */
private List selectedObjectPath;
/** . */
@@ -348,16 +339,6 @@
return auth;
}
- public SelectItem[] getInstanceItems()
- {
- return instanceItems;
- }
-
- public SelectItem[] getPortalPageItems()
- {
- return portalPageItems;
- }
-
public List getSelectedObjectPath()
{
return selectedObjectPath;
@@ -539,7 +520,7 @@
Map pmap = getRequestParameterMap();
selectedPlugin = (String)pmap.get("plugin");
}
-
+
public Map getRequestParameterMap()
{
return
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
@@ -595,7 +576,7 @@
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO,
stringMessage, stringMessage);
FacesContext.getCurrentInstance().addMessage("status",
message);
-
+
selectedDeletingObject = null;
}
else
@@ -616,8 +597,6 @@
public void refresh()
{
propertyAction = null;
- instanceItems = null;
- portalPageItems = null;
selectedObjectPath = null;
selectedObject = null;
selectedProperties = null;
@@ -652,18 +631,6 @@
theme = new ThemeBean(selectedObject);
//
- Collection pages = getSelectedObject().getChildren(PortalObject.PAGE_MASK);
- ArrayList list = new ArrayList(pages.size() + 1);
- for (Iterator iterator = pages.iterator(); iterator.hasNext();)
- {
- PortalObject o = (PortalObject)iterator.next();
- SelectItem item = new SelectItem(o.getName());
- list.add(item);
- }
- list.add(new SelectItem("", "no selection"));
- portalPageItems = (SelectItem[])list.toArray(new SelectItem[list.size()]);
-
- //
PortalObject o = getSelectedObject();
ArrayList path = new ArrayList();
while (o != null)
@@ -673,17 +640,6 @@
}
Collections.reverse(path);
selectedObjectPath = path;
-
- //
- List tmp = new ArrayList(instanceContainer.getDefinitions());
- Collections.sort(tmp, InstanceManagerBean.INSTANCE_COMPARATOR);
- for (int i = 0; i < tmp.size(); i++)
- {
- Instance instance = (Instance)tmp.get(i);
- SelectItem item = new SelectItem(instance.getId());
- tmp.set(i, item);
- }
- instanceItems = (SelectItem[])tmp.toArray(new SelectItem[tmp.size()]);
}
public void processEvent(ActionEvent event)