Author: chris.laprun(a)jboss.com
Date: 2009-01-21 10:29:51 -0500 (Wed, 21 Jan 2009)
New Revision: 12585
Added:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
Log:
- JBPORTAL-2274: added PhaseListener to redirect to consumer list view if we cannot
restore a consumer after session expiration.
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-01-21
14:59:19 UTC (rev 12584)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-01-21
15:29:51 UTC (rev 12585)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.jboss.portal.wsrp.admin.ui;
@@ -44,18 +45,20 @@
{
private ConsumerRegistry registry;
private String selectedId;
- private static final String CONSUMER_ID = "consumerId";
- static final String CONFIGURE_CONSUMER = "configureConsumer";
- static final String CONSUMERS = "consumers";
- static final String EXPECTED_REG_INFO_KEY = "expectedRegistrationInfo";
private static final String NO_CONSUMER =
"bean_consumermanager_no_consumer";
private static final String INVALID_NEW_CONSUMER_NAME =
"bean_consumermanager_invalid_new_consumer_name";
private static final String REFRESH_BYPASSED =
"bean_consumermanager_refresh_bypassed";
private static final String REFRESH_SUCCESS =
"bean_consumermanager_refresh_success";
private static final String REFRESH_FAILURE =
"bean_consumermanager_refresh_failure";
private static final String REFRESH_EXCEPTION =
"bean_consumermanager_refresh_exception";
+ static final String CONFIGURE_CONSUMER = "configureConsumer";
+
+ static final String CONSUMERS = "consumers";
+ static final String EXPECTED_REG_INFO_KEY = "expectedRegistrationInfo";
static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
+ static final String REQUESTED_CONSUMER_ID = "id";
+ static final String SESSION_CONSUMER_ID = "consumerId";
public ConsumerRegistry getRegistry()
{
@@ -328,7 +331,7 @@
private String refreshConsumerId()
{
- selectedId = beanContext.getParameter("id");
+ selectedId = beanContext.getParameter(REQUESTED_CONSUMER_ID);
return selectedId;
}
@@ -342,11 +345,11 @@
if (!remove)
{
- sessionMap.put(CONSUMER_ID, selectedId);
+ sessionMap.put(SESSION_CONSUMER_ID, selectedId);
}
else
{
- sessionMap.remove(CONSUMER_ID);
+ sessionMap.remove(SESSION_CONSUMER_ID);
}
}
Added:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java 2009-01-21
15:29:51 UTC (rev 12585)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.jboss.portal.wsrp.admin.ui;
+
+import org.jboss.portal.faces.gui.JSFBeanContext;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class RedirectOnNoConsumerListener implements PhaseListener
+{
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ FacesContext facesContext = phaseEvent.getFacesContext();
+
+ // check if we have a currently selected consumer in the request...
+ String currentConsumer =
JSFBeanContext.getParameter(ConsumerManagerBean.REQUESTED_CONSUMER_ID, facesContext);
+
+ // if not, check the session...
+ if (currentConsumer == null)
+ {
+ currentConsumer =
(String)JSFBeanContext.getSessionMap(facesContext).get(ConsumerManagerBean.SESSION_CONSUMER_ID);
+
+ // if we still don't have consumer id, redirect to consumer list view
+ if (currentConsumer == null)
+ {
+ NavigationHandler navigationHandler =
facesContext.getApplication().getNavigationHandler();
+ navigationHandler.handleNavigation(facesContext, null,
"consumers");
+ }
+ }
+ }
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.RESTORE_VIEW;
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml 2009-01-21
14:59:19 UTC (rev 12584)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml 2009-01-21
15:29:51 UTC (rev 12585)
@@ -1,29 +1,29 @@
<?xml version="1.0"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ JBoss, a division of Red Hat ~
- ~ Copyright 2007, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ 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 ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ 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. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.0//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
+ "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
@@ -34,13 +34,17 @@
org.jboss.portletbridge.application.PortletViewHandler
</view-handler>
<state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager>
- <locale-config>
+ <locale-config>
<default-locale>en</default-locale>
<supported-locale>fr</supported-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
+ <lifecycle>
+
<phase-listener>org.jboss.portal.wsrp.admin.ui.RedirectOnNoConsumerListener</phase-listener>
+ </lifecycle>
+
<converter>
<converter-for-class>org.jboss.portal.wsrp.registration.LocalizedString</converter-for-class>
<converter-class>org.jboss.portal.wsrp.admin.ui.LocalizedStringConverter</converter-class>
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-01-21
14:59:19 UTC (rev 12584)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-01-21
15:29:51 UTC (rev 12585)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -52,6 +52,8 @@
*/
public abstract String getParameter(String key);
+// public abstract void redirectTo(String )
+
protected abstract void createMessage(String target, String message, Object
severity);
protected abstract Object getErrorSeverity();
@@ -174,7 +176,7 @@
}
getFromSession(name, newValue.getClass(), sessionMap, "Provided object: "
+ newValue
- + " is not compatible with previously assigned '" + name +
"' object: " + CURRENT_PLACEHOLDER);
+ + " is not compatible with previously assigned '" + name +
"' object: " + CURRENT_PLACEHOLDER);
sessionMap.put(name, newValue);
return newValue;
}
@@ -192,7 +194,7 @@
public <T> T getFromSession(String name, Class<T> expectedClass)
{
return getFromSession(name, expectedClass, getSessionMap(), "Current
object:" + CURRENT_PLACEHOLDER
- + " is not compatible with expected class " + expectedClass +
" for '" + name + "'");
+ + " is not compatible with expected class " + expectedClass + "
for '" + name + "'");
}
/**
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-01-21
14:59:19 UTC (rev 12584)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-01-21
15:29:51 UTC (rev 12585)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -37,15 +37,25 @@
{
public String getParameter(String key)
{
- Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ return getParameter(key, FacesContext.getCurrentInstance());
+ }
+
+ public static String getParameter(String key, FacesContext facesContext)
+ {
+ Map pmap = facesContext.getExternalContext().getRequestParameterMap();
return (String)pmap.get(key);
}
public Map<String, Object> getSessionMap()
{
- return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ return JSFBeanContext.getSessionMap(FacesContext.getCurrentInstance());
}
+ public static Map<String, Object> getSessionMap(FacesContext facesContext)
+ {
+ return facesContext.getExternalContext().getSessionMap();
+ }
+
protected void createMessage(String target, String message, Object severity)
{
FacesMessage.Severity jsfSeverity;