[gatein-commits] gatein SVN: r4242 - in portal/trunk: examples/portlets/api and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Sep 19 07:53:08 EDT 2010


Author: julien_viet
Date: 2010-09-19 07:53:07 -0400 (Sun, 19 Sep 2010)
New Revision: 4242

Added:
   portal/trunk/examples/portlets/api/
   portal/trunk/examples/portlets/api/pom.xml
   portal/trunk/examples/portlets/api/src/
   portal/trunk/examples/portlets/api/src/main/
   portal/trunk/examples/portlets/api/src/main/java/
   portal/trunk/examples/portlets/api/src/main/java/org/
   portal/trunk/examples/portlets/api/src/main/java/org/gatein/
   portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/
   portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/
   portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/
   portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/PRPPortlet.java
   portal/trunk/examples/portlets/api/src/main/resources/
   portal/trunk/examples/portlets/api/src/main/webapp/
   portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/
   portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
   portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/web.xml
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/InternalPropertiesPlugin.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java
Removed:
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java
Modified:
   portal/trunk/examples/portlets/pom.xml
   portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
GTNPORTAL-1484: GateIn PRP API Sample
GTNPORTAL-1398: Portal navigational properties based on JSR-286 / fix a bug where the local name of the PRP definition qname was used instead of the PRP definition identifier


Added: portal/trunk/examples/portlets/api/pom.xml
===================================================================
--- portal/trunk/examples/portlets/api/pom.xml	                        (rev 0)
+++ portal/trunk/examples/portlets/api/pom.xml	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <!--
+      the parent isn't required, you can drop it if you add a groupId
+      and version
+   -->
+   <parent>
+      <groupId>org.gatein.portal.examples.portlets</groupId>
+      <artifactId>parent</artifactId>
+      <version>3.2.0-Beta01-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>gatein-api</artifactId>
+   <packaging>war</packaging>
+   <name>GateIn Portal Examples - GateIn API</name>
+
+   <build>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <configuration>
+               <source>1.5</source>
+               <target>1.5</target>
+            </configuration>
+         </plugin>
+      </plugins>
+   </build>
+
+   <dependencies>
+      <dependency>
+         <groupId>javax.portlet</groupId>
+         <artifactId>portlet-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+   </dependencies>
+</project>
\ No newline at end of file

Added: portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/PRPPortlet.java
===================================================================
--- portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/PRPPortlet.java	                        (rev 0)
+++ portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/PRPPortlet.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.samples.api;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PRPPortlet extends GenericPortlet
+{
+
+   @Override
+   protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, IOException
+   {
+      resp.setContentType("text/html");
+      PrintWriter writer = resp.getWriter();
+
+      //
+      writer.println("Public Render Parameters<br/>");
+      writer.println("<table>");
+      for (Map.Entry<String, String[]> entry : req.getParameterMap().entrySet())
+      {
+         writer.print("<tr>");
+         writer.print("<td>");
+         writer.print(entry.getKey());
+         writer.print("</td>");
+         writer.print("<td>");
+         writer.print(entry.getValue()[0]);
+         writer.print("</td>");
+         writer.print("</tr>");
+      }
+      writer.println("</table>");
+
+      //
+      writer.close();
+   }
+}

Added: portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml	                        (rev 0)
+++ portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2009 eXo Platform SAS.
+
+    This is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Lesser General Public License as
+    published by the Free Software Foundation; either version 2.1 of
+    the License, or (at your option) any later version.
+
+    This software is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this software; if not, write to the Free
+    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+    02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<!--
+<portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
+ -->
+
+ <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="1.0">
+
+   <portlet>
+    <description xml:lang="EN">Public Render Parameter API Portlet</description>
+    <portlet-name>PRPAPIPortlet</portlet-name>
+    <display-name xml:lang="EN">Public Render Parameter API Portlet</display-name>
+    <portlet-class>org.gatein.portal.samples.api.PRPPortlet</portlet-class>
+
+    <supports>
+      <mime-type>text/html</mime-type>
+    </supports>
+
+    <portlet-info>
+      <title>PRP Portlet</title>
+      <short-title>PRP Portlet</short-title>
+      <keywords>Sample</keywords>
+    </portlet-info>
+
+     <supported-public-render-parameter>navigation_uri</supported-public-render-parameter>
+     <supported-public-render-parameter>page_name</supported-public-render-parameter>
+     <supported-public-render-parameter>site_type</supported-public-render-parameter>
+     <supported-public-render-parameter>site_name</supported-public-render-parameter>
+     <supported-public-render-parameter>window_width</supported-public-render-parameter>
+     <supported-public-render-parameter>window_height</supported-public-render-parameter>
+     <supported-public-render-parameter>window_show_info_bar</supported-public-render-parameter>
+
+  </portlet>
+
+  <public-render-parameter>
+     <identifier>navigation_uri</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:navigation_uri</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>page_name</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:page_name</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>site_type</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_type</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>site_name</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_name</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>window_width</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_width</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>window_height</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_height</qname>
+  </public-render-parameter>
+  <public-render-parameter>
+     <identifier>window_show_info_bar</identifier>
+     <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_show_info_bar</qname>
+  </public-render-parameter>
+
+</portlet-app>

