Author: chris.laprun(a)jboss.com
Date: 2007-07-12 01:27:37 -0400 (Thu, 12 Jul 2007)
New Revision: 7731
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
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/PortalObjectPath.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
Log:
- JBPORTAL-1574: Handle root case specifically so that we bypass issue with Oracle.
- Use constants instead of hardcoded values (more could be done in particular for
LegacyFormat)...
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -30,12 +30,12 @@
import org.jboss.portal.security.RoleSecurityBinding;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -114,10 +114,10 @@
/**
* Create and persist the provided child object. The object also becomes of child of
this node.
*
- * @param name the child name
+ * @param name the child name
* @param childObject the child object
* @throws DuplicatePortalObjectException if a child with such a name already exists
- * @throws IllegalArgumentException if the name is null or zero length or the child
object is null
+ * @throws IllegalArgumentException if the name is null or zero length or the
child object is null
*/
void addChild(String name, PortalObjectImpl childObject) throws
DuplicatePortalObjectException, IllegalArgumentException
{
@@ -243,7 +243,7 @@
public String toString()
{
- return path + ":" + name;
+ return path.toString() + PortalObjectId.NAMESPACE_SEPARATOR + name;
}
protected PortalObjectId toChildPath(String name)
@@ -342,4 +342,4 @@
return null;
}
}
-}
+}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -22,23 +22,22 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.portal;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.jboss.logging.Logger;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.jems.hibernate.ObjectContextualizer;
import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
import javax.naming.InitialContext;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -47,7 +46,8 @@
{
/** The query for lookup when the path is null. */
- private static final String LOOKUP_QUERY_FOR_NULL_PATH = "from ObjectNode where
path=:path or path is null";
+ private static final String LOOKUP_QUERY_FOR_EMPTY_PATH = "from ObjectNode where
path=:path";
+ private static final String LOOKUP_QUERY_FOR_ROOT = "from ObjectNode where
path=:path or path is null";
/** . */
private static Logger log = Logger.getLogger(PersistentPortalObjectContainer.class);
@@ -247,9 +247,15 @@
Object result;
if (id.getPath().getLength() == 0)
{
- // For oracle where an empty path is treated as null so we need to add that
here
- // See also org.jboss.portal.core.hibernate.OracleString
- Query query = session.createQuery(LOOKUP_QUERY_FOR_NULL_PATH);
+ // Oracle returns the root object when using LOOKUP_QUERY_FOR_NULL_PATH thus
preventing the creation of the
+ // dashboard node as null is never returned for it and is therefore cached...
+ String queryString = LOOKUP_QUERY_FOR_EMPTY_PATH;
+ if (id.toString().lastIndexOf(PortalObjectPath.CanonicalFormat.PATH_SEPARATOR)
== 0)
+ {
+ queryString = LOOKUP_QUERY_FOR_ROOT;
+ }
+
+ Query query = session.createQuery(queryString);
query.setParameter("path", id);
query.setCacheable(true);
result = query.uniqueResult();
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 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -26,11 +26,9 @@
/**
* A composite id for a portal object in the scope of its container.
+ * <p/>
+ * <ul> <li>The empty string maps to the empty namespace and the empty
path</li> </ul>
*
- * <ul>
- * <li>The empty string maps to the empty namespace and the empty path</li>
- * </ul>
- *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -51,12 +49,13 @@
/** The lazy computed to string value for legacy format. */
private String toStringLegacyFormat;
+ public static final char NAMESPACE_SEPARATOR = ':';
/**
* Build a new portal object id.
*
* @param namespace the namespace value
- * @param path the path object
+ * @param path the path object
* @throws IllegalArgumentException if any argument is null
*/
public PortalObjectId(String namespace, PortalObjectPath path) throws
IllegalArgumentException
@@ -120,9 +119,9 @@
* Parse a portal object id given its string representation.
*
* @param idValue the id string value
- * @param format the format
- * @throws IllegalArgumentException if any argument is null or not well formed
+ * @param format the format
* @return the PortalObjectId
+ * @throws IllegalArgumentException if any argument is null or not well formed
*/
public static PortalObjectId parse(String idValue, PortalObjectPath.Format format)
throws IllegalArgumentException
{
@@ -130,7 +129,7 @@
{
throw new IllegalArgumentException("No null id value accepted");
}
- int pos = idValue.indexOf(':');
+ int pos = idValue.indexOf(NAMESPACE_SEPARATOR);
//
if (pos == -1)
@@ -150,7 +149,7 @@
*
* @param namespace the namespace value
* @param pathValue the path value
- * @param format the path format
+ * @param format the path format
* @return the PortalObjectId
* @throws IllegalArgumentException if any argument is null or not well formed
*/
@@ -210,8 +209,8 @@
* Format a portal object id values to a string value.
*
* @param namespace the id value
- * @param path the id path
- * @param format the desired format
+ * @param path the id path
+ * @param format the desired format
* @return the formated value
* @throws IllegalArgumentException if any argument is null or not well formed
*/
@@ -227,7 +226,7 @@
}
if (namespace.length() > 0)
{
- return namespace + ":" + path.toString(format);
+ return namespace + NAMESPACE_SEPARATOR + path.toString(format);
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -22,9 +22,9 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.Base64;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
@@ -232,9 +232,7 @@
return hashCode.intValue();
}
- /**
- * Lexicographical order based implementation on the names atoms.
- */
+ /** Lexicographical order based implementation on the names atoms. */
public int compareTo(Object o)
{
PortalObjectPath that = (PortalObjectPath)o;
@@ -339,12 +337,16 @@
}
/** Canonical format, smth like /a/b/c. */
- public static final PortalObjectPath.Format CANONICAL_FORMAT = new
PortalObjectPath.Format()
+ public static final PortalObjectPath.Format CANONICAL_FORMAT = new CanonicalFormat();
+
+ public static final class CanonicalFormat extends Format
{
+ public static final char PATH_SEPARATOR = '/';
+
public String[] parse(String value)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value,
"value", "Format.parse(value)");
- if (value.charAt(0) != '/')
+ if (value.charAt(0) != PATH_SEPARATOR)
{
throw new IllegalArgumentException("Not a canonical value " +
value);
}
@@ -358,7 +360,7 @@
int previous = 1;
while (true)
{
- int next = value.indexOf('/', previous);
+ int next = value.indexOf(PATH_SEPARATOR, previous);
if (next == -1)
{
break;
@@ -373,7 +375,7 @@
previous = 1;
while (true)
{
- int next = value.indexOf('/', previous);
+ int next = value.indexOf(PATH_SEPARATOR, previous);
if (next == -1)
{
break;
@@ -392,7 +394,7 @@
ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string
array");
if (from == to)
{
- return "/";
+ return "" + PATH_SEPARATOR;
}
else
{
@@ -404,13 +406,15 @@
{
throw new IllegalArgumentException("No null name expected in the
name string array");
}
- tmp.append('/').append(name);
+ tmp.append(PATH_SEPARATOR).append(name);
}
return tmp.toString();
}
}
- };
+ }
+ ;
+
/** The internal format when it is persisted, smth like a.b.c . */
public static final PortalObjectPath.Format LEGACY_FORMAT = new
PortalObjectPath.LegacyFormat();
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -70,6 +70,16 @@
TransactionAssert.commitTransaction();
}
+ public void testDashboardNodeCreation() throws DuplicatePortalObjectException
+ {
+ TransactionAssert.beginTransaction();
+ PortalObject root = container.getContext();
+ PortalObject dashboard = container.createContext("dashboard");
+ assertNotNull(dashboard);
+ assertFalse(root.equals(dashboard));
+ TransactionAssert.commitTransaction();
+ }
+
public void testPropertyUpdateCascadeToDescendantsWhenTheyDoNotDeclareIt() throws
Exception
{
TransactionAssert.beginTransaction();
@@ -395,4 +405,4 @@
return po1.getId().compareTo(po2.getId());
}
}
-}
\ No newline at end of file
+}
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2007-07-12
05:19:40 UTC (rev 7730)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2007-07-12
05:27:37 UTC (rev 7731)
@@ -22,24 +22,24 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui.dashboard;
+import org.jboss.portal.common.util.IteratorStatus;
+import org.jboss.portal.core.admin.ui.actions.AddPageAction;
+import org.jboss.portal.core.admin.ui.common.PageManagerBean;
+import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
import org.jboss.portal.core.model.portal.PortalObjectPath;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.admin.ui.common.PageManagerBean;
-import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
-import org.jboss.portal.core.admin.ui.actions.AddPageAction;
import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.common.util.IteratorStatus;
+import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
-import javax.faces.context.FacesContext;
import java.util.Collection;
/**
@@ -50,7 +50,8 @@
{
/** . */
- private static final PortalObjectId dashboardId =
PortalObjectId.parse("dashboard:/", PortalObjectPath.CANONICAL_FORMAT);
+ private static final PortalObjectId dashboardId =
PortalObjectId.parse("dashboard"
+ + PortalObjectId.NAMESPACE_SEPARATOR +
PortalObjectPath.CanonicalFormat.PATH_SEPARATOR, PortalObjectPath.CANONICAL_FORMAT);
// Wired services
@@ -127,7 +128,7 @@
{
return;
}
-
+
// Page for editting
if (selectedPageName != null)
{
@@ -150,7 +151,7 @@
//
Collection pages = userPortal.getChildren(PortalObject.PAGE_MASK);
pageItems = new SelectItem[pages.size()];
- for (IteratorStatus i = new IteratorStatus(pages);i.hasNext();)
+ for (IteratorStatus i = new IteratorStatus(pages); i.hasNext();)
{
PortalObject object = (PortalObject)i.next();
SelectItem item = new SelectItem();