Author: chris.laprun(a)jboss.com
Date: 2007-07-06 14:56:20 -0400 (Fri, 06 Jul 2007)
New Revision: 7688
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
Log:
- JBPORTAL-1541: Check for null parent.
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 2007-07-06
17:03:44 UTC (rev 7687)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-07-06
18:56:20 UTC (rev 7688)
@@ -23,21 +23,21 @@
package org.jboss.portal.core.impl.model.portal;
import org.apache.log4j.Logger;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.common.NotYetImplemented;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -211,7 +211,7 @@
else
{
int count = 0;
- for (Iterator i = iterator();i.hasNext();)
+ for (Iterator i = iterator(); i.hasNext();)
{
i.next();
count++;
@@ -280,7 +280,7 @@
{
ObjectNode childNode = (ObjectNode)iterator.next();
PortalObjectImpl childObject = childNode.getObject();
- if (mask == ALL_TYPES_MASK || (childObject.getMask() & mask) !=
0)
+ if (mask == ALL_TYPES_MASK || (childObject.getMask() & mask) != 0)
{
nextChild = childObject;
}
@@ -395,9 +395,7 @@
return accessedChildren;
}
- /**
- * Get the aggregated properties in a lazy manner.
- */
+ /** Get the aggregated properties in a lazy manner. */
public Map getProperties()
{
// Lazy compute properties
@@ -457,7 +455,13 @@
if (value == null)
{
declaredPropertyMap.remove(name);
- String parentValue = getParent().getProperty(name);
+ PortalObject parent = getParent();
+ String parentValue = null;
+ if (parent != null)
+ {
+ parentValue = parent.getProperty(name);
+ }
+
propagatePropertyUpdate(name, parentValue, true);
}
else
@@ -468,44 +472,44 @@
}
/**
- * This method propagates a property value update to descendants which have been
*loaded* from the database.
- * It considers that if the <code>properties</code> field of the runtime
state is null then it means that
- * the object is loaded but children have not made an attempt to read the properties
of this object. Indeed
- * if a child is loaded any attempt to access its aggregated properties will trigger
the computation of
- * the aggregated properties of this object.
- *
+ * This method propagates a property value update to descendants which have been
*loaded* from the database. It
+ * considers that if the <code>properties</code> field of the runtime
state is null then it means that the object is
+ * loaded but children have not made an attempt to read the properties of this object.
Indeed if a child is loaded
+ * any attempt to access its aggregated properties will trigger the computation of the
aggregated properties of this
+ * object.
+ * <p/>
* Null property values are considered as removal
*
- * @param name the property name
+ * @param name the property name
* @param value the new property value
* @param force the update
*/
private void propagatePropertyUpdate(String name, String value, boolean force)
{
- if (properties != null)
- {
- if (force || !declaredPropertyMap.containsKey(name))
- {
- if (value == null)
- {
- properties.remove(name);
- }
- else
- {
- properties.put(name, value);
- }
+ if (properties != null)
+ {
+ if (force || !declaredPropertyMap.containsKey(name))
+ {
+ if (value == null)
+ {
+ properties.remove(name);
+ }
+ else
+ {
+ properties.put(name, value);
+ }
- //
- if (accessedChildren != null)
+ //
+ if (accessedChildren != null)
+ {
+ for (Iterator i = accessedChildren.iterator(); i.hasNext();)
{
- for (Iterator i = accessedChildren.iterator(); i.hasNext();)
- {
- PortalObjectImpl child = (PortalObjectImpl)i.next();
- child.propagatePropertyUpdate(name, value, false);
- }
+ PortalObjectImpl child = (PortalObjectImpl)i.next();
+ child.propagatePropertyUpdate(name, value, false);
}
- }
- }
+ }
+ }
+ }
}
public String getProperty(String name)
@@ -561,9 +565,7 @@
protected abstract PortalObjectImpl cloneObject();
- /**
- * Overridable callback.
- */
+ /** Overridable callback. */
protected void destroy()
{
}
@@ -573,9 +575,7 @@
return getMask(getType());
}
- /**
- * Returns the mask for this kind of object.
- */
+ /** Returns the mask for this kind of object. */
protected final int getMask(int portalObjectType)
{
switch (portalObjectType)
@@ -639,7 +639,7 @@
// Clone children recursively
if (deep)
{
- for (Iterator i = getChildren().iterator();i.hasNext();)
+ for (Iterator i = getChildren().iterator(); i.hasNext();)
{
PortalObjectImpl child = (PortalObjectImpl)i.next();
Show replies by date