Added: portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ portal/trunk/examples/portlets/api/src/main/webapp/WEB-INF/web.xml	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+        version="2.5">
+
+  <servlet>
+    <servlet-name>GateInServlet</servlet-name>
+    <servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GateInServlet</servlet-name>
+    <url-pattern>/gateinservlet</url-pattern>
+  </servlet-mapping>
+
+</web-app>

Modified: portal/trunk/examples/portlets/pom.xml
===================================================================
--- portal/trunk/examples/portlets/pom.xml	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/examples/portlets/pom.xml	2010-09-19 11:53:07 UTC (rev 4242)
@@ -14,6 +14,7 @@
    <name>GateIn Portal Examples - Portlets</name>
 
    <modules>
+      <module>api</module>
       <module>jsfhellouser</module>
       <module>jsphellouser</module>
       <module>simplesthelloworld</module>

Modified: portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
--- portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml	2010-09-19 11:53:07 UTC (rev 4242)
@@ -43,22 +43,39 @@
       <type>org.exoplatform.portal.application.state.ContextualPropertyManagerImpl</type>
       <component-plugins>
          <component-plugin>
-           <name>NavigationalStateProviderPlugin</name>
+           <name>PublicPropertiesPlugin</name>
            <set-method>addPlugin</set-method>
-           <type>org.exoplatform.portal.application.state.NavigationalStateProviderPlugin</type>
+           <type>org.exoplatform.portal.application.state.PublicPropertiesPlugin</type>
            <init-params>
              <value-param>
                <name>namespaceURI</name>
                <description>Namespace URI</description>
-               <value>http://www.gatein.org</value>
+               <value>http://www.gatein.org/xml/ns/prp_1_0</value>
              </value-param>
              <value-param>
                <name>prefix</name>
                <description>Prefix of QName</description>
-               <value>gtn</value>
+               <value>prp</value>
              </value-param>
            </init-params>
          </component-plugin>
+        <component-plugin>
+          <name>InternalPropertiesPlugin</name>
+          <set-method>addPlugin</set-method>
+          <type>org.exoplatform.portal.application.state.InternalPropertiesPlugin</type>
+          <init-params>
+            <value-param>
+              <name>namespaceURI</name>
+              <description>Namespace URI</description>
+              <value>http://www.gatein.org/xml/ns/internal_prp_1_0</value>
+            </value-param>
+            <value-param>
+              <name>prefix</name>
+              <description>Prefix of QName</description>
+              <value>iprp</value>
+            </value-param>
+          </init-params>
+        </component-plugin>
       </component-plugins>
    </component>  
 </configuration>

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -23,16 +23,39 @@
 import javax.xml.namespace.QName;
 
 import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
 import org.exoplatform.portal.webui.application.UIPortlet;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
 
 /**
  * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
- * @date
  */
-
 public abstract class AbstractContextualPropertyProviderPlugin extends BaseComponentPlugin
 {
    
-   public abstract Map<QName, String[]> getProperties(UIPortlet portletWindow);
+   /** . */
+   protected final Logger log = LoggerFactory.getLogger(getClass());
 
+   /** . */
+   protected final String namespaceURI;
+
+   /** . */
+   protected final String prefix;
+
+   protected AbstractContextualPropertyProviderPlugin(InitParams params)
+   {
+      this.namespaceURI = params.getValueParam("namespaceURI").getValue();
+      this.prefix = params.getValueParam("prefix").getValue();
+   }
+
+   public abstract void getProperties(UIPortlet portletWindow, Map<QName, String[]> properties);
+
+   protected final void addProperty(Map<QName, String[]> map, QName qname, String value)
+   {
+      if (value != null)
+      {
+         map.put(qname, new String[]{value});
+      }
+   }
 }

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -23,16 +23,19 @@
 import javax.xml.namespace.QName;
 
 import org.exoplatform.portal.webui.application.UIPortlet;
