From portal-commits at lists.jboss.org Thu Jul 12 01:19:41 2007 Content-Type: multipart/mixed; boundary="===============3160992315264707956==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r7730 - in trunk: core/src/main/org/jboss/portal/core/model/portal and 2 other directories. Date: Thu, 12 Jul 2007 01:19:41 -0400 Message-ID: --===============3160992315264707956== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: chris.laprun(a)jboss.com Date: 2007-07-12 01:19:40 -0400 (Thu, 12 Jul 2007) New Revision: 7730 Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/Dashb= oardBean.java trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.j= ava trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPo= rtalObjectContainer.java trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.ja= va trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.= java trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObject= ContainerTestCase.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 particul= ar for LegacyFormat)... Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/Objec= tNode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.= java 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.= java 2007-07-12 05:19:40 UTC (rev 7730) @@ -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 Julien Viet @@ -114,10 +114,10 @@ /** * Create and persist the provided child object. The object also become= s 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 a= lready 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 l= ength or the child object is null */ void addChild(String name, PortalObjectImpl childObject) throws Duplica= tePortalObjectException, IllegalArgumentException { @@ -243,7 +243,7 @@ = public String toString() { - return path + ":" + name; + return path.toString() + PortalObjectId.NAMESPACE_SEPARATOR + name; } = protected PortalObjectId toChildPath(String name) Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/Persi= stentPortalObjectContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentP= ortalObjectContainer.java 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentP= ortalObjectContainer.java 2007-07-12 05:19:40 UTC (rev 7730) @@ -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.PortalAuthorizationManagerFactor= y; -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 Julien Viet * @version $Revision$ @@ -47,7 +46,8 @@ { = /** The query for lookup when the path is null. */ - private static final String LOOKUP_QUERY_FOR_NULL_PATH =3D "from Object= Node where path=3D:path or path is null"; + private static final String LOOKUP_QUERY_FOR_EMPTY_PATH =3D "from Objec= tNode where path=3D:path"; + private static final String LOOKUP_QUERY_FOR_ROOT =3D "from ObjectNode = where path=3D:path or path is null"; = /** . */ private static Logger log =3D Logger.getLogger(PersistentPortalObjectCo= ntainer.class); @@ -247,9 +247,15 @@ Object result; if (id.getPath().getLength() =3D=3D 0) { - // For oracle where an empty path is treated as null so we need t= o add that here - // See also org.jboss.portal.core.hibernate.OracleString - Query query =3D session.createQuery(LOOKUP_QUERY_FOR_NULL_PATH); + // Oracle returns the root object when using LOOKUP_QUERY_FOR_NUL= L_PATH thus preventing the creation of the + // dashboard node as null is never returned for it and is therefo= re cached... + String queryString =3D LOOKUP_QUERY_FOR_EMPTY_PATH; + if (id.toString().lastIndexOf(PortalObjectPath.CanonicalFormat.PA= TH_SEPARATOR) =3D=3D 0) + { + queryString =3D LOOKUP_QUERY_FOR_ROOT; + } + + Query query =3D session.createQuery(queryString); query.setParameter("path", id); query.setCacheable(true); result =3D query.uniqueResult(); Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObje= ctId.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.j= ava 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.j= ava 2007-07-12 05:19:40 UTC (rev 7730) @@ -26,11 +26,9 @@ = /** * A composite id for a portal object in the scope of its container. + *

+ *

* - * - * * @author Julien Viet * @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 =3D ':'; = /** * 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 I= llegalArgumentException @@ -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.For= mat format) throws IllegalArgumentException { @@ -130,7 +129,7 @@ { throw new IllegalArgumentException("No null id value accepted"); } - int pos =3D idValue.indexOf(':'); + int pos =3D idValue.indexOf(NAMESPACE_SEPARATOR); = // if (pos =3D=3D -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: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObje= ctPath.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath= .java 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath= .java 2007-07-12 05:19:40 UTC (rev 7730) @@ -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 =3D (PortalObjectPath)o; @@ -339,12 +337,16 @@ } = /** Canonical format, smth like /a/b/c. */ - public static final PortalObjectPath.Format CANONICAL_FORMAT =3D new Po= rtalObjectPath.Format() + public static final PortalObjectPath.Format CANONICAL_FORMAT =3D new Ca= nonicalFormat(); + + public static final class CanonicalFormat extends Format { + public static final char PATH_SEPARATOR =3D '/'; + public String[] parse(String value) { ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value, = "value", "Format.parse(value)"); - if (value.charAt(0) !=3D '/') + if (value.charAt(0) !=3D PATH_SEPARATOR) { throw new IllegalArgumentException("Not a canonical value " + = value); } @@ -358,7 +360,7 @@ int previous =3D 1; while (true) { - int next =3D value.indexOf('/', previous); + int next =3D value.indexOf(PATH_SEPARATOR, previous); if (next =3D=3D -1) { break; @@ -373,7 +375,7 @@ previous =3D 1; while (true) { - int next =3D value.indexOf('/', previous); + int next =3D value.indexOf(PATH_SEPARATOR, previous); if (next =3D=3D -1) { break; @@ -392,7 +394,7 @@ ParameterValidation.throwIllegalArgExceptionIfNull(names, "name s= tring array"); if (from =3D=3D to) { - return "/"; + return "" + PATH_SEPARATOR; } else { @@ -404,13 +406,15 @@ { throw new IllegalArgumentException("No null name expecte= d 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 =3D new Porta= lObjectPath.LegacyFormat(); = Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/Porta= lObjectContainerTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjec= tContainerTestCase.java 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjec= tContainerTestCase.java 2007-07-12 05:19:40 UTC (rev 7730) @@ -70,6 +70,16 @@ TransactionAssert.commitTransaction(); } = + public void testDashboardNodeCreation() throws DuplicatePortalObjectExc= eption + { + TransactionAssert.beginTransaction(); + PortalObject root =3D container.getContext(); + PortalObject dashboard =3D container.createContext("dashboard"); + assertNotNull(dashboard); + assertFalse(root.equals(dashboard)); + TransactionAssert.commitTransaction(); + } + public void testPropertyUpdateCascadeToDescendantsWhenTheyDoNotDeclareI= t() throws Exception { TransactionAssert.beginTransaction(); Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboar= d/DashboardBean.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/Dash= boardBean.java 2007-07-11 22:16:34 UTC (rev 7729) +++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/Dash= boardBean.java 2007-07-12 05:19:40 UTC (rev 7730) @@ -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 =3D PortalObjectId.pars= e("dashboard:/", PortalObjectPath.CANONICAL_FORMAT); + private static final PortalObjectId dashboardId =3D PortalObjectId.pars= e("dashboard" + + PortalObjectId.NAMESPACE_SEPARATOR + PortalObjectPath.CanonicalFor= mat.PATH_SEPARATOR, PortalObjectPath.CANONICAL_FORMAT); = // Wired services = @@ -127,7 +128,7 @@ { return; } - = + // Page for editting if (selectedPageName !=3D null) { @@ -150,7 +151,7 @@ // Collection pages =3D userPortal.getChildren(PortalObject.PAGE_MASK); pageItems =3D new SelectItem[pages.size()]; - for (IteratorStatus i =3D new IteratorStatus(pages);i.hasNext();) + for (IteratorStatus i =3D new IteratorStatus(pages); i.hasNext();) { PortalObject object =3D (PortalObject)i.next(); SelectItem item =3D new SelectItem(); --===============3160992315264707956==--