Author: julien_viet
Date: 2010-02-25 19:57:47 -0500 (Thu, 25 Feb 2010)
New Revision: 1871
Removed:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyPortalStateManager.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/ReplicatingStateManager.java
Modified:
portal/trunk/component/portal/src/main/java/gatein_objects_1_0.xsd
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java
portal/trunk/component/portal/src/main/resources/binding.xml
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java
portal/trunk/component/portal/src/test/resources/portal/portal/test/navigation.xml
portal/trunk/examples/extension/war/src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic/navigation.xml
portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/conf/sample-portal/portal/portal/classic/navigation.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
Log:
GTNPORTAL-767: Improve node navigation visibility
Modified: portal/trunk/component/portal/src/main/java/gatein_objects_1_0.xsd
===================================================================
--- portal/trunk/component/portal/src/main/java/gatein_objects_1_0.xsd 2010-02-25 23:10:54
UTC (rev 1870)
+++ portal/trunk/component/portal/src/main/java/gatein_objects_1_0.xsd 2010-02-26 00:57:47
UTC (rev 1871)
@@ -66,13 +66,21 @@
<xs:element name="icon" type="xs:string"
minOccurs="0" maxOccurs="1"/>
<xs:element name="start-publication-date" type="xs:string"
minOccurs="0" maxOccurs="1"/>
<xs:element name="end-publication-date" type="xs:string"
minOccurs="0" maxOccurs="1"/>
- <xs:element name="show-publication-date" type="xs:boolean"
minOccurs="0" maxOccurs="1"/>
- <xs:element name="visible" type="xs:boolean"
default="true" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="visibility" type="visibility"
default="VISIBLE" minOccurs="0" maxOccurs="1"/>
<xs:element name="page-reference" type="xs:string"
minOccurs="0" maxOccurs="1"/>
<xs:element name="node" type="nodeType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
+ <xs:simpleType name="visibility">
+ <xs:restriction base='xs:string'>
+ <xs:enumeration value="DISPLAYED"/>
+ <xs:enumeration value="HIDDEN"/>
+ <xs:enumeration value="TEMPORAL"/>
+ <xs:enumeration value="SYSTEM"/>
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:complexType name="pageSetType">
<xs:sequence>
<xs:element name="page" type="pageType"
minOccurs="0" maxOccurs="unbounded"/>
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNode.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -20,6 +20,7 @@
package org.exoplatform.portal.config.model;
import org.exoplatform.commons.utils.ExpressionUtil;
+import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.pom.data.NavigationNodeData;
import java.util.ArrayList;
@@ -46,10 +47,8 @@
private Date endPublicationDate;
- private boolean showPublicationDate = false;
+ private Visibility visibility = Visibility.DISPLAYED;
- private boolean visible = true;
-
private String pageReference;
private transient boolean modifiable;
@@ -74,8 +73,7 @@
this.name = nav.getName();
this.startPublicationDate = nav.getStartPublicationDate();
this.endPublicationDate = nav.getEndPublicationDate();
- this.showPublicationDate = nav.getShowPublicationDate();
- this.visible = nav.isVisible();
+ this.visibility = nav.getVisibility();
this.pageReference = nav.getPageReference();
this.children = children;
}
@@ -203,26 +201,56 @@
public boolean isDisplay()
{
- if (visible && showPublicationDate)
+ switch (visibility)
{
- return isInPublicationDate();
+ case DISPLAYED:
+ return true;
+ case HIDDEN:
+ return false;
+ case TEMPORAL:
+ return isInPublicationDate();
+ case SYSTEM:
+ return false;
+ default:
+ throw new AssertionError();
}
- return visible;
}
public boolean isVisible()
{
- return visible;
+ switch (visibility)
+ {
+ case DISPLAYED:
+ case TEMPORAL:
+ return true;
+ case SYSTEM:
+ case HIDDEN:
+ return false;
+ default:
+ throw new AssertionError();
+ }
}
- public boolean getVisible()
+ public void setVisible(Boolean b)
{
- return visible;
+ if (b != null)
+ {
+ switch (visibility)
+ {
+ case SYSTEM:
+ break;
+ case HIDDEN:
+ case DISPLAYED:
+ case TEMPORAL:
+ visibility = b ? Visibility.DISPLAYED : Visibility.HIDDEN;
+ break;
+ }
+ }
}
- public void setVisible(Boolean b)
+ public void setVisibility(Visibility visibility)
{
- visible = b.booleanValue();
+ this.visibility = visibility;
}
private boolean isInPublicationDate()
@@ -230,22 +258,33 @@
if (startPublicationDate != null && endPublicationDate != null)
{
Date currentDate = new Date();
- if (currentDate.compareTo(startPublicationDate) >= 0 &&
currentDate.compareTo(endPublicationDate) <= 0)
- return true;
+
+ //
+ return currentDate.compareTo(startPublicationDate) >= 0 &&
currentDate.compareTo(endPublicationDate) <= 0;
}
- else if (startPublicationDate == null && endPublicationDate == null)
- return true;
- return false;
+ else return startPublicationDate == null && endPublicationDate == null;
}
public void setShowPublicationDate(Boolean show)
{
- showPublicationDate = show.booleanValue();
+ if (show != null)
+ {
+ switch (visibility)
+ {
+ case SYSTEM:
+ case HIDDEN:
+ break;
+ case TEMPORAL:
+ case DISPLAYED:
+ visibility = show ? Visibility.TEMPORAL : Visibility.DISPLAYED;
+ break;
+ }
+ }
}
public boolean isShowPublicationDate()
{
- return showPublicationDate;
+ return visibility == Visibility.TEMPORAL;
}
public PageNode getChild(String name)
@@ -275,10 +314,9 @@
newNode.setResolvedLabel(resolvedLabel);
newNode.setPageReference(pageReference);
newNode.setModifiable(modifiable);
- newNode.setShowPublicationDate(showPublicationDate);
newNode.setStartPublicationDate(startPublicationDate);
newNode.setEndPublicationDate(endPublicationDate);
- newNode.setVisible(visible);
+ newNode.setVisibility(visibility);
if (children == null || children.size() < 1)
return newNode;
for (PageNode ele : children)
@@ -300,8 +338,7 @@
name,
startPublicationDate,
endPublicationDate,
- showPublicationDate,
- visible,
+ visibility,
pageReference,
children
);
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -68,13 +68,10 @@
public static final Key<Date> END_PUBLICATION_DATE =
Key.create("end-publication-date", ValueType.DATE);
/** . */
- public static final Key<Boolean> VISIBLE = Key.create("visible",
ValueType.BOOLEAN);
-
- /** . */
public static final Key<String> TEMPLATE = Key.create("template",
ValueType.STRING);
/** . */
- public static final Key<Boolean> SHOW_PUBLICATION_DATE =
Key.create("show-publication-date", ValueType.BOOLEAN);
+ public static final Key<String> VISIBILITY = Key.create("visibility",
ValueType.STRING);
/** . */
public static final Key<Boolean> SHOW_INFO_BAR =
Key.create("show-info-bar", ValueType.BOOLEAN);
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -29,6 +29,7 @@
import org.exoplatform.portal.config.model.PersistentApplicationState;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.Utils;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
@@ -162,8 +163,7 @@
src.getName(),
attrs.getValue(MappedAttributes.START_PUBLICATION_DATE),
attrs.getValue(MappedAttributes.END_PUBLICATION_DATE),
- attrs.getValue(MappedAttributes.SHOW_PUBLICATION_DATE, false),
- attrs.getValue(MappedAttributes.VISIBLE, true),
+ Visibility.valueOf(attrs.getValue(MappedAttributes.VISIBILITY,
Visibility.DISPLAYED.toString())),
pageReference,
children
);
@@ -211,8 +211,7 @@
attrs.setValue(MappedAttributes.ICON, node.getIcon());
attrs.setValue(MappedAttributes.START_PUBLICATION_DATE,
node.getStartPublicationDate());
attrs.setValue(MappedAttributes.END_PUBLICATION_DATE,
node.getEndPublicationDate());
- attrs.setValue(MappedAttributes.SHOW_PUBLICATION_DATE,
node.getShowPublicationDate());
- attrs.setValue(MappedAttributes.VISIBLE, node.isVisible());
+ attrs.setValue(MappedAttributes.VISIBILITY, node.getVisibility().name());
}
else if (src instanceof NavigationData)
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/NavigationNodeData.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.portal.pom.data;
+import org.exoplatform.portal.mop.Visibility;
+
import java.util.Date;
import java.util.List;
@@ -47,12 +49,9 @@
private final Date endPublicationDate;
/** . */
- private final boolean showPublicationDate;
+ private final Visibility visibility;
/** . */
- private final boolean visible;
-
- /** . */
private final String pageReference;
public NavigationNodeData(
@@ -62,12 +61,11 @@
String name,
Date startPublicationDate,
Date endPublicationDate,
- Boolean showPublicationDate,
- Boolean visible,
+ Visibility visibility,
String pageReference,
List<NavigationNodeData> children)
{
- this(null, uri, label, icon, name, startPublicationDate, endPublicationDate,
showPublicationDate, visible, pageReference, children);
+ this(null, uri, label, icon, name, startPublicationDate, endPublicationDate,
visibility, pageReference, children);
}
public NavigationNodeData(
@@ -78,8 +76,7 @@
String name,
Date startPublicationDate,
Date endPublicationDate,
- Boolean showPublicationDate,
- Boolean visible,
+ Visibility visibility,
String pageReference,
List<NavigationNodeData> children)
{
@@ -92,8 +89,7 @@
this.name = name;
this.startPublicationDate = startPublicationDate;
this.endPublicationDate = endPublicationDate;
- this.showPublicationDate = showPublicationDate != null ? showPublicationDate :
false;
- this.visible = visible != null ? visible : true;
+ this.visibility = visibility;
this.pageReference = pageReference;
}
public String getURI()
@@ -126,16 +122,11 @@
return endPublicationDate;
}
- public boolean getShowPublicationDate()
+ public Visibility getVisibility()
{
- return showPublicationDate;
+ return visibility;
}
- public boolean isVisible()
- {
- return visible;
- }
-
public String getPageReference()
{
return pageReference;
Modified: portal/trunk/component/portal/src/main/resources/binding.xml
===================================================================
--- portal/trunk/component/portal/src/main/resources/binding.xml 2010-02-25 23:10:54 UTC
(rev 1870)
+++ portal/trunk/component/portal/src/main/resources/binding.xml 2010-02-26 00:57:47 UTC
(rev 1871)
@@ -96,8 +96,7 @@
<value name="icon" field="icon"
usage="optional"/>
<value name="start-publication-date"
field="startPublicationDate" usage="optional"/>
<value name="end-publication-date" field="endPublicationDate"
usage="optional"/>
- <value name="show-publication-date"
field="showPublicationDate" usage="optional"/>
- <value name="visible" field="visible"
usage="optional" default="true"/>
+ <value name="visibility" field="visibility"
usage="optional" default="DISPLAYED"/>
<value name="page-reference" field="pageReference"
usage="optional"/>
<collection field="children" usage="optional"
item-type="org.exoplatform.portal.config.model.PageNode"/>
</mapping>
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -119,8 +119,7 @@
GregorianCalendar end = new GregorianCalendar(2009, 2, 21, 1, 33, 0);
end.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals(end.getTime(), nodeAttrs.getDate("end-publication-date"));
- assertEquals(true,
(boolean)nodeAttrs.getBoolean("show-publication-date"));
- assertEquals(true, (boolean)nodeAttrs.getBoolean("visible"));
+ assertEquals("TEMPORAL", nodeAttrs.getString("visibility"));
//
Link link = nodeNavigation.getLink();
Modified:
portal/trunk/component/portal/src/test/resources/portal/portal/test/navigation.xml
===================================================================
---
portal/trunk/component/portal/src/test/resources/portal/portal/test/navigation.xml 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/component/portal/src/test/resources/portal/portal/test/navigation.xml 2010-02-26
00:57:47 UTC (rev 1871)
@@ -33,8 +33,7 @@
<icon>node_icon</icon>
<start-publication-date>2000-03-21T01:33:00</start-publication-date>
<end-publication-date>2009-03-21T01:33:00</end-publication-date>
- <show-publication-date>true</show-publication-date>
- <visible>true</visible>
+ <visibility>TEMPORAL</visibility>
<page-reference>portal::test::test</page-reference>
</node>
<node>
Modified:
portal/trunk/examples/extension/war/src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic/navigation.xml
===================================================================
---
portal/trunk/examples/extension/war/src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic/navigation.xml 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/examples/extension/war/src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic/navigation.xml 2010-02-26
00:57:47 UTC (rev 1871)
@@ -37,8 +37,8 @@
<uri>groupnavigation</uri>
<name>groupnavigation</name>
<label>#{portal.classic.groupnavigation}</label>
- <!-- Change visible attribute to "true" -->
- <visible>true</visible>
+ <!-- Change visibility attribute to displayed -->
+ <visibility>DISPLAYED</visibility>
<page-reference>portal::classic::groupnavigation</page-reference>
</node>
</page-nodes>
Modified:
portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/conf/sample-portal/portal/portal/classic/navigation.xml
===================================================================
---
portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/conf/sample-portal/portal/portal/classic/navigation.xml 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/examples/portal/war/src/main/webapp/WEB-INF/conf/sample-portal/portal/portal/classic/navigation.xml 2010-02-26
00:57:47 UTC (rev 1871)
@@ -37,8 +37,8 @@
<uri>groupnavigation</uri>
<name>groupnavigation</name>
<label>#{portal.classic.groupnavigation}</label>
- <!-- Change visible attribute to "true" -->
- <visible>true</visible>
+ <!-- Change visibility attribute to displayed -->
+ <visibility>DISPLAYED</visibility>
<page-reference>portal::classic::groupnavigation</page-reference>
</node>
</page-nodes>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml 2010-02-26
00:57:47 UTC (rev 1871)
@@ -36,28 +36,28 @@
<uri>sitemap</uri>
<name>sitemap</name>
<label>#{portal.classic.sitemap}</label>
- <visible>true</visible>
+ <visibility>DISPLAYED</visibility>
<page-reference>portal::classic::sitemap</page-reference>
</node>
<node>
<uri>groupnavigation</uri>
<name>groupnavigation</name>
<label>#{portal.classic.groupnavigation}</label>
- <visible>false</visible>
- <page-reference>portal::classic::groupnavigation</page-reference>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::groupnavigation</page-reference>
</node>
<node>
<uri>portalnavigation</uri>
<name>portalnavigation</name>
<label>#{portal.classic.portalnavigation}</label>
- <visible>false</visible>
- <page-reference>portal::classic::portalnavigation</page-reference>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::classic::portalnavigation</page-reference>
</node>
<node>
<uri>register</uri>
<name>register</name>
<label>#{portal.classic.register}</label>
- <visible>false</visible>
+ <visibility>SYSTEM</visibility>
<page-reference>portal::classic::register</page-reference>
</node>
</page-nodes>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml 2010-02-26
00:57:47 UTC (rev 1871)
@@ -37,21 +37,21 @@
<uri>groupnavigation</uri>
<name>groupnavigation</name>
<label>Group Navigation</label>
- <visible>false</visible>
+ <visibility>SYSTEM</visibility>
<page-reference>portal::@owner@::groupnavigation</page-reference>
</node>
<node>
<uri>portalnavigation</uri>
<name>portalnavigation</name>
<label>Portal Navigation</label>
- <visible>false</visible>
+ <visibility>SYSTEM</visibility>
<page-reference>portal::@owner@::portalnavigation</page-reference>
</node>
<node>
<uri>register</uri>
<name>register</name>
<label>Register</label>
- <visible>false</visible>
+ <visibility>SYSTEM</visibility>
<page-reference>portal::@owner@::register</page-reference>
</node>
</page-nodes>
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyPortalStateManager.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyPortalStateManager.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyPortalStateManager.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -1,213 +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;
-
-import org.exoplatform.commons.utils.Safe;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.SessionManagerContainer;
-import org.exoplatform.portal.config.UserPortalConfig;
-import org.exoplatform.portal.config.UserPortalConfigService;
-import org.exoplatform.portal.webui.workspace.UIPortalApplication;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.webui.application.ConfigurationManager;
-import org.exoplatform.webui.application.StateManager;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.application.portlet.PortletRequestContext;
-import org.exoplatform.webui.core.UIApplication;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class LegacyPortalStateManager extends StateManager
-{
-
- protected static Log log =
ExoLogger.getLogger("portal:PortalStateManager");
-
- /** ConcurrentMap<SessionId, HashMap<PortalName, PortalApplicationState>>
* */
- private ConcurrentMap<String, HashMap<String, PortalApplicationState>>
uiApplications =
- new ConcurrentHashMap<String, HashMap<String,
PortalApplicationState>>();
-
- /**
- * This method is used to restore the UI component tree either the current request
targets a portlet or the portal.
- * <p/>
- * In both cases, if the tree is not stored already it is created and then stored in a
local Map
- */
- @SuppressWarnings("unchecked")
- public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws
Exception
- {
- context.setStateManager(this);
- WebuiApplication app = (WebuiApplication)context.getApplication();
-
- /*
- * If the request context is of type PortletRequestContext, we extract the parent
context which will
- * allow to get access to the PortalApplicationState object thanks to the session
id used as the key for the
- * synchronize Map uiApplications
- */
- if (context instanceof PortletRequestContext)
- {
- WebuiRequestContext preqContext =
(WebuiRequestContext)context.getParentAppRequestContext();
- PortletRequestContext pcontext = (PortletRequestContext)context;
- String key = pcontext.getApplication().getApplicationId() + "/" +
pcontext.getWindowId();
- PortalApplicationState state = getApplicationState(preqContext);
- UIApplication uiApplication = state.get(key);
- if (uiApplication != null)
- {
- return uiApplication;
- }
- ConfigurationManager cmanager = app.getConfigurationManager();
- String uirootClass = cmanager.getApplication().getUIRootComponent();
- Class type =
Thread.currentThread().getContextClassLoader().loadClass(uirootClass);
- uiApplication = (UIApplication)app.createUIComponent(type, null, null,
context);
- state.put(key, uiApplication);
- return uiApplication;
- }
-
- PortalRequestContext pcontext = (PortalRequestContext)context;
- PortalApplicationState state = getApplicationState(pcontext);
- if (state != null)
- {
- if (!Safe.equals(pcontext.getRemoteUser(), state.getUserName()))
- {
- clearSession(pcontext.getRequest().getSession());
- state = null;
- }
- }
- if (state == null)
- {
- ConfigurationManager cmanager = app.getConfigurationManager();
- String uirootClass = cmanager.getApplication().getUIRootComponent();
- Class type =
Thread.currentThread().getContextClassLoader().loadClass(uirootClass);
- UserPortalConfig config = getUserPortalConfig(pcontext);
- if (config == null)
- {
- HttpServletResponse response = pcontext.getResponse();
- // if(pcontext.getRemoteUser() == null) {
- // String portalName = pcontext.getPortalOwner() ;
- // portalName = URLEncoder.encode(portalName, "UTF-8") ;
- // String redirect = pcontext.getRequest().getContextPath() +
"/private/" + portalName + "/";
- // response.sendRedirect(redirect);
- // }
- // else response.sendRedirect(pcontext.getRequest().getContextPath() +
"/portal-unavailable.jsp");
- response.sendRedirect(pcontext.getRequest().getContextPath() +
"/portal-unavailable.jsp");
- pcontext.setResponseComplete(true);
- return null;
- }
- pcontext.setAttribute(UserPortalConfig.class, config);
- UIPortalApplication uiApplication =
(UIPortalApplication)app.createUIComponent(type, null, null, context);
- state = new PortalApplicationState(uiApplication, pcontext.getRemoteUser());
- cacheApplicationState(pcontext.getSessionId(), pcontext.getPortalOwner(),
state);
- SessionManagerContainer pcontainer =
(SessionManagerContainer)app.getApplicationServiceContainer();
- pcontainer.createSessionContainer(context.getSessionId(),
uiApplication.getOwner());
- }
- return state.getUIPortalApplication();
- }
-
- @SuppressWarnings("unused")
- public void storeUIRootComponent(WebuiRequestContext context)
- {
- }
-
- public void expire(String sessionId, WebuiApplication app)
- {
- uiApplications.remove(sessionId);
- SessionManagerContainer pcontainer =
(SessionManagerContainer)app.getApplicationServiceContainer();
- pcontainer.removeSessionContainer(sessionId);
- }
-
- private PortalApplicationState getApplicationState(WebuiRequestContext context)
- {
- PortalRequestContext portalContext = null;
- if (context instanceof PortalRequestContext)
- {
- portalContext = (PortalRequestContext)context;
- }
- else
- {
- portalContext = (PortalRequestContext)context.getParentAppRequestContext();
- }
- String portalName = portalContext.getPortalOwner();
- String sessionId = portalContext.getSessionId();
-
- HashMap<String, PortalApplicationState> appStates =
uiApplications.get(sessionId);
- return (appStates == null) ? null : appStates.get(portalName);
- }
-
- private void cacheApplicationState(String sessionId, String portalName,
PortalApplicationState state)
- {
- HashMap<String, PortalApplicationState> appStates =
uiApplications.get(sessionId);
- if (appStates == null)
- {
- appStates = new HashMap<String, PortalApplicationState>();
- uiApplications.put(sessionId, appStates);
- }
- appStates.put(portalName, state);
- }
-
- private UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws
Exception
- {
- ExoContainer appContainer =
context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService service_ =
-
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- String remoteUser = context.getRemoteUser();
- String ownerUser = context.getPortalOwner();
- return service_.getUserPortalConfig(ownerUser, remoteUser);
- }
-
- private void clearSession(HttpSession session)
- {
- Enumeration<?> e = session.getAttributeNames();
- while (e.hasMoreElements())
- {
- String name = (String)e.nextElement();
- session.removeAttribute(name);
- }
- }
-
- @SuppressWarnings("serial")
- static public class PortalApplicationState extends HashMap<String,
UIApplication>
- {
-
- private final UIPortalApplication uiPortalApplication_;
-
- private final String userName_;
-
- public PortalApplicationState(UIPortalApplication uiPortalApplication, String
userName)
- {
- uiPortalApplication_ = uiPortalApplication;
- userName_ = userName;
- }
-
- public String getUserName()
- {
- return userName_;
- }
-
- public UIPortalApplication getUIPortalApplication()
- {
- return uiPortalApplication_;
- }
- }
-}
\ No newline at end of file
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -19,49 +19,164 @@
package org.exoplatform.portal.application;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.container.ExoContainer;
-import org.exoplatform.portal.application.replication.ReplicatingStateManager;
+import org.exoplatform.portal.application.replication.ApplicationState;
+import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.webui.application.ConfigurationManager;
import org.exoplatform.webui.application.StateManager;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.core.UIApplication;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
public class PortalStateManager extends StateManager
{
/** . */
- private final StateManager impl;
+ private static final String APPLICATION_ATTRIBUTE_PREFIX = "rsm.";
- public PortalStateManager()
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(PortalStateManager.class);
+
+ @Override
+ public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws
Exception
{
- boolean clustered = ExoContainer.getProfiles().contains("cluster");
+ context.setStateManager(this);
//
- if (clustered)
+ WebuiApplication app = (WebuiApplication)context.getApplication();
+
+ //
+ ApplicationState appState = null;
+ HttpSession session = getSession(context);
+ String key = getKey(context);
+ if (session != null)
{
- impl = new ReplicatingStateManager();
+ appState = (ApplicationState)session.getAttribute(APPLICATION_ATTRIBUTE_PREFIX +
key);
}
+
+ //
+
+ //
+ UIApplication uiapp = null;
+ if (appState != null)
+ {
+ if (Safe.equals(context.getRemoteUser(), appState.getUserName()))
+ {
+ uiapp = appState.getApplication();
+ }
+ }
+
+ //
+ if (appState != null)
+ {
+ log.debug("Found application " + key + " :" +
appState.getApplication());
+ }
else
{
- impl = new LegacyPortalStateManager();
+ log.debug("Application " + key + " not found");
}
+
+ // Looks like some necessary hacking
+ if (context instanceof PortalRequestContext)
+ {
+ PortalRequestContext portalRC = (PortalRequestContext)context;
+ UserPortalConfig config = getUserPortalConfig(portalRC);
+ if (config == null)
+ {
+ HttpServletResponse response = portalRC.getResponse();
+ response.sendRedirect(portalRC.getRequest().getContextPath() +
"/portal-unavailable.jsp");
+ portalRC.setResponseComplete(true);
+ return null;
+ }
+ portalRC.setAttribute(UserPortalConfig.class, config);
+ }
+
+ //
+ if (uiapp == null)
+ {
+ ConfigurationManager cmanager = app.getConfigurationManager();
+ String uirootClass = cmanager.getApplication().getUIRootComponent();
+ Class<? extends UIApplication> type = (Class<UIApplication>)
Thread.currentThread().getContextClassLoader().loadClass(uirootClass);
+ uiapp = app.createUIComponent(type, null, null, context);
+ }
+
+ //
+ return uiapp;
}
@Override
- public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws
Exception
+ public void storeUIRootComponent(final WebuiRequestContext context) throws Exception
{
- return impl.restoreUIRootComponent(context);
+ UIApplication uiapp = context.getUIApplication();
+
+ //
+ HttpSession session = getSession(context);
+
+ // At this point if it returns null it means that it was not possible to create a
session
+ // because the session might be invalidated and the response is already commited to
the client.
+ // That situation happens during a logout that invalidates the HttpSession
+ if (session != null)
+ {
+ String key = getKey(context);
+ log.debug("Storing application " + key);
+ session.setAttribute(APPLICATION_ATTRIBUTE_PREFIX + key, new
ApplicationState(uiapp, context.getRemoteUser()));
+ }
}
@Override
- public void storeUIRootComponent(WebuiRequestContext context) throws Exception
+ public void expire(String sessionId, WebuiApplication app) throws Exception
{
- impl.storeUIRootComponent(context);
+ // For now do nothing....
}
- @Override
- public void expire(String sessionId, WebuiApplication app) throws Exception
+ private UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws
Exception
{
- impl.expire(sessionId, app);
+ ExoContainer appContainer =
context.getApplication().getApplicationServiceContainer();
+ UserPortalConfigService service_ =
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
+ String remoteUser = context.getRemoteUser();
+ String ownerUser = context.getPortalOwner();
+ return service_.getUserPortalConfig(ownerUser, remoteUser);
}
+
+ private String getKey(WebuiRequestContext webuiRC)
+ {
+ if (webuiRC instanceof PortletRequestContext)
+ {
+ PortletRequestContext portletRC = (PortletRequestContext)webuiRC;
+
+ // We are temporarily not using the window id as it changes when the back end is
not the same
+ return portletRC.getApplication().getApplicationId()/* + "/" +
portletRC.getWindowId()*/;
+ }
+ else
+ {
+ PortalRequestContext portalRC = (PortalRequestContext)webuiRC;
+ String portalOwner = portalRC.getPortalOwner();
+ return "portal_" + portalOwner;
+ }
+ }
+
+ private HttpSession getSession(WebuiRequestContext webuiRC)
+ {
+ PortalRequestContext portalRC;
+ if (webuiRC instanceof PortletRequestContext)
+ {
+ PortletRequestContext portletRC = (PortletRequestContext)webuiRC;
+ portalRC = (PortalRequestContext) portletRC.getParentAppRequestContext();
+ }
+ else
+ {
+ portalRC = (PortalRequestContext)webuiRC;
+ }
+ HttpServletRequest req = portalRC.getRequest();
+ return req.getSession(false);
+ }
}
\ No newline at end of file
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/ReplicatingStateManager.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/ReplicatingStateManager.java 2010-02-25
23:10:54 UTC (rev 1870)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/ReplicatingStateManager.java 2010-02-26
00:57:47 UTC (rev 1871)
@@ -1,186 +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.replication;
-
-import org.exoplatform.commons.utils.Safe;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.portal.application.LegacyPortalStateManager;
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.config.UserPortalConfig;
-import org.exoplatform.portal.config.UserPortalConfigService;
-import org.exoplatform.webui.application.ConfigurationManager;
-import org.exoplatform.webui.application.StateManager;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.application.portlet.PortletRequestContext;
-import org.exoplatform.webui.core.UIApplication;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-/**
- * The basis is either {@link org.exoplatform.webui.core.UIPortletApplication} or
- * {@link org.exoplatform.portal.webui.workspace.UIPortalApplication}.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class ReplicatingStateManager extends StateManager
-{
-
- /** . */
- private static final String APPLICATION_ATTRIBUTE_PREFIX = "rsm.";
-
- /** . */
- private static final Logger log =
LoggerFactory.getLogger(ReplicatingStateManager.class);
-
- @Override
- public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws
Exception
- {
- context.setStateManager(this);
-
- //
- WebuiApplication app = (WebuiApplication)context.getApplication();
-
- //
- HttpSession session = getSession(context);
- String key = getKey(context);
-
- //
- ApplicationState appState =
(ApplicationState)session.getAttribute(APPLICATION_ATTRIBUTE_PREFIX + key);
-
- //
- UIApplication uiapp = null;
- if (appState != null)
- {
- if (Safe.equals(context.getRemoteUser(), appState.getUserName()))
- {
- uiapp = appState.getApplication();
- }
- }
-
- //
- if (appState != null)
- {
- log.debug("Found application " + key + " :" +
appState.getApplication());
- }
- else
- {
- log.debug("Application " + key + " not found");
- }
-
- // Looks like some necessary hacking
- if (context instanceof PortalRequestContext)
- {
- PortalRequestContext portalRC = (PortalRequestContext)context;
- UserPortalConfig config = getUserPortalConfig(portalRC);
- if (config == null)
- {
- HttpServletResponse response = portalRC.getResponse();
- response.sendRedirect(portalRC.getRequest().getContextPath() +
"/portal-unavailable.jsp");
- portalRC.setResponseComplete(true);
- return null;
- }
- portalRC.setAttribute(UserPortalConfig.class, config);
-// SessionManagerContainer pcontainer =
(SessionManagerContainer)app.getApplicationServiceContainer();
-// pcontainer.createSessionContainer(context.getSessionId(), uiapp.getOwner());
- }
-
- //
- if (uiapp == null)
- {
- ConfigurationManager cmanager = app.getConfigurationManager();
- String uirootClass = cmanager.getApplication().getUIRootComponent();
- Class<? extends UIApplication> type = (Class<UIApplication>)
Thread.currentThread().getContextClassLoader().loadClass(uirootClass);
- uiapp = app.createUIComponent(type, null, null, context);
- }
-
- //
- return uiapp;
- }
-
- @Override
- public void storeUIRootComponent(final WebuiRequestContext context) throws Exception
- {
- UIApplication uiapp = context.getUIApplication();
-
- //
- HttpSession session = getSession(context);
-
- //
- String key = getKey(context);
-
- //
- log.debug("Storing application " + key);
- session.setAttribute(APPLICATION_ATTRIBUTE_PREFIX + key, new
ApplicationState(uiapp, context.getRemoteUser()));
- }
-
- @Override
- public void expire(String sessionId, WebuiApplication app) throws Exception
- {
- // For now do nothing....
- }
-
- private UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws
Exception
- {
- ExoContainer appContainer =
context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService service_ =
(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- String remoteUser = context.getRemoteUser();
- String ownerUser = context.getPortalOwner();
- return service_.getUserPortalConfig(ownerUser, remoteUser);
- }
-
- private String getKey(WebuiRequestContext webuiRC)
- {
- if (webuiRC instanceof PortletRequestContext)
- {
- PortletRequestContext portletRC = (PortletRequestContext)webuiRC;
-
- // We are temporarily not using the window id as it changes when the back end is
not the same
- return portletRC.getApplication().getApplicationId()/* + "/" +
portletRC.getWindowId()*/;
- }
- else
- {
- PortalRequestContext portalRC = (PortalRequestContext)webuiRC;
- String portalOwner = portalRC.getPortalOwner();
- return "portal_" + portalOwner;
- }
- }
-
- private HttpSession getSession(WebuiRequestContext webuiRC)
- {
- if (webuiRC instanceof PortletRequestContext)
- {
- PortletRequestContext portletRC = (PortletRequestContext)webuiRC;
- PortalRequestContext portalRC = (PortalRequestContext)
portletRC.getParentAppRequestContext();
- HttpServletRequest req = portalRC.getRequest();
- return req.getSession();
- }
- else
- {
- PortalRequestContext portalRC = (PortalRequestContext)webuiRC;
- HttpServletRequest req = portalRC.getRequest();
- return req.getSession();
- }
- }
-}