-import org.picocontainer.Startable;
 
 /**
  * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
- * @date
  */
-
-public interface ContextualPropertyManager extends Startable
+public interface ContextualPropertyManager
 {
 
+   /**
+    * Returns a map of qualified names and string values for contextual properties of the portlet.
+    *
+    * @param portletWindow the portlet
+    * @return the contextual properties
+    */
    public Map<QName, String[]> getProperties(UIPortlet portletWindow);
 
 }

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -27,41 +27,42 @@
 
 import org.exoplatform.container.component.ComponentPlugin;
 import org.exoplatform.portal.webui.application.UIPortlet;
+import org.picocontainer.Startable;
 
 /**
  * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
  * @date
  */
 
-public class ContextualPropertyManagerImpl implements ContextualPropertyManager
+public class ContextualPropertyManagerImpl implements ContextualPropertyManager, Startable
 {
 
-   private List<AbstractContextualPropertyProviderPlugin> propertyProviderPlugins;
+   private ArrayList<AbstractContextualPropertyProviderPlugin> propertyProviderPlugins;
    
    public ContextualPropertyManagerImpl() throws Exception
    {
       propertyProviderPlugins = new ArrayList<AbstractContextualPropertyProviderPlugin>();
    }
    
-   @Override
    public Map<QName, String[]> getProperties(UIPortlet portletWindow)
    {
       Map<QName, String[]> whatPortletWindowSee = new HashMap<QName, String[]>();
-      
-      for(AbstractContextualPropertyProviderPlugin plugin : propertyProviderPlugins)
+
+      // No need to use an iterator here
+      for (int i = 0;i < propertyProviderPlugins.size();i++)
       {
-         whatPortletWindowSee.putAll(plugin.getProperties(portletWindow));
+         AbstractContextualPropertyProviderPlugin plugin  = propertyProviderPlugins.get(i);
+         plugin.getProperties(portletWindow, whatPortletWindowSee);
       }
-      
+
+      //
       return whatPortletWindowSee;
    }
 
-   @Override
    public void start()
    {
    }
 
-   @Override
    public void stop()
    {
    }
@@ -73,5 +74,4 @@
          propertyProviderPlugins.add((AbstractContextualPropertyProviderPlugin)plugin);
       }
    }
-
 }

Added: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/InternalPropertiesPlugin.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/InternalPropertiesPlugin.java	                        (rev 0)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/InternalPropertiesPlugin.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application.state;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.webui.application.UIPortlet;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * This plugins setup properties that are NOT publicly supported, however it is recommanded to not change anything
+ * but there are no guarantees that it won't change.
+ *
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InternalPropertiesPlugin extends AbstractContextualPropertyProviderPlugin
+{
+
+   /** . */
+   private final QName storageIdQName;
+
+   /** . */
+   private final QName storageNameQName;
+
+   public InternalPropertiesPlugin(InitParams params)
+   {
+      super(params);
+
+      //
+      this.storageIdQName = new QName(namespaceURI, "storage_id", prefix);
+      this.storageNameQName = new QName(namespaceURI, "storage_name", prefix);
+   }
+
+   @Override
+   public void getProperties(UIPortlet portletWindow, Map<QName, String[]> properties)
+   {
+      addProperty(properties, storageIdQName, portletWindow.getStorageId());
+      addProperty(properties, storageNameQName, portletWindow.getStorageName());
+   }
+}

Deleted: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.portal.application.state;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.webui.application.UIPortlet;
-import org.exoplatform.portal.webui.page.UIPage;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.util.Util;
-
-/**
- * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
- * @date
- */
-
-public class NavigationalStateProviderPlugin extends AbstractContextualPropertyProviderPlugin
-{
-
-   private final String NAMESPACE_URI;
-   
-   private final String PREFIX;
-   
-   public NavigationalStateProviderPlugin(InitParams params) throws Exception
-   {
-      NAMESPACE_URI = params.getValueParam("namespaceURI").getValue();
-      PREFIX = params.getValueParam("prefix").getValue();
-   }
-   
-   @Override
-   public Map<QName, String[]> getProperties(UIPortlet portletWindow)
-   {
-      Map<QName, String[]> whatThisPluginProvides = new HashMap<QName, String[]>();
-
-      try
-      {
-         UIPortal currentSite = Util.getUIPortalApplication().getShowedUIPortal();
-         PageNode currentNode = currentSite.getSelectedNode();
-         
-         //Provides current node URI
-         whatThisPluginProvides.put(new QName(NAMESPACE_URI, "navigation_uri", PREFIX), new String[]{currentNode.getUri()});
-         
-         //Provides current page name
-         UIPage currentPage = currentSite.getUIPage(currentNode.getPageReference());
-         if(currentPage != null)
-         {
-            whatThisPluginProvides.put(new QName(NAMESPACE_URI, "page_name", PREFIX), new String[]{currentPage.getTitle()});
-         }
-         
-         //Provides current site type
-         whatThisPluginProvides.put(new QName(NAMESPACE_URI, "site_type", PREFIX), new String[]{currentSite.getOwnerType()});
-         
-         //Provides current site name
-         whatThisPluginProvides.put(new QName(NAMESPACE_URI, "site_name", PREFIX), new String[]{currentSite.getOwner()});
-         
-         return whatThisPluginProvides;
-      }
-      catch (Exception ex)
-      {
-         ex.printStackTrace();
-         return null;
-      }
-   }
-
-}

