Author: hoang_to
Date: 2010-08-24 06:59:10 -0400 (Tue, 24 Aug 2010)
New Revision: 3904
Added:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/conf/portal/configuration.xml
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
GTNPORTAL-1398: Portal navigational properties based on JSR-286
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-24
08:54:09 UTC (rev 3903)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-24
10:59:10 UTC (rev 3904)
@@ -37,4 +37,28 @@
<!--type>org.exoplatform.portal.application.NoBrowserLocalePolicyService</type-->
<type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
</component>
+
+ <component>
+
<key>org.exoplatform.portal.application.state.ContextualPropertyManager</key>
+
<type>org.exoplatform.portal.application.state.ContextualPropertyManagerImpl</type>
+ <component-plugins>
+ <component-plugin>
+ <name>NavigationalStateProviderPlugin</name>
+ <set-method>addPlugin</set-method>
+
<type>org.exoplatform.portal.application.state.NavigationalStateProviderPlugin</type>
+ <init-params>
+ <value-param>
+ <name>namespaceURI</name>
+ <description>Namespace URI</description>
+ <value>http://www.gatein.org</value>
+ </value-param>
+ <value-param>
+ <name>prefix</name>
+ <description>Prefix of QName</description>
+ <value>gtn</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
</configuration>
Added:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java
(rev 0)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/AbstractContextualPropertyProviderPlugin.java 2010-08-24
10:59:10 UTC (rev 3904)
@@ -0,0 +1,38 @@
+/*
+ * 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.component.BaseComponentPlugin;
+import org.exoplatform.portal.webui.application.UIPortlet;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @date
+ */
+
+public abstract class AbstractContextualPropertyProviderPlugin extends
BaseComponentPlugin
+{
+
+ public abstract Map<QName, String[]> getProperties(UIPortlet portletWindow);
+
+}
Added:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java
(rev 0)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManager.java 2010-08-24
10:59:10 UTC (rev 3904)
@@ -0,0 +1,38 @@
+/*
+ * 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.portal.webui.application.UIPortlet;
+import org.picocontainer.Startable;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @date
+ */
+
+public interface ContextualPropertyManager extends Startable
+{
+
+ public Map<QName, String[]> getProperties(UIPortlet portletWindow);
+
+}
Added:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java
(rev 0)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/ContextualPropertyManagerImpl.java 2010-08-24
10:59:10 UTC (rev 3904)
@@ -0,0 +1,77 @@
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.exoplatform.container.component.ComponentPlugin;
+import org.exoplatform.portal.webui.application.UIPortlet;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @date
+ */
+
+public class ContextualPropertyManagerImpl implements ContextualPropertyManager
+{
+
+ private List<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)
+ {
+ whatPortletWindowSee.putAll(plugin.getProperties(portletWindow));
+ }
+
+ return whatPortletWindowSee;
+ }
+
+ @Override
+ public void start()
+ {
+ }
+
+ @Override
+ public void stop()
+ {
+ }
+
+ public void addPlugin(ComponentPlugin plugin)
+ {
+ if(plugin instanceof AbstractContextualPropertyProviderPlugin)
+ {
+ propertyProviderPlugins.add((AbstractContextualPropertyProviderPlugin)plugin);
+ }
+ }
+
+}
Added:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java
(rev 0)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/application/state/NavigationalStateProviderPlugin.java 2010-08-24
10:59:10 UTC (rev 3904)
@@ -0,0 +1,86 @@
+/*
+ * 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@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;
+ }
+ }
+
+}
Modified:
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-08-24
08:54:09 UTC (rev 3903)
+++
portal/branches/branched-r3845/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-08-24
10:59:10 UTC (rev 3904)
@@ -23,6 +23,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.application.UserProfileLifecycle;
+import org.exoplatform.portal.application.state.ContextualPropertyManager;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.NoSuchDataException;
import org.exoplatform.portal.config.model.ApplicationType;
@@ -615,6 +616,7 @@
Map<String, String[]> publicParams = uiPortal.getPublicParameters();
Set<String> allPublicParamsNames = publicParams.keySet();
List<String> supportedPublicParamNames = getPublicRenderParamNames();
+
for (String oneOfAllParams : allPublicParamsNames)
{
if (supportedPublicParamNames.contains(oneOfAllParams))
@@ -622,6 +624,17 @@
publicParamsMap.put(oneOfAllParams, publicParams.get(oneOfAllParams));
}
}
+
+ //Handle exposed portal contextual properties
+ ContextualPropertyManager propertyManager =
this.getApplicationComponent(ContextualPropertyManager.class);
+ Map<QName, String[]> exposedPortalState =
propertyManager.getProperties(this);
+ for(QName qName : exposedPortalState.keySet())
+ {
+ if(supportsPublicParam(qName.getLocalPart()))
+ {
+ publicParamsMap.put(qName.toString(), exposedPortalState.get(qName));
+ }
+ }
return publicParamsMap;
}