[portal-commits] JBoss Portal SVN: r8822 - in branches/JBoss_Portal_Branch_2_6/core/src: main/org/jboss/portal/core/impl/model/portal and 3 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Nov 2 10:27:24 EDT 2007


Author: thomas.heute at jboss.com
Date: 2007-11-02 10:27:24 -0400 (Fri, 02 Nov 2007)
New Revision: 8822

Modified:
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.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/PortalObjectImpl.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
   branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
Log:
JBPORTAL-1736: Adding display name to Portal Objects

Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java	2007-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeImpl.java	2007-11-02 14:27:24 UTC (rev 8822)
@@ -25,6 +25,7 @@
 import org.jboss.portal.api.PortalRuntimeContext;
 import org.jboss.portal.api.node.PortalNode;
 import org.jboss.portal.api.node.PortalNodeURL;
+import org.jboss.portal.common.i18n.LocalizedString;
 import org.jboss.portal.common.i18n.ResourceBundleManager;
 import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
 import org.jboss.portal.common.path.RelativePathParser;
@@ -168,8 +169,18 @@
    }
 
    public String getDisplayName(Locale locale)
-   {
-      // Lazyly compute the display name
+   {      
+      LocalizedString ldisplayName = object.getDisplayName();
+      if (ldisplayName != null)
+      {
+         String result = ldisplayName.getString(locale, true);
+         if (result != null)
+         {
+            return result;
+         }
+      }
+      
+      // Lazily compute the display name
       if (displayNameKey == null)
       {
          displayNameKey = RESOURCE_PREFIX + object.getName();

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-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java	2007-11-02 14:27:24 UTC (rev 8822)
@@ -22,13 +22,6 @@
  ******************************************************************************/
 package org.jboss.portal.core.impl.model.portal;
 
-import org.jboss.logging.Logger;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
-import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.jems.hibernate.ContextObject;
-import org.jboss.portal.security.RoleSecurityBinding;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -37,6 +30,13 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.jems.hibernate.ContextObject;
+import org.jboss.portal.security.RoleSecurityBinding;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
@@ -68,7 +68,7 @@
       this.path = null;
       this.name = null;
       this.children = null;
-      this.children = null;
+      this.securityConstraints = null;
    }
 
    public ObjectNode(AbstractPortalObjectContainer.ContainerContext containerContext, PortalObjectId path, String name)

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-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java	2007-11-02 14:27:24 UTC (rev 8822)
@@ -22,18 +22,12 @@
  ******************************************************************************/
 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 java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
@@ -41,6 +35,14 @@
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.i18n.LocalizedString;
+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;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
@@ -65,6 +67,9 @@
    /** . */
    private String listener;
 
+   /** . */
+   private Map displayNames;
+
    /** The node. */
    private ObjectNode objectNode;
 
@@ -135,7 +140,21 @@
    {
       return objectNode.getName();
    }
+   
+   public void setDisplayNames(Map displayNames)
+   {
+      this.displayNames = displayNames;
+   }
+   
+   public Map getDisplayNames()
+   {
+      return displayNames;
+   }
 
+   public LocalizedString getDisplayName()
+   {
+      return new LocalizedString(displayNames, Locale.ENGLISH);
+   }
 
    public PortalObject copy(PortalObject parent, String name, boolean deep) throws DuplicatePortalObjectException, IllegalArgumentException
    {

Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java	2007-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java	2007-11-02 14:27:24 UTC (rev 8822)
@@ -25,6 +25,8 @@
 import java.util.Collection;
 import java.util.Map;
 
+import org.jboss.portal.common.i18n.LocalizedString;
+
 /**
  * The base interface for all portal objects.
  *
@@ -84,8 +86,22 @@
     * @return the object name
     */
    String getName();
+   
+   /**
+    * Return the localized string used to represent that object.
+    *
+    * @return the localized display name
+    */
+   LocalizedString getDisplayName();
 
    /**
+    * Set the localized string used to represent that object.
+    *
+    * @param the localized display name
+    */
+   void setDisplayNames(Map localizedString);
+
+   /**
     * Returns the listener id or null if there is none.
     *
     * @return the listener

Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java	2007-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java	2007-11-02 14:27:24 UTC (rev 8822)
@@ -22,7 +22,15 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal.metadata;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
 import org.jboss.logging.Logger;
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.util.ConversionException;
 import org.jboss.portal.common.util.Tools;
 import org.jboss.portal.common.xml.XMLTools;
 import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
@@ -37,11 +45,6 @@
 import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
 import org.w3c.dom.Element;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
@@ -56,6 +59,7 @@
    private Map properties;
    private Map children;
    private SecurityConstraintsMetaData securityConstraints;
+   private Map displayNames;
 
    public PortalObjectMetaData()
    {
@@ -102,6 +106,16 @@
    {
       this.children = children;
    }
+   
+   public void setDisplayNames(Map displayNames)
+   {
+      this.displayNames = displayNames;
+   }
+   
+   public Map getDisplayNames()
+   {
+      return displayNames;
+   }
 
    public SecurityConstraintsMetaData getSecurityConstraints()
    {
@@ -162,6 +176,9 @@
 
       // Configure listener
       object.setListener(listener);
+      
+      // Configure display name
+      object.setDisplayNames(displayNames);
 
       // Configure security
       SecurityConstraintsMetaData securityConstraints = getSecurityConstraints();
@@ -248,6 +265,8 @@
          {
             buildListenerMetaData(portalObjectMD, listenerElt);
          }
+         
+         buildDisplayNameMetaData(portalObjectMD, portalObjectElt);
       }
       return portalObjectMD;
    }
@@ -267,6 +286,34 @@
          portalObjectMD.getProperties().put(name, value);
       }
    }
+   
+   public static void buildDisplayNameMetaData(PortalObjectMetaData portalObjectMD, Element portalObjectElt)
+   {
+      Iterator displayNamesIt = XMLTools.getChildrenIterator(portalObjectElt, "display-name");
+      
+      // Configure localized display-name
+      Map localizedStringValues = new HashMap();
+      while (displayNamesIt.hasNext())
+      {
+         Element element = (Element)displayNamesIt.next();
+         String lang = element.getAttribute("xml:lang");
+         Locale locale;
+         try
+         {
+            locale = LocaleFormat.DEFAULT.getLocale(lang);
+            localizedStringValues.put(locale, element.getTextContent());
+         }
+         catch (ConversionException e)
+         {
+            log.error("Cannot set localized display-name, for language: " + lang, e);
+         }
+      }
+      if (localizedStringValues.size() != 0)
+      {
+         portalObjectMD.setDisplayNames(localizedStringValues);
+      }
+   }
+   
 
    public static void buildListenerMetaData(PortalObjectMetaData portalObjectMD, Element listenerElt)
    {

Modified: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml	2007-11-02 14:11:31 UTC (rev 8821)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml	2007-11-02 14:27:24 UTC (rev 8822)
@@ -62,7 +62,7 @@
             type="org.jboss.portal.jems.hibernate.MagicString"
             column="NAME"/>
          <one-to-many class="org.jboss.portal.core.impl.model.portal.ObjectNode"/>
-      </map>
+      </map>      
       <many-to-one
          name="parent"
          column="PARENT_KEY"
@@ -104,6 +104,13 @@
          name="listener"
          column="LISTENER"/>
       <map
+         name="displayNames"
+         table="JBP_INSTANCE_DISPLAY_NAMES">
+         <key column="INSTANCE_PK"/>
+         <map-key type="locale" column="LOCALE"/>
+		 <element type="string" column="TEXT"/>
+      </map>         
+      <map
          name="declaredPropertyMap"
          cascade="all-delete-orphan"
          table="JBP_PORTAL_OBJECT_PROPS"




More information about the portal-commits mailing list