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 ta...@apache.org on 2006/03/28 21:11:05 UTC

svn commit: r389584 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java

Author: taylor
Date: Tue Mar 28 11:11:04 2006
New Revision: 389584

URL: http://svn.apache.org/viewcvs?rev=389584&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-514
Special handling for desktop actions: do not redirect

Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java?rev=389584&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/DesktopPortletContainerImpl.java Tue Mar 28 11:11:04 2006
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerImpl;
+import org.apache.pluto.core.InternalActionResponse;
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.pluto.services.information.DynamicInformationProvider;
+import org.apache.pluto.services.information.InformationProviderAccess;
+import org.apache.pluto.services.information.PortletURLProvider;
+
+/**
+ * Desktop Portlet Container implementation. This implementation does not
+ * redirect, but instead returns back the 'redirect' URL in the response to the
+ * Ajax client for client-side aggregation.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class DesktopPortletContainerImpl extends PortletContainerImpl implements
+        PortletContainer
+{
+
+    /**
+     * This redirect does not redirect, instead returns the redirect URL in the response
+     */
+    protected void redirect(String location, PortletWindow portletWindow,
+            HttpServletRequest servletRequest,
+            HttpServletResponse servletResponse,
+            InternalActionResponse _actionResponse) throws IOException
+    {
+        if (location == null && _actionResponse != null)
+        {
+            DynamicInformationProvider provider = InformationProviderAccess
+                    .getDynamicProvider(servletRequest);
+
+            // TODO: don't send changes in case of exception -> PORTLET:SPEC:17
+
+            PortletMode portletMode = provider.getPortletMode(portletWindow);
+            WindowState windowState = provider.getWindowState(portletWindow);
+
+            // get the changings of this portlet entity that might be set during
+            // action handling
+            // change portlet mode
+            if (_actionResponse.getChangedPortletMode() != null)
+            {
+                portletMode = _actionResponse.getChangedPortletMode();
+                InformationProviderAccess.getDynamicProvider(servletRequest)
+                        .getPortletActionProvider(portletWindow)
+                        .changePortletMode(portletMode);
+            }
+            // change window state
+            if (_actionResponse.getChangedWindowState() != null)
+            {
+                windowState = _actionResponse.getChangedWindowState();
+                InformationProviderAccess.getDynamicProvider(servletRequest)
+                        .getPortletActionProvider(portletWindow)
+                        .changePortletWindowState(windowState);
+            }
+            // get render parameters
+            Map renderParameter = _actionResponse.getRenderParameters();
+
+            PortletURLProvider redirectURL = provider
+                    .getPortletURLProvider(portletWindow);
+
+            if (provider.getPortletMode(portletWindow) != null)
+            {
+                redirectURL.setPortletMode(portletMode);
+            }
+            if (provider.getWindowState(portletWindow) != null)
+            {
+                redirectURL.setWindowState(windowState);
+            }
+            if (servletRequest.isSecure())
+            {
+                redirectURL.setSecure(); // TBD
+            }
+            redirectURL.clearParameters();
+            redirectURL.setParameters(renderParameter);
+
+            location = servletResponse
+                    .encodeRedirectURL(redirectURL.toString());
+        }
+
+        javax.servlet.http.HttpServletResponse redirectResponse = servletResponse;
+        while (redirectResponse instanceof javax.servlet.http.HttpServletResponseWrapper)
+        {
+            redirectResponse = (javax.servlet.http.HttpServletResponse) ((javax.servlet.http.HttpServletResponseWrapper) redirectResponse)
+                    .getResponse();
+        }
+        //redirectResponse.sendRedirect(location);
+        System.out.println("+++ >>>> location is " + location);
+        redirectResponse.getWriter().print(location);
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org