Copied: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java (from rev 4221, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java)
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java	                        (rev 0)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.portal.application.state;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.webui.application.UIPortlet;
+import org.exoplatform.portal.webui.page.UIPage;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.util.Util;
+
+/**
+ * This plugin setup properties that are publicly supported, hence this is part of a public API
+ * and once published its contract must not change whatsoever.
+ *
+ * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
+ */
+public class PublicPropertiesPlugin extends AbstractContextualPropertyProviderPlugin
+{
+
+   /** . */
+   private final QName navigationURIQName;
+
+   /** . */
+   private final QName pageNameQName;
+
+   /** . */
+   private final QName siteTypeQName;
+
+   /** . */
+   private final QName siteNameQName;
+
+   /** . */
+   private final QName windowShowInfoBarQName;
+
+   /** . */
+   private final QName windowHeight;
+
+   /** . */
+   private final QName windowWidth;
+
+   public PublicPropertiesPlugin(InitParams params) throws Exception
+   {
+      super(params);
+
+      //
+      this.navigationURIQName = new QName(namespaceURI, "navigation_uri", prefix);
+      this.pageNameQName = new QName(namespaceURI, "page_name", prefix);
+      this.siteTypeQName = new QName(namespaceURI, "site_type", prefix);
+      this.siteNameQName = new QName(namespaceURI, "site_name", prefix);
+      this.windowWidth = new QName(namespaceURI, "window_width", prefix);
+      this.windowHeight = new QName(namespaceURI, "window_height", prefix);
+      this.windowShowInfoBarQName = new QName(namespaceURI, "window_show_info_bar", prefix);
+   }
+
+   @Override
+   public void getProperties(UIPortlet portletWindow, Map<QName, String[]> properties)
+   {
+      try
+      {
+         UIPortal currentSite = Util.getUIPortalApplication().getShowedUIPortal();
+         PageNode currentNode = currentSite.getSelectedNode();
+         
+         // Navigation related properties
+         addProperty(properties, navigationURIQName, currentNode.getUri());
+
+         // Page related properties
+         UIPage currentPage = currentSite.getUIPage(currentNode.getPageReference());
+         if(currentPage != null)
+         {
+            addProperty(properties, pageNameQName, currentPage.getTitle());
+         }
+         
+         // Site related properties
+         addProperty(properties, siteTypeQName, currentSite.getOwnerType());
+         addProperty(properties, siteNameQName, currentSite.getOwner());
+
+         // Window related properties
+         addProperty(properties, windowShowInfoBarQName, Boolean.toString(portletWindow.getShowInfoBar()));
+         addProperty(properties, windowWidth, portletWindow.getWidth());
+         addProperty(properties, windowHeight, portletWindow.getHeight());
+      }
+      catch (Exception ex)
+      {
+         log.error("Could not obtain contextual properties for portlet " + portletWindow, ex);
+      }
+   }
+}

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2010-09-17 14:42:13 UTC (rev 4241)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java	2010-09-19 11:53:07 UTC (rev 4242)
@@ -154,7 +154,7 @@
 
    private List<QName> supportedPublishingEvents_;
 
-   private List<String> supportedPublicParams_;
+   private Map<QName, String> supportedPublicParams_;
 
    private boolean portletInPortal_ = true;
 
@@ -351,12 +351,37 @@
       supportedProcessingEvents_ = supportedProcessingEvents;
    }
 
