You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by dl...@apache.org on 2005/07/05 23:55:50 UTC
svn commit: r209328 [3/14] - in /portals/jetspeed-2/trunk/components/portal:
src/ src/java/ src/java/org/ src/java/org/apache/
src/java/org/apache/jetspeed/ src/java/org/apache/jetspeed/aggregator/
src/java/org/apache/jetspeed/aggregator/impl/ src/java...
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.invoker;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.container.ContainerConstants;
+import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.factory.PortletInstance;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletApplication;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.servlet.WebApplicationDefinition;
+
+/**
+ * ServletPortletInvoker invokes portlets in another web application, calling a
+ * portlet's render or action method via a cross context request dispatcher.
+ * In order for this class to work, a servlet must be special servlet must be
+ * infused into the web (portlet) application. This servlet knows how to delegate
+ * to portlets and package their response back into a servlet response.
+ * The context name of the servlet should be configurable. The default context name is "/container"
+ * ServletPortletInvokerFactory is the factory for creating portlet invokers that
+ * use Jetspeed Container servlet.
+ * <h3>Sample Factory Configuration</h3>
+ * <pre>
+ * <code>
+ * factory.invoker.servlet = org.apache.jetspeed.container.invoker.ServletPortletInvoker
+ * factory.invoker.servlet.pool.size = 50
+ * factory.invoker.servlet.mapping.name = /container
+ * </code>
+ * </pre>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletPortletInvoker.java 188436 2005-03-23 22:54:30Z ate $
+ */
+public class ServletPortletInvoker implements JetspeedPortletInvoker
+{
+ private final static Log log = LogFactory.getLog(ServletPortletInvoker.class);
+
+ protected PortletFactory portletFactory;
+ protected ServletContext jetspeedContext;
+ protected ServletConfig jetspeedConfig;
+ protected PortletDefinition portletDefinition;
+ protected boolean activated = false;
+ protected String servletMappingName;
+
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.container.invoker.JetspeedPortletInvoker#passivate()
+ */
+ public void passivate()
+ {
+ activated = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.container.invoker.JetspeedPortletInvoker#isActivated()
+ */
+ public boolean isActivated()
+ {
+ return activated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.container.invoker.JetspeedPortletInvoker#activate(PortletFactory,org.apache.pluto.om.portlet.PortletDefinition, javax.servlet.ServletConfig)
+ */
+ public void activate(PortletFactory portletFactory, PortletDefinition portletDefinition, ServletConfig servletConfig)
+ {
+ this.portletFactory = portletFactory;
+ this.jetspeedConfig = servletConfig;
+ jetspeedContext = servletConfig.getServletContext();
+ this.portletDefinition = portletDefinition;
+ activated = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.container.invoker.JetspeedPortletInvoker#activate(PortletFactory,org.apache.pluto.om.portlet.PortletDefinition, javax.servlet.ServletConfig, java.lang.String)
+ */
+ public void activate(PortletFactory portletFactory, PortletDefinition portletDefinition, ServletConfig servletConfig, String servletMappingName)
+ {
+ this.servletMappingName = servletMappingName;
+ activate(portletFactory, portletDefinition, servletConfig);
+ }
+
+ /**
+ *
+ * @param request
+ * @param response
+ * @throws PortletException
+ */
+ public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
+ invoke(request, response, ContainerConstants.METHOD_RENDER);
+ }
+
+ /**
+ *
+ */
+ public void action(ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
+ invoke(request, response, ContainerConstants.METHOD_ACTION);
+ }
+
+ /**
+ *
+ */
+ public void load(PortletRequest request, RenderResponse response) throws PortletException
+ {
+ try
+ {
+ invoke(request, response, ContainerConstants.METHOD_NOOP);
+ }
+ catch (IOException e)
+ {
+ log.error("ServletPortletInvokerImpl.load() - Error while dispatching portlet.", e);
+ throw new PortletException(e);
+ }
+ }
+
+ /**
+ * Creates a servlet request dispatcher to dispatch to another web application to render the portlet.
+ * NOTE: this method requires that your container supports cross-context dispatching.
+ * Cross-context dispatching is known to work on Tomcat, Catalina, Tomcat-5.
+ *
+ * @param portletRequest
+ * @param portletResponse
+ * @param methodID
+ * @throws PortletException
+ * @throws IOException
+ */
+ protected void invoke(PortletRequest portletRequest, PortletResponse portletResponse, Integer methodID)
+ throws PortletException, IOException
+ {
+ ClassLoader paClassLoader = portletFactory.getPortletApplicationClassLoader((PortletApplication)portletDefinition.getPortletApplicationDefinition());
+
+ MutablePortletApplication app = (MutablePortletApplication)portletDefinition.getPortletApplicationDefinition();
+
+ WebApplicationDefinition webApplicationDefinition = app.getWebApplicationDefinition();
+ if(webApplicationDefinition == null)
+ {
+ throw new IllegalStateException("Portlet application "+app.getName()+ " has no associated web application.");
+ }
+ String portletApplicationName = webApplicationDefinition.getContextRoot();
+
+ // gather all required data from request and response
+ ServletRequest servletRequest = ((HttpServletRequestWrapper)((HttpServletRequestWrapper)portletRequest).getRequest()).getRequest();
+
+ ServletResponse servletResponse = ((HttpServletResponseWrapper) portletResponse).getResponse();
+
+ ServletContext appContext = jetspeedContext.getContext(portletApplicationName);
+ if (null == appContext)
+ {
+ String message = "Failed to find Servlet context for Portlet Application: " + portletApplicationName;
+ log.error(message);
+ throw new PortletException(message);
+ }
+ PortletInstance portletInstance = portletFactory.getPortletInstance(appContext, portletDefinition);
+ RequestDispatcher dispatcher = appContext.getRequestDispatcher(servletMappingName);
+ if (null == dispatcher)
+ {
+ String message =
+ "Failed to get Request Dispatcher for Portlet Application: "
+ + portletApplicationName
+ + ", servlet: "
+ + servletMappingName;
+ log.error(message);
+ throw new PortletException(message);
+ }
+
+ try
+ {
+ servletRequest.setAttribute(ContainerConstants.PORTLET, portletInstance);
+ servletRequest.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
+ servletRequest.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
+ servletRequest.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
+ servletRequest.setAttribute(ContainerConstants.METHOD_ID, methodID);
+ RequestContext requestContext = (RequestContext)servletRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+ servletRequest.setAttribute(ContainerConstants.PORTAL_CONTEXT, requestContext.getRequest().getContextPath());
+
+ dispatcher.include(servletRequest, servletResponse);
+
+ }
+ catch (Exception e)
+ {
+ String message =
+ "Failed to dispatch.include for Portlet Application: " + portletApplicationName + ", servlet: " + servletMappingName;
+ log.error(message, e);
+ throw new PortletException(message, e);
+ }
+ finally
+ {
+ servletRequest.removeAttribute(ContainerConstants.PORTLET);
+ servletRequest.removeAttribute(ContainerConstants.PORTLET_CONFIG);
+ servletRequest.removeAttribute(ContainerConstants.PORTLET_REQUEST);
+ servletRequest.removeAttribute(ContainerConstants.PORTLET_RESPONSE);
+ servletRequest.removeAttribute(ContainerConstants.METHOD_ID);
+ servletRequest.removeAttribute(ContainerConstants.PORTAL_CONTEXT);
+ }
+
+ }
+
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapper.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapper.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapper.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.namespace;
+
+import org.apache.pluto.util.NamespaceMapper;
+
+/**
+ * Jetspeed NamespaceMapper interface extension
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: JetspeedNamespaceMapper.java 188577 2005-05-17 15:57:13Z ate $
+ */
+public interface JetspeedNamespaceMapper extends NamespaceMapper
+{
+ static final String DEFAULT_PREFIX = "js_";
+
+ String getPrefix();
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactory.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactory.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactory.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactory.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.namespace;
+
+import org.apache.pluto.factory.NamespaceMapperFactory;
+
+/**
+ * Jetspeed extension of the NamespaceMapperFactory interface
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: JetspeedNamespaceMapperFactory.java 188577 2005-05-17 15:57:13Z ate $
+ */
+public interface JetspeedNamespaceMapperFactory extends NamespaceMapperFactory
+{
+ JetspeedNamespaceMapper getJetspeedNamespaceMapper();
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactoryImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactoryImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactoryImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperFactoryImpl.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.namespace;
+
+import org.apache.pluto.util.NamespaceMapper;
+
+/**
+ * Jetspeed version of the Factory implementation for the NamespaceMapper
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: JetspeedNamespaceMapperFactoryImpl.java 188577 2005-05-17 15:57:13Z ate $
+ */
+public class JetspeedNamespaceMapperFactoryImpl implements JetspeedNamespaceMapperFactory
+{
+ private JetspeedNamespaceMapper namespaceMapper;
+
+ public void init(javax.servlet.ServletConfig config, java.util.Map properties) throws Exception
+ {
+ namespaceMapper = (JetspeedNamespaceMapper)properties.get("JetspeedNamespaceMapper");
+ }
+
+ public void destroy() throws Exception
+ {
+ }
+
+ public NamespaceMapper getNamespaceMapper()
+ {
+ return namespaceMapper;
+ }
+
+ public JetspeedNamespaceMapper getJetspeedNamespaceMapper()
+ {
+ return namespaceMapper;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/namespace/JetspeedNamespaceMapperImpl.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.namespace;
+
+import org.apache.pluto.om.common.ObjectID;
+
+
+/**
+ * Jetspeed implementation of Name space mapping for creating named attributes.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: JetspeedNamespaceMapperImpl.java 188577 2005-05-17 15:57:13Z ate $
+ */
+public class JetspeedNamespaceMapperImpl implements JetspeedNamespaceMapper
+{
+ private String prefix;
+
+ public JetspeedNamespaceMapperImpl(String prefix)
+ {
+ this.prefix = prefix;
+ if ( this.prefix == null )
+ {
+ this.prefix = DEFAULT_PREFIX;
+ }
+ }
+
+ public JetspeedNamespaceMapperImpl()
+ {
+ this(null);
+ }
+
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ public String encode(String ns, String name)
+ {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append(prefix);
+ buffer.append(ns);
+ buffer.append('_');
+ buffer.append(name);
+ return buffer.toString();
+ }
+
+ public String encode(String ns1, String ns2, String name)
+ {
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append(prefix);
+ buffer.append(ns1);
+ buffer.append('_');
+ buffer.append(ns2);
+ buffer.append('_');
+ buffer.append(name);
+ return buffer.toString();
+ }
+
+ public String decode(String ns, String name)
+ {
+ if (!name.startsWith(prefix)) return null;
+ StringBuffer buffer = new StringBuffer(50);
+ buffer.append(prefix);
+ buffer.append(ns);
+ buffer.append('_');
+ if (!name.startsWith(buffer.toString())) return null;
+ return name.substring(buffer.length());
+ }
+
+ public String encode(long id, String name)
+ {
+ return encode(new Long(id).toString(),name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.util.NamespaceMapper#encode(org.apache.pluto.om.common.ObjectID, java.lang.String)
+ */
+ public String encode(ObjectID ns, String name)
+ {
+ return encode(ns.toString(),name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.util.NamespaceMapper#encode(org.apache.pluto.om.common.ObjectID, org.apache.pluto.om.common.ObjectID, java.lang.String)
+ */
+ public String encode(ObjectID ns1, ObjectID ns2, String name)
+ {
+ return encode(ns1.toString(),ns2.toString(),name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.util.NamespaceMapper#decode(org.apache.pluto.om.common.ObjectID, java.lang.String)
+ */
+ public String decode(ObjectID ns, String name)
+ {
+ return decode(ns.toString(),name);
+ }
+
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/ContainerLoggerAdaptor.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/ContainerLoggerAdaptor.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/ContainerLoggerAdaptor.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/ContainerLoggerAdaptor.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.services.log;
+
+import org.apache.pluto.services.log.Logger;
+import org.apache.commons.logging.Log;
+
+/**
+ * ContainerLoggerAdaptor
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ContainerLoggerAdaptor.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class ContainerLoggerAdaptor implements Logger
+{
+ private Log log = null;
+
+ public ContainerLoggerAdaptor(Log log)
+ {
+ this.log = log;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#isDebugEnabled()
+ */
+ public boolean isDebugEnabled()
+ {
+ return log.isDebugEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#isInfoEnabled()
+ */
+ public boolean isInfoEnabled()
+ {
+ return log.isInfoEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#isWarnEnabled()
+ */
+ public boolean isWarnEnabled()
+ {
+ return log.isWarnEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#isErrorEnabled()
+ */
+ public boolean isErrorEnabled()
+ {
+ return log.isErrorEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#debug(java.lang.String)
+ */
+ public void debug(String aMessage)
+ {
+ log.debug(aMessage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#debug(java.lang.String, java.lang.Throwable)
+ */
+ public void debug(String aMessage, Throwable aThrowable)
+ {
+ log.debug(aMessage, aThrowable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#info(java.lang.String)
+ */
+ public void info(String aMessage)
+ {
+ log.info(aMessage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#warn(java.lang.String)
+ */
+ public void warn(String aMessage)
+ {
+ log.warn(aMessage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#error(java.lang.String)
+ */
+ public void error(String aMessage)
+ {
+ log.error(aMessage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#error(java.lang.String, java.lang.Throwable)
+ */
+ public void error(String aMessage, Throwable aThrowable)
+ {
+ log.error(aMessage, aThrowable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.Logger#error(java.lang.Throwable)
+ */
+ public void error(Throwable aThrowable)
+ {
+ log.error(aThrowable);
+ }
+
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/PlutoLogService.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/PlutoLogService.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/PlutoLogService.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/services/log/PlutoLogService.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.services.log;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.services.log.LogService;
+import org.apache.pluto.services.log.Logger;
+
+
+/**
+ * Implements the logging service adaptor for the Pluto container
+ * adapting Jetspeed logging service implemented in Commons to Pluto
+ *
+ * NOTE: this implementation may have performance issues
+ * since everytime we call isSomethingEnabled, we must get a logger
+ * I recommend deprecated Pluto's logging container service and
+ * this adaptor once we get the Pluto source in Apache's CVS
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PlutoLogService.java 187177 2004-08-02 18:58:57Z weaver $
+ */
+public class PlutoLogService
+ implements LogService
+{
+ private final static Log defaultLog = LogFactory.getLog(PlutoLogService.class);
+
+
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.LogService#getLogger(java.lang.String)
+ */
+ public Logger getLogger(String component)
+ {
+ return new ContainerLoggerAdaptor(getConfiguredLogger(component));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pluto.services.log.LogService#getLogger(java.lang.Class)
+ */
+ public Logger getLogger(Class klass)
+ {
+
+ return new ContainerLoggerAdaptor(getConfiguredLogger(klass));
+ }
+
+ /**
+ * Given a string class name returns a logger for that class, or if we can't find a logger for the class
+ * the it returns the default logger for this class
+ *
+ * @param className
+ * @return Log The logger configured for the given class name or the default logger if failed to load class
+ */
+ private Log getConfiguredLogger(String className)
+ {
+ Class classe = null;
+ Log log = defaultLog;
+
+ try
+ {
+ classe = Class.forName(className);
+ log = LogFactory.getLog(classe);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // use the default logger
+ }
+ catch (LogConfigurationException e)
+ {
+ // use the default logger
+ }
+ return log;
+ }
+
+ /**
+ * Given a string class name returns a logger for that class, or if we can't find a logger for the class
+ * the it returns the default logger for this class
+ *
+ * @param classe the class to get a logger for
+ * @return Log The logger configured for the given class name or the default logger if failed to load class
+ */
+ private Log getConfiguredLogger(Class classe)
+ {
+ Log log = defaultLog;
+
+ try
+ {
+ log = LogFactory.getLog(classe);
+ }
+ catch (LogConfigurationException e)
+ {
+ // use the default logger
+ }
+ return log;
+ }
+
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/AbstractNavigationalState.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.jetspeed.container.state.MutableNavigationalState;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * BaseNavigationalState
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: AbstractNavigationalState.java 188606 2005-05-24 17:30:46Z ate $
+ */
+public abstract class AbstractNavigationalState implements MutableNavigationalState
+{
+ private NavigationalStateCodec codec;
+ private PortletWindowRequestNavigationalStates requestStates;
+
+ public AbstractNavigationalState(NavigationalStateCodec codec)
+ {
+ this.codec = codec;
+ }
+
+ public void init(String encodedState, String characterEncoding)
+ throws UnsupportedEncodingException
+ {
+ if ( requestStates == null )
+ {
+ requestStates = codec.decode(encodedState, characterEncoding);
+ }
+ }
+
+ protected PortletWindowRequestNavigationalStates getPortletWindowRequestNavigationalStates()
+ {
+ return requestStates;
+ }
+
+ public void setState(PortletWindow window, WindowState windowState)
+ {
+ if ( windowState != null )
+ {
+ String windowId = window.getId().toString();
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
+ if (state != null && (state.getWindowState() == null || !state.getWindowState().equals(windowState)))
+ {
+ state.setWindowState(windowState);
+ }
+ else
+ {
+ state = new PortletWindowRequestNavigationalState(windowId);
+ requestStates.addPortletWindowNavigationalState(windowId, state);
+ state.setWindowState(windowState);
+ }
+ }
+ }
+
+ public void setMode(PortletWindow window, PortletMode portletMode)
+ {
+ if ( portletMode != null )
+ {
+ String windowId = window.getId().toString();
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
+ if (state != null && (state.getPortletMode() == null || !state.getPortletMode().equals(portletMode)))
+ {
+ state.setPortletMode(portletMode);
+ }
+ else
+ {
+ state = new PortletWindowRequestNavigationalState(windowId);
+ requestStates.addPortletWindowNavigationalState(windowId, state);
+ state.setPortletMode(portletMode);
+ }
+ }
+ }
+
+ public WindowState getState(String windowId)
+ {
+ WindowState windowState = null;
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
+ if (state != null)
+ {
+ windowState = state.getWindowState();
+ }
+ return windowState != null ? windowState : WindowState.NORMAL;
+ }
+
+ public WindowState getState(PortletWindow window)
+ {
+ return getState(window.getId().toString());
+ }
+
+ public PortletMode getMode(String windowId)
+ {
+ PortletMode portletMode = null;
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(windowId);
+ if (state != null)
+ {
+ portletMode = state.getPortletMode();
+ }
+ return portletMode != null ? portletMode : PortletMode.VIEW;
+ }
+
+ public PortletMode getMode(PortletWindow window)
+ {
+ return getMode(window.getId().toString());
+ }
+
+ public PortletWindow getMaximizedWindow()
+ {
+ return requestStates.getMaximizedWindow();
+ }
+
+ public Iterator getParameterNames(PortletWindow window)
+ {
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(window.getId().toString());
+ if ( state != null && state.getParametersMap() != null )
+ {
+ return state.getParametersMap().keySet().iterator();
+ }
+ else
+ {
+ return Collections.EMPTY_LIST.iterator();
+ }
+ }
+
+ public String[] getParameterValues(PortletWindow window, String parameterName)
+ {
+ PortletWindowRequestNavigationalState state = requestStates.getPortletWindowNavigationalState(window.getId().toString());
+ if ( state != null && state.getParametersMap() != null )
+ {
+ return (String[])state.getParametersMap().get(parameterName);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public PortletWindow getPortletWindowOfAction()
+ {
+ return requestStates.getActionWindow();
+ }
+
+ public String encode(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action)
+ throws UnsupportedEncodingException
+ {
+ return codec.encode(requestStates, window, parameters, mode, state, action, isNavigationalParameterStateFull(),
+ isRenderParameterStateFull());
+ }
+
+ public String encode(PortletWindow window, PortletMode mode, WindowState state)
+ throws UnsupportedEncodingException
+ {
+ return codec.encode(requestStates, window, mode, state, isNavigationalParameterStateFull(),
+ isRenderParameterStateFull());
+ }
+
+ public Iterator getWindowIdIterator()
+ {
+ return requestStates.getWindowIdIterator();
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateCodec.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,630 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * JetspeedNavigationalStateCodec
+ *
+ * @author <a href="mailto:ate@apache.org">Ate Douma</a>
+ * @version $Id: JetspeedNavigationalStateCodec.java 188508 2005-04-21 09:00:40Z ate $
+ */
+public class JetspeedNavigationalStateCodec implements NavigationalStateCodec
+{
+ /** Commons logging */
+ protected final static Log log = LogFactory.getLog(JetspeedNavigationalStateCodec.class);
+
+ protected static final char PARAMETER_SEPARATOR = '|';
+ protected static final char PARAMETER_ELEMENT_SEPARATOR = '=';
+ protected static final char RENDER_WINDOW_ID_KEY = 'a';
+ protected static final char ACTION_WINDOW_ID_KEY = 'b';
+ protected static final char MODE_KEY = 'c';
+ protected static final char STATE_KEY = 'd';
+ protected static final char PARAM_KEY = 'e';
+ protected static final char CLEAR_PARAMS_KEY = 'f';
+
+ protected static final String keytable = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ protected final PortletMode[] portletModes;
+ protected final WindowState[] windowStates;
+
+ public JetspeedNavigationalStateCodec()
+ {
+ Object o;
+ ArrayList list = new ArrayList();
+ Enumeration portletModesEnum = Jetspeed.getContext().getSupportedPortletModes();
+
+ // ensure standard modes will be first in the portletModeNames array
+ // this ensures those modes are never lost from a bookmarked url when new modes are added somewhere in the
+ // middle
+ list.add(PortletMode.VIEW);
+ list.add(PortletMode.EDIT);
+ list.add(PortletMode.HELP);
+
+ while ( portletModesEnum.hasMoreElements() )
+ {
+ o = portletModesEnum.nextElement();
+ if ( !list.contains(o) )
+ {
+ list.add(o);
+ }
+ }
+ portletModes = (PortletMode[])list.toArray(new PortletMode[list.size()]);
+ if (portletModes.length > keytable.length())
+ {
+ throw new UnsupportedOperationException("Too many supported PortletModes found. Can only handle max: "+keytable.length());
+ }
+
+ list.clear();
+
+ // ensure standard states will be first in the windowStateNames array
+ // this ensures those states are never lost from a bookmarked url when new states are added somewhere in the
+ // middle
+ list.add(WindowState.NORMAL);
+ list.add(WindowState.MAXIMIZED);
+ list.add(WindowState.MINIMIZED);
+ Enumeration windowStatesEnum = Jetspeed.getContext().getSupportedWindowStates();
+ while ( windowStatesEnum.hasMoreElements() )
+ {
+ o = windowStatesEnum.nextElement();
+ if ( !list.contains(o) )
+ {
+ list.add(o);
+ }
+ }
+ windowStates = (WindowState[])list.toArray(new WindowState[list.size()]);
+ if (windowStates.length > keytable.length())
+ {
+ throw new UnsupportedOperationException("Too many supported WindowModes found. Can only handle max: "+keytable.length());
+ }
+ }
+
+ public PortletWindowRequestNavigationalStates decode(String parameters, String characterEncoding)
+ throws UnsupportedEncodingException
+ {
+ PortletWindowRequestNavigationalStates states = new PortletWindowRequestNavigationalStates(characterEncoding);
+ if ( parameters != null && parameters.length() > 0 )
+ {
+ String decodedParameters = decodeParameters(parameters, characterEncoding);
+
+ int position = 0;
+ StringBuffer buffer = new StringBuffer();
+ PortletWindowAccessor accessor = (PortletWindowAccessor) Jetspeed.getComponentManager().getComponent(PortletWindowAccessor.class);
+ PortletWindowRequestNavigationalState currentState = null;
+ String parameter;
+ while ( (position = decodeArgument(position, decodedParameters, buffer, PARAMETER_SEPARATOR )) != -1 )
+ {
+ parameter = buffer.toString();
+ currentState = decodeParameter( accessor, states, currentState, parameter);
+ }
+ if ( log.isDebugEnabled() )
+ {
+ buffer.setLength(0);
+
+ String actionWindowId = states.getActionWindow() != null ? states.getActionWindow().getId().toString() : "";
+
+ Iterator iter = states.getWindowIdIterator();
+ while ( iter.hasNext() )
+ {
+ if ( buffer.length() == 0 )
+ {
+ buffer.append("[[");
+ }
+ else
+ {
+ buffer.append(",[");
+ }
+ currentState = states.getPortletWindowNavigationalState((String)iter.next());
+ buffer.append("window:"+currentState.getWindowId());
+
+ if ( currentState.getWindowId().equals(actionWindowId))
+ {
+ buffer.append(",action:true");
+ }
+ if (currentState.getPortletMode() != null)
+ {
+ buffer.append(",mode:"+currentState.getPortletMode());
+ }
+ if (currentState.getWindowState() != null )
+ {
+ buffer.append(",state:"+currentState.getWindowState());
+ }
+ if (!currentState.isClearParameters())
+ {
+ if (currentState.getParametersMap() != null)
+ {
+ buffer.append(",parameters:[");
+ boolean first = true;
+ Iterator parIter = currentState.getParametersMap().keySet().iterator();
+ while ( parIter.hasNext() )
+ {
+ if ( first )
+ {
+ first = false;
+ }
+ else
+ {
+ buffer.append(",");
+ }
+ String name = (String)parIter.next();
+ buffer.append(name+":[");
+ String[] values = (String[])currentState.getParametersMap().get(name);
+ for ( int i = 0; i < values.length; i++ )
+ {
+ if ( i > 0 )
+ {
+ buffer.append(",");
+ }
+ buffer.append(values[i]);
+ }
+ buffer.append("]");
+ }
+ }
+ }
+ buffer.append("]");
+ }
+ if ( buffer.length() > 0 )
+ {
+ buffer.append("]");
+ log.debug("navstate decoded="+buffer.toString());
+ }
+ }
+ }
+ return states;
+ }
+
+ public String encode(PortletWindowRequestNavigationalStates states, PortletWindow window, PortletMode portletMode,
+ WindowState windowState, boolean navParamsStateFull, boolean renderParamsStateFull)
+ throws UnsupportedEncodingException
+ {
+ String windowId = window.getId().toString();
+ PortletWindowRequestNavigationalState currentState = states.getPortletWindowNavigationalState(windowId);
+ PortletWindowRequestNavigationalState targetState = new PortletWindowRequestNavigationalState(windowId);
+ targetState.setPortletMode(portletMode != null ? portletMode : currentState != null ? currentState.getPortletMode() : null);
+ targetState.setWindowState(windowState != null ? windowState : currentState != null ? currentState.getWindowState() : null);
+
+ // never retain actionRequest parameters nor session stored renderParameters
+ if ( currentState != null && !renderParamsStateFull )
+ {
+ // retain current request parameters if any
+ if ( currentState.getParametersMap() != null )
+ {
+ Iterator parametersIter = currentState.getParametersMap().entrySet().iterator();
+ Map.Entry entry;
+ while ( parametersIter.hasNext())
+ {
+ entry = (Map.Entry)parametersIter.next();
+ targetState.setParameters((String)entry.getKey(), (String[])entry.getValue());
+ }
+ }
+ }
+ // encode as requestURL parameters
+ return encode(states, windowId, targetState, false, navParamsStateFull, renderParamsStateFull);
+ }
+
+ public String encode(PortletWindowRequestNavigationalStates states, PortletWindow window, Map parameters,
+ PortletMode portletMode, WindowState windowState, boolean action, boolean navParamsStateFull,
+ boolean renderParamsStateFull)
+ throws UnsupportedEncodingException
+ {
+ String windowId = window.getId().toString();
+ PortletWindowRequestNavigationalState currentState = states.getPortletWindowNavigationalState(windowId);
+ PortletWindowRequestNavigationalState targetState = new PortletWindowRequestNavigationalState(windowId);
+ targetState.setPortletMode(portletMode != null ? portletMode : currentState != null ? currentState.getPortletMode() : null);
+ targetState.setWindowState(windowState != null ? windowState : currentState != null ? currentState.getWindowState() : null);
+
+ Iterator parametersIter = parameters.entrySet().iterator();
+
+ Map.Entry entry;
+ // fill in the new parameters
+ while ( parametersIter.hasNext())
+ {
+ entry = (Map.Entry)parametersIter.next();
+ targetState.setParameters((String)entry.getKey(), (String[])entry.getValue());
+ }
+ if ( renderParamsStateFull && targetState.getParametersMap() == null )
+ {
+ // Indicate that the saved (in the session) render parameters for this PortletWindow must be cleared
+ // and not copied when synchronizing the state (encoded as CLEAR_PARAMS_KEY)
+ targetState.setClearParameters(true);
+ }
+ return encode(states, windowId, targetState, action, navParamsStateFull, renderParamsStateFull);
+ }
+
+ protected String encode(PortletWindowRequestNavigationalStates states, String targetWindowId,
+ PortletWindowRequestNavigationalState targetState, boolean action, boolean navParamsStateFull,
+ boolean renderParamsStateFull)
+ throws UnsupportedEncodingException
+ {
+ StringBuffer buffer = new StringBuffer();
+ String encodedState;
+ boolean haveState = false;
+
+ // skip other states if all non-targeted PortletWindow states are kept in the session
+ if ( !navParamsStateFull || !renderParamsStateFull )
+ {
+ PortletWindowRequestNavigationalState pwfns;
+ String windowId;
+ Iterator iter = states.getWindowIdIterator();
+ while ( iter.hasNext() )
+ {
+ windowId = (String)iter.next();
+ pwfns = states.getPortletWindowNavigationalState(windowId);
+ if ( windowId.equals(targetWindowId))
+ {
+ // skip it for now, it will be encoded as the last one below
+ }
+ else
+ {
+ encodedState = encodePortletWindowNavigationalState(windowId, pwfns, false, navParamsStateFull,
+ renderParamsStateFull);
+ if ( encodedState.length() > 0 )
+ {
+ if ( !haveState )
+ {
+ haveState = true;
+ }
+ else
+ {
+ buffer.append(PARAMETER_SEPARATOR);
+ }
+ buffer.append(encodedState);
+ }
+ }
+ }
+ }
+ encodedState = encodePortletWindowNavigationalState(targetWindowId, targetState, action, false, false);
+ if ( encodedState.length() > 0 )
+ {
+ if ( !haveState )
+ {
+ haveState = true;
+ }
+ else
+ {
+ buffer.append(PARAMETER_SEPARATOR);
+ }
+ buffer.append(encodedState);
+ }
+
+ String encodedNavState = null;
+ if ( haveState )
+ {
+ encodedNavState = encodeParameters(buffer.toString(), states.getCharacterEncoding());
+ }
+ return encodedNavState;
+ }
+
+ protected String encodePortletWindowNavigationalState(String windowId, PortletWindowRequestNavigationalState state,
+ boolean action, boolean navParamsStateFull, boolean renderParamsStateFull)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(action ? ACTION_WINDOW_ID_KEY : RENDER_WINDOW_ID_KEY);
+ buffer.append(windowId);
+ boolean encoded = action;
+
+ if ( action || !navParamsStateFull )
+ {
+ if (state.getPortletMode() != null)
+ {
+ buffer.append(PARAMETER_SEPARATOR);
+ buffer.append(MODE_KEY);
+ buffer.append(encodePortletMode(state.getPortletMode()));
+ encoded = true;
+ }
+
+ if (state.getWindowState() != null)
+ {
+ buffer.append(PARAMETER_SEPARATOR);
+ buffer.append(STATE_KEY);
+ buffer.append(encodeWindowState(state.getWindowState()));
+ encoded = true;
+ }
+ }
+
+ if (state.getParametersMap() != null && (action || !renderParamsStateFull) )
+ {
+ Map.Entry entry;
+ String parameterName;
+ String[] parameterValues;
+
+ StringBuffer paramBuffer = new StringBuffer();
+ Iterator iter = state.getParametersMap().entrySet().iterator();
+ while ( iter.hasNext() )
+ {
+ encoded = true;
+ entry = (Map.Entry)iter.next();
+ parameterName = (String)entry.getKey();
+ parameterValues = (String[])entry.getValue();
+
+ buffer.append(PARAMETER_SEPARATOR);
+ buffer.append(PARAM_KEY);
+
+ paramBuffer.setLength(0);
+ paramBuffer.append(encodeArgument(parameterName, PARAMETER_ELEMENT_SEPARATOR));
+ paramBuffer.append(PARAMETER_ELEMENT_SEPARATOR);
+ paramBuffer.append(parameterValues.length);
+ for ( int i = 0; i < parameterValues.length; i++ )
+ {
+ paramBuffer.append(PARAMETER_ELEMENT_SEPARATOR);
+ paramBuffer.append(encodeArgument(parameterValues[i], PARAMETER_ELEMENT_SEPARATOR));
+ }
+
+ buffer.append(encodeArgument(paramBuffer.toString(),PARAMETER_SEPARATOR));
+ }
+ }
+ else if ( state.isClearParameters() )
+ {
+ // Special case: for a targeted PortletWindow for which no parameters are specified
+ // indicate its saved (in the session) request parameters must be cleared instead of copying them when
+ // synchronizing the state.
+ // During decoding this CLEAR_PARAMS_KEY will set the clearParameters flag of the PortletWindowRequestNavigationalState.
+ buffer.append(PARAMETER_SEPARATOR);
+ buffer.append(CLEAR_PARAMS_KEY);
+ encoded = true;
+ }
+ return encoded ? buffer.toString() : "";
+ }
+
+ protected PortletWindowRequestNavigationalState decodeParameter(PortletWindowAccessor accessor, PortletWindowRequestNavigationalStates states, PortletWindowRequestNavigationalState currentState, String parameter)
+ {
+ char parameterType = parameter.charAt(0);
+ if (parameterType == RENDER_WINDOW_ID_KEY || parameterType == ACTION_WINDOW_ID_KEY )
+ {
+ String windowId = parameter.substring(1);
+ currentState = states.getPortletWindowNavigationalState(windowId);
+ if ( currentState == null )
+ {
+ PortletWindow window = accessor.getPortletWindow(windowId);
+ if ( window != null )
+ {
+ currentState = new PortletWindowRequestNavigationalState(windowId);
+ states.addPortletWindowNavigationalState(windowId, currentState);
+ if ( parameterType == ACTION_WINDOW_ID_KEY )
+ {
+ states.setActionWindow(window);
+ }
+ }
+ }
+ }
+ else if ( currentState != null )
+ {
+ switch ( parameterType )
+ {
+ case MODE_KEY:
+ {
+ char c = parameter.charAt(1);
+ PortletMode portletMode = decodePortletMode(parameter.charAt(1));
+ if ( portletMode != null )
+ {
+ currentState.setPortletMode(portletMode);
+ }
+ break;
+ }
+ case STATE_KEY:
+ {
+ char c = parameter.charAt(1);
+ WindowState windowState = decodeWindowState(parameter.charAt(1));
+ if ( windowState != null )
+ {
+ currentState.setWindowState(windowState);
+ if (windowState.equals(WindowState.MAXIMIZED))
+ {
+ states.setMaximizedWindow(accessor.getPortletWindow(currentState.getWindowId()));
+ }
+ }
+ break;
+ }
+ case PARAM_KEY:
+ {
+ int position = 1;
+ StringBuffer buffer = new StringBuffer();
+ String parameterName = null;
+ int parameterValueCount = -1;
+ String parameterValues[] = null;
+ int parameterValueIndex = -1;
+ while ( (position = decodeArgument(position, parameter, buffer, PARAMETER_ELEMENT_SEPARATOR)) != -1 )
+ {
+ if ( parameterName == null )
+ {
+ parameterName = buffer.toString();
+ parameterValueCount = -1;
+ }
+ else if ( parameterValueCount == -1 )
+ {
+ parameterValueCount = Integer.parseInt(buffer.toString(), 16);
+ parameterValues = new String[parameterValueCount];
+ parameterValueIndex = 0;
+ }
+ else
+ {
+ parameterValues[parameterValueIndex++] = buffer.toString();
+ parameterValueCount--;
+ if ( parameterValueCount == 0 )
+ {
+ currentState.setParameters(parameterName, parameterValues);
+ break;
+ }
+ }
+ }
+ break;
+ }
+ case CLEAR_PARAMS_KEY:
+ {
+ currentState.setClearParameters(true);
+ }
+ }
+ }
+ return currentState;
+
+ }
+
+ protected PortletMode decodePortletMode(char mode)
+ {
+ PortletMode portletMode = null;
+ int index = keytable.indexOf(mode);
+ if (index > -1 && index < portletModes.length)
+ {
+ portletMode = portletModes[index];
+ }
+ return portletMode;
+ }
+
+ protected char encodePortletMode(PortletMode portletMode)
+ {
+ for ( int i = 0; i < portletModes.length; i++ )
+ {
+ if (portletModes[i].equals(portletMode))
+ return keytable.charAt(i);
+ }
+ throw new IllegalArgumentException("Unsupported PortletMode: "+portletMode);
+ }
+
+ protected WindowState decodeWindowState(char state)
+ {
+ WindowState windowState = null;
+ int index = keytable.indexOf(state);
+ if (index > -1 && index < windowStates.length)
+ {
+ windowState = windowStates[index];
+ }
+ return windowState;
+ }
+
+ protected char encodeWindowState(WindowState windowState)
+ {
+ for ( int i = 0; i < windowStates.length; i++ )
+ {
+ if (windowStates[i].equals(windowState))
+ return keytable.charAt(i);
+ }
+ throw new IllegalArgumentException("Unsupported WindowState: "+windowState);
+ }
+
+ /**
+ * Decodes a Base64 encoded string.
+ *
+ * Because the encoded string is used in an URL
+ * the two '/' and '=' which has some significance in an URL
+ * are encoded on top of the Base64 encoding and are first translated back before decoding.
+ *
+ * @param value
+ * @param characterEncoding String containing the name of the chararacter encoding
+ * @return decoded string
+ */
+ protected String decodeParameters(String value, String characterEncoding)
+ throws UnsupportedEncodingException
+ {
+ value = StringUtils.replace(value,"-","/");
+ value = StringUtils.replace(value,"_","=");
+ if ( characterEncoding != null )
+ {
+ return new String(Base64.decodeBase64(value.getBytes(characterEncoding)), characterEncoding);
+ }
+ else
+ {
+ return new String(Base64.decodeBase64(value.getBytes()));
+ }
+ }
+
+ /**
+ * Encodes a string with Base64.
+ *
+ * Because the encoded string is used in an URL
+ * the two '/' and '=' which has some significance in an URL
+ * are encoded on top of/after the Base64 encoding
+ *
+ * @param value
+ * @return encoded string
+ */
+ protected String encodeParameters(String value, String characterEncoding)
+ throws UnsupportedEncodingException
+ {
+ if ( characterEncoding != null )
+ {
+ value = new String(Base64.encodeBase64(value.getBytes(characterEncoding)));
+ }
+ else
+ {
+ value = new String(Base64.encodeBase64(value.getBytes()));
+ }
+ value = StringUtils.replace(value,"/","-");
+ value = StringUtils.replace(value,"=","_");
+ return value;
+ }
+
+ protected String encodeArgument( String argument, char escape )
+ {
+ int length = argument.length();
+ StringBuffer buffer = new StringBuffer(length);
+ buffer.setLength(0);
+ char c;
+ for ( int i = 0; i < length; i++ )
+ {
+ c = argument.charAt(i);
+ buffer.append(c);
+ if ( c == escape )
+ {
+ buffer.append(c);
+ }
+ }
+ return buffer.toString();
+ }
+
+ protected int decodeArgument(int position, String arguments, StringBuffer buffer, char escape)
+ {
+ int maxLength = arguments.length();
+ buffer.setLength(0);
+ char c;
+ for ( ; position < maxLength; position++ )
+ {
+ c = arguments.charAt(position);
+ if ( c != escape )
+ {
+ buffer.append(c);
+ }
+ else
+ {
+ if ( c == escape && position < maxLength-1 && arguments.charAt(position+1) == escape )
+ {
+ buffer.append(c);
+ position++;
+ }
+ else
+ {
+ position++;
+ break;
+ }
+ }
+ }
+ return buffer.length() > 0 ? position : -1;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.lang.reflect.Constructor;
+import java.util.Enumeration;
+import java.util.HashMap;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.container.state.FailedToCreateNavStateException;
+import org.apache.jetspeed.container.state.FailedToCreatePortalUrlException;
+import org.apache.jetspeed.container.state.NavigationalState;
+import org.apache.jetspeed.container.state.NavigationalStateComponent;
+import org.apache.jetspeed.container.url.PortalURL;
+import org.apache.jetspeed.util.ArgUtil;
+
+/**
+ * JetspeedNavigationalStateComponent
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: JetspeedNavigationalStateComponent.java 187758 2004-10-17 14:02:38Z ate $
+ */
+public class JetspeedNavigationalStateComponent implements NavigationalStateComponent
+{
+ private String navClassName = null;
+ private String urlClassName = null;
+ private Class navClass = null;
+ private Class urlClass = null;
+ private Class navCodecClass = null;
+ private NavigationalStateCodec navStateCodec = null;
+
+ // maps containing allowed PortletMode and WindowState objects on their lowercase name
+ // ensuring only allowed, and always the same objects are returned and allowing comparision by value
+ private HashMap supportedPortletModes = new HashMap();
+ private HashMap supportedWindowStates = new HashMap();
+
+ private final static Log log = LogFactory.getLog(JetspeedNavigationalStateComponent.class);
+
+ /**
+ * @param navClassName
+ * name of the class implementing Navigational State instances
+ * @param urlClassName
+ * name of the class implementing Portal URL instances
+ * @param navCodecClassName
+ * name of the class implementing Navigational State Codec instance
+ * @throws ClassNotFoundException
+ * if <code>navClassName</code> or <code>urlClassName</code>
+ * do not exist.
+ */
+ public JetspeedNavigationalStateComponent( String navClassName, String urlClassName, String navCodecClassName )
+ throws ClassNotFoundException
+ {
+ ArgUtil.assertNotNull(String.class, navClassName, this);
+ ArgUtil.assertNotNull(String.class, urlClassName, this);
+ ArgUtil.assertNotNull(String.class, navCodecClassName, this);
+ this.urlClass = Class.forName(urlClassName);
+ this.navClass = Class.forName(navClassName);
+ this.navCodecClass = Class.forName(navCodecClassName);
+ this.navClassName = navClassName;
+ this.urlClassName = urlClassName;
+
+ Enumeration portletModesEnum = Jetspeed.getContext().getSupportedPortletModes();
+ PortletMode portletMode;
+ while ( portletModesEnum.hasMoreElements() )
+ {
+ portletMode = (PortletMode)portletModesEnum.nextElement();
+ supportedPortletModes.put(portletMode.toString(), portletMode);
+ }
+ Enumeration windowStatesEnum = Jetspeed.getContext().getSupportedWindowStates();
+ WindowState windowState;
+ while ( windowStatesEnum.hasMoreElements() )
+ {
+ windowState = (WindowState)windowStatesEnum.nextElement();
+ supportedWindowStates.put(windowState.toString(), windowState);
+ }
+ }
+
+ /**
+ *
+ * <p>
+ * create
+ * </p>
+ *
+ * @see org.apache.jetspeed.container.state.NavigationalStateComponent#create(org.apache.jetspeed.request.RequestContext)
+ * @return @throws
+ * FailedToCreateNavStateException if the nav state could not be
+ * created. Under normal circumstances, this should not happen.
+ */
+ public NavigationalState create() throws FailedToCreateNavStateException
+ {
+ NavigationalState state = null;
+
+ try
+ {
+ if ( navStateCodec == null )
+ {
+ navStateCodec = (NavigationalStateCodec)navCodecClass.newInstance();
+ }
+ Constructor constructor = navClass.getConstructor(new Class[]{NavigationalStateCodec.class});
+ state = (NavigationalState) constructor.newInstance(new Object[]{navStateCodec});
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new FailedToCreateNavStateException("Error invoking create() method. "
+ + "There is more than likely a problem invoking navClass " + navClassName);
+ }
+
+ return state;
+ }
+
+ /**
+ *
+ * <p>
+ * createURL
+ * </p>
+ *
+ * @see org.apache.jetspeed.container.state.NavigationalStateComponent#createURL(org.apache.jetspeed.request.RequestContext)
+ * @param context
+ * @return
+ */
+ public PortalURL createURL( HttpServletRequest request, String characterEncoding )
+ {
+ PortalURL url = null;
+
+ try
+ {
+ Constructor constructor = urlClass.getConstructor(new Class[]{HttpServletRequest.class, String.class,
+ NavigationalState.class});
+
+ url = (PortalURL) constructor.newInstance(new Object[]{request, characterEncoding, create()});
+ return url;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new FailedToCreatePortalUrlException("Error invoking createURL() method. "
+ + "There is more than likely a problem invoking urlClass " + urlClassName);
+ }
+ }
+
+ public WindowState lookupWindowState( String name )
+ {
+ return (WindowState)supportedWindowStates.get(name.toLowerCase());
+ }
+
+ public PortletMode lookupPortletMode( String name )
+ {
+ return (PortletMode)supportedPortletModes.get(name.toLowerCase());
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/NavigationalStateCodec.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.pluto.om.window.PortletWindow;
+
+public interface NavigationalStateCodec
+{
+ PortletWindowRequestNavigationalStates decode(String parameters, String characterEncoding) throws UnsupportedEncodingException;
+
+ String encode(PortletWindowRequestNavigationalStates states, PortletWindow window, PortletMode portletMode,
+ WindowState windowState, boolean navParamsStateFull, boolean renderParamsStateFull) throws UnsupportedEncodingException;
+
+ String encode(PortletWindowRequestNavigationalStates states, PortletWindow window, Map parameters,
+ PortletMode portletMode, WindowState windowState, boolean action, boolean navParamsStateFull,
+ boolean renderParamsStateFull) throws UnsupportedEncodingException;
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PathNavigationalState.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * PathNavigationalStateContext stores all navigational state in the URL.
+ * This implementation does not currently support persisting navigational state.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PathNavigationalState.java 187753 2004-10-15 21:47:25Z ate $
+ */
+public class PathNavigationalState extends AbstractNavigationalState
+{
+
+ public PathNavigationalState(NavigationalStateCodec codec)
+ {
+ super(codec);
+ }
+
+ public void sync(RequestContext context)
+ {
+ }
+
+ public boolean isNavigationalParameterStateFull()
+ {
+ return false;
+ }
+
+ public boolean isRenderParameterStateFull()
+ {
+ return false;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowBaseNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowBaseNavigationalState.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowBaseNavigationalState.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowBaseNavigationalState.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.io.Serializable;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+/**
+ * PortletWindowBaseNavigationalState
+ *
+ * @author <a href="mailto:ate@apache.org">Ate Douma</a>
+ * @version $Id: PortletWindowBaseNavigationalState.java 187753 2004-10-15 21:47:25Z ate $
+ */
+public class PortletWindowBaseNavigationalState implements Serializable
+{
+ private PortletMode portletMode;
+ private WindowState windowState;
+
+ public PortletMode getPortletMode()
+ {
+ return portletMode;
+ }
+
+ public void setPortletMode(PortletMode portletMode)
+ {
+ this.portletMode = portletMode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public void setWindowState(WindowState windowState)
+ {
+ this.windowState = windowState;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowExtendedNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowExtendedNavigationalState.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowExtendedNavigationalState.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowExtendedNavigationalState.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PortletWindowExtendedNavigationalState
+ *
+ * @author <a href="mailto:ate@apache.org">Ate Douma</a>
+ * @version $Id: PortletWindowExtendedNavigationalState.java 187753 2004-10-15 21:47:25Z ate $
+ */
+public class PortletWindowExtendedNavigationalState extends PortletWindowBaseNavigationalState
+{
+ private Map parametersMap;
+
+ public Map getParametersMap()
+ {
+ return parametersMap;
+ }
+
+ public void setParameters(String name, String[] values)
+ {
+ if ( parametersMap == null )
+ {
+ parametersMap = new HashMap();
+ }
+ parametersMap.put(name, values);
+ }
+
+ public void setParametersMap(Map parametersMap)
+ {
+ this.parametersMap = parametersMap;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalState.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+/**
+ * PortletWindowRequestNavigationalState
+ *
+ * @author <a href="mailto:ate@apache.org">Ate Douma</a>
+ * @version $Id: PortletWindowRequestNavigationalState.java 187753 2004-10-15 21:47:25Z ate $
+ */
+public class PortletWindowRequestNavigationalState extends PortletWindowExtendedNavigationalState
+{
+ private String windowId;
+
+ /**
+ * true if for a targeted PortletWindow using StateFullParameters the saved (in the session) render parameters
+ * must be cleared when synchronizing the states.
+ * Prevents the default behavior when using StateFullParameters to copy the parameters from the session
+ * when no parameters are specified in the PortletURL.
+ * Used if for the targeted PortletWindow no render parameters are specified.
+ */
+ private boolean clearParameters;
+
+ public PortletWindowRequestNavigationalState(String windowId)
+ {
+ this.windowId = windowId;
+ }
+
+ public String getWindowId()
+ {
+ return windowId;
+ }
+
+ public boolean isClearParameters()
+ {
+ return clearParameters;
+ }
+
+ public void setClearParameters(boolean ignoreParameters)
+ {
+ this.clearParameters = ignoreParameters;
+ }
+}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowRequestNavigationalStates.java Tue Jul 5 14:55:37 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.state.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.pluto.om.window.PortletWindow;
+
+public class PortletWindowRequestNavigationalStates
+{
+ private String characterEncoding;
+ private Map pwnStates = new HashMap();
+ private PortletWindow maximizedWindow;
+ private PortletWindow actionWindow;
+
+ public PortletWindowRequestNavigationalStates(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public Iterator getWindowIdIterator()
+ {
+ return pwnStates.keySet().iterator();
+ }
+
+ public void removePortletWindowNavigationalState(String windowId)
+ {
+ pwnStates.remove(windowId);
+ }
+
+ public PortletWindowRequestNavigationalState getPortletWindowNavigationalState(String windowId)
+ {
+ return (PortletWindowRequestNavigationalState)pwnStates.get(windowId);
+ }
+
+ public void addPortletWindowNavigationalState(String windowId, PortletWindowRequestNavigationalState pwnState)
+ {
+ pwnStates.put(windowId, pwnState);
+ }
+
+ public PortletWindow getMaximizedWindow()
+ {
+ return maximizedWindow;
+ }
+
+ public void setMaximizedWindow(PortletWindow maximizedWindow)
+ {
+ this.maximizedWindow = maximizedWindow;
+ }
+
+ public PortletWindow getActionWindow()
+ {
+ return actionWindow;
+ }
+ public void setActionWindow(PortletWindow actionWindow)
+ {
+ this.actionWindow = actionWindow;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org