Author: julien(a)jboss.com
Date: 2008-01-31 08:17:54 -0500 (Thu, 31 Jan 2008)
New Revision: 9684
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
Log:
- implemented PortletRequest.getWindowID()
- added test case for window id
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-01-31
13:17:54 UTC (rev 9684)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.info;
+
+import org.jboss.portal.portlet.LifeCyclePhase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerFilterInfo
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String className;
+
+ /** . */
+ private final LifeCyclePhase lifeCycle;
+
+ /** . */
+ private final LocalizedString displayName;
+
+ /** . */
+ private final LocalizedString description;
+
+ /** . */
+ private final Map<String, String> parameters;
+
+ public ContainerFilterInfo(
+ String name,
+ String className,
+ LifeCyclePhase lifeCycle,
+ LocalizedString displayName,
+ LocalizedString description,
+ Map<String, String> parameters)
+ {
+ this.name = name;
+ this.className = className;
+ this.lifeCycle = lifeCycle;
+ this.displayName = displayName;
+ this.description = description;
+ this.parameters = parameters;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public LifeCyclePhase getLifeCycle()
+ {
+ return lifeCycle;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public Map<String, String> getParameters()
+ {
+ return parameters;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-01-31
11:36:26 UTC (rev 9683)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-01-31
13:17:54 UTC (rev 9684)
@@ -38,7 +38,9 @@
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
+import org.jboss.portal.portlet.impl.metadata.filter.FilterMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.value.StringValue;
@@ -60,6 +62,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
+import java.util.Collections;
import java.net.URI;
import java.net.URISyntaxException;
@@ -292,12 +295,39 @@
//
publicParameters.put(parameter.getId(), parameter);
}
+
+ //
+// for (FilterMetaData filterMD : tmp.getFilterCollection())
+// {
+// ContainerFilterInfo filter = build(filterMD);
+// }
}
//
return new ContainerPortletApplicationInfo(defaultNamespace);
}
+ private ContainerFilterInfo build(FilterMetaData filterMD)
+ {
+ Map<String, String> initParameters = new HashMap<String, String>();
+ for (InitParamMetaData initParamMD : filterMD.getInitParams())
+ {
+ initParameters.put(initParamMD.getName(), initParamMD.getValue());
+ }
+
+ LifeCyclePhase lifeCycle;
+
+ //
+ return new ContainerFilterInfo(
+ filterMD.getFilterName(),
+ filterMD.getFilterClass(),
+ null,
+ filterMD.getDisplayName(),
+ filterMD.getDescription(),
+ Collections.unmodifiableMap(initParameters)
+ );
+ }
+
private ContainerParameterInfo build(PublicRenderParameterMetaData parameterMD)
{
QName name = getName(parameterMD.getQname(), parameterMD.getName());
@@ -357,6 +387,13 @@
ContainerSessionInfo containerSession = buildContainerSession(portletMD);
//
+ Map<String, String> initParameters = new HashMap<String, String>();
+ for (InitParamMetaData initParamMD : portletMD.getInitParams())
+ {
+ initParameters.put(initParamMD.getName(), initParamMD.getValue());
+ }
+
+ //
ContainerPortletInfo containerPortletInfo;
if (portletApplicationMD instanceof PortletApplication20MetaData)
{
@@ -375,6 +412,7 @@
containerNavigation,
portletMD.getPortletName(),
portletMD.getPortletClass(),
+ Collections.unmodifiableMap(initParameters),
false,
context.getBundleManager(portletMD)
);
@@ -390,18 +428,13 @@
containerSession,
portletMD.getPortletName(),
portletMD.getPortletClass(),
+ Collections.unmodifiableMap(initParameters),
false,
context.getBundleManager(portletMD)
);
}
//
- for (InitParamMetaData initParamMD : portletMD.getInitParams())
- {
- containerPortletInfo.addInitParameter(initParamMD.getName(),
initParamMD.getValue());
- }
-
- //
return containerPortletInfo;
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-31
11:36:26 UTC (rev 9683)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-31
13:17:54 UTC (rev 9684)
@@ -87,6 +87,7 @@
ContainerSessionInfo session,
String name,
String className,
+ Map<String, String> initParameters,
Boolean remotable,
ResourceBundleManager bundleManager)
{
@@ -100,7 +101,7 @@
this.navigation = new ContainerNavigationInfo();
this.name = name;
this.className = className;
- this.initParameters = new HashMap<String, String>();
+ this.initParameters = initParameters;
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -116,6 +117,7 @@
ContainerNavigationInfo navigation,
String name,
String className,
+ Map<String, String> initParameters,
Boolean remotable,
ResourceBundleManager bundleManager)
{
@@ -129,7 +131,7 @@
this.navigation = navigation;
this.name = name;
this.className = className;
- this.initParameters = new HashMap<String, String>();
+ this.initParameters = initParameters;
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -149,11 +151,6 @@
return className;
}
- public void addInitParameter(String parameterName, String parameterValue)
- {
- initParameters.put(parameterName, parameterValue);
- }
-
public Set<String> getInitParameterNames()
{
return initParameters.keySet();
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31
11:36:26 UTC (rev 9683)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31
13:17:54 UTC (rev 9684)
@@ -453,7 +453,7 @@
public String getWindowID()
{
- throw new NotYetImplemented();
+ return windowContext.getId();
}
public Cookie[] getCookies()
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31
13:17:54 UTC (rev 9684)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(Assertion.JSR286_97)
+public class WindowIDTestCase
+{
+
+ public WindowIDTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ String windowID = request.getWindowID();
+ WindowIDRetriever retriever = new WindowIDRetriever();
+ request.getPortletSession().setAttribute("retriever", retriever);
+ assertEquals(retriever.getWindowID(), windowID);
+ return new EndTestResponse();
+ }
+ });
+ }
+
+ public static class WindowIDRetriever implements HttpSessionBindingListener
+ {
+
+ /** . */
+ private String windowID;
+
+ public void valueBound(HttpSessionBindingEvent event)
+ {
+ String name = event.getName();
+ windowID = name.substring("javax.portlet.p.".length(),
name.indexOf('?'));
+ }
+
+ public void valueUnbound(HttpSessionBindingEvent event)
+ {
+ }
+
+ public String getWindowID()
+ {
+ return windowID;
+ }
+ }
+}