-   public List<String> getSupportedPublicRenderParameters()
+   public Map<QName, String> getSupportedPublicRenderParameters()
    {
+      if (supportedPublicParams_ == null)
+      {
+         if (producedOfferedPortlet == null)
+         {
+            log.info("Could not find portlet with ID : " + producerOfferedPortletContext.getId());
+            return Collections.emptyMap();
+         }
+
+         //
+         Collection<ParameterInfo> parameters = (Collection<ParameterInfo>)producedOfferedPortlet.getInfo().getNavigation().getPublicParameters();
+         Map<QName, String> supportedPublicParams = Collections.emptyMap();
+         for (ParameterInfo parameter : parameters)
+         {
+            if (supportedPublicParams.isEmpty())
+            {
+               supportedPublicParams = new HashMap<QName, String>();
+            }
+            supportedPublicParams.put(parameter.getName(), parameter.getId());
+         }
+
+         //
+         this.supportedPublicParams_ = supportedPublicParams;
+      }
+
+      //
       return supportedPublicParams_;
    }
 
-   public void setSupportedPublicRenderParameters(List<String> supportedPublicRenderParameters)
+   public void setSupportedPublicRenderParameters(Map<QName, String> supportedPublicRenderParameters)
    {
       supportedPublicParams_ = supportedPublicRenderParameters;
    }
@@ -542,46 +567,35 @@
 
    /**
     * Tells, according to the info located in portlet.xml, wether this portlet supports the public render parameter
-    * given as a method argument
+    * qname given as method argument. If the qname is supported, the public render parameter id is returned otherwise
+    * false is returned.
+    *
+    * @param supportedPublicParam the supported public parameter qname
+    * @return the supported public parameter id
     */
-   public boolean supportsPublicParam(String supportedPublicParam)
+   public String supportsPublicParam(QName supportedPublicParam)
    {
-      if (supportedPublicParams_ == null)
-      {
+      Map<QName, String> supportedPublicParams = getSupportedPublicRenderParameters();
+      return supportedPublicParams.get(supportedPublicParam);
+   }
 
-         //
-         if (producedOfferedPortlet == null)
-         {
-            log.info("Could not find portlet with ID : " + producerOfferedPortletContext.getId());
-            return false;
-         }
-
-         //
-         Collection<ParameterInfo> parameters =
-            (Collection<ParameterInfo>)producedOfferedPortlet.getInfo().getNavigation().getPublicParameters();
-         supportedPublicParams_ = new ArrayList<String>();
-         for (ParameterInfo parameter : parameters)
-         {
-            supportedPublicParams_.add(parameter.getId());
-         }
-      }
-
-      //
-      for (String publicParam : supportedPublicParams_)
+   /**
+    * Tells, according to the info located in portlet.xml, wether this portlet supports the public render parameter
+    * id given as a method argument.
+    *
+    * @param supportedPublicParamId the supported public parameter id
+    * @return true if the supported public parameter id is supported
+    */
+   public boolean supportsPublicParam(String supportedPublicParamId)
+   {
+      Map<QName, String> supportedPublicParams = getSupportedPublicRenderParameters();
+      boolean supported = supportedPublicParams.containsValue(supportedPublicParamId);
+      if (supported && log.isDebugEnabled())
       {
-         if (publicParam.equals(supportedPublicParam))
-         {
-            if (log.isDebugEnabled())
-            {
-               log.debug("The Portlet " + producerOfferedPortletContext.getId()
-                  + " supports the public render parameter : " + supportedPublicParam);
-            }
-            return true;
-         }
+         log.debug("The Portlet " + producerOfferedPortletContext.getId()
+            + " supports the public render parameter : " + supportedPublicParamId);
       }
-
-      //
-      return false;
+      return true;
    }
 
    /**
@@ -625,16 +639,19 @@
          }
       }
       
-      //Handle exposed portal contextual properties
+      // Handle exposed portal contextual properties
       ContextualPropertyManager propertyManager = this.getApplicationComponent(ContextualPropertyManager.class);
       Map<QName, String[]> exposedPortalState = propertyManager.getProperties(this);
-      for(QName qName : exposedPortalState.keySet())
+      for(QName prpQName : exposedPortalState.keySet())
       {
-         if(supportsPublicParam(qName.getLocalPart()))
+         String prpId = supportsPublicParam(prpQName);
+         if(prpId != null)
          {
-            publicParamsMap.put(qName.toString(), exposedPortalState.get(qName));
+            publicParamsMap.put(prpId, exposedPortalState.get(prpQName));
          }
       }
+
+      //
       return publicParamsMap;
    }
 



More information about the gatein-commits mailing list