JBoss Portal SVN: r9527 - in modules/portlet/trunk/portlet/src: main/java/org/jboss/portal/portlet/impl/jsr168 and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-17 08:44:09 -0500 (Thu, 17 Jan 2008)
New Revision: 9527
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
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/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
Log:
added PortletParameterMap object that manages the different maps that a Portlet can create at runtime to update the navigational states (private and public). The intent is to reuse it then in the PortletURLImpl.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-01-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -84,6 +84,10 @@
*/
public static ParametersStateString create(StateString stateString) throws IllegalArgumentException
{
+ if (stateString == null)
+ {
+ throw new IllegalArgumentException("No null state string accepted");
+ }
if (stateString instanceof ParametersStateString)
{
return (ParametersStateString)stateString;
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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.jsr168;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class PortletParameter
+{
+
+ enum Scope
+ {
+
+ PUBLIC, PRIVATE
+
+ }
+
+ /** The entry scope. */
+ private final Scope scope;
+
+ /** The entry value. */
+ private String[] values;
+
+ PortletParameter(Scope scope, String[] values)
+ {
+ this.scope = scope;
+ this.values = values;
+ }
+
+ Scope getScope()
+ {
+ return scope;
+ }
+
+ String[] getValues()
+ {
+ return values;
+ }
+
+ void setValues(String[] values)
+ {
+ this.values = values;
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -0,0 +1,284 @@
+/******************************************************************************
+ * 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.jsr168;
+
+import org.jboss.portal.common.util.TypedMap;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletParameterMap
+{
+
+ /** . */
+ private static final String[] EMPTY_STRINGS = new String[0];
+
+ /** . */
+ private NavigationInfo navigationInfo;
+
+ /** . */
+ private Map<String, PortletParameter> entries = new HashMap<String, PortletParameter>();
+
+ /** . */
+ private Set<String> publicEntryRemovals = new HashSet<String>();
+
+ /** . */
+ private TypedMap<String, String[], String, PortletParameter> combinedMap = new TypedMap<String, String[], String, PortletParameter>(entries, keyConverter, valueConverter);
+
+ public PortletParameterMap(NavigationInfo navigationInfo)
+ {
+ this.navigationInfo = navigationInfo;
+ }
+
+ public String getParameterValue(String name)
+ {
+ String[] values = getParameterValues(name);
+
+ return (values != null && values.length > 0) ? values[0] : null;
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PortletParameter entry = entries.get(name);
+
+ //
+ return entry != null ? entry.getValues() : null;
+ }
+
+ public void setParameterValue(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null string array accepted");
+ }
+
+ //
+ internalPut(name, new String[]{value}, false);
+ }
+
+ public void setParameterValues(String name, String[] value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null string array accepted");
+ }
+ if (value.length == 0)
+ {
+ throw new IllegalArgumentException("Render parameter value cannot be a zero length array");
+ }
+ for (int i = 0;i < value.length;i++)
+ {
+ if (value[i] == null)
+ {
+ throw new IllegalArgumentException("String of parameter value at index " + i + " must not be null");
+ }
+ }
+
+ //
+ internalPut(name, value, true);
+ }
+
+ private void internalPut(String name, String[] value, boolean cloneValue)
+ {
+ // Look if we have an entry already
+ PortletParameter entry = entries.get(name);
+
+ //
+ PortletParameter.Scope scope;
+ if (entry == null)
+ {
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(name);
+ scope = parameterInfo == null ? PortletParameter.Scope.PRIVATE : PortletParameter.Scope.PUBLIC;
+ }
+ else
+ {
+ scope = entry.getScope();
+ }
+
+ //
+ if (cloneValue)
+ {
+ value = value.clone();
+ }
+
+ //
+ if (entry == null)
+ {
+ publicEntryRemovals.remove(name);
+ entries.put(name, new PortletParameter(scope, value));
+ }
+ else
+ {
+ entry.setValues(value);
+ }
+ }
+
+ public void removePublicParameterValue(String name)
+ {
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(name);
+
+ //
+ if (parameterInfo != null)
+ {
+ publicEntryRemovals.add(name);
+ entries.remove(name);
+ }
+ }
+
+ public Map<String, String[]> getMap()
+ {
+ return combinedMap;
+ }
+
+ public void setMap(Map<String, String[]> map)
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException("No null map accepted");
+ }
+
+ // Make the check first to ensure atomicity of the update
+ for (Map.Entry<String, String[]> entry : map.entrySet())
+ {
+ // We need to check that for portlets not using generics
+ if (!(entry.getKey() instanceof String))
+ {
+ throw new IllegalArgumentException();
+ }
+ // We need to check that for portlets not using generics
+ if (!(entry.getValue() instanceof String[]))
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] values = entry.getValue();
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ //
+ entries.clear();
+ for (Map.Entry<String, String[]> entry : map.entrySet())
+ {
+ internalPut(entry.getKey(), entry.getValue(), true);
+ }
+ }
+
+ public Map<String, String[]> getPrivateMapSnapshot()
+ {
+ Map<String, String[]> snapshot = getMapSnapshot(PortletParameter.Scope.PRIVATE);
+ for (String removal : publicEntryRemovals)
+ {
+ snapshot.put(removal, EMPTY_STRINGS);
+ }
+ return snapshot;
+ }
+
+ public Map<String, String[]> getPublicMapSnapshot()
+ {
+ return getMapSnapshot(PortletParameter.Scope.PUBLIC);
+ }
+
+ private Map<String, String[]> getMapSnapshot(PortletParameter.Scope scope)
+ {
+ Map<String, String[]> snapshot = new HashMap<String, String[]>();
+
+ //
+ for (Map.Entry<String, PortletParameter> entry : entries.entrySet())
+ {
+ PortletParameter parameter = entry.getValue();
+
+ //
+ if (parameter.getScope() == scope)
+ {
+ snapshot.put(entry.getKey(), parameter.getValues().clone());
+ }
+ }
+
+ //
+ return snapshot;
+ }
+
+ private static TypedMap.Converter<String, String> keyConverter = new TypedMap.Converter<String, String>()
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ };
+
+ private static TypedMap.Converter<String[], PortletParameter> valueConverter = new TypedMap.Converter<String[], PortletParameter>()
+ {
+ protected PortletParameter getInternal(String[] external) throws IllegalArgumentException, ClassCastException
+ {
+ throw new UnsupportedOperationException("Cannot write");
+ }
+
+ protected String[] getExternal(PortletParameter internal)
+ {
+ // We clone the value as it may be accessed
+ return internal.getValues().clone();
+ }
+
+ protected boolean equals(PortletParameter left, PortletParameter right)
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+}
Copied: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java (from rev 9520, modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java)
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -0,0 +1,197 @@
+/******************************************************************************
+ * 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.jsr168;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.info.NavigationInfo;
+
+import java.util.Iterator;
+
+/**
+ * The main responsibility of this class is to combine the different parameter sources (private navigational state,
+ * public navigational state, interaction state, form) into the private map, public map and parameter map.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletRequestParameterMap
+{
+
+ /** . */
+ protected final ParameterMap parameters;
+
+ /** . */
+ protected final ParameterMap privateParameters;
+
+ /** . */
+ protected final ParameterMap publicParameters;
+
+ public PortletRequestParameterMap(NavigationInfo navigationInfo, PortletInvocationContext context)
+ {
+ // Get public nav state and filter it
+ ParameterMap publicParameters = null;
+ if (context.getPublicNavigationalState() != null)
+ {
+ publicParameters = new ParameterMap(context.getPublicNavigationalState());
+
+ // Remove any parameter that would have been sent by the producer by mistake
+ for (Iterator<String> i = publicParameters.keySet().iterator(); i.hasNext();)
+ {
+ String name = i.next();
+ if (navigationInfo.getPublicParameter(name) == null)
+ {
+ i.remove();
+ }
+ }
+ }
+
+ //
+ if (context instanceof ActionContext)
+ {
+ ActionContext actionContext = (ActionContext)context;
+
+ // The private parameters
+ ParameterMap privateParameters = null;
+
+ // Get the possibly null interaction state
+ StateString interactionState = actionContext.getInteractionState();
+ if (interactionState != null)
+ {
+ //
+ ParametersStateString parametersState = ParametersStateString.create(interactionState);
+
+ //
+ privateParameters = parametersState.getParameters();
+ }
+
+ // Combine form if we have one
+ ParameterMap form = actionContext.getForm();
+ if (form != null)
+ {
+ if (privateParameters == null)
+ {
+ privateParameters = form;
+ }
+ else
+ {
+ privateParameters = ParameterMap.clone(privateParameters);
+ privateParameters.append(form);
+ }
+ }
+
+ //
+ ParameterMap parameters;
+ if (publicParameters != null)
+ {
+ if (privateParameters != null)
+ {
+ ParameterMap tmp = ParameterMap.clone(privateParameters);
+ tmp.append(publicParameters);
+ parameters = tmp;
+ }
+ else
+ {
+ parameters = publicParameters;
+ }
+ }
+ else
+ {
+ if (privateParameters != null)
+ {
+ parameters = privateParameters;
+ }
+ else
+ {
+ parameters = null;
+ }
+ }
+
+ //
+ this.privateParameters = privateParameters;
+ this.publicParameters = publicParameters;
+ this.parameters = parameters;
+ }
+ else
+ {
+ // Get the possibly null navigational state
+ StateString navigationalState = context.getNavigationalState();
+
+ //
+ ParameterMap privateParameters = null;
+ if (navigationalState != null)
+ {
+ privateParameters = ParametersStateString.create(navigationalState).getParameters();
+ }
+
+ // Build combined map
+ ParameterMap parameters;
+ if (publicParameters != null)
+ {
+ if (privateParameters != null)
+ {
+ parameters = ParameterMap.clone(privateParameters);
+ parameters.putAll(publicParameters);
+ }
+ else
+ {
+ parameters = publicParameters;
+ }
+ }
+ else
+ {
+ if (privateParameters != null)
+ {
+ parameters = privateParameters;
+ }
+ else
+ {
+ parameters = null;
+ }
+ }
+
+ //
+ this.privateParameters = privateParameters;
+ this.publicParameters = publicParameters;
+ this.parameters = parameters;
+ }
+ }
+
+ public ParameterMap getParameters()
+ {
+ return parameters;
+ }
+
+ public ParameterMap getPrivateParameters()
+ {
+ return privateParameters;
+ }
+
+ public ParameterMap getPublicParameters()
+ {
+ return publicParameters;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -60,34 +60,24 @@
public void sendRedirect(String location) throws IOException
{
+ checkRedirect("sendRedirect cannot be called after " +
+ "setPortletMode/setWindowState/setRenderParameter/setRenderParameters " +
+ "has been called previously");
+
+ //
if (location == null)
{
- // do something more clever than simply returning
+ // Do something more clever than simply returning
return;
}
+ //
if (location.startsWith("http://") || location.startsWith("https://") || location.startsWith("/"))
{
- //
- if (decision == null)
- {
- WantRedirect redirect = new WantRedirect();
- redirect.location = location;
+ WantRedirect redirect = requireRedirect();
- //
- decision = redirect;
- }
- else if (decision instanceof WantRedirect)
- {
- WantRedirect redirect = (WantRedirect)decision;
- redirect.location = location;
- }
- else
- {
- throw new IllegalStateException("sendRedirect cannot be called after " +
- "setPortletMode/setWindowState/setRenderParameter/setRenderParameters " +
- "has been called previously");
- }
+ //
+ redirect.location = location;
}
else
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -44,8 +44,10 @@
{
if (eventRequest == null)
{
- // Do something ???
+ return;
}
+
+ //
if (eventRequest != preq)
{
// Do something ???
@@ -55,10 +57,11 @@
PortletInvocationContext context = invocation.getPortletContext();
//
- WantUpdate update = (WantUpdate)decision;
+ WantUpdate update = wantUpdate();
update.mode = context.getMode();
update.windowState = context.getWindowState();
- update.navigationalState = ParametersStateString.create(context.getNavigationalState()).getParameters();
- update.publicNavigationalState = context.getPublicNavigationalState();
+
+// update.navigationalState = ParametersStateString.create(context.getNavigationalState()).getParameters();
+// update.publicNavigationalState = context.getPublicNavigationalState();
}
}
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-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -31,7 +31,7 @@
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestAttributes;
-import org.jboss.portal.portlet.impl.jsr168.RequestParameters;
+import org.jboss.portal.portlet.impl.jsr168.PortletRequestParameterMap;
import org.jboss.portal.portlet.impl.info.ContainerSecurityInfo;
import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.impl.info.ContainerNavigationInfo;
@@ -93,7 +93,7 @@
protected final PortletRequestAttributes attributes;
/** . */
- protected final RequestParameters requestParameters;
+ protected final PortletRequestParameterMap requestParameterMap;
public PortletRequestImpl(PortletInvocation invocation)
{
@@ -106,7 +106,7 @@
//
this.invocation = invocation;
- this.requestParameters = new RequestParameters(invocation.getPortletContext());
+ this.requestParameterMap = new PortletRequestParameterMap(navigationInfo, invocation.getPortletContext());
this.userContext = invocation.getUserContext();
this.securityContext = invocation.getSecurityContext();
this.requestContext = invocation.getRequestContext();
@@ -123,7 +123,7 @@
public String getParameter(String name)
{
- ParameterMap parameters = requestParameters.getParameters();
+ ParameterMap parameters = requestParameterMap.getParameters();
//
if (name == null)
@@ -142,7 +142,7 @@
public Enumeration<String> getParameterNames()
{
- ParameterMap parameters = requestParameters.getParameters();
+ ParameterMap parameters = requestParameterMap.getParameters();
//
if (parameters != null)
@@ -162,7 +162,7 @@
throw new IllegalArgumentException("name must not be null");
}
- ParameterMap parameters = requestParameters.getParameters();
+ ParameterMap parameters = requestParameterMap.getParameters();
//
if (parameters != null)
@@ -177,7 +177,7 @@
public Map<String, String[]> getParameterMap()
{
- ParameterMap parameters = requestParameters.getParameters();
+ ParameterMap parameters = requestParameterMap.getParameters();
//
if (parameters != null)
@@ -502,7 +502,7 @@
public Map<String, String[]> getPrivateParameterMap()
{
- ParameterMap parameters = requestParameters.getPrivateParameters();
+ ParameterMap parameters = requestParameterMap.getPrivateParameters();
//
if (parameters != null)
@@ -517,7 +517,7 @@
public Map<String, String[]> getPublicParameterMap()
{
- ParameterMap parameters = requestParameters.getPublicParameters();
+ ParameterMap parameters = requestParameterMap.getPublicParameters();
//
if (parameters != null)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -27,17 +27,15 @@
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
import org.jboss.portal.portlet.impl.info.ContainerEventingInfo;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.impl.info.ContainerTypeInfo;
import org.jboss.portal.portlet.impl.info.ContainerEventInfo;
-import org.jboss.portal.portlet.impl.info.ContainerParameterInfo;
import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.ParameterMap;
import org.apache.log4j.Logger;
import javax.portlet.StateAwareResponse;
@@ -55,7 +53,6 @@
import java.util.UUID;
import java.util.List;
import java.util.LinkedList;
-import java.util.HashMap;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
@@ -72,24 +69,30 @@
private static final Logger log = Logger.getLogger(ActionResponseImpl.class);
/** . */
- protected Decision decision;
+ protected WantUpdate wantUpdate;
/** . */
+ protected WantRedirect wantRedirect;
+
+ /** . */
private List<StateResponse.Event> events;
public StateAwareResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
-
- //
- this.decision = null;
}
public StateResponse getResponse()
{
- Decision decision = this.decision;
+ Decision decision = wantRedirect;
//
+ if (wantRedirect == null)
+ {
+ decision = wantUpdate;
+ }
+
+ //
if (decision == null)
{
decision = new WantUpdate();
@@ -99,25 +102,52 @@
return decision.getResponse();
}
- protected WantUpdate wantUpdate(String errorMsg)
+ protected WantUpdate requireUpdate(String errorMsg)
{
- if (decision instanceof WantUpdate)
+ if (wantRedirect != null)
{
- return (WantUpdate)decision;
+ throw new IllegalStateException(errorMsg);
}
- else if (decision == null)
+ else if (wantUpdate == null)
{
- return new WantUpdate();
+ wantUpdate = new WantUpdate();
}
- else
+ return wantUpdate;
+ }
+
+ protected void checkRedirect(String errorMsg)
+ {
+ if (wantUpdate != null)
{
throw new IllegalStateException(errorMsg);
}
}
+ protected WantRedirect requireRedirect()
+ {
+ if (wantUpdate != null)
+ {
+ throw new IllegalStateException();
+ }
+ else if (wantRedirect == null)
+ {
+ wantRedirect = new WantRedirect();
+ }
+ return wantRedirect;
+ }
+
+ protected WantUpdate wantUpdate()
+ {
+ if (wantUpdate == null)
+ {
+ wantUpdate = new WantUpdate();
+ }
+ return wantUpdate;
+ }
+
public void setWindowState(WindowState windowState) throws WindowStateException
{
- WantUpdate update = wantUpdate("Window state cannot be set after redirect");
+ WantUpdate update = requireUpdate("Window state cannot be set after redirect");
//
if (!preq.isWindowStateAllowed(windowState))
@@ -127,12 +157,11 @@
//
update.windowState = org.jboss.portal.WindowState.create(windowState.toString());
- decision = update;
}
public void setPortletMode(PortletMode portletMode) throws PortletModeException
{
- WantUpdate update = wantUpdate("Portlet mode cannot be set after redirect");
+ WantUpdate update = requireUpdate("Portlet mode cannot be set after redirect");
//
if (portletMode == null)
@@ -150,59 +179,47 @@
//
update.mode = Mode.create(portletMode.toString());
- decision = update;
}
}
public void setRenderParameters(Map<String, String[]> map)
{
- PortletUtils.checkPortletParameterMapValidity(map);
+ WantUpdate update = requireUpdate("setRenderParameters cannot be called after redirect");
//
- WantUpdate update = wantUpdate("setRenderParameters cannot be called after redirect");
-
- //
- update.navigationalState.replace(map);
- decision = update;
+ update.navigationalState.setMap(map);
}
public void setRenderParameter(String name, String value)
{
- PortletUtils.checkPortletParameterValidity(name, value);
+ WantUpdate update = requireUpdate("setRenderParameter cannot be called after redirect");
//
- setRenderParameter(name, new String[]{value});
+ update.navigationalState.setParameterValue(name, value);
}
public void setRenderParameter(String name, String[] values)
{
- PortletUtils.checkPortletParameterValidity(name, values);
+ WantUpdate update = requireUpdate("setRenderParameter cannot be called after redirect");
//
- WantUpdate update = wantUpdate("setRenderParameter cannot be called after redirect");
+ update.navigationalState.setParameterValues(name, values);
+ }
- // Find out
- ContainerParameterInfo pi = preq.navigationInfo.getPublicParameter(name);
+ public Map<String, String[]> getRenderParameterMap()
+ {
+ WantUpdate update = wantUpdate();
//
- if (pi != null)
- {
- for (String value : values)
- {
- if (value == null)
- {
- throw new IllegalArgumentException();
- }
- }
- update.publicNavigationalState.put(name, values.clone());
- }
- else
- {
- update.navigationalState.setValues(name, values);
- }
+ return update.navigationalState.getMap();
+ }
+ public void removePublicRenderParameter(String name)
+ {
+ WantUpdate update = wantUpdate();
+
//
- decision = update;
+ update.navigationalState.removePublicParameterValue(name);
}
private static final Set<? extends Class<? extends Serializable>> acceptedFinalClasses = Tools.toSet(
@@ -322,11 +339,6 @@
setEvent(name, value);
}
- public Map<String, String[]> getRenderParameterMap()
- {
- throw new NotYetImplemented();
- }
-
public PortletMode getPortletMode()
{
throw new NotYetImplemented();
@@ -337,11 +349,6 @@
throw new NotYetImplemented();
}
- public void removePublicRenderParameter(String s)
- {
- throw new NotYetImplemented();
- }
-
protected final void queueEvent(QName name, Serializable value)
{
if (events == null)
@@ -379,7 +386,7 @@
{
/** The navigational state returned. */
- protected ParameterMap navigationalState = new ParameterMap(ParameterMap.AccessMode.get(true, false));
+ protected PortletParameterMap navigationalState = new PortletParameterMap(preq.navigationInfo);
/** The new window state requested. */
protected org.jboss.portal.WindowState windowState;
@@ -387,9 +394,6 @@
/** The new mode requested. */
protected Mode mode;
- /** The update to the shared parameters. */
- protected Map<String,String[]> publicNavigationalState;
-
protected StateResponse createResponse()
{
UpdateNavigationalStateResponse response = new UpdateNavigationalStateResponse();
@@ -397,8 +401,8 @@
//
response.setMode(mode);
response.setWindowState(windowState);
- response.setPublicNavigationalStateUpdates(publicNavigationalState);
- response.setNavigationalState(new ParametersStateString(navigationalState));
+ response.setPublicNavigationalStateUpdates(navigationalState.getPublicMapSnapshot());
+ response.setNavigationalState(new ParametersStateString(navigationalState.getPrivateMapSnapshot()));
//
return response;
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-17 10:29:15 UTC (rev 9526)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-17 13:44:09 UTC (rev 9527)
@@ -22,17 +22,22 @@
******************************************************************************/
package org.jboss.portal.test.portlet;
-import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+import org.jboss.portal.portlet.support.info.NavigationInfoSupport;
+import org.jboss.portal.portlet.support.info.ParameterInfoSupport;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.unit.api.pojo.annotations.Create;
import org.jboss.unit.api.pojo.annotations.Destroy;
+import javax.xml.namespace.QName;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6639 $
@@ -45,18 +50,21 @@
{
}
- private ParameterMap param;
+ private NavigationInfoSupport navigation;
+ private PortletParameterMap map;
@Create
public void setUp()
{
- param = new ParameterMap();
+ navigation = new NavigationInfoSupport();
+ map = new PortletParameterMap(navigation);
}
@Destroy
public void tearDown()
{
- param = null;
+ map = null;
+ navigation = null;
}
@Test
@@ -64,10 +72,10 @@
{
try
{
- param.getValue(null);
+ map.getParameterValue(null);
fail("Expected IllegalArgumentException");
}
- catch (NullPointerException e)
+ catch (IllegalArgumentException e)
{
}
}
@@ -75,8 +83,8 @@
@Test
public void testSet()
{
- param.setValue("a", "b");
- assertEquals(param.getValue("a"), "b");
+ map.setParameterValue("a", "b");
+ assertEquals(map.getParameterValue("a"), "b");
}
@Test
@@ -84,10 +92,10 @@
{
try
{
- param.setValue(null, "b");
+ map.setParameterValue(null, "b");
fail("Expected IllegalArgumentException");
}
- catch (NullPointerException e)
+ catch (IllegalArgumentException e)
{
}
}
@@ -97,7 +105,7 @@
{
try
{
- param.setValue("a", null);
+ map.setParameterValue("a", null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -105,34 +113,34 @@
}
}
- @Test
- public void testRemoveWithNullName()
- {
- try
- {
- param.remove(null);
- fail("Expected IllegalArgumentException");
- }
- catch (NullPointerException e)
- {
- }
- }
+// @Test
+// public void testRemoveWithNullName()
+// {
+// try
+// {
+// param.remove(null);
+// fail("Expected IllegalArgumentException");
+// }
+// catch (NullPointerException e)
+// {
+// }
+// }
- @Test
- public void testRemove()
- {
- param.setValue("a", "b");
- param.remove("a");
- assertEquals(param.getValue("a"), null);
- }
+// @Test
+// public void testRemove()
+// {
+// param.setValue("a", "b");
+// param.remove("a");
+// assertEquals(param.getValue("a"), null);
+// }
@Test
public void testSetValues()
{
- param.setValues("a", new String[]{"b", "c"});
- assertTrue(Arrays.equals(param.getValues("a"), new String[]{
+ map.setParameterValues("a", new String[]{"b", "c"});
+ assertTrue(Arrays.equals(map.getParameterValues("a"), new String[]{
"b", "c"}));
- assertEquals(param.getValue("a"), "b");
+ assertEquals(map.getParameterValue("a"), "b");
}
@Test
@@ -140,10 +148,10 @@
{
try
{
- param.setValues(null, new String[]{"a"});
+ map.setParameterValues(null, new String[]{"a"});
fail("Expected IllegalArgumentException");
}
- catch (NullPointerException e)
+ catch (IllegalArgumentException e)
{
}
}
@@ -153,10 +161,10 @@
{
try
{
- param.setValues("a", null);
+ map.setParameterValues("a", null);
fail("Expected IllegalArgumentException");
}
- catch (NullPointerException e)
+ catch (IllegalArgumentException e)
{
}
}
@@ -166,7 +174,7 @@
{
try
{
- param.setValues("a", new String[0]);
+ map.setParameterValues("a", new String[0]);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -179,7 +187,7 @@
{
try
{
- param.setValues("a", new String[]{"a", null});
+ map.setParameterValues("a", new String[]{"a", null});
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -187,142 +195,142 @@
}
}
- @Test
- public void testReplaceWithParameters()
- {
- ParameterMap other = new ParameterMap();
- other.setValue("a", "b");
- other.setValues("c", new String[]{"d", "e"});
- param.replace(other);
- assertEquals("b", param.getValue("a"));
- assertTrue(Arrays.equals(param.getValues("c"), new String[]{"d", "e"}));
- }
+// @Test
+// public void testReplaceWithParameters()
+// {
+// ParameterMap other = new ParameterMap();
+// other.setValue("a", "b");
+// other.setValues("c", new String[]{"d", "e"});
+// param.replace(other);
+// assertEquals("b", param.getValue("a"));
+// assertTrue(Arrays.equals(param.getValues("c"), new String[]{"d", "e"}));
+// }
@Test
- public void testCopyConstructorWithNullParameters()
+ public void testBlah()
{
- try
- {
- ParameterMap.clone(null);
- fail("Expected IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
- }
+ navigation.addPublicParameter(new ParameterInfoSupport("foo", new QName("", "foo")));
+ navigation.addPublicParameter(new ParameterInfoSupport("abc", new QName("", "abc")));
- @Test
- public void testCopyConstructorWithNullMap()
- {
- try
- {
- ParameterMap.clone(null);
- fail("Expected IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
- }
+ map.setParameterValue("juu", "daa");
+ map.setParameterValue("foo", "bar");
+ map.removePublicParameterValue("abc");
- @Test
- public void testReplaceWithNullMap()
- {
- try
- {
- param.replace(null);
- fail("Expected NullPointerException");
- }
- catch (NullPointerException e)
- {
- }
- }
+ Map<String, String[]> privateMap = map.getPrivateMapSnapshot();
+ assertEquals(2, privateMap.size());
+ assertEquals(new String[]{"daa"}, privateMap.get("juu"));
+ assertEquals(new String[]{}, privateMap.get("abc"));
- @Test
- public void testReplaceWithInvalidMap()
- {
- Map[] maps = buildInvalidMaps();
- Class[] exceptionClasses = buildExceptionClasses();
- for (int i = 0; i < maps.length; i++)
- {
- try
- {
- Map map = maps[i];
- param.replace(map);
- fail("Expected IllegalArgumentException with map=" + map);
- }
- catch (Exception e)
- {
- assertTrue(exceptionClasses[i].isAssignableFrom(e.getClass()));
- }
- }
- }
+ Map<String, String[]> publicMap = map.getPublicMapSnapshot();
+ assertEquals(1, publicMap.size());
+ assertEquals(new String[]{"bar"}, publicMap.get("foo"));
- @Test
- public void testReplace()
- {
- param.setValue("a", "b");
- param.setValues("c", new String[]{"d", "e"});
- param.setValue("f", "g");
- Map map = new HashMap();
- map.put("a", new String[]{"_b"});
- map.put("c", new String[]{"_d", "_e"});
- map.put("h", new String[]{"_i"});
- param.replace(map);
- assertEquals(3, param.size());
- assertEquals(param.getValues("a"), new String[]{"_b"});
- assertEquals(param.getValues("c"), new String[]{"_d", "_e"});
- assertEquals(param.getValues("h"), new String[]{"_i"});
- }
+ Map<String, String[]> combinedMap = map.getMap();
+ assertEquals(2, combinedMap.size());
+ assertEquals(new String[]{"bar"}, combinedMap.get("foo"));
+ assertEquals(new String[]{"daa"}, combinedMap.get("juu"));
- @Test
- public void testAppendWithInvalidMap()
- {
- Map[] maps = buildInvalidMaps();
- Class[] exceptionClasses = buildExceptionClasses();
- for (int i = 0; i < maps.length; i++)
- {
- try
- {
- Map map = maps[i];
- param.append(map);
- fail("Expected IllegalArgumentException with map=" + map);
- }
- catch (Exception e)
- {
- if (!exceptionClasses[i].isAssignableFrom(e.getClass()))
- {
- fail("Exception class " + exceptionClasses[i].getName() + " (index=" + i + ") should be assignable from caught exception " + e.getClass());
- }
- }
- }
}
- @Test
- public void testAppend()
- {
- param.setValue("a", "b");
- param.setValues("c", new String[]{"d", "e"});
- param.setValue("f", "g");
- Map map = new HashMap();
- map.put("a", new String[]{"_b"});
- map.put("c", new String[]{"_d", "_e"});
- map.put("h", new String[]{"_i"});
- param.append(map);
- assertEquals(4, param.size());
- assertEquals(param.getValues("a"), new String[]{"b", "_b"});
- assertEquals(param.getValues("c"), new String[]{"d", "e", "_d", "_e"});
- assertEquals(param.getValues("f"), new String[]{"g"});
- assertEquals(param.getValues("h"), new String[]{"_i"});
- }
+// @Test
+// public void testReplaceWithNullMap()
+// {
+// try
+// {
+// param.replace(null);
+// fail("Expected NullPointerException");
+// }
+// catch (NullPointerException e)
+// {
+// }
+// }
- @Test
- public void testClear()
- {
- param.setValue("a", "b");
- param.clear();
- assertNull(param.getValue("a"));
- }
+// @Test
+// public void testReplaceWithInvalidMap()
+// {
+// Map[] maps = buildInvalidMaps();
+// Class[] exceptionClasses = buildExceptionClasses();
+// for (int i = 0; i < maps.length; i++)
+// {
+// try
+// {
+// Map map = maps[i];
+// param.replace(map);
+// fail("Expected IllegalArgumentException with map=" + map);
+// }
+// catch (Exception e)
+// {
+// assertTrue(exceptionClasses[i].isAssignableFrom(e.getClass()));
+// }
+// }
+// }
+// @Test
+// public void testReplace()
+// {
+// param.setValue("a", "b");
+// param.setValues("c", new String[]{"d", "e"});
+// param.setValue("f", "g");
+// Map map = new HashMap();
+// map.put("a", new String[]{"_b"});
+// map.put("c", new String[]{"_d", "_e"});
+// map.put("h", new String[]{"_i"});
+// param.replace(map);
+// assertEquals(3, param.size());
+// assertEquals(param.getValues("a"), new String[]{"_b"});
+// assertEquals(param.getValues("c"), new String[]{"_d", "_e"});
+// assertEquals(param.getValues("h"), new String[]{"_i"});
+// }
+
+// @Test
+// public void testAppendWithInvalidMap()
+// {
+// Map[] maps = buildInvalidMaps();
+// Class[] exceptionClasses = buildExceptionClasses();
+// for (int i = 0; i < maps.length; i++)
+// {
+// try
+// {
+// Map map = maps[i];
+// param.append(map);
+// fail("Expected IllegalArgumentException with map=" + map);
+// }
+// catch (Exception e)
+// {
+// if (!exceptionClasses[i].isAssignableFrom(e.getClass()))
+// {
+// fail("Exception class " + exceptionClasses[i].getName() + " (index=" + i + ") should be assignable from caught exception " + e.getClass());
+// }
+// }
+// }
+// }
+
+// @Test
+// public void testAppend()
+// {
+// param.setValue("a", "b");
+// param.setValues("c", new String[]{"d", "e"});
+// param.setValue("f", "g");
+// Map map = new HashMap();
+// map.put("a", new String[]{"_b"});
+// map.put("c", new String[]{"_d", "_e"});
+// map.put("h", new String[]{"_i"});
+// param.append(map);
+// assertEquals(4, param.size());
+// assertEquals(param.getValues("a"), new String[]{"b", "_b"});
+// assertEquals(param.getValues("c"), new String[]{"d", "e", "_d", "_e"});
+// assertEquals(param.getValues("f"), new String[]{"g"});
+// assertEquals(param.getValues("h"), new String[]{"_i"});
+// }
+
+// @Test
+// public void testClear()
+// {
+// param.setValue("a", "b");
+// param.clear();
+// assertNull(param.getValue("a"));
+// }
+
public Class[] buildExceptionClasses()
{
return new Class[]
18 years, 3 months
JBoss Portal SVN: r9526 - branches/JBoss_Portal_Branch_2_6/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-17 05:29:15 -0500 (Thu, 17 Jan 2008)
New Revision: 9526
Modified:
branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
Log:
Snapshots are bad
Modified: branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2008-01-17 10:10:59 UTC (rev 9525)
+++ branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2008-01-17 10:29:15 UTC (rev 9526)
@@ -47,11 +47,11 @@
are pushed to the http://repository.jboss.com site.
-->
- <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/web" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/test" version="1.0-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/portlet" version="1.0-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/identity" version="1.0-SNAPSHOT"/>
+ <componentref name="jboss-portal/modules/common" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/web" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/test" version="1.0.1"/>
+ <componentref name="jboss-portal/modules/portlet" version="1.0.1"/>
+ <componentref name="jboss-portal/modules/identity" version="1.0.1"/>
<componentref name="antlr" version="2.7.6.ga"/>
<componentref name="apache-ant" version="1.6.5"/>
<componentref name="jackrabbit" version="1.1.1"/>
18 years, 3 months
JBoss Portal SVN: r9525 - tags/JBoss_Portal_2_6_3/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-17 05:10:59 -0500 (Thu, 17 Jan 2008)
New Revision: 9525
Modified:
tags/JBoss_Portal_2_6_3/build/build-thirdparty.xml
Log:
Doh !
Have to change this for records
Modified: tags/JBoss_Portal_2_6_3/build/build-thirdparty.xml
===================================================================
--- tags/JBoss_Portal_2_6_3/build/build-thirdparty.xml 2008-01-17 02:12:48 UTC (rev 9524)
+++ tags/JBoss_Portal_2_6_3/build/build-thirdparty.xml 2008-01-17 10:10:59 UTC (rev 9525)
@@ -47,11 +47,11 @@
are pushed to the http://repository.jboss.com site.
-->
- <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/web" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/test" version="1.0-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/portlet" version="1.0-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/identity" version="1.0-SNAPSHOT"/>
+ <componentref name="jboss-portal/modules/common" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/web" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/test" version="1.0.1"/>
+ <componentref name="jboss-portal/modules/portlet" version="1.0.1"/>
+ <componentref name="jboss-portal/modules/identity" version="1.0.1/>
<componentref name="antlr" version="2.7.6.ga"/>
<componentref name="apache-ant" version="1.6.5"/>
<componentref name="jackrabbit" version="1.1.1"/>
18 years, 3 months
JBoss Portal SVN: r9524 - in branches/JBoss_Portal_Branch_2_6: theme/src/bin/portal-ajax-war/dyna and 2 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2008-01-16 21:12:48 -0500 (Wed, 16 Jan 2008)
New Revision: 9524
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
branches/JBoss_Portal_Branch_2_6/theme/src/bin/portal-ajax-war/dyna/style.css
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
Log:
JBPORTAL-1769 - Portlet disappears in IE 7.0 after it is maximized
Modified: branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2008-01-16 12:30:17 UTC (rev 9523)
+++ branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2008-01-17 02:12:48 UTC (rev 9524)
@@ -464,11 +464,17 @@
/* wrapper for floating portlet window modes */
.portlet-mode-container {
- float: right;
- padding-top: 4px;
white-space: nowrap;
+ float:right;
}
+.mode-button {
+ /*position:absolute;*/
+ margin-right: 3px;
+ padding-top:5px;
+ float:left;
+}
+
.portlet-titlebar-title {
color: #656565;
font-family: Verdana, Arial, Helvetica, sans-serif;
@@ -480,6 +486,9 @@
text-indent: 5px;
padding-top: 5px;
padding-bottom: 6px;
+ width:90%;
+ display:block;
+ margin-right:10px;
}
/* ------ NOT CURRENTLY IN USE FOR NEW 2.6 FUNCTIONALITY -------
@@ -500,6 +509,7 @@
background-repeat: repeat-x;
height: 29px;
background-position: bottom;
+ position:relative;
}
.portlet-titlebar-right {
Modified: branches/JBoss_Portal_Branch_2_6/theme/src/bin/portal-ajax-war/dyna/style.css
===================================================================
--- branches/JBoss_Portal_Branch_2_6/theme/src/bin/portal-ajax-war/dyna/style.css 2008-01-16 12:30:17 UTC (rev 9523)
+++ branches/JBoss_Portal_Branch_2_6/theme/src/bin/portal-ajax-war/dyna/style.css 2008-01-17 02:12:48 UTC (rev 9524)
@@ -9,7 +9,6 @@
.dnd-handle {
cursor: move;
- overflow: auto;
}
Modified: branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2008-01-16 12:30:17 UTC (rev 9523)
+++ branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2008-01-17 02:12:48 UTC (rev 9524)
@@ -58,7 +58,11 @@
//
renderTitle(rendererContext, drc);
- //
+ //End the dyna-handle early so it doesn't encompass
+ //the mode container -
+ markup.print("</div>");
+ markup.print("</div>");
+
markup.print("<div class=\"portlet-mode-container\">");
renderTriggerableActions(rendererContext, drc, ActionRendererContext.MODES_KEY);
renderTriggerableActions(rendererContext, drc, ActionRendererContext.WINDOWSTATES_KEY);
@@ -97,7 +101,7 @@
if (action.isEnabled())
{
PrintWriter out = ctx.getWriter();
- out.print("<span title=\"");
+ out.print("<span class=\"mode-button\" title=\"");
out.print(action.getName());
out.print("\"><a class=\"portlet-mode-");
out.print(action.getName());
Modified: branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2008-01-16 12:30:17 UTC (rev 9523)
+++ branches/JBoss_Portal_Branch_2_6/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2008-01-17 02:12:48 UTC (rev 9524)
@@ -71,15 +71,16 @@
//
delegate.render(rendererContext, drc);
- //
- markup.print("</div>\n");
- markup.print("</div>\n");
+ //end element in DivDecorationRenderer
+ /*markup.print("</div>\n");
+ markup.print("</div>\n");*/
}
else
{
markup.print("<div class=\"dyna-decoration\">\n");
delegate.render(rendererContext, drc);
- markup.print("</div>\n");
+ //end element in DivDecorationRenderer
+ //markup.print("</div>\n");
}
}
else
18 years, 3 months
JBoss Portal SVN: r9523 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/invocation/response and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-16 07:30:17 -0500 (Wed, 16 Jan 2008)
New Revision: 9523
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
Log:
update Portlet module to take in account common module updates to TypeMap and ParameterMap
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-16 12:18:04 UTC (rev 9522)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-16 12:30:17 UTC (rev 9523)
@@ -55,6 +55,7 @@
import java.util.UUID;
import java.util.List;
import java.util.LinkedList;
+import java.util.HashMap;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
@@ -186,7 +187,14 @@
//
if (pi != null)
{
- update.publicNavigationalState.setValues(name, values);
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ update.publicNavigationalState.put(name, values.clone());
}
else
{
@@ -371,7 +379,7 @@
{
/** The navigational state returned. */
- protected ParameterMap navigationalState = new ParameterMap();
+ protected ParameterMap navigationalState = new ParameterMap(ParameterMap.AccessMode.get(true, false));
/** The new window state requested. */
protected org.jboss.portal.WindowState windowState;
@@ -380,7 +388,7 @@
protected Mode mode;
/** The update to the shared parameters. */
- protected ParameterMap publicNavigationalState = new ParameterMap();
+ protected Map<String,String[]> publicNavigationalState;
protected StateResponse createResponse()
{
@@ -389,7 +397,7 @@
//
response.setMode(mode);
response.setWindowState(windowState);
- response.setPublicNavigationalState(publicNavigationalState);
+ response.setPublicNavigationalStateUpdates(publicNavigationalState);
response.setNavigationalState(new ParametersStateString(navigationalState));
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java 2008-01-16 12:18:04 UTC (rev 9522)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java 2008-01-16 12:30:17 UTC (rev 9523)
@@ -27,6 +27,8 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
+import java.util.Map;
+
/**
* Update the navigational state.
*
@@ -45,15 +47,18 @@
/** The new mode requested. */
protected Mode mode;
- /** The update to the shared parameters. */
- protected ParameterMap publicNavigationalState;
+ /**
+ * The update to the public parameters. Each entry having a zero length value must be interpeted as
+ * a public parameter removal otherwise it must be interpreted as a public parameter values update.
+ */
+ protected Map<String, String[]> publicNavigationalStateUpdates;
public UpdateNavigationalStateResponse()
{
navigationalState = null;
windowState = null;
mode = null;
- publicNavigationalState = null;
+ publicNavigationalStateUpdates = null;
}
public Mode getMode()
@@ -86,13 +91,13 @@
this.navigationalState = state;
}
- public ParameterMap getPublicNavigationalState()
+ public Map<String, String[]> getPublicNavigationalStateUpdates()
{
- return publicNavigationalState;
+ return publicNavigationalStateUpdates;
}
- public void setPublicNavigationalState(ParameterMap publicNavigationalState)
+ public void setPublicNavigationalStateUpdates(Map<String, String[]> publicNavigationalStateUpdates)
{
- this.publicNavigationalState = publicNavigationalState;
+ this.publicNavigationalStateUpdates = publicNavigationalStateUpdates;
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-16 12:18:04 UTC (rev 9522)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-16 12:30:17 UTC (rev 9523)
@@ -502,23 +502,23 @@
portalNS.setWindowNavigationalState(portletId, windowNS);
// Now update shared state scoped at page
- ParameterMap publicNS = update.getPublicNavigationalState();
- if (publicNS != null)
- {
- NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
- for (Map.Entry<String, String[]> entry : publicNS.entrySet())
- {
- String id = entry.getKey();
- ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
-
- //
- if (parameterInfo != null)
- {
- QName name = parameterInfo.getName();
- portalNS.getPageNavigationalState().put(name, entry.getValue());
- }
- }
- }
+// Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
+// if (publicNS != null)
+// {
+// NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
+// for (Map.Entry<String, String[]> entry : publicNS.entrySet())
+// {
+// String id = entry.getKey();
+// ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
+//
+// //
+// if (parameterInfo != null)
+// {
+// QName name = parameterInfo.getName();
+// portalNS.getPageNavigationalState().put(name, entry.getValue());
+// }
+// }
+// }
}
static class Action
18 years, 3 months
JBoss Portal SVN: r9522 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-16 07:18:04 -0500 (Wed, 16 Jan 2008)
New Revision: 9522
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
Log:
- updated ParameterMap test case to include test case that were in portlet module
- minor update of ParameterMap access mode
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-01-16 03:11:23 UTC (rev 9521)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-01-16 12:18:04 UTC (rev 9522)
@@ -29,7 +29,8 @@
import java.io.Serializable;
/**
- * A decorator that enforce the map content to be <String,String[]>
+ * A decorator that enforce the map content to be <String,String[]>. It also provides capabilities for
+ * making a copy of the value either on a read or on a write.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6671 $
@@ -40,48 +41,10 @@
/** . */
private static final KeyConverter keyConv = new KeyConverter();
- /** . */
- private static final ValueConverter valueConv1 = new ValueConverter(false, false);
-
- /** . */
- private static final ValueConverter valueConv2 = new ValueConverter(false, true);
-
- /** . */
- private static final ValueConverter valueConv3 = new ValueConverter(true, false);
-
- /** . */
- private static final ValueConverter valueConv4 = new ValueConverter(true, true);
-
- private static ValueConverter getValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
- {
- if (cloneInternalValue)
- {
- if (cloneExternalValue)
- {
- return valueConv4;
- }
- else
- {
- return valueConv3;
- }
- }
- else
- {
- if (cloneExternalValue)
- {
- return valueConv2;
- }
- else
- {
- return valueConv1;
- }
- }
- }
-
/**
* Copy the parameter map.
*
- * @param parameterMap the parameter map to copy
+ * @param map the parameter map to copy
* @return a parameter map initialized from the argument map
* @throws NullPointerException if the map contains a null key or a null value
* @throws IllegalArgumentException if the map is null or it contains a value with a zero length array or a null
@@ -89,9 +52,9 @@
* @throws ClassCastException if the map contains a key that is not a string or a value that is not a string
* array
*/
- public static ParameterMap clone(Map<String,String[]> parameterMap) throws NullPointerException, ClassCastException, IllegalArgumentException
+ public static ParameterMap clone(Map<String, String[]> map) throws NullPointerException, ClassCastException, IllegalArgumentException
{
- if (parameterMap == null)
+ if (map == null)
{
throw new IllegalArgumentException("No null map accepted");
}
@@ -100,7 +63,7 @@
ParameterMap pm = new ParameterMap();
//
- pm.replace(parameterMap);
+ pm.replace(map);
//
return pm;
@@ -125,148 +88,81 @@
}
}
- /** . */
- private final boolean cloneInternalValue;
+ /**
+ * Safely wrap the map as a portlet parameters object. If the map is already a parameter map object, just return
+ * that object otherwise return a wrapper around the map.
+ *
+ * @param map the map
+ * @return the portlet parameters
+ */
+ public static ParameterMap wrap(Map<String, String[]> map, AccessMode accessPolicy)
+ {
+ if (map instanceof ParameterMap)
+ {
+ return new ParameterMap((ParameterMap)map, accessPolicy);
+ }
+ else
+ {
+ return new ParameterMap(map, accessPolicy);
+ }
+ }
/** . */
- private final boolean cloneExternalValue;
+ private final AccessMode accessMode;
- public ParameterMap(boolean cloneInternalValue, boolean cloneExternalValue)
+ /**
+ * Reuse the same underlying map than the provided parameter map but it allows to have an alternative configuration
+ * of the access. This is not a copy constructor.
+ */
+ public ParameterMap(ParameterMap map, AccessMode accessMode)
{
- this(new HashMap<String, String[]>(), cloneInternalValue, cloneExternalValue);
+ super(map);
+
+ //
+ this.accessMode = accessMode;
}
+ public ParameterMap(AccessMode accessMode)
+ {
+ this(new HashMap<String, String[]>(), accessMode);
+ }
+
public ParameterMap(MapAccessor<String, String[]> accessor)
{
- this(accessor, false, false);
+ this(accessor, AccessMode.A);
}
public ParameterMap(Map<String, String[]> delegate)
{
- this(delegate, false, false);
+ this(delegate, AccessMode.A);
}
public ParameterMap()
{
- this(false, false);
+ this(AccessMode.A);
}
- public ParameterMap(MapAccessor<String, String[]> accessor, boolean cloneInternalValue, boolean cloneExternalValue)
+ public ParameterMap(MapAccessor<String, String[]> accessor, AccessMode accessMode)
{
- super(accessor, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+ super(accessor, keyConv, accessMode.converter);
//
- this.cloneInternalValue = cloneInternalValue;
- this.cloneExternalValue = cloneExternalValue;
+ this.accessMode = accessMode;
}
- public ParameterMap(Map<String, String[]> delegate, boolean cloneInternalValue, boolean cloneExternalValue)
+ public ParameterMap(Map<String, String[]> delegate, AccessMode accessMode)
{
- super(delegate, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+ super(delegate, keyConv, accessMode.converter);
//
- this.cloneInternalValue = cloneInternalValue;
- this.cloneExternalValue = cloneExternalValue;
+ this.accessMode = accessMode;
}
- /**
- * Return true if values returned by the map are cloned.
- *
- * @return true if returned values are cloned
- */
- public boolean isCloneInternalValue()
+ public AccessMode getAccessMode()
{
- return cloneInternalValue;
+ return accessMode;
}
- public boolean isCloneExternalValue()
- {
- return cloneExternalValue;
- }
-
- private static class KeyConverter extends Converter<String, String>
- {
- protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
- {
- return external;
- }
- protected String getExternal(String internal)
- {
- return internal;
- }
- protected boolean equals(String left, String right)
- {
- return left.equals(right);
- }
- }
-
- private static class ValueConverter extends Converter<String[], String[]>
- {
-
- /** . */
- private final boolean cloneInternalValue;
-
- /** . */
- private final boolean cloneExternalValue;
-
- private ValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
- {
- this.cloneInternalValue = cloneInternalValue;
- this.cloneExternalValue = cloneExternalValue;
- }
-
- /**
- * Only check are made to the value. The only valid values accepted
- * are string arrays with non zero length and containing non null
- * values.
- *
- * @param external
- * @return
- * @throws NullPointerException if the value is null
- * @throws ClassCastException if the value type is not an array of string
- * @throws IllegalArgumentException if the array length is zero or one of the array value is null
- */
- protected String[] getInternal(String[] external) throws IllegalArgumentException, ClassCastException, NullPointerException
- {
- if (external.length == 0)
- {
- throw new IllegalArgumentException("Array must not be zero length");
- }
-
- //
- for (int i = external.length - 1;i >= 0;i--)
- {
- if (external[i] == null)
- {
- throw new IllegalArgumentException("No null entries allowed in String[]");
- }
- }
-
- //
- if (cloneExternalValue)
- {
- external = external.clone();
- }
-
- //
- return external;
- }
-
- protected String[] getExternal(String[] internal)
- {
- if (cloneInternalValue)
- {
- internal = internal.clone();
- }
- return internal;
- }
-
- protected boolean equals(String[] left, String[] right)
- {
- return Arrays.equals(left, right);
- }
- }
-
/**
* Return the parameter value or null if it does not exist.
*
@@ -379,4 +275,133 @@
buffer.append(']');
return buffer.toString();
}
+
+ private static class KeyConverter extends Converter<String, String>
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ }
+
+ /**
+ * Defines how the state of the values are managed.
+ */
+ public static class AccessMode
+ {
+
+ public static AccessMode get(boolean copyValueOnRead, boolean copyValueOnWrite)
+ {
+ return copyValueOnRead ? copyValueOnWrite ? D : C : copyValueOnWrite ? B : A;
+ }
+
+ /** . */
+ private static final AccessMode A = new AccessMode(false, false);
+
+ /** . */
+ private static final AccessMode B = new AccessMode(false, true);
+
+ /** . */
+ private static final AccessMode C = new AccessMode(true, false);
+
+ /** . */
+ private static final AccessMode D = new AccessMode(true, true);
+
+ /** . */
+ private final boolean copyValueOnRead;
+
+ /** . */
+ private final boolean copyValueOnWrite;
+
+ /** . */
+ private final ValueConverter converter;
+
+ private AccessMode(boolean copyValueOnRead, boolean copyOnWrite)
+ {
+ this.copyValueOnRead = copyValueOnRead;
+ this.copyValueOnWrite = copyOnWrite;
+ this.converter = new ValueConverter(this);
+ }
+
+ public boolean getCopyValueOnRead()
+ {
+ return copyValueOnRead;
+ }
+
+ public boolean getCopyValueOnWrite()
+ {
+ return copyValueOnWrite;
+ }
+ }
+
+ private static class ValueConverter extends Converter<String[], String[]>
+ {
+
+ /** . */
+ private final AccessMode accessMode;
+
+ private ValueConverter(AccessMode accessMode)
+ {
+ this.accessMode = accessMode;
+ }
+
+ /**
+ * Only check are made to the value. The only valid values accepted
+ * are string arrays with non zero length and containing non null
+ * values.
+ *
+ * @param external
+ * @return
+ * @throws NullPointerException if the value is null
+ * @throws ClassCastException if the value type is not an array of string
+ * @throws IllegalArgumentException if the array length is zero or one of the array value is null
+ */
+ protected String[] getInternal(String[] external) throws IllegalArgumentException, ClassCastException, NullPointerException
+ {
+ if (external.length == 0)
+ {
+ throw new IllegalArgumentException("Array must not be zero length");
+ }
+
+ //
+ for (int i = external.length - 1;i >= 0;i--)
+ {
+ if (external[i] == null)
+ {
+ throw new IllegalArgumentException("No null entries allowed in String[]");
+ }
+ }
+
+ //
+ if (accessMode.copyValueOnWrite)
+ {
+ external = external.clone();
+ }
+
+ //
+ return external;
+ }
+
+ protected String[] getExternal(String[] internal)
+ {
+ if (accessMode.copyValueOnRead)
+ {
+ internal = internal.clone();
+ }
+ return internal;
+ }
+
+ protected boolean equals(String[] left, String[] right)
+ {
+ return Arrays.equals(left, right);
+ }
+ }
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/TypedMap.java 2008-01-16 03:11:23 UTC (rev 9521)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/TypedMap.java 2008-01-16 12:18:04 UTC (rev 9522)
@@ -123,6 +123,18 @@
/** The value converter. */
private final Converter<EV, IV> valueConverter;
+ /**
+ * Constructor that will reuse the same attributes than the provided map. This is not a copy constructor.
+ *
+ * @param that the other map
+ */
+ public TypedMap(TypedMap<EK, EV, IK, IV> that)
+ {
+ this.accessor = that.accessor;
+ this.keyConverter = that.keyConverter;
+ this.valueConverter = that.valueConverter;
+ }
+
public TypedMap(MapAccessor<IK, IV> accessor, Converter<EK, IK> keyConverter, Converter<EV, IV> valueConverter)
{
if (accessor == null)
@@ -554,7 +566,7 @@
public boolean add(EV ev)
{
- throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ throw new UnsupportedOperationException();
}
public boolean contains(Object o)
@@ -562,39 +574,39 @@
throw new NotYetImplemented("TypedEntrySet.contains(Object o)");
}
- public boolean remove(Object o)
+ public boolean containsAll(Collection<?> objects)
{
- throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
}
- public boolean addAll(Collection<? extends EV> evs)
+ public <T> T[] toArray(T[] ts)
{
- throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
}
- public boolean containsAll(Collection<?> objects)
+ public Iterator<EV> iterator()
{
- throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ return new ValueIterator();
}
- public boolean removeAll(Collection<?> objects)
+ public boolean remove(Object o)
{
- throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ throw new UnsupportedOperationException();
}
- public boolean retainAll(Collection<?> objects)
+ public boolean addAll(Collection<? extends EV> evs)
{
- throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ throw new UnsupportedOperationException();
}
- public <T> T[] toArray(T[] ts)
+ public boolean removeAll(Collection<?> objects)
{
- throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ throw new UnsupportedOperationException();
}
- public Iterator<EV> iterator()
+ public boolean retainAll(Collection<?> objects)
{
- return new ValueIterator();
+ throw new UnsupportedOperationException();
}
public class ValueIterator implements Iterator<EV>
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java 2008-01-16 03:11:23 UTC (rev 9521)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java 2008-01-16 12:18:04 UTC (rev 9522)
@@ -24,11 +24,15 @@
import junit.framework.TestCase;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.junit.ExtendedAssert;
import java.util.HashMap;
import java.util.Set;
import java.util.Iterator;
import java.util.Map;
+import java.util.Arrays;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -37,16 +41,38 @@
public class ParameterMapTestCase extends TestCase
{
+ /** . */
+ private ParameterMap param;
+
+ public ParameterMapTestCase()
+ {
+ }
+
+ public ParameterMapTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp()
+ {
+ param = new ParameterMap();
+ }
+
+ public void tearDown()
+ {
+ param = null;
+ }
+
public void testPut()
{
- ParameterMap pm = new ParameterMap(new HashMap());
+ ParameterMap pm = new ParameterMap(new HashMap<String, String[]>());
pm.put("foo", new String[]{"bar"});
// ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])pm.get("foo"));
}
public void testEntry()
{
- ParameterMap pm = new ParameterMap(new HashMap());
+ ParameterMap pm = new ParameterMap(new HashMap<String, String[]>());
pm.put("foo", new String[]{"bar"});
Set entries = pm.entrySet();
assertNotNull(entries);
@@ -61,7 +87,7 @@
public void testPutThrowsException()
{
- ParameterMap pm = new ParameterMap(new HashMap());
+ ParameterMap pm = new ParameterMap(new HashMap<String, String[]>());
try
{
((Map)pm).put(new Object(), new String[]{"bar"});
@@ -98,7 +124,7 @@
public void testEntrySetValueThrowsException()
{
- ParameterMap pm = new ParameterMap(new HashMap());
+ ParameterMap pm = new ParameterMap(new HashMap<String, String[]>());
pm.put("foo", new String[]{"bar"});
Set entries = pm.entrySet();
assertNotNull(entries);
@@ -140,4 +166,348 @@
{
}
}
+
+ public void testNoCopyOnRead()
+ {
+ Map<String, String[]> internal = new HashMap<String, String[]>();
+ String[] internalValue = {"bar"};
+ internal.put("foo", internalValue);
+
+ //
+ ParameterMap map = new ParameterMap(internal, ParameterMap.AccessMode.get(false, false));
+
+ //
+ String[] externalValue = map.get("foo");
+ assertNotNull(externalValue);
+ assertEquals(1, externalValue.length);
+ assertEquals("bar", externalValue[0]);
+ internalValue[0] = null;
+ assertEquals(null, externalValue[0]);
+ }
+
+ public void testCopyOnRead()
+ {
+ Map<String, String[]> internal = new HashMap<String, String[]>();
+ String[] internalValue = {"bar"};
+ internal.put("foo", internalValue);
+
+ //
+ ParameterMap map = new ParameterMap(internal, ParameterMap.AccessMode.get(true, false));
+
+ //
+ String[] externalValue = map.get("foo");
+ assertNotNull(externalValue);
+ assertEquals(1, externalValue.length);
+ assertEquals("bar", externalValue[0]);
+ internalValue[0] = null;
+ assertEquals("bar", externalValue[0]);
+ }
+
+ public void testNoCopyOnWrite()
+ {
+ Map<String, String[]> internal = new HashMap<String, String[]>();
+
+ //
+ ParameterMap map = new ParameterMap(internal, ParameterMap.AccessMode.get(false, false));
+
+ //
+ String[] externalValue = new String[]{"bar"};
+ map.put("foo", externalValue);
+
+ //
+ String[] internalValue = internal.get("foo");
+ assertNotNull(internalValue);
+ assertEquals(1, internalValue.length);
+ assertEquals("bar", internalValue[0]);
+ externalValue[0] = null;
+ assertEquals(null, internalValue[0]);
+ }
+
+ public void testCopyOnWrite()
+ {
+ Map<String, String[]> internal = new HashMap<String, String[]>();
+
+ //
+ ParameterMap map = new ParameterMap(internal, ParameterMap.AccessMode.get(false, true));
+
+ //
+ String[] externalValue = new String[]{"bar"};
+ map.put("foo", externalValue);
+
+ //
+ String[] internalValue = internal.get("foo");
+ assertNotNull(internalValue);
+ assertEquals(1, internalValue.length);
+ assertEquals("bar", internalValue[0]);
+ externalValue[0] = null;
+ assertEquals("bar", internalValue[0]);
+ }
+
+ public void testGetWithNullName()
+ {
+ try
+ {
+ param.getValue(null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testSet()
+ {
+ param.setValue("a", "b");
+ assertEquals(param.getValue("a"), "b");
+ }
+
+ public void testSetWithNullName()
+ {
+ try
+ {
+ param.setValue(null, "b");
+ fail("Expected IllegalArgumentException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testSetWithNullValue()
+ {
+ try
+ {
+ param.setValue("a", null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testRemoveWithNullName()
+ {
+ try
+ {
+ param.remove(null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testRemove()
+ {
+ param.setValue("a", "b");
+ param.remove("a");
+ assertEquals(param.getValue("a"), null);
+ }
+
+ public void testSetValues()
+ {
+ param.setValues("a", new String[]{"b", "c"});
+ assertTrue(Arrays.equals(param.getValues("a"), new String[]{
+ "b", "c"}));
+ assertEquals(param.getValue("a"), "b");
+ }
+
+ public void testSetValuesWithNullName()
+ {
+ try
+ {
+ param.setValues(null, new String[]{"a"});
+ fail("Expected IllegalArgumentException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testSetValuesWithNullValues()
+ {
+ try
+ {
+ param.setValues("a", null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testSetValuesWithZeroLengthValues()
+ {
+ try
+ {
+ param.setValues("a", new String[0]);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testSetValuesWithOneNullValue()
+ {
+ try
+ {
+ param.setValues("a", new String[]{"a", null});
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testReplaceWithParameters()
+ {
+ ParameterMap other = new ParameterMap();
+ other.setValue("a", "b");
+ other.setValues("c", new String[]{"d", "e"});
+ param.replace(other);
+ assertEquals("b", param.getValue("a"));
+ assertTrue(Arrays.equals(param.getValues("c"), new String[]{"d", "e"}));
+ }
+
+ public void testCopyConstructorWithNullParameters()
+ {
+ try
+ {
+ ParameterMap.clone(null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testCopyConstructorWithNullMap()
+ {
+ try
+ {
+ ParameterMap.clone(null);
+ fail("Expected IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testReplaceWithNullMap()
+ {
+ try
+ {
+ param.replace(null);
+ fail("Expected NullPointerException");
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testReplaceWithInvalidMap()
+ {
+ List<Map<String, String[]>> maps = buildInvalidMaps();
+ Class[] exceptionClasses = buildExceptionClasses();
+ for (int i = 0;i < maps.size();i++)
+ {
+ try
+ {
+ Map<String, String[]> map = maps.get(i);
+ param.replace(map);
+ fail("Expected IllegalArgumentException with map=" + map);
+ }
+ catch (Exception e)
+ {
+ assertTrue(exceptionClasses[i].isAssignableFrom(e.getClass()));
+ }
+ }
+ }
+
+ public void testReplace()
+ {
+ param.setValue("a", "b");
+ param.setValues("c", new String[]{"d", "e"});
+ param.setValue("f", "g");
+ Map<String, String[]> map = new HashMap<String, String[]>();
+ map.put("a", new String[]{"_b"});
+ map.put("c", new String[]{"_d", "_e"});
+ map.put("h", new String[]{"_i"});
+ param.replace(map);
+ assertEquals(3, param.size());
+ ExtendedAssert.assertEquals(param.getValues("a"), new String[]{"_b"});
+ ExtendedAssert.assertEquals(param.getValues("c"), new String[]{"_d", "_e"});
+ ExtendedAssert.assertEquals(param.getValues("h"), new String[]{"_i"});
+ }
+
+ public void testAppendWithInvalidMap()
+ {
+ List<Map<String, String[]>> maps = buildInvalidMaps();
+ Class[] exceptionClasses = buildExceptionClasses();
+ for (int i = 0; i < maps.size();i++)
+ {
+ try
+ {
+ Map<String, String[]> map = maps.get(i);
+ param.append(map);
+ fail("Expected IllegalArgumentException with map=" + map);
+ }
+ catch (Exception e)
+ {
+ if (!exceptionClasses[i].isAssignableFrom(e.getClass()))
+ {
+ fail("Exception class " + exceptionClasses[i].getName() + " (index=" + i + ") should be assignable from caught exception " + e.getClass());
+ }
+ }
+ }
+ }
+
+ public void testAppend()
+ {
+ param.setValue("a", "b");
+ param.setValues("c", new String[]{"d", "e"});
+ param.setValue("f", "g");
+ Map<String, String[]> map = new HashMap<String, String[]>();
+ map.put("a", new String[]{"_b"});
+ map.put("c", new String[]{"_d", "_e"});
+ map.put("h", new String[]{"_i"});
+ param.append(map);
+ assertEquals(4, param.size());
+ ExtendedAssert.assertEquals(param.getValues("a"), new String[]{"b", "_b"});
+ ExtendedAssert.assertEquals(param.getValues("c"), new String[]{"d", "e", "_d", "_e"});
+ ExtendedAssert.assertEquals(param.getValues("f"), new String[]{"g"});
+ ExtendedAssert.assertEquals(param.getValues("h"), new String[]{"_i"});
+ }
+
+ public void testClear()
+ {
+ param.setValue("a", "b");
+ param.clear();
+ assertNull(param.getValue("a"));
+ }
+
+ public Class[] buildExceptionClasses()
+ {
+ return new Class[]
+ {
+ NullPointerException.class,
+ IllegalArgumentException.class,
+ IllegalArgumentException.class,
+ ClassCastException.class
+ };
+ }
+
+ public List<Map<String, String[]>> buildInvalidMaps()
+ {
+ Map<String, String[]> map1 = new HashMap<String, String[]>();
+ map1.put("a", null);
+ Map<String, String[]> map2 = new HashMap<String, String[]>();
+ map2.put("a", new String[0]);
+ Map<String, String[]> map3 = new HashMap<String, String[]>();
+ map3.put("a", new String[]{null});
+ Map map4 = new HashMap();
+ map4.put("a", new Object());
+ return Tools.toList(map1, map2, map3, (Map<String, String[]>)map4);
+ }
}
18 years, 3 months
JBoss Portal SVN: r9521 - in branches/presentation: presentation/src/main/org/jboss/portal/presentation/ajax/client and 9 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-01-15 22:11:23 -0500 (Tue, 15 Jan 2008)
New Revision: 9521
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/AnchorListener.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/ListenerUtil.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/SubmitListener.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncGetAction.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncPostAction.java
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java
Modified:
branches/presentation/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/MyGWTPrototype.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Session.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/ManagedObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/GetActivation.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java
branches/presentation/presentation/src/resources/client/ajax/src/org/jboss/portal/presentation/ajax/public/mygwt.html
Log:
Ajax User Agent - improved event processing after testing for JSF support
Property changes on: branches/presentation
___________________________________________________________________
Name: svn:ignore
- thirdparty
.classpath
.project
.settings
core-samples
cms
core-admin
core-cms
search
workflow
+ thirdparty
.classpath
.project
.settings
core-samples
cms
core-admin
core-cms
search
workflow
presentation-samples
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/MyGWTPrototype.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/MyGWTPrototype.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/MyGWTPrototype.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -23,9 +23,15 @@
package org.jboss.portal.presentation.ajax.client;
import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.core.client.JavaScriptObject;
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.event.BaseEvent;
@@ -42,6 +48,9 @@
*/
public class MyGWTPrototype implements EntryPoint
{
+ private static JavaScriptObject originalSubmitFunction = null;
+ private static JavaScriptObject overrideSubmitFunction = null;
+
/**
*
*/
@@ -51,8 +60,9 @@
RootPanel.get("currentPage").add(panel);
// Fillup panel with MyGWT widgets for testing
- this.createButtonWidget(panel);
- this.createPortletWindowWidget(panel);
+ //this.createButtonWidget(panel);
+ //this.createPortletWindowWidget(panel);
+ this.loadTestHTML(panel);
}
/**
@@ -111,4 +121,206 @@
panel.add(contentPanel);
}
+
+ /**
+ *
+ * @param panel
+ */
+ private void loadTestHTML(VerticalPanel panel)
+ {
+ this.originalSubmitFunction = this.getOriginalSubmitFunction();
+ this.overrideSubmitFunction = this.getOverRideSubmitFunction();
+ this.overwriteSubmit(this.overrideSubmitFunction);
+
+ this.startClickListener();
+
+ HTML html = new HTML("<div class='window-normal-button'>" +
+ "<form id='testform' method='post' action='http://www.google.com'>" +
+ "<input type=\"hidden\" name=\"j_id_jsp_1600481012_9\" value=\"j_id_jsp_1600481012_9\" />" +
+ "<input type='Button' value='Hello World' onclick='document.getElementById(\"testform\").submit();'>" +
+ "<br/>" +
+ "<span><a href='#' onclick='document.getElementById(\"testform\").submit();' class='portlet-font'>Test Command Link</a></span>" +
+ "<br/>" +
+ "<a href='http://www.google.com' class='portlet-font'><span>Test Plain Link</span></a>" +
+ "<br/>" +
+ "<input type='submit'>" +
+ "</form>" +
+ "</div>");
+
+ ContentPanel contentPanel = new ContentPanel(Style.HEADER);
+ contentPanel.add(html);
+ contentPanel.setSize(200, 200);
+
+ //html.addClickListener(new ContentListener());
+
+ panel.add(contentPanel);
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native JavaScriptObject getOriginalSubmitFunction()
+ /*-{
+ return $wnd.HTMLFormElement.prototype.submit;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native JavaScriptObject getOverRideSubmitFunction()
+ /*-{
+ function overrideSubmit(event)
+ {
+ var target = null;
+ if(event != null)
+ {
+ target = event.target;
+ @org.jboss.portal.presentation.ajax.client.MyGWTPrototype::submitCallback(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;)(event,target);
+ }
+ else
+ {
+ target = this;
+ @org.jboss.portal.presentation.ajax.client.MyGWTPrototype::submitCallback(Lcom/google/gwt/user/client/Element;)(target);
+ }
+ }
+ return overrideSubmit;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native void overwriteSubmit(JavaScriptObject overrideSubmitFunction)
+ /*-{
+ $wnd.addEventListener('submit', overrideSubmitFunction, true);
+ $wnd.HTMLFormElement.prototype.submit = overrideSubmitFunction;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native void forceSubmit(JavaScriptObject originalSubmitFunction, JavaScriptObject overrideSubmitFunction, JavaScriptObject form)
+ /*-{
+ $wnd.HTMLFormElement.prototype.submit = originalSubmitFunction;
+ form.submit();
+ $wnd.HTMLFormElement.prototype.submit = overrideSubmitFunction;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native String serializeForm(Element currentForm)
+ /*-{
+ var formData = $wnd.Form.serialize(currentForm);
+ return formData;
+ }-*/;
+
+ /**
+ *
+ *
+ */
+ public static void submitCallback(Event event, Element currentForm)
+ {
+ String action = DOM.getElementAttribute(currentForm, "action");
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String serializedForm = serializeForm(currentForm);
+
+ /*System.out.println("---------------------------------------------");
+ System.out.println(event);
+ System.out.println(action);
+ System.out.println(method);
+ System.out.println(enctype);
+ System.out.println(serializedForm);*/
+
+ DOM.eventPreventDefault(event);
+
+ //Force a submit
+ forceSubmit(originalSubmitFunction, overrideSubmitFunction, currentForm);
+ }
+
+ /**
+ *
+ *
+ */
+ public static void submitCallback(Element currentForm)
+ {
+ String action = DOM.getElementAttribute(currentForm, "action");
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String serializedForm = serializeForm(currentForm);
+
+ /*System.out.println("---------------------------------------------");
+ System.out.println(action);
+ System.out.println(method);
+ System.out.println(enctype);
+ System.out.println(serializedForm);*/
+
+ //Force a submit
+ forceSubmit(originalSubmitFunction, overrideSubmitFunction, currentForm);
+ }
+ //--------Testing Anchor click listener----------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native void startClickListener()
+ /*-{
+ function listenClick(event)
+ {
+ if(event != null)
+ {
+ @org.jboss.portal.presentation.ajax.client.MyGWTPrototype::clickCallback(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;)(event,event.target);
+ }
+ else
+ {
+ @org.jboss.portal.presentation.ajax.client.MyGWTPrototype::clickCallback(Lcom/google/gwt/user/client/Element;)(this);
+ }
+ }
+ $wnd.addEventListener('click', listenClick, true);
+ }-*/;
+
+ /**
+ *
+ * @param target
+ */
+ public static void clickCallback(Event event, Element target)
+ {
+ if(target.toString().toUpperCase().trim().indexOf("</A>") != -1 && DOM.getElementAttribute(target, "ONCLICK") == null)
+ {
+ DOM.eventPreventDefault(event);
+ System.out.println(target);
+ }
+ }
+
+ public static void clickCallback(Element target)
+ {
+ if(target.toString().toUpperCase().trim().indexOf("</A>") != -1 && DOM.getElementAttribute(target, "ONCLICK") == null)
+ {
+ System.out.println(target);
+ }
+ }
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ /*private class ContentListener implements ClickListener
+ {
+ public void onClick(Widget sender)
+ {
+ Event event = DOM.eventGetCurrentEvent();
+ Element target = DOM.eventGetTarget(event);
+ System.out.println(target);
+ }
+ }*/
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -24,9 +24,10 @@
import com.google.gwt.core.client.EntryPoint;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
import org.jboss.portal.presentation.ajax.client.protocol.Caller;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxViewUIObjectAction;
+import org.jboss.portal.presentation.ajax.client.listener.SubmitListener;
+import org.jboss.portal.presentation.ajax.client.listener.AnchorListener;
/**
* This is the Entry Point of the client-side Ajax agent of the Presentation Framework
@@ -44,6 +45,9 @@
//Load the default page of the default portal upon loading the user agent
AjaxViewUIObjectAction action = new AjaxViewUIObjectAction("/default/default");
action.execute(this);
+
+ Session.getInstance().setSubmitListener(new SubmitListener());
+ Session.getInstance().setAnchorListener(new AnchorListener());
}
/**
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Session.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Session.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Session.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -26,6 +26,8 @@
import java.util.HashMap;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
+import org.jboss.portal.presentation.ajax.client.listener.SubmitListener;
+import org.jboss.portal.presentation.ajax.client.listener.AnchorListener;
/**
* This is the client side Session. This is a singleton since there should only be one session for each client
@@ -51,6 +53,16 @@
private AjaxUIContext uiContext = null;
/**
+ *
+ */
+ private SubmitListener submitListener = null;
+
+ /**
+ *
+ */
+ private AnchorListener anchorListener = null;
+
+ /**
* @gwt.typeArgs <java.lang.String, java.lang.Object>
*/
private Map attributes = null;
@@ -98,6 +110,42 @@
/**
*
+ * @return
+ */
+ public SubmitListener getSubmitListener()
+ {
+ return submitListener;
+ }
+
+ /**
+ *
+ * @param progSubmitListener
+ */
+ public void setSubmitListener(SubmitListener submitListener)
+ {
+ this.submitListener = submitListener;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public AnchorListener getAnchorListener()
+ {
+ return anchorListener;
+ }
+
+ /**
+ *
+ * @param anchorListener
+ */
+ public void setAnchorListener(AnchorListener anchorListener)
+ {
+ this.anchorListener = anchorListener;
+ }
+
+ /**
+ *
* @param attributeKey
* @param value
*/
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -35,7 +35,7 @@
*
*/
public class Util
-{
+{
/**
*
* @param portalPage
@@ -81,9 +81,9 @@
//layout the page and its corresponding windows
LayoutManager.doLayout(displayWindows);
- }
+ }
}
-
+
/**
*
* @param portalPage
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/AnchorListener.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/AnchorListener.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/AnchorListener.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.presentation.ajax.client.listener;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.ClickListener;
+
+import org.jboss.portal.presentation.ajax.client.Util;
+import org.jboss.portal.presentation.ajax.client.protocol.AsyncGetAction;
+import org.jboss.portal.presentation.ajax.client.protocol.Caller;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AnchorListener implements Caller, ClickListener
+{
+ /**
+ *
+ * @param callback
+ */
+ public AnchorListener()
+ {
+ }
+ //-------ClickListener impl------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void onClick(Widget sender)
+ {
+ Event event = DOM.eventGetCurrentEvent();
+ Element target = DOM.eventGetTarget(event);
+
+ //Process normal click
+ if(target.toString().toUpperCase().trim().indexOf("</A>") != -1 && DOM.getElementAttribute(target, "ONCLICK") == null)
+ {
+ String link = DOM.getElementAttribute(target, "HREF");
+
+ //A link inside the portlet window was clicked
+ //Load its content asynchronously inside this window
+ boolean isPartialRefreshAllowed = ListenerUtil.isPartialRefreshAllowed(link.trim());
+ if(isPartialRefreshAllowed)
+ {
+ DOM.eventPreventDefault(event);
+ handlePartialRefreshLink(link.trim());
+ }
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param url
+ * @param portletWindow
+ */
+ private void handlePartialRefreshLink(String url)
+ {
+ AsyncGetAction action = new AsyncGetAction(url);
+ action.execute(this);
+ }
+ //----Caller impl---------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void callback(Object result)
+ {
+ Util.displayPortalPage();
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/ListenerUtil.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/ListenerUtil.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/ListenerUtil.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * 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.presentation.ajax.client.listener;
+
+import com.google.gwt.core.client.GWT;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ListenerUtil
+{
+ /**
+ *
+ * @param url
+ * @return
+ */
+ public static boolean isPartialRefreshAllowed(String url)
+ {
+ String basePortalURL = GWT.getModuleBaseURL();
+
+ /**
+ * TODO: This is hard coded for now, but must be populated from the Portal deployment environment
+ * If Portal is installed at Root context, this value will be an empty string
+ */
+ String portalContext = "presentation";
+
+ //Make sure this is not just an anchor link with real submission in the onclick event
+ if(url.length() == 0 || url.startsWith("#"))
+ {
+ return false;
+ }
+
+ if(url.startsWith(basePortalURL))
+ {
+ //This is an Absolute URL, but it points back to
+ //the Portal
+ //An Async Page Refresh call should be allowed in this case
+ return true;
+ }
+
+ if(url.startsWith("http://"))
+ {
+ //This is an Absolute URL and does not point back
+ //to the Portal
+ //Async Page Refresh call should not be allowed
+ return false;
+ }
+ else
+ {
+ //This is a relative URL.
+
+ //Make sure it points back to the Portal for an Async Page Refresh
+ //If it points to some other resource like another third-party web application etc, the response
+ //has nothing to do with Portal
+ //(unless ofcourse the client side processor of the Portal, wants to
+ //take this response and aggregate this inside the current Portal Page and Window being displayed. This is an exceptional usecase
+ //and not desired behavior for every scenario from end user standpoint)
+ //As standard behavior, Async Page Refresh to be done, only when Portlet Markup is sending a request back to the Portal
+ if(url.startsWith("/"))
+ {
+ if(!portalContext.equals(""))
+ {
+ String urlContext = null;
+ int index = url.indexOf('/', 1);
+ if(index != -1)
+ {
+ urlContext = url.substring(1, index);
+ }
+ else
+ {
+ urlContext = url.substring(1);
+ }
+
+ if(!portalContext.equals(urlContext))
+ {
+ //This request is not being sent to the Portal. It is being sent to some other web application
+ return false;
+ }
+ }
+ else
+ {
+ //If Portal is running on root context, there is no way to tell from client side, if this request is actually
+ //to be sent to the Portal or some other web application. Hence, in the interest of functional safety/correctness
+ //no Async Page Refresh here
+ //If Portal is running on Root context, Partial Refresh will happen only for pure relative links
+ return false;
+ }
+ }
+
+ //If I get here, Async Page Refresh through the Portal should be allowed
+ return true;
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/SubmitListener.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/SubmitListener.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/listener/SubmitListener.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * 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.presentation.ajax.client.listener;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+
+import org.jboss.portal.presentation.ajax.client.Util;
+import org.jboss.portal.presentation.ajax.client.Session;
+import org.jboss.portal.presentation.ajax.client.protocol.AsyncPostAction;
+import org.jboss.portal.presentation.ajax.client.protocol.Caller;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class SubmitListener implements Caller
+{
+ private JavaScriptObject originalSubmitFunction = null;
+ private JavaScriptObject overrideSubmitFunction = null;
+
+ /**
+ *
+ *
+ */
+ public SubmitListener()
+ {
+ this.originalSubmitFunction = this.getOriginalSubmitFunction();
+ this.overrideSubmitFunction = this.getOverRideSubmitFunction();
+ this.overwriteSubmit(this.overrideSubmitFunction);
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ *
+ */
+ public static void submitCallback(Event event, Element currentForm)
+ {
+ DOM.eventPreventDefault(event);
+ SubmitListener.submitCallback(currentForm);
+ }
+
+ /**
+ *
+ *
+ */
+ public static void submitCallback(Element currentForm)
+ {
+ Session.getInstance().getSubmitListener().handlePartialRefreshForm(currentForm);
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param url
+ * @param portletWindow
+ */
+ private void handlePartialRefreshForm(Element currentForm)
+ {
+ String url = DOM.getElementAttribute(currentForm, "action");
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String postData = serializeForm(currentForm);
+
+ boolean isPartialRefreshAllowed = ListenerUtil.isPartialRefreshAllowed(url.trim());
+ if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
+ {
+ AsyncPostAction action = new AsyncPostAction(url, postData);
+ action.execute(this);
+ }
+ else
+ {
+ //Go ahead and perform a regular form submit
+ this.forceSubmit(originalSubmitFunction, overrideSubmitFunction, currentForm);
+ }
+ }
+ //----Caller impl---------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void callback(Object result)
+ {
+ Util.displayPortalPage();
+ }
+ //---low-level native Javascripts layer------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public native JavaScriptObject getOriginalSubmitFunction()
+ /*-{
+ return $wnd.HTMLFormElement.prototype.submit;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public native JavaScriptObject getOverRideSubmitFunction()
+ /*-{
+ function overrideSubmit(event)
+ {
+ var target = null;
+ if(event != null)
+ {
+ target = event.target;
+ @org.jboss.portal.presentation.ajax.client.listener.SubmitListener::submitCallback(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/user/client/Element;)(event,target);
+ }
+ else
+ {
+ target = this;
+ @org.jboss.portal.presentation.ajax.client.listener.SubmitListener::submitCallback(Lcom/google/gwt/user/client/Element;)(target);
+ }
+ }
+ return overrideSubmit;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public native void overwriteSubmit(JavaScriptObject overrideSubmitFunction)
+ /*-{
+ $wnd.addEventListener('submit', overrideSubmitFunction, true);
+ $wnd.HTMLFormElement.prototype.submit = overrideSubmitFunction;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public native void forceSubmit(JavaScriptObject originalSubmitFunction, JavaScriptObject overrideSubmitFunction, JavaScriptObject form)
+ /*-{
+ $wnd.HTMLFormElement.prototype.submit = originalSubmitFunction;
+ form.submit();
+ $wnd.HTMLFormElement.prototype.submit = overrideSubmitFunction;
+ }-*/;
+
+ /**
+ *
+ * @param currentForm
+ * @return
+ */
+ public static native String serializeForm(Element currentForm)
+ /*-{
+ var formData = $wnd.Form.serialize(currentForm);
+ return formData;
+ }-*/;
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -85,9 +85,8 @@
* TODO: Handle exception properly
*/
}
- };
- Map queryParams = new HashMap();
- queryParams.put("windowstate", this.windowState);
- portalRPC.asyncActivate(this.getTargetId(), queryParams, callback);
+ };
+ String url = this.getTargetId() + "?" + "windowstate=" + this.windowState;
+ portalRPC.asyncGet(url, callback);
}
}
Deleted: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -1,90 +0,0 @@
-/******************************************************************************
- * 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.presentation.ajax.client.protocol;
-
-import org.jboss.portal.presentation.ajax.client.Session;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
-import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
-import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class AsyncActivateAction extends ClientAction
-{
- /**
- *
- */
- private String url = null;
-
- /**
- *
- * @param targetId
- */
- public AsyncActivateAction(String url)
- {
- this.url = url;
- }
-
- /**
- *
- */
- public void execute(final Caller caller)
- {
- PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
- ((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- if(result instanceof AjaxShowUIObjectResponse)
- {
- AjaxUIObject uiObject = ((AjaxShowUIObjectResponse)result).getUiObject();
- Session.getInstance().getUiContext().addObject(uiObject);
- if(uiObject instanceof AjaxUIPage)
- {
- Session.getInstance().setAttribute(Session.display, uiObject.getId());
- }
- caller.callback(uiObject);
- }
- }
-
- public void onFailure(Throwable caught)
- {
- /**
- * TODO: Handle exception properly
- */
- }
- };
- portalRPC.asyncActivate(this.url, callback);
- }
-}
Copied: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncGetAction.java (from rev 9447, branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java)
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncGetAction.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncGetAction.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.presentation.ajax.client.protocol;
+
+import org.jboss.portal.presentation.ajax.client.Session;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AsyncGetAction extends ClientAction
+{
+ /**
+ *
+ */
+ private String url = null;
+
+ /**
+ *
+ * @param targetId
+ */
+ public AsyncGetAction(String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ *
+ */
+ public void execute(final Caller caller)
+ {
+ PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
+ ((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
+ AsyncCallback callback = new AsyncCallback()
+ {
+ public void onSuccess(Object result)
+ {
+ if(result instanceof AjaxShowUIObjectResponse)
+ {
+ AjaxUIObject uiObject = ((AjaxShowUIObjectResponse)result).getUiObject();
+ Session.getInstance().getUiContext().addObject(uiObject);
+ if(uiObject instanceof AjaxUIPage)
+ {
+ Session.getInstance().setAttribute(Session.display, uiObject.getId());
+ }
+ caller.callback(uiObject);
+ }
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ /**
+ * TODO: Handle exception properly
+ */
+ }
+ };
+ portalRPC.asyncGet(this.url, callback);
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncPostAction.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncPostAction.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncPostAction.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * 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.presentation.ajax.client.protocol;
+
+import org.jboss.portal.presentation.ajax.client.Session;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AsyncPostAction extends ClientAction
+{
+ /**
+ *
+ */
+ private String url = null;
+ private String body = null;
+
+ /**
+ *
+ * @param targetId
+ */
+ public AsyncPostAction(String url, String body)
+ {
+ this.url = url;
+ this.body = body;
+ }
+
+ /**
+ *
+ */
+ public void execute(final Caller caller)
+ {
+ PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
+ ((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
+ AsyncCallback callback = new AsyncCallback()
+ {
+ public void onSuccess(Object result)
+ {
+ if(result instanceof AjaxShowUIObjectResponse)
+ {
+ AjaxUIObject uiObject = ((AjaxShowUIObjectResponse)result).getUiObject();
+ Session.getInstance().getUiContext().addObject(uiObject);
+ if(uiObject instanceof AjaxUIPage)
+ {
+ Session.getInstance().setAttribute(Session.display, uiObject.getId());
+ }
+ caller.callback(uiObject);
+ }
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ /**
+ * TODO: Handle exception properly
+ */
+ }
+ };
+ portalRPC.asyncPost(this.url, this.body, callback);
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -43,19 +43,14 @@
public ClientResponse loadObject(String objectId);
/**
- * Asynchronously send a UI activation to the Portal Server
- *
- * @param uiObjectId
- * @gwt.typeArgs queryParams <java.lang.String, java.lang.String>
- * @return
+ * Asynchronously send a UI Get Activation to the Portal Server
+ *
*/
- public ClientResponse asyncActivate(String uiObjectId, Map queryParams);
+ public ClientResponse asyncGet(String url);
/**
- * Asynchronously send a UI activation to the Portal Server
- *
- * @param url
- * @return
+ * Asynchronously send a UI Post activation to the Portal Server
+ *
*/
- public ClientResponse asyncActivate(String url);
+ public ClientResponse asyncPost(String url, String body);
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -40,19 +40,14 @@
public void loadObject(String objectId, AsyncCallback callback);
/**
- * Asynchronously send a UI activation to the Portal Server
- *
- * @param uiObjectId
- * @gwt.typeArgs queryParams <java.lang.String, java.lang.String>
- * @param callback
+ * Asynchronously send a UI Get Activation to the Portal Server
+ *
*/
- public void asyncActivate(String uiObjectId, Map queryParams, AsyncCallback callback);
+ public void asyncGet(String url, AsyncCallback callback);
/**
- * Asynchronously send a UI activation to the Portal Server
- *
- * @param url
- * @param callback
+ * Asynchronously send a UI Post activation to the Portal Server
+ *
*/
- public void asyncActivate(String url, AsyncCallback callback);
+ public void asyncPost(String url, String body, AsyncCallback callback);
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -22,13 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.ajax.client.widget;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Widget;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.Style;
@@ -40,10 +34,8 @@
import org.jboss.portal.presentation.ajax.client.Util;
import org.jboss.portal.presentation.ajax.client.Session;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxUpdateWindowStateAction;
import org.jboss.portal.presentation.ajax.client.protocol.Caller;
-import org.jboss.portal.presentation.ajax.client.protocol.AsyncActivateAction;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -137,151 +129,20 @@
portletWindow.add(windowContent);
//Event Listener for actions perfomed inside the portlet window content
- //itself. Used for performing Partial Refresh of a Portal Page
- ClickListener contentListener = new ContentListener();
- windowContent.addClickListener(contentListener);
+ //itself. Used for performing Partial Refresh of a Portal Page
+ windowContent.addClickListener(Session.getInstance().getAnchorListener());
}
return portletWindow;
}
- //-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ //----Caller impl---------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
*/
public void callback(Object result)
{
Util.displayPortalPage();
- }
-
- /**
- *
- *
- */
- private void refresh()
- {
- String display = (String)Session.getInstance().getAttribute(Session.display);
- AjaxUIPage displayedPage = (AjaxUIPage)Session.getInstance().getUiContext().getObject(display);
-
- this.window = (AjaxUIWindow)displayedPage.getChild(this.getName());
- }
-
- //-------------------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- *
- * @param url
- * @param portletWindow
- */
- private void handlePartialRefreshLink(String url, Widget windowContent)
- {
- AsyncActivateAction action = new AsyncActivateAction(url);
- action.execute(this);
- }
-
- /**
- *
- * @param url
- * @param portletWindow
- */
- private void handlePartialRefreshForm(String url, String method, String postData, Widget windowContent)
- {
- if(postData != null && postData.trim().length() > 0)
- {
- if(url.indexOf('?') == -1)
- {
- url = url + "?" + postData;
- }
- else
- {
- url = url + "&" + postData;
- }
- }
- AsyncActivateAction action = new AsyncActivateAction(url);
- action.execute(this);
- }
-
- /**
- *
- * @param url
- * @return
- */
- private boolean isPartialRefreshAllowed(String url)
- {
- String basePortalURL = GWT.getModuleBaseURL();
- String portalContext = "presentation"; //This is hard coded for now, but must be populated from the Portal deployment environment
- //If Portal is installed at Root context, this value will be an empty string
-
- if(url.startsWith(basePortalURL))
- {
- //This is an Absolute URL, but it points back to
- //the Portal
- //An Async Page Refresh call should be allowed in this case
- return true;
- }
-
- if(url.startsWith("http://"))
- {
- //This is an Absolute URL and does not point back
- //to the Portal
- //Async Page Refresh call should not be allowed
- return false;
- }
- else
- {
- //This is a relative URL.
-
- //Make sure it points back to the Portal for an Async Page Refresh
- //If it points to some other resource like another third-party web application etc, the response
- //has nothing to do with Portal
- //(unless ofcourse the client side processor of the Portal, wants to
- //take this response and aggregate this inside the current Portal Page and Window being displayed. This is an exceptional usecase
- //and not desired behavior for every scenario from end user standpoint)
- //As standard behavior, Async Page Refresh to be done, only when Portlet Markup is sending a request back to the Portal
- if(url.startsWith("/"))
- {
- if(!portalContext.equals(""))
- {
- String urlContext = null;
- int index = url.indexOf('/', 1);
- if(index != -1)
- {
- urlContext = url.substring(1, index);
- }
- else
- {
- urlContext = url.substring(1);
- }
-
- if(!portalContext.equals(urlContext))
- {
- //This request is not being sent to the Portal. It is being sent to some other web application
- return false;
- }
- }
- else
- {
- //If Portal is running on root context, there is no way to tell from client side, if this request is actually
- //to be sent to the Portal or some other web application. Hence, in the interest of functional safety/correctness
- //no Async Page Refresh here
- //If Portal is running on Root context, Partial Refresh will happen only for pure relative links
- return false;
- }
- }
-
- //If I get here, Async Page Refresh through the Portal should be allowed
- return true;
- }
- }
-
- /**
- *
- * @param currentForm
- * @return
- */
- public native String serializeForm(Element currentForm)
- /*-{
- var formData = $wnd.Form.serialize(currentForm);
- return formData;
- }-*/;
+ }
//-----------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
@@ -340,50 +201,5 @@
Info.show("Help", "Loading Help Mode....", "Loading Help Mode....");
}
}
- }
-
- /**
- *
- */
- private class ContentListener implements ClickListener
- {
- public void onClick(Widget sender)
- {
- Event event = DOM.eventGetCurrentEvent();
- Element target = DOM.eventGetTarget(event);
-
- if(target.toString().toUpperCase().trim().indexOf("</A>") != -1)
- {
- String link = DOM.getElementAttribute(target, "HREF");
-
- //A link inside the portlet window was clicked
- //Load its content asynchronously inside this window
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link.trim());
- if(isPartialRefreshAllowed)
- {
- DOM.eventPreventDefault(event);
- handlePartialRefreshLink(link.trim(), sender);
- }
- }
- else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1 &&
- target.toString().toUpperCase().trim().indexOf("SUBMIT") != -1
- )
- {
- Element currentForm = DOM.getParent(target);
- String enctype = DOM.getElementAttribute(currentForm, "enctype");
- String action = DOM.getElementAttribute(currentForm, "action");
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action.trim());
- if((isPartialRefreshAllowed) && (enctype == null || !enctype.equals("multipart/form-data")))
- {
- DOM.eventPreventDefault(event);
-
- //Call a native javascript function here
- String method = DOM.getElementAttribute(currentForm, "method");
- String serializedForm = serializeForm(currentForm);
-
- handlePartialRefreshForm(action.trim(), method, serializedForm, sender);
- }
- }
- }
- }
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -49,6 +49,7 @@
import java.io.PrintWriter;
import java.util.List;
import java.util.Collection;
+import java.util.Map;
/**
* The UIServer is responsible for generating the output that is sent back to the client based on the Portal state of a particular Portal Request
@@ -180,14 +181,16 @@
{
ServerInvocationContext invocationContext = invocation.getServerContext();
String requestPath = invocation.getServerContext().getPortalRequestPath();
+ WebRequest webReq = ((ServerInvocationContextImpl)invocation.getContext()).getWebRequest();
+ Map queryParameters = webReq.getQueryParameterMap();
//
- if (requestPath.startsWith("/invoke/"))
+ if (queryParameters != null && queryParameters.containsKey("action"))
{
UIObject target = presentationContext.getUIContext();
//
- int from = "/invoke/".length();
+ int from = 1;
while (true)
{
int pos = requestPath.indexOf('/', from);
@@ -207,11 +210,8 @@
break;
}
from = pos + 1;
- }
+ }
- // I know but it will go away later when we remove dependency on server module
- WebRequest webReq = ((ServerInvocationContextImpl)invocation.getContext()).getWebRequest();
-
//
if (target != null)
{
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -22,6 +22,9 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.ajax.entry;
+import java.util.Map;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
@@ -35,6 +38,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
+
/**
* This filter is activated or deactivated depending on whether the Portal needs to runs in Ajax mode or Classic Html mode
*
@@ -105,6 +111,35 @@
response.getOutputStream().flush();
return;
}
+
+
+ String method = request.getMethod();
+ String url = request.getRequestURL().toString();
+ String targetId = this.parseTargetId(url);
+ Map queryParameters = new HashMap();
+ Enumeration paramNames = request.getParameterNames();
+ if(paramNames != null)
+ {
+ while(paramNames.hasMoreElements())
+ {
+ String name = (String)paramNames.nextElement();
+ String value = (String)request.getParameter(name);
+ queryParameters.put(name, new String[]{value});
+ }
+ }
+ if(method.equalsIgnoreCase("get"))
+ {
+ GetActivation get = new GetActivation(targetId, queryParameters);
+ request.getSession().setAttribute("serverAction", get);
+ }
+ else
+ {
+ PostActivation post = new PostActivation(targetId, queryParameters, null);
+ request.getSession().setAttribute("serverAction", post);
+ }
+
+
+ response.sendRedirect(contextPath+"/"+"index.html");
}
/**
@@ -151,4 +186,26 @@
return content;
}
+
+ /**
+ *
+ * @param url
+ * @return
+ */
+ private String parseTargetId(String url)
+ {
+ String targetId = null;
+
+ int fromIndex = 0; //hard coding the portal deployment context for now
+ fromIndex = url.indexOf("presentation") != -1 ? url.indexOf("presentation") + "presentation".length() : 0;
+ targetId = url.indexOf('?') != -1 ? url.substring(fromIndex, url.indexOf('?')):url.substring(fromIndex);
+
+ //Removes the PATH data if any found
+ if(targetId.indexOf(';')!=-1)
+ {
+ targetId = targetId.substring(0, targetId.indexOf(';'));
+ }
+
+ return targetId;
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -2,8 +2,6 @@
import java.util.Map;
-import java.util.List;
-import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.net.URLDecoder;
@@ -35,15 +33,10 @@
import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
-import org.jboss.portal.presentation.ajax.client.model.AjaxUIPortal;
-import org.jboss.portal.presentation.ajax.client.model.Page;
-import org.jboss.portal.presentation.ajax.client.model.Window;
import org.jboss.portal.presentation.ajax.client.protocol.ClientResponse;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxShowUIObjectResponse;
-import org.jboss.portal.presentation.server.ProcessorResponse;
import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -130,48 +123,57 @@
{
try
{
- AjaxUIObject uiObject = null;
+ ClientResponse clientResponse = null;
HttpServletRequest request = this.getThreadLocalRequest();
+ Object pendingServerAction = request.getSession().getAttribute("serverAction");
+ if(pendingServerAction != null)
+ {
+ request.setAttribute("serverAction", pendingServerAction);
+ request.getSession().removeAttribute("serverAction");
+ }
+
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ if(uiObject != null)
+ {
+ clientResponse = new AjaxShowUIObjectResponse(uiObject);
+ }
- return new AjaxShowUIObjectResponse(uiObject);
+ return clientResponse;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
-
+
/**
*
- * @param objectId
- * @param windowState
+ * @param url
* @return
*/
- public ClientResponse asyncActivate(String uiObjectId, Map queryParams)
+ public ClientResponse asyncGet(String url)
{
try
{
ClientResponse clientResponse = null;
-
+
HttpServletRequest request = this.getThreadLocalRequest();
-
- Map params = new HashMap();
- for(Iterator itr=queryParams.keySet().iterator(); itr.hasNext();)
- {
- String key = (String)itr.next();
- String value = (String)queryParams.get(key);
- params.put(key, new String[]{value});
- }
- GetActivation get = new GetActivation(uiObjectId, params);
+ //Parse the query parameters into a Map of name value pairs
+ Map queryParams = this.parseQueryParams(url);
+ //Parse the UIObject target id
+ String targetId = this.parseTargetId(url);
+
+
+ GetActivation get = new GetActivation(targetId, queryParams);
+
request.setAttribute("serverAction", get);
//execute the call on the Portal
@@ -195,52 +197,106 @@
/**
*
* @param url
+ * @param body
* @return
*/
- public ClientResponse asyncActivate(String url)
+ public ClientResponse asyncPost(String url, String body)
{
try
{
- Map queryParams = new HashMap();
+ ClientResponse clientResponse = null;
+
+ HttpServletRequest request = this.getThreadLocalRequest();
+
+ //Parse the query parameters into a Map of name value pairs
+ Map queryParams = this.parseQueryParams(url);
- //Parse the query parameters into a Map of name value pairs
- if(url.indexOf('?') != -1)
+ //Parse the UIObject target id
+ String targetId = this.parseTargetId(url);
+
+ //Parse the serialized post body into parameters
+ StringTokenizer st = new StringTokenizer(body, "&");
+ while(st.hasMoreTokens())
{
- String queryString = url.substring(url.indexOf('?')+1);
- StringTokenizer st = new StringTokenizer(queryString, "&");
- while(st.hasMoreTokens())
- {
- String token = st.nextToken();
- int equalIndex = token.indexOf('=');
- String name = token.substring(0, equalIndex);
- String value = token.substring(equalIndex+1);
- queryParams.put(name, URLDecoder.decode(value, "UTF-8"));
- }
+ String token = st.nextToken();
+ int equalIndex = token.indexOf('=');
+ String name = token.substring(0, equalIndex);
+ String value = token.substring(equalIndex+1);
+
+ queryParams.put(URLDecoder.decode(name, "UTF-8"), new String[]{URLDecoder.decode(value, "UTF-8")});
}
+
+ PostActivation post = new PostActivation(targetId, queryParams, null);
- //Parse the UIObject id
- String uiObjectId = null;
- int invokeIndex = url.indexOf("presentation"); //hard coding the portal deployment context for now
- int endIndex = url.indexOf('?');
- if(endIndex != -1)
+ request.setAttribute("serverAction", post);
+
+ //execute the call on the Portal
+ this.callPortalServer();
+
+ //Setup the initial UIContext for the client session
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ if(uiObject != null)
{
- uiObjectId = url.substring(invokeIndex+"presentation".length(), endIndex);
+ clientResponse = new AjaxShowUIObjectResponse(uiObject);
}
- else
- {
- uiObjectId = url.substring(invokeIndex+"presentation".length());
- }
- return this.asyncActivate(uiObjectId, queryParams);
+ return clientResponse;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
- //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
+ */
+ private Map parseQueryParams(String url) throws Exception
+ {
+ Map queryParams = new HashMap();
+
+ if(url.indexOf('?') != -1)
+ {
+ String queryString = url.substring(url.indexOf('?')+1);
+ StringTokenizer st = new StringTokenizer(queryString, "&");
+ while(st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ int equalIndex = token.indexOf('=');
+ String name = token.substring(0, equalIndex);
+ String value = token.substring(equalIndex+1);
+
+ queryParams.put(name, new String[]{URLDecoder.decode(value, "UTF-8")});
+ }
+ }
+
+ return queryParams;
+ }
+
+ /**
+ *
+ * @param url
+ * @return
+ */
+ private String parseTargetId(String url)
+ {
+ String targetId = null;
+
+ int fromIndex = 0; //hard coding the portal deployment context for now
+ fromIndex = url.indexOf("presentation") != -1 ? url.indexOf("presentation") + "presentation".length() : 0;
+ targetId = url.indexOf('?') != -1 ? url.substring(fromIndex, url.indexOf('?')):url.substring(fromIndex);
+
+ //Removes the PATH data if any found
+ if(targetId.indexOf(';')!=-1)
+ {
+ targetId = targetId.substring(0, targetId.indexOf(';'));
+ }
+
+ return targetId;
+ }
+
+ /**
+ *
*
*/
private void callPortalServer() throws Exception
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/ManagedObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/ManagedObject.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/ManagedObject.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -250,10 +250,18 @@
}
//
- for (UIContainerObject child : getChildren())
+ Collection<UIContainerObject> children = getChildren();
+ for (UIContainerObject child : children)
{
- if (child.getName().equals(name))
+ String childName = child.getName();
+ if(childName == null)
{
+ String id = child.getId();
+ childName = id.substring(id.lastIndexOf('/')+1);
+ }
+
+ if (childName.equals(name))
+ {
return child;
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/GetActivation.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/GetActivation.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/GetActivation.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.protocol;
import java.util.Map;
+import java.util.Iterator;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -34,4 +35,25 @@
{
super(targetId, queryParameters);
}
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ if(this.queryParameters != null)
+ {
+ buffer.append("QueryString---------------\n");
+ for(Iterator itr=this.queryParameters.keySet().iterator(); itr.hasNext();)
+ {
+ String key = (String)itr.next();
+ String[] value = (String[])this.queryParameters.get(key);
+ buffer.append(key+"="+value[0]+"\n");
+ }
+ }
+
+ return buffer.toString();
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java 2008-01-16 03:11:23 UTC (rev 9521)
@@ -24,6 +24,7 @@
import org.jboss.portal.web.Body;
+import java.util.Iterator;
import java.util.Map;
/**
@@ -52,4 +53,33 @@
{
return body;
}
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ if(this.queryParameters != null)
+ {
+ buffer.append("QueryString---------------\n");
+ for(Iterator itr=this.queryParameters.keySet().iterator(); itr.hasNext();)
+ {
+ String key = (String)itr.next();
+ String[] value = (String[])this.queryParameters.get(key);
+ buffer.append(key+"="+value[0]+"\n");
+ }
+ }
+
+ if(this.body != null && ((Body.Form)this.body).getParameters() != null)
+ {
+ buffer.append("PostBody---------------\n");
+ for(Iterator itr=((Body.Form)this.body).getParameters().keySet().iterator(); itr.hasNext();)
+ {
+ String key = (String)itr.next();
+ String[] value = ((Body.Form)this.body).getParameters().get(key);
+ buffer.append(key+"="+value[0]+"\n");
+ }
+ }
+
+ return buffer.toString();
+ }
}
Modified: branches/presentation/presentation/src/resources/client/ajax/src/org/jboss/portal/presentation/ajax/public/mygwt.html
===================================================================
--- branches/presentation/presentation/src/resources/client/ajax/src/org/jboss/portal/presentation/ajax/public/mygwt.html 2008-01-15 23:52:11 UTC (rev 9520)
+++ branches/presentation/presentation/src/resources/client/ajax/src/org/jboss/portal/presentation/ajax/public/mygwt.html 2008-01-16 03:11:23 UTC (rev 9521)
@@ -10,6 +10,7 @@
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
+ <script language='javascript' src='prototype.js'></script>
<script language='javascript' src='org.jboss.portal.presentation.ajax.MyGWT.nocache.js'></script>
</head>
18 years, 3 months
JBoss Portal SVN: r9520 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-15 18:52:11 -0500 (Tue, 15 Jan 2008)
New Revision: 9520
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/navigation/StateStringTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
Log:
- rename PortletParametersStateString to ParametersStateString
- moved a factory method of ParametersStateString to a plain constructor
Copied: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java (from rev 9519, modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java)
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -0,0 +1,347 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.common.util.Base64;
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A set of parameters.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6549 $
+ */
+public class ParametersStateString extends StateString implements Serializable
+{
+ /** . */
+ public static final String JBPNS_PREFIX = "JBPNS_";
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8529807471117491810L;
+
+ /** . */
+ private static final String EOF = "__EOF__";
+
+ /**
+ * Factory method that will create the most appropriate form from the string representation.
+ *
+ * @param opaqueValue the opaque value
+ * @return a new state string
+ */
+ public static StateString create(String opaqueValue)
+ {
+ if (opaqueValue == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (opaqueValue.startsWith(JBPNS_PREFIX))
+ {
+ return new ParametersStateString(opaqueValue);
+ }
+ else
+ {
+ return new OpaqueStateString(opaqueValue);
+ }
+ }
+
+ /**
+ * Create a parameters state string. It assumes that the argument is either an instance of
+ * <code>ParametersStateString</code> or that it is the string encoded value of a
+ * <code>ParametersStateString</code>.
+ *
+ * @param stateString the state string
+ * @return a new state string
+ * @throws IllegalArgumentException if the state string is opaque and does not represent parameters
+ */
+ public static ParametersStateString create(StateString stateString) throws IllegalArgumentException
+ {
+ if (stateString instanceof ParametersStateString)
+ {
+ return (ParametersStateString)stateString;
+ }
+ else
+ {
+ return new ParametersStateString(stateString.getStringValue());
+ }
+ }
+
+ /** The data. */
+ private ParameterMap parameters;
+
+ public ParametersStateString(String opaqueValue)
+ {
+ if (opaqueValue == null)
+ {
+ throw new IllegalArgumentException("No navigational state provided");
+ }
+ if (!opaqueValue.startsWith(JBPNS_PREFIX))
+ {
+ throw new IllegalArgumentException("Bad format");
+ }
+ opaqueValue = opaqueValue.substring(JBPNS_PREFIX.length());
+ if (opaqueValue.length() > 0)
+ {
+ try
+ {
+ byte[] bytes = Base64.decode(opaqueValue, true);
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ Map<String, String[]> params = new HashMap<String, String[]>();
+
+ //
+ String[] values;
+
+ // read the first String which should be a param name
+ String current = ois.readUTF();
+
+ // keep reading until we haven't reached the EOF marker
+ while (!EOF.equals(current))
+ {
+ // next is the size of the value array
+ int length = ois.readInt();
+ values = new String[length];
+
+ // read as many Strings as are supposed to be in the array
+ for (int i = 0; i < length; i++)
+ {
+ values[i] = ois.readUTF();
+ }
+
+ // we're done for this param, add it to the param map
+ params.put(current, values);
+
+ // read the next string to loop
+ current = ois.readUTF();
+ }
+
+ parameters = ParameterMap.clone(params);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ parameters = new ParameterMap();
+ }
+ }
+
+ /** Creates an empty parameter set. */
+ public ParametersStateString()
+ {
+ this.parameters = new ParameterMap();
+ }
+
+ /**
+ * Copy the parameter map to initialize the object state.
+ *
+ * @param parameterMap the parameter map to clone
+ * @throws IllegalArgumentException if the parameter map is null or not valid
+ */
+ public ParametersStateString(Map<String, String[]> parameterMap)
+ {
+ this.parameters = ParameterMap.clone(parameterMap);
+ }
+
+ /**
+ * Copy the parameter map to initialize the object state.
+ *
+ * @param parameterMap the parameter map to clone
+ * @throws IllegalArgumentException if the parameter map is null or not valid
+ */
+ public ParametersStateString(ParameterMap parameterMap)
+ {
+ this.parameters = ParameterMap.clone(parameterMap);
+ }
+
+ /**
+ * Return the parameter value or null if it does not exist.
+ *
+ * @param name the parameter name
+ * @return the parameter value or null if it does not exist
+ * @throws IllegalArgumentException if the name is null
+ */
+ public String getValue(String name) throws IllegalArgumentException
+ {
+ return parameters.getValue(name);
+ }
+
+ /**
+ * Return the parameter values or null if it does not exist.
+ *
+ * @param name the value to get
+ * @return the parameter values
+ * @throws IllegalArgumentException if the name is null
+ */
+ public String[] getValues(String name) throws IllegalArgumentException
+ {
+ return parameters.getValues(name);
+ }
+
+ /** Clear all the parameters. */
+ public void clear()
+ {
+ parameters.clear();
+ }
+
+ /**
+ * Replace all the parameters.
+ *
+ * @param map the map to replace
+ * @throws IllegalArgumentException if the map is not valid
+ */
+ public void replace(Map<String, String[]> map)
+ {
+ this.parameters.replace(map);
+ }
+
+ /**
+ * Set the a parameter value.
+ *
+ * @param name the parameter name
+ * @param value the parameter value
+ * @throws IllegalArgumentException if the name or the value is null
+ */
+ public void setValue(String name, String value)
+ {
+ parameters.setValue(name, value);
+ }
+
+ /**
+ * Set the parameter values. This method does not make a defensive copy of the values.
+ *
+ * @param name the parameter name
+ * @param values the parameter values
+ * @throws IllegalArgumentException if the name is null
+ */
+ public void setValues(String name, String[] values)
+ {
+ parameters.setValues(name, values);
+ }
+
+ /**
+ * Remove a parameter.
+ *
+ * @param name the parameter name
+ * @throws IllegalArgumentException if the name is null
+ */
+ public void remove(String name)
+ {
+ parameters.remove(name);
+ }
+
+ /**
+ * Return the size.
+ *
+ * @return the size
+ */
+ public int getSize()
+ {
+ return parameters.size();
+ }
+
+ /**
+ * Return the underlying parameter object.
+ *
+ * @return the parameter object
+ */
+ public ParameterMap getParameters()
+ {
+ return parameters;
+ }
+
+ /**
+ * Retrieves the opaque version associated with this navigational state.
+ *
+ * @return a URL-safe String representation of this navigational state.
+ */
+ public String getStringValue()
+ {
+ if (parameters != null && parameters.size() != 0)
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ for (Map.Entry entry : parameters.entrySet())
+ {
+ String name = (String)entry.getKey();
+ oos.writeUTF(name);
+ String[] values = (String[])entry.getValue();
+ int length = values.length;
+ oos.writeInt(length);
+ for (String value : values)
+ {
+ oos.writeUTF(value);
+ }
+ }
+ oos.writeUTF(EOF);
+ oos.close();
+ byte[] bytes = baos.toByteArray();
+ return JBPNS_PREFIX + Base64.encodeBytes(bytes, true);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ return JBPNS_PREFIX;
+ }
+ }
+
+ public int hashCode()
+ {
+ return getParameters().hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof ParametersStateString)
+ {
+ ParametersStateString that = (ParametersStateString)o;
+ return that.parameters.equals(parameters);
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return "StateString[" + parameters + "]";
+ }
+}
Property changes on: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
___________________________________________________________________
Name: svn:executable
+
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -1,333 +0,0 @@
-/******************************************************************************
- * 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;
-
-import org.jboss.portal.common.util.Base64;
-import org.jboss.portal.common.util.ParameterMap;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A set of parameters.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 6549 $
- */
-public class PortletParametersStateString extends StateString implements Serializable
-{
- /** . */
- public static final String JBPNS_PREFIX = "JBPNS_";
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -8529807471117491810L;
-
- /** . */
- private static final String EOF = "__EOF__";
-
- /** The data. */
- private ParameterMap parameters;
-
- /**
- * Factory method that will create the most appropriate form.
- *
- * @param opaqueValue the opaque value
- * @return a new state string
- */
- public static StateString create(String opaqueValue)
- {
- if (opaqueValue == null)
- {
- throw new IllegalArgumentException();
- }
- if (opaqueValue.startsWith(JBPNS_PREFIX))
- {
- return new PortletParametersStateString(opaqueValue);
- }
- else
- {
- return new OpaqueStateString(opaqueValue);
- }
- }
-
- public static PortletParametersStateString create(StateString stateString)
- {
- if (stateString instanceof PortletParametersStateString)
- {
- return (PortletParametersStateString)stateString;
- }
- else
- {
- return new PortletParametersStateString(stateString.getStringValue());
- }
- }
-
- public static PortletParametersStateString create(Map<String, String[]> parameterMap)
- {
- ParameterMap params = ParameterMap.wrap(parameterMap);
- return new PortletParametersStateString(params);
- }
-
- public PortletParametersStateString(String opaqueValue)
- {
- if (opaqueValue == null)
- {
- throw new IllegalArgumentException("No navigational state provided");
- }
- if (!opaqueValue.startsWith(JBPNS_PREFIX))
- {
- throw new IllegalArgumentException("Bad format");
- }
- opaqueValue = opaqueValue.substring(JBPNS_PREFIX.length());
- if (opaqueValue.length() > 0)
- {
- try
- {
- byte[] bytes = Base64.decode(opaqueValue, true);
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
- Map<String, String[]> params = new HashMap<String, String[]>();
-
- //
- String[] values;
-
- // read the first String which should be a param name
- String current = ois.readUTF();
-
- // keep reading until we haven't reached the EOF marker
- while (!EOF.equals(current))
- {
- // next is the size of the value array
- int length = ois.readInt();
- values = new String[length];
-
- // read as many Strings as are supposed to be in the array
- for (int i = 0; i < length; i++)
- {
- values[i] = ois.readUTF();
- }
-
- // we're done for this param, add it to the param map
- params.put(current, values);
-
- // read the next string to loop
- current = ois.readUTF();
- }
-
- parameters = ParameterMap.clone(params);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- else
- {
- parameters = new ParameterMap();
- }
- }
-
- /** Creates an empty parameter set. */
- public PortletParametersStateString()
- {
- this.parameters = new ParameterMap();
- }
-
- /**
- * Copy the parameter map to initialize the object state.
- *
- * @param parameterMap the parameter map to clone
- * @throws IllegalArgumentException if the parameter map is null or not valid
- */
- public PortletParametersStateString(ParameterMap parameterMap)
- {
- this.parameters = ParameterMap.clone(parameterMap);
- }
-
- /**
- * Return the parameter value or null if it does not exist.
- *
- * @param name the parameter name
- * @return the parameter value or null if it does not exist
- * @throws IllegalArgumentException if the name is null
- */
- public String getValue(String name) throws IllegalArgumentException
- {
- return parameters.getValue(name);
- }
-
- /**
- * Return the parameter values or null if it does not exist.
- *
- * @param name the value to get
- * @return the parameter values
- * @throws IllegalArgumentException if the name is null
- */
- public String[] getValues(String name) throws IllegalArgumentException
- {
- return parameters.getValues(name);
- }
-
- /** Clear all the parameters. */
- public void clear()
- {
- parameters.clear();
- }
-
- /**
- * Replace all the parameters.
- *
- * @param map the map to replace
- * @throws IllegalArgumentException if the map is not valid
- */
- public void replace(Map<String, String[]> map)
- {
- this.parameters.replace(map);
- }
-
- /**
- * Set the a parameter value.
- *
- * @param name the parameter name
- * @param value the parameter value
- * @throws IllegalArgumentException if the name or the value is null
- */
- public void setValue(String name, String value)
- {
- parameters.setValue(name, value);
- }
-
- /**
- * Set the parameter values. This method does not make a defensive copy of the values.
- *
- * @param name the parameter name
- * @param values the parameter values
- * @throws IllegalArgumentException if the name is null
- */
- public void setValues(String name, String[] values)
- {
- parameters.setValues(name, values);
- }
-
- /**
- * Remove a parameter.
- *
- * @param name the parameter name
- * @throws IllegalArgumentException if the name is null
- */
- public void remove(String name)
- {
- parameters.remove(name);
- }
-
- /**
- * Return the size.
- *
- * @return the size
- */
- public int getSize()
- {
- return parameters.size();
- }
-
- /**
- * Return the underlying parameter object.
- *
- * @return the parameter object
- */
- public ParameterMap getParameters()
- {
- return parameters;
- }
-
- /**
- * Retrieves the opaque version associated with this navigational state.
- *
- * @return a URL-safe String representation of this navigational state.
- */
- public String getStringValue()
- {
- if (parameters != null && parameters.size() != 0)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- for (Map.Entry entry : parameters.entrySet())
- {
- String name = (String)entry.getKey();
- oos.writeUTF(name);
- String[] values = (String[])entry.getValue();
- int length = values.length;
- oos.writeInt(length);
- for (String value : values)
- {
- oos.writeUTF(value);
- }
- }
- oos.writeUTF(EOF);
- oos.close();
- byte[] bytes = baos.toByteArray();
- return JBPNS_PREFIX + Base64.encodeBytes(bytes, true);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
- else
- {
- return JBPNS_PREFIX;
- }
- }
-
- public int hashCode()
- {
- return getParameters().hashCode();
- }
-
- public boolean equals(Object o)
- {
- if (o == this)
- {
- return true;
- }
- if (o instanceof PortletParametersStateString)
- {
- PortletParametersStateString that = (PortletParametersStateString)o;
- return that.parameters.equals(parameters);
- }
- return false;
- }
-
- public String toString()
- {
- return "StateString[" + parameters + "]";
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -30,7 +30,7 @@
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.spi.RenderContext;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.invocation.AttributeResolver;
@@ -89,17 +89,17 @@
{
useEntry = true;
}
- else if (entryNavState instanceof PortletParametersStateString)
+ else if (entryNavState instanceof ParametersStateString)
{
// We consider a parameters state string empty equivalent to a null value
- useEntry = ((PortletParametersStateString)entryNavState).getSize() == 0;
+ useEntry = ((ParametersStateString)entryNavState).getSize() == 0;
}
}
else if (entryNavState == null)
{
- if (navState instanceof PortletParametersStateString)
+ if (navState instanceof ParametersStateString)
{
- useEntry = ((PortletParametersStateString)navState).getSize() == 0;
+ useEntry = ((ParametersStateString)navState).getSize() == 0;
}
}
else
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -26,7 +26,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.OpaqueStateString;
import java.util.Iterator;
@@ -170,7 +170,7 @@
if (!opaque)
{
// Compute the parameters skipping the portlet navigational state that may be encoded as well
- PortletParametersStateString query = new PortletParametersStateString();
+ ParametersStateString query = new ParametersStateString();
for (Iterator i = queryParams.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry)i.next();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -26,7 +26,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.ActionURL;
@@ -100,7 +100,7 @@
//
if (interactionState != null)
{
- if (interactionState instanceof PortletParametersStateString)
+ if (interactionState instanceof ParametersStateString)
{
if (navigationalState != null)
{
@@ -108,7 +108,7 @@
}
// Add the parameters
- ParameterMap parameters = ((PortletParametersStateString)interactionState).getParameters();
+ ParameterMap parameters = ((ParametersStateString)interactionState).getParameters();
configure(parameters);
}
else
@@ -143,10 +143,10 @@
int meta = PortletRequestDecoder.RENDER_MASK;
//
- if (navigationalState instanceof PortletParametersStateString)
+ if (navigationalState instanceof ParametersStateString)
{
// Add the parameters
- ParameterMap parameters = ((PortletParametersStateString)navigationalState).getParameters();
+ ParameterMap parameters = ((ParametersStateString)navigationalState).getParameters();
configure(parameters);
}
else
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -26,7 +26,7 @@
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.spi.ActionContext;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
/**
* The main responsibility of this class is to combine the different parameter sources (private navigational state,
@@ -63,14 +63,14 @@
if (interactionState != null)
{
// Unserialize the interaction state if necessary
- PortletParametersStateString parametersState;
- if (interactionState instanceof PortletParametersStateString)
+ ParametersStateString parametersState;
+ if (interactionState instanceof ParametersStateString)
{
- parametersState = (PortletParametersStateString)interactionState;
+ parametersState = (ParametersStateString)interactionState;
}
else
{
- parametersState = new PortletParametersStateString(interactionState.getStringValue());
+ parametersState = new ParametersStateString(interactionState.getStringValue());
}
//
@@ -140,7 +140,7 @@
}
else
{
- privateParameters = PortletParametersStateString.create(navigationalState).getParameters();
+ privateParameters = ParametersStateString.create(navigationalState).getParameters();
}
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
@@ -47,7 +47,7 @@
//
UpdateNavigationalStateResponse rr = new UpdateNavigationalStateResponse();
- rr.setNavigationalState(new PortletParametersStateString());
+ rr.setNavigationalState(new ParametersStateString());
//
this.response = rr;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
@@ -163,7 +163,7 @@
{
/** . */
- private PortletParametersStateString parameters = new PortletParametersStateString();
+ private ParametersStateString parameters = new ParametersStateString();
protected ParameterMap getInternalParameters()
{
@@ -186,7 +186,7 @@
{
/** . */
- private PortletParametersStateString navigationalState = new PortletParametersStateString();
+ private ParametersStateString navigationalState = new ParametersStateString();
protected ParameterMap getInternalParameters()
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import javax.portlet.EventResponse;
import javax.portlet.EventRequest;
@@ -58,7 +58,7 @@
WantUpdate update = (WantUpdate)decision;
update.mode = context.getMode();
update.windowState = context.getWindowState();
- update.navigationalState = PortletParametersStateString.create(context.getNavigationalState()).getParameters();
+ update.navigationalState = ParametersStateString.create(context.getNavigationalState()).getParameters();
update.publicNavigationalState = context.getPublicNavigationalState();
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -26,7 +26,7 @@
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.info.ContainerEventingInfo;
@@ -390,7 +390,7 @@
response.setMode(mode);
response.setWindowState(windowState);
response.setPublicNavigationalState(publicNavigationalState);
- response.setNavigationalState(new PortletParametersStateString(navigationalState));
+ response.setNavigationalState(new ParametersStateString(navigationalState));
//
return response;
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -26,7 +26,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.OpaqueStateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -265,7 +265,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalState());
+ assertEquals(new ParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -277,7 +277,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalState());
+ assertEquals(new ParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -289,7 +289,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalState());
+ assertEquals(new ParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertEquals(WindowState.NORMAL, o.getWindowState());
@@ -302,7 +302,7 @@
Map queryParams = new HashMap();
Map bodyParams = new HashMap();
PortletRequestDecoder o = new PortletRequestDecoder();
- PortletParametersStateString navState = new PortletParametersStateString();
+ ParametersStateString navState = new ParametersStateString();
// Query parameter
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
@@ -511,7 +511,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
- assertEquals(new PortletParametersStateString(), o.getInteractionState());
+ assertEquals(new ParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
@@ -523,7 +523,7 @@
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
- assertEquals(new PortletParametersStateString(), o.getInteractionState());
+ assertEquals(new ParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
@@ -535,7 +535,7 @@
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
- assertEquals(new PortletParametersStateString(), o.getInteractionState());
+ assertEquals(new ParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
@@ -549,7 +549,7 @@
Map queryParams = new HashMap();
Map bodyParams = new HashMap();
PortletRequestDecoder o = new PortletRequestDecoder();
- PortletParametersStateString intState = new PortletParametersStateString();
+ ParametersStateString intState = new ParametersStateString();
ParameterMap form = new ParameterMap();
// Query parameter
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.impl.PortletRequestEncoder;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -81,20 +81,20 @@
public void _testEncodeRender(int lifecycle, int lifecycleMask)
{
- PortletParametersStateString pp = new PortletParametersStateString();
+ ParametersStateString pp = new ParametersStateString();
encode(pp, null, null, lifecycle);
assertEquals(1, params.size());
_assertEquals(lifecycleMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue(PortletRequestDecoder.META_PARAMETER, "foo");
encode(pp, null, null, lifecycle);
assertEquals(1, params.size());
_assertEquals(new String[]{Integer.toHexString(lifecycleMask),"foo"}, params.getValues(PortletRequestDecoder.META_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue("foo", "bar");
encode(pp, null, null, lifecycle);
assertEquals(2, params.size());
@@ -102,14 +102,14 @@
_assertEquals("bar", params.getValues("foo"));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
encode(pp, Mode.VIEW, null, lifecycle);
assertEquals(2, params.size());
_assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
_assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue(PortletRequestDecoder.MODE_PARAMETER, "foo");
encode(pp, Mode.VIEW, null, lifecycle);
assertEquals(2, params.size());
@@ -117,7 +117,7 @@
_assertEquals(new String[]{Mode.VIEW.toString(),"foo"}, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue("foo", "bar");
encode(pp, Mode.VIEW, null, lifecycle);
assertEquals(3, params.size());
@@ -126,14 +126,14 @@
_assertEquals("bar", params.getValues("foo"));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
encode(pp, null, WindowState.NORMAL, lifecycle);
assertEquals(2, params.size());
_assertEquals(lifecycleMask | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
_assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "foo");
encode(pp, null, WindowState.NORMAL, lifecycle);
assertEquals(2, params.size());
@@ -141,7 +141,7 @@
_assertEquals(new String[]{WindowState.NORMAL.toString(),"foo"}, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue("foo", "bar");
encode(pp, null, WindowState.NORMAL, lifecycle);
assertEquals(3, params.size());
@@ -150,7 +150,7 @@
_assertEquals("bar", params.getValues("foo"));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
encode(pp, Mode.VIEW, WindowState.NORMAL, lifecycle);
assertEquals(3, params.size());
_assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
@@ -158,7 +158,7 @@
_assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
//
- pp = new PortletParametersStateString();
+ pp = new ParametersStateString();
pp.setValue("foo", "bar");
encode(pp, Mode.VIEW, WindowState.NORMAL, lifecycle);
assertEquals(4, params.size());
@@ -191,7 +191,7 @@
_assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
}
- private void encode(PortletParametersStateString params, Mode view, WindowState normal, int lifecycle)
+ private void encode(ParametersStateString params, Mode view, WindowState normal, int lifecycle)
{
if (lifecycle == RENDER)
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/navigation/StateStringTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/navigation/StateStringTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/navigation/StateStringTestCase.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.portlet.navigation;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.unit.api.pojo.annotations.Test;
import static org.jboss.unit.api.Assert.*;
@@ -43,7 +43,7 @@
@Test
public void testNavigationalState() throws Exception
{
- PortletParametersStateString ns = new PortletParametersStateString();
+ ParametersStateString ns = new ParametersStateString();
ns.setValue(NAME1, VALUE1);
assertEquals(VALUE1, ns.getValue(NAME1));
@@ -51,7 +51,7 @@
System.out.println("opaqueValue = " + opaqueValue);
assertNotNull(opaqueValue);
- ns = new PortletParametersStateString(opaqueValue);
+ ns = new ParametersStateString(opaqueValue);
assertEquals(VALUE1, ns.getValue(NAME1));
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
@@ -114,7 +114,7 @@
UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
updateNavigationalState.setMode(action.mode);
updateNavigationalState.setWindowState(action.windowState);
- updateNavigationalState.setNavigationalState(PortletParametersStateString.create(action.queryParameters));
+ updateNavigationalState.setNavigationalState(new ParametersStateString(action.queryParameters));
return updateNavigationalState;
}
else
@@ -167,7 +167,7 @@
portletNS,
publicNS,
MARKUP_INFO,
- PortletParametersStateString.create(action.queryParameters),
+ new ParametersStateString(action.queryParameters),
action.bodyParameters != null ? ParameterMap.clone(action.bodyParameters) : null);
ActionInvocation actionInvocation = new ActionInvocation(actionContext);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-15 23:40:57 UTC (rev 9519)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-15 23:52:11 UTC (rev 9520)
@@ -25,7 +25,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.test.url.CodecBuilder;
import org.jboss.portal.portlet.test.url.ParameterEncoder;
@@ -117,11 +117,11 @@
ParameterMap actualParameters;
if (portletURL instanceof RenderURL)
{
- actualParameters = ((PortletParametersStateString)((RenderURL)portletURL).getNavigationalState()).getParameters();
+ actualParameters = ((ParametersStateString)((RenderURL)portletURL).getNavigationalState()).getParameters();
}
else
{
- actualParameters = ((PortletParametersStateString)((ActionURL)portletURL).getInteractionState()).getParameters();
+ actualParameters = ((ParametersStateString)((ActionURL)portletURL).getInteractionState()).getParameters();
}
//
18 years, 3 months
JBoss Portal SVN: r9519 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-15 18:40:57 -0500 (Tue, 15 Jan 2008)
New Revision: 9519
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParameters.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ActionContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ActionContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
Log:
remove PortletParameters class in favor of ParameterMap
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParameters.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParameters.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParameters.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -1,148 +0,0 @@
-/******************************************************************************
- * 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;
-
-import org.jboss.portal.common.util.ParameterMap;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-
-/**
- * A set of parameters.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7209 $
- */
-public final class PortletParameters extends ParameterMap implements Serializable
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -8529807471117491810L;
-
- /** Creates an empty parameter set. */
- public PortletParameters()
- {
- }
-
- /**
- * Copy the parameter map to initialize the object state.
- *
- * @param parameterMap the parameter map
- * @throws NullPointerException if the map contains a null key or a null value
- * @throws IllegalArgumentException if the map is null or it contains a value with a zero length array or a null
- * element in the array
- * @throws ClassCastException if the map contains a key that is not a string or a value that is not a string
- * array
- */
- public PortletParameters(Map<String,String[]> parameterMap) throws NullPointerException, ClassCastException, IllegalArgumentException
- {
- if (parameterMap == null)
- {
- throw new IllegalArgumentException("No null map accepted");
- }
-
- //
- replace(parameterMap);
- }
-
- /**
- * Append the content of the argument map to that map. If both maps contains an entry sharing the same key, then the
- * string arrays or the two entries will be concatenated into a single array. Each entry present on the argument map
- * and not in the current map will be kept as is. The argument validation is performed before the state is updated.
- *
- * @param params the parameters to appends
- * @throws NullPointerException if the map contains a null key or a null value
- * @throws IllegalArgumentException if the map is null or it contains a value with a zero length array or a null
- * element in the array
- * @throws ClassCastException if the map contains a key that is not a string or a value that is not a string
- * array
- */
- public void append(Map<String, String[]> params) throws ClassCastException, NullPointerException, IllegalArgumentException
- {
- // Clone
- params = new HashMap<String, String[]>(params);
-
- //
- for (Map.Entry<String, String[]> entry : params.entrySet())
- {
- String[] existingValue = get(entry.getKey());
-
- // Perform the appending operation if the entry exist
- if (existingValue != null)
- {
- String[] appendedValue = entry.getValue();
- String[] newValue = new String[existingValue.length + appendedValue.length];
- System.arraycopy(existingValue, 0, newValue, 0, existingValue.length);
- System.arraycopy(appendedValue, 0, newValue, existingValue.length, appendedValue.length);
- entry.setValue(newValue);
- }
- }
-
- //
- putAll(params);
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer("Parameters[");
- for (Iterator i = entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- String[] values = (String[])entry.getValue();
- buffer.append(name);
- for (int j = 0; j < values.length; j++)
- {
- buffer.append(j > 0 ? ',' : '=').append(values[j]);
- }
- if (i.hasNext())
- {
- buffer.append(" | ");
- }
- }
- buffer.append(']');
- return buffer.toString();
- }
-
- /**
- * Safely wrap the map as a portlet parameters object. If the map is already a portlet parameter object, just return
- * that object otherwise return a wrapper around the map.
- *
- * @param map the map
- * @return the portlet parameters
- */
- public static PortletParameters wrap(Map<String, String[]> map)
- {
- if (map instanceof PortletParameters)
- {
- return (PortletParameters)map;
- }
- else
- {
- return new PortletParameters(map);
- }
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletParametersStateString.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet;
import org.jboss.portal.common.util.Base64;
+import org.jboss.portal.common.util.ParameterMap;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -51,7 +52,7 @@
private static final String EOF = "__EOF__";
/** The data. */
- private PortletParameters parameters;
+ private ParameterMap parameters;
/**
* Factory method that will create the most appropriate form.
@@ -89,7 +90,7 @@
public static PortletParametersStateString create(Map<String, String[]> parameterMap)
{
- PortletParameters params = PortletParameters.wrap(parameterMap);
+ ParameterMap params = ParameterMap.wrap(parameterMap);
return new PortletParametersStateString(params);
}
@@ -139,7 +140,7 @@
current = ois.readUTF();
}
- parameters = new PortletParameters(params);
+ parameters = ParameterMap.clone(params);
}
catch (Exception e)
{
@@ -148,14 +149,14 @@
}
else
{
- parameters = new PortletParameters();
+ parameters = new ParameterMap();
}
}
/** Creates an empty parameter set. */
public PortletParametersStateString()
{
- this.parameters = new PortletParameters();
+ this.parameters = new ParameterMap();
}
/**
@@ -164,9 +165,9 @@
* @param parameterMap the parameter map to clone
* @throws IllegalArgumentException if the parameter map is null or not valid
*/
- public PortletParametersStateString(PortletParameters parameterMap)
+ public PortletParametersStateString(ParameterMap parameterMap)
{
- this.parameters = new PortletParameters(parameterMap);
+ this.parameters = ParameterMap.clone(parameterMap);
}
/**
@@ -260,7 +261,7 @@
*
* @return the parameter object
*/
- public PortletParameters getParameters()
+ public ParameterMap getParameters()
{
return parameters;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -24,8 +24,8 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.OpaqueStateString;
@@ -94,7 +94,7 @@
private StateString interactionState;
/** . */
- private PortletParameters form;
+ private ParameterMap form;
/** . */
private int type;
@@ -202,7 +202,7 @@
}
// Julien :
- PortletParameters form = new PortletParameters();
+ ParameterMap form = new ParameterMap();
if (bodyParams != null)
{
form.putAll(bodyParams);
@@ -250,7 +250,7 @@
}
//
- form = new PortletParameters();
+ form = new ParameterMap();
if (bodyParams != null)
{
form.putAll(bodyParams);
@@ -312,7 +312,7 @@
return interactionState;
}
- public PortletParameters getForm()
+ public ParameterMap getForm()
{
return form;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -27,7 +27,6 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.ActionURL;
@@ -66,7 +65,7 @@
public PortletRequestEncoder()
{
- this(new PortletParameters());
+ this(new ParameterMap());
}
public void encode(PortletURL portletURL) throws IllegalArgumentException
@@ -109,7 +108,7 @@
}
// Add the parameters
- PortletParameters parameters = ((PortletParametersStateString)interactionState).getParameters();
+ ParameterMap parameters = ((PortletParametersStateString)interactionState).getParameters();
configure(parameters);
}
else
@@ -147,7 +146,7 @@
if (navigationalState instanceof PortletParametersStateString)
{
// Add the parameters
- PortletParameters parameters = ((PortletParametersStateString)navigationalState).getParameters();
+ ParameterMap parameters = ((PortletParametersStateString)navigationalState).getParameters();
configure(parameters);
}
else
@@ -181,7 +180,7 @@
return queryParameters;
}
- private void configure(PortletParameters parameters)
+ private void configure(ParameterMap parameters)
{
for (Iterator i = parameters.entrySet().iterator(); i.hasNext();)
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import javax.servlet.RequestDispatcher;
@@ -104,7 +104,7 @@
//
if (queryString.length() > 0)
{
- this.parameters = new PortletParameters(rreq.getParameterMap());
+ this.parameters = ParameterMap.clone(rreq.getParameterMap());
this.parameters.putAll(QueryStringParser.getInstance().parseQueryString(queryString));
}
else
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/RequestParameters.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -26,7 +26,6 @@
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.spi.ActionContext;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
/**
@@ -58,7 +57,7 @@
StateString interactionState = actionContext.getInteractionState();
// Take care of the interaction state if any
- PortletParameters privateParameters = null;
+ ParameterMap privateParameters = null;
//
if (interactionState != null)
@@ -79,7 +78,7 @@
}
//
- PortletParameters form = actionContext.getForm();
+ ParameterMap form = actionContext.getForm();
if (form != null)
{
if (privateParameters == null)
@@ -88,7 +87,7 @@
}
else
{
- privateParameters = new PortletParameters(privateParameters);
+ privateParameters = ParameterMap.clone(privateParameters);
privateParameters.append(form);
}
}
@@ -102,7 +101,7 @@
{
if (privateParameters != null)
{
- PortletParameters tmp = new PortletParameters(privateParameters);
+ ParameterMap tmp = ParameterMap.clone(privateParameters);
tmp.append(publicParameters);
parameters = tmp;
}
@@ -153,7 +152,7 @@
{
if (privateParameters != null)
{
- parameters = new PortletParameters(privateParameters);
+ parameters = ParameterMap.clone(privateParameters);
parameters.putAll(publicParameters);
}
else
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,11 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.ActionRequest;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.StateString;
@@ -32,6 +31,7 @@
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.BaseURL;
import javax.portlet.PortletRequest;
@@ -156,7 +156,7 @@
return null;
}
- protected abstract PortletParameters getInternalParameters();
+ protected abstract ParameterMap getInternalParameters();
}
public static class InternalActionURL extends InternalPortletURL implements ActionURL
@@ -165,7 +165,7 @@
/** . */
private PortletParametersStateString parameters = new PortletParametersStateString();
- protected PortletParameters getInternalParameters()
+ protected ParameterMap getInternalParameters()
{
return parameters.getParameters();
}
@@ -188,7 +188,7 @@
/** . */
private PortletParametersStateString navigationalState = new PortletParametersStateString();
- protected PortletParameters getInternalParameters()
+ protected ParameterMap getInternalParameters()
{
return navigationalState.getParameters();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,18 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.spi.RenderContext;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.RenderRequest;
-import javax.servlet.http.Cookie;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -27,7 +27,6 @@
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.info.ContainerEventingInfo;
@@ -372,7 +371,7 @@
{
/** The navigational state returned. */
- protected PortletParameters navigationalState = new PortletParameters();
+ protected ParameterMap navigationalState = new ParameterMap();
/** The new window state requested. */
protected org.jboss.portal.WindowState windowState;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -24,7 +24,6 @@
import org.jboss.portal.portlet.spi.ActionContext;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MarkupInfo;
@@ -45,7 +44,7 @@
protected StateString interactionState;
/** . */
- protected PortletParameters form;
+ protected ParameterMap form;
protected AbstractActionContext(
@@ -55,7 +54,7 @@
ParameterMap publicNavigationalState,
MarkupInfo markupInfo,
StateString interactionState,
- PortletParameters form)
+ ParameterMap form)
{
super(mode, windowState, navigationalState, publicNavigationalState, markupInfo);
@@ -94,7 +93,7 @@
return interactionState;
}
- public PortletParameters getForm()
+ public ParameterMap getForm()
{
return form;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ActionContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ActionContext.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ActionContext.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.common.util.ParameterMap;
import java.io.BufferedReader;
import java.io.IOException;
@@ -109,5 +109,5 @@
*
* @return the request form
*/
- PortletParameters getForm();
+ ParameterMap getForm();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ActionContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ActionContextSupport.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ActionContextSupport.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,9 +22,9 @@
******************************************************************************/
package org.jboss.portal.portlet.support.spi;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.common.util.ParameterMap;
import java.io.BufferedReader;
import java.io.IOException;
@@ -67,7 +67,7 @@
throw new UnsupportedOperationException();
}
- public PortletParameters getForm()
+ public ParameterMap getForm()
{
throw new UnsupportedOperationException();
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.portlet;
-import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.common.util.ParameterMap;
import java.util.Arrays;
import java.util.HashMap;
@@ -45,12 +45,12 @@
{
}
- private PortletParameters param;
+ private ParameterMap param;
@Create
public void setUp()
{
- param = new PortletParameters();
+ param = new ParameterMap();
}
@Destroy
@@ -190,7 +190,7 @@
@Test
public void testReplaceWithParameters()
{
- PortletParameters other = new PortletParameters();
+ ParameterMap other = new ParameterMap();
other.setValue("a", "b");
other.setValues("c", new String[]{"d", "e"});
param.replace(other);
@@ -203,7 +203,7 @@
{
try
{
- new PortletParameters(null);
+ ParameterMap.clone(null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -216,7 +216,7 @@
{
try
{
- new PortletParameters((Map)null);
+ ParameterMap.clone(null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -24,8 +24,8 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.OpaqueStateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -510,7 +510,7 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -522,7 +522,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK | PortletRequestDecoder.MODE_MASK)));
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -534,7 +534,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK | PortletRequestDecoder.WINDOW_STATE_MASK)));
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -550,7 +550,7 @@
Map bodyParams = new HashMap();
PortletRequestDecoder o = new PortletRequestDecoder();
PortletParametersStateString intState = new PortletParametersStateString();
- PortletParameters form = new PortletParameters();
+ ParameterMap form = new ParameterMap();
// Query parameter
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
@@ -625,7 +625,7 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK | PortletRequestDecoder.OPAQUE_MASK)));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertNull(o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -637,7 +637,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER, asStringArray("navstatevalue"));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertNull(o.getInteractionState());
assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -649,7 +649,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER, asStringArray("intstatevalue"));
o.decode(queryParams, null);
- assertEquals(new PortletParameters(), o.getForm());
+ assertEquals(new ParameterMap(), o.getForm());
assertEquals(new OpaqueStateString("intstatevalue"), o.getInteractionState());
assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
@@ -664,7 +664,7 @@
queryParams.put("foo3", new String[]{"bar4"});
bodyParams.put("foo3", new String[]{"bar5"});
o.decode(queryParams, bodyParams);
- PortletParameters form = new PortletParameters();
+ ParameterMap form = new ParameterMap();
form.setValue("foo1", "bar1");
form.setValues("foo2", new String[]{"bar2", "bar3"});
form.setValues("foo3", new String[]{"bar5"});
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PortletRequestEncoderTestCase.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -24,7 +24,6 @@
import org.jboss.portal.portlet.impl.PortletRequestEncoder;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.Mode;
@@ -57,7 +56,7 @@
@Create
public void setUp() throws Exception
{
- params = new PortletParameters();
+ params = new ParameterMap();
encoder = new PortletRequestEncoder(params);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -22,9 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.PortletParameters;
-
import javax.xml.namespace.QName;
import java.util.Map;
import java.util.HashMap;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -25,7 +25,6 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
@@ -169,7 +168,7 @@
publicNS,
MARKUP_INFO,
PortletParametersStateString.create(action.queryParameters),
- action.bodyParameters != null ? new PortletParameters(action.bodyParameters) : null);
+ action.bodyParameters != null ? ParameterMap.clone(action.bodyParameters) : null);
ActionInvocation actionInvocation = new ActionInvocation(actionContext);
//
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-15 22:57:36 UTC (rev 9518)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-15 23:40:57 UTC (rev 9519)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
@@ -55,7 +54,7 @@
ParameterMap publicNavigationalState,
MarkupInfo markupInfo,
StateString interactionState,
- PortletParameters form)
+ ParameterMap form)
{
super(mode, windowState, navigationalState, publicNavigationalState, markupInfo, interactionState, form);
18 years, 3 months
JBoss Portal SVN: r9518 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-15 17:57:36 -0500 (Tue, 15 Jan 2008)
New Revision: 9518
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
Log:
moving methods from PortletParameters to ParameterMap as they are generic enough.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-01-15 22:45:05 UTC (rev 9517)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-01-15 22:57:36 UTC (rev 9518)
@@ -25,6 +25,8 @@
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
+import java.util.Iterator;
+import java.io.Serializable;
/**
* A decorator that enforce the map content to be <String,String[]>
@@ -32,7 +34,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6671 $
*/
-public class ParameterMap extends TypedMap<String, String[], String, String[]>
+public class ParameterMap extends TypedMap<String, String[], String, String[]> implements Serializable
{
/** . */
@@ -76,6 +78,53 @@
}
}
+ /**
+ * Copy the parameter map.
+ *
+ * @param parameterMap the parameter map to copy
+ * @return a parameter map initialized from the argument map
+ * @throws NullPointerException if the map contains a null key or a null value
+ * @throws IllegalArgumentException if the map is null or it contains a value with a zero length array or a null
+ * element in the array
+ * @throws ClassCastException if the map contains a key that is not a string or a value that is not a string
+ * array
+ */
+ public static ParameterMap clone(Map<String,String[]> parameterMap) throws NullPointerException, ClassCastException, IllegalArgumentException
+ {
+ if (parameterMap == null)
+ {
+ throw new IllegalArgumentException("No null map accepted");
+ }
+
+ //
+ ParameterMap pm = new ParameterMap();
+
+ //
+ pm.replace(parameterMap);
+
+ //
+ return pm;
+ }
+
+ /**
+ * Safely wrap the map as a portlet parameters object. If the map is already a parameter map object, just return
+ * that object otherwise return a wrapper around the map.
+ *
+ * @param map the map
+ * @return the portlet parameters
+ */
+ public static ParameterMap wrap(Map<String, String[]> map)
+ {
+ if (map instanceof ParameterMap)
+ {
+ return (ParameterMap)map;
+ }
+ else
+ {
+ return new ParameterMap(map);
+ }
+ }
+
/** . */
private final boolean cloneInternalValue;
@@ -271,4 +320,63 @@
{
put(name, values);
}
+
+ /**
+ * Append the content of the argument map to that map. If both maps contains an entry sharing the same key, then the
+ * string arrays or the two entries will be concatenated into a single array. Each entry present on the argument map
+ * and not in the current map will be kept as is. The argument validation is performed before the state is updated.
+ *
+ * @param params the parameters to appends
+ * @throws NullPointerException if the map contains a null key or a null value
+ * @throws IllegalArgumentException if the map is null or it contains a value with a zero length array or a null
+ * element in the array
+ * @throws ClassCastException if the map contains a key that is not a string or a value that is not a string
+ * array
+ */
+ public void append(Map<String, String[]> params) throws ClassCastException, NullPointerException, IllegalArgumentException
+ {
+ // Clone
+ params = new HashMap<String, String[]>(params);
+
+ //
+ for (Map.Entry<String, String[]> entry : params.entrySet())
+ {
+ String[] existingValue = get(entry.getKey());
+
+ // Perform the appending operation if the entry exist
+ if (existingValue != null)
+ {
+ String[] appendedValue = entry.getValue();
+ String[] newValue = new String[existingValue.length + appendedValue.length];
+ System.arraycopy(existingValue, 0, newValue, 0, existingValue.length);
+ System.arraycopy(appendedValue, 0, newValue, existingValue.length, appendedValue.length);
+ entry.setValue(newValue);
+ }
+ }
+
+ //
+ putAll(params);
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("ParameterMap[");
+ for (Iterator i = entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ String[] values = (String[])entry.getValue();
+ buffer.append(name);
+ for (int j = 0; j < values.length; j++)
+ {
+ buffer.append(j > 0 ? ',' : '=').append(values[j]);
+ }
+ if (i.hasNext())
+ {
+ buffer.append(" | ");
+ }
+ }
+ buffer.append(']');
+ return buffer.toString();
+ }
}
18 years, 3 months