Author: mwringe
Date: 2009-08-26 01:10:47 -0400 (Wed, 26 Aug 2009)
New Revision: 89
Added:
components/pc/trunk/pc/src/main/java/org/gatein/pc/impl/state/MapStateConverter.java
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java
components/pc/trunk/api/src/main/java/org/gatein/pc/api/invocation/SimplePortletInvocationContext.java
components/pc/trunk/controller/src/main/java/org/gatein/pc/controller/impl/ControllerRequestParameterMapFactory.java
components/pc/trunk/exo/src/main/java/org/gatein/pc/exo/ExoKernelIntegration.java
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java
components/pc/trunk/pc/src/test/java/org/gatein/pc/jsr168/api/portletcontext/ServerInfoTestCase.java
components/pc/trunk/test/src/main/java/org/gatein/pc/test/ExoKernelIntegration.java
Log:
Update PC component for changes in Portal.
-Change the portletcontext to better match what is being used in the Portal.
-Update the portletcontexts to allow for class extensions outside of package.
-Few other bug fixes.
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java 2009-08-26
00:46:55 UTC (rev 88)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletContext.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -39,7 +39,7 @@
/** . */
protected final String id;
- PortletContext(String id) throws IllegalArgumentException
+ protected PortletContext(String id) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "portlet
id", "PortletContext");
this.id = id;
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java
===================================================================
---
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/api/src/main/java/org/gatein/pc/api/StatefulPortletContext.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -54,7 +54,7 @@
/** . */
private final PortletStateType<S> type;
- StatefulPortletContext(String id, PortletStateType<S> type, S state) throws
IllegalArgumentException
+ protected StatefulPortletContext(String id, PortletStateType<S> type, S state)
throws IllegalArgumentException
{
super(id);
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/invocation/SimplePortletInvocationContext.java
===================================================================
---
components/pc/trunk/api/src/main/java/org/gatein/pc/api/invocation/SimplePortletInvocationContext.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/api/src/main/java/org/gatein/pc/api/invocation/SimplePortletInvocationContext.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -33,9 +35,11 @@
import org.gatein.pc.api.ContainerURL;
import org.gatein.pc.api.RenderURL;
import org.gatein.pc.api.ResourceURL;
+import org.gatein.pc.api.StateString;
import org.gatein.pc.api.URLFormat;
import org.gatein.pc.api.spi.PortletInvocationContext;
+
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
@@ -46,18 +50,19 @@
private MarkupInfo markupInfo;
private String baseURL;
private HttpServletResponse response;
+ private HttpServletRequest request;
- public SimplePortletInvocationContext(MarkupInfo markupInfo, String baseURL,
HttpServletResponse response)
+ public SimplePortletInvocationContext(MarkupInfo markupInfo, String baseURL,
HttpServletRequest request, HttpServletResponse response)
{
this.markupInfo = markupInfo;
this.baseURL = baseURL;
+ this.request = request;
this.response = response;
}
public String encodeResourceURL(String url) throws IllegalArgumentException
{
return response.encodeURL(url);
- //throw new IllegalArgumentException("EncodeResourceURL method not yet
supported");
}
public MarkupInfo getMarkupInfo()
@@ -89,9 +94,24 @@
url += "&portal:type=" + type;
- //TODO: fix this part
- url += "&portal:isSecure=" + "false";
+ url += "&portal:isSecure=" + request.isSecure();
+ if (containerURL instanceof ActionURL)
+ {
+ ActionURL actionURL = (ActionURL) containerURL;
+ Map<String, String[]> map =
StateString.decodeOpaqueValue(actionURL.getInteractionState().getStringValue());
+ Iterator<String> keys = map.keySet().iterator();
+ while (keys.hasNext())
+ {
+ String key = keys.next();
+ String[] values = map.get(key);
+ for (String value : values)
+ {
+ url += "&" + key + "=" + value;
+ }
+ }
+ }
+
return url;
}
@@ -100,6 +120,5 @@
String url = renderURL(containerURL, format);
writer.write(url);
}
-
}
Modified:
components/pc/trunk/controller/src/main/java/org/gatein/pc/controller/impl/ControllerRequestParameterMapFactory.java
===================================================================
---
components/pc/trunk/controller/src/main/java/org/gatein/pc/controller/impl/ControllerRequestParameterMapFactory.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/controller/src/main/java/org/gatein/pc/controller/impl/ControllerRequestParameterMapFactory.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -59,9 +59,6 @@
Map<String, String> parameters = new HashMap<String, String>();
//
- parameters.put(ControllerRequestParameterNames.WINDOW_ID, windowId);
-
- //
String type;
if (containerURL instanceof ActionURL)
{
Modified:
components/pc/trunk/exo/src/main/java/org/gatein/pc/exo/ExoKernelIntegration.java
===================================================================
---
components/pc/trunk/exo/src/main/java/org/gatein/pc/exo/ExoKernelIntegration.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/exo/src/main/java/org/gatein/pc/exo/ExoKernelIntegration.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -40,9 +40,11 @@
import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.pc.federation.impl.FederatingPortletInvokerService;
import org.gatein.pc.impl.state.StateConverterV0;
+import org.gatein.pc.impl.state.MapStateConverter;
import org.gatein.pc.impl.state.StateManagementPolicyService;
import org.gatein.pc.impl.state.producer.PortletStatePersistenceManagerService;
import org.gatein.pc.mc.PortletApplicationDeployer;
+import org.gatein.pc.state.StateConverter;
import org.gatein.pc.state.producer.PortletStatePersistenceManager;
import org.gatein.pc.state.producer.ProducerPortletInvoker;
import org.gatein.wci.ServletContainer;
@@ -70,10 +72,10 @@
// The producer state management policy
StateManagementPolicyService producerStateManagementPolicy = new
StateManagementPolicyService();
- producerStateManagementPolicy.setPersistLocally(true);
+ producerStateManagementPolicy.setPersistLocally(false);
// The producer state converter
- StateConverterV0 producerStateConverter = new StateConverterV0();
+ StateConverter producerStateConverter = new
MapStateConverter();//StateConverterV0();
// The portlet container invoker
ContainerPortletInvoker containerPortletInvoker = new ContainerPortletInvoker();
@@ -136,7 +138,7 @@
// register local portlet invoker with federating portlet invoker
federatingPortletInvoker.registerInvoker(FederatingPortletInvoker.LOCAL_PORTLET_INVOKER_ID,
consumerPortletInvoker);
/* register with container */
- container.registerComponentInstance(PortletInvoker.class,
federatingPortletInvoker);//consumerPortletInvoker); //federatingPortletInvoker);
+ container.registerComponentInstance(PortletInvoker.class,
federatingPortletInvoker);
portletApplicationRegistry.start();
}
Modified:
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java
===================================================================
---
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -205,8 +205,8 @@
public PortletImpl(PortletContainer container)
{
this.container = container;
- this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId() +
"." + container.getId());
- //this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId().substring(1)
+ "/" + container.getId());
+ //this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId() +
"." + container.getId());
+ this.context =
PortletContext.createPortletContext(container.getPortletApplication().getId().substring(1)
+ "/" + container.getId());
}
public PortletContext getContext()
Added:
components/pc/trunk/pc/src/main/java/org/gatein/pc/impl/state/MapStateConverter.java
===================================================================
--- components/pc/trunk/pc/src/main/java/org/gatein/pc/impl/state/MapStateConverter.java
(rev 0)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/impl/state/MapStateConverter.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * 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.gatein.pc.impl.state;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.state.PropertyMap;
+import org.gatein.pc.state.SimplePropertyMap;
+import org.gatein.pc.state.StateConversionException;
+import org.gatein.pc.state.StateConverter;
+import org.gatein.pc.state.producer.PortletState;
+
+/**
+ * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
+ * @version $Revision$
+ */
+public class MapStateConverter implements StateConverter
+{
+
+ public <S extends Serializable> S marshall(PortletStateType<S> stateType,
PortletState state)
+ throws StateConversionException, IllegalArgumentException
+ {
+ if (stateType.getJavaType().equals(HashMap.class))
+ {
+ Object map = marshall(state);
+ return (S)map;
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public HashMap marshall(PortletState state)
+ {
+ if (state == null)
+ {
+ throw new IllegalArgumentException("No null state");
+ }
+
+ HashMap map = new HashMap();
+ Iterator<String> iKeys = state.getProperties().keySet().iterator();
+ while (iKeys.hasNext())
+ {
+ String key = iKeys.next();
+ List<String> propList = state.getProperties().getProperty(key);
+
+ map.put(key, propList.toArray());
+ }
+
+ map.put("portletID", state.getPortletId());
+
+ return map;
+ }
+
+ public <S extends Serializable> PortletState
unmarshall(PortletStateType<S> stateType, S marshalledState)
+ throws StateConversionException, IllegalArgumentException
+ {
+ if (stateType.getJavaType().equals(HashMap.class))
+ {
+ HashMap map = (HashMap)marshalledState;
+ return unmarshall(map);
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public PortletState unmarshall(Map marshalledState)
+ {
+ if (marshalledState == null)
+ {
+ throw new IllegalArgumentException("No null map");
+ }
+
+ PropertyMap properties = new SimplePropertyMap(marshalledState.size());
+
+
+ Iterator<String> iKeys = marshalledState.keySet().iterator();
+ while (iKeys.hasNext())
+ {
+ String key = iKeys.next();
+ if (key != "portletID")
+ {
+ Object mapValue = marshalledState.get(key);
+
+ if (mapValue instanceof Object[])
+ {
+ Object[] values = (Object[])mapValue;
+
+ List valueList = new ArrayList<String>();
+ for (Object value: values)
+ {
+ if (value instanceof String)
+ valueList.add((String)value);
+ }
+
+ properties.put(key, valueList);
+ }
+ }
+ }
+
+ String portletID = (String) marshalledState.get("portletID");
+
+ return new PortletState(portletID, properties);
+ }
+
+}
+
Modified:
components/pc/trunk/pc/src/test/java/org/gatein/pc/jsr168/api/portletcontext/ServerInfoTestCase.java
===================================================================
---
components/pc/trunk/pc/src/test/java/org/gatein/pc/jsr168/api/portletcontext/ServerInfoTestCase.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/pc/src/test/java/org/gatein/pc/jsr168/api/portletcontext/ServerInfoTestCase.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -47,7 +47,7 @@
{
/** . */
- private static final String VERSION_REGEX =
"JBossPortletContainer/[0-9]+\\.[0-9]+";
+ private static final String VERSION_REGEX =
"JBossPortletContainer/[0-9]+\\.[0-9]+(|\\.SNAPSHOT)";
/** . */
private static final Pattern VERSION_PATTERN = Pattern.compile(VERSION_REGEX,
Pattern.CASE_INSENSITIVE);
Modified:
components/pc/trunk/test/src/main/java/org/gatein/pc/test/ExoKernelIntegration.java
===================================================================
---
components/pc/trunk/test/src/main/java/org/gatein/pc/test/ExoKernelIntegration.java 2009-08-26
00:46:55 UTC (rev 88)
+++
components/pc/trunk/test/src/main/java/org/gatein/pc/test/ExoKernelIntegration.java 2009-08-26
05:10:47 UTC (rev 89)
@@ -37,9 +37,10 @@
import org.gatein.pc.aspects.portlet.ValveInterceptor;
import org.gatein.pc.container.ContainerPortletDispatcher;
import org.gatein.pc.container.ContainerPortletInvoker;
-import org.gatein.pc.impl.state.StateConverterV0;
+import org.gatein.pc.impl.state.MapStateConverter;
import org.gatein.pc.impl.state.StateManagementPolicyService;
import org.gatein.pc.impl.state.producer.PortletStatePersistenceManagerService;
+import org.gatein.pc.state.StateConverter;
import org.gatein.pc.state.producer.PortletStatePersistenceManager;
import org.gatein.pc.state.producer.ProducerPortletInvoker;
import org.jboss.portal.test.framework.impl.generic.server.GenericServiceExporter;
@@ -75,10 +76,10 @@
// The producer state management policy
StateManagementPolicyService producerStateManagementPolicy = new
StateManagementPolicyService();
- producerStateManagementPolicy.setPersistLocally(true);
+ producerStateManagementPolicy.setPersistLocally(false);
// The producer state converter
- StateConverterV0 producerStateConverter = new StateConverterV0();
+ StateConverter producerStateConverter = new MapStateConverter();
// The portlet container invoker
ContainerPortletInvoker containerPortletInvoker = new ContainerPortletInvoker();
@@ -143,7 +144,7 @@
//federatingPortletInvoker.registerInvoker(LOCAL_PORTLET_INVOKER_ID,
containerPortletInvoker);//containerPortletInvoker);
/* register with container */
- container.registerComponentInstance(PortletInvoker.class, consumerPortletInvoker);
//federatingPortletInvoker);
+ container.registerComponentInstance(PortletInvoker.class, consumerPortletInvoker);
portletApplicationRegistry.start();