portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: r345682 - in /portals/pluto/trunk: pluto-container/src/main/java/org/apache/pluto/core/ pluto-container/src/main/java/org/apache/pluto/core/impl/ pluto-container/src/resources/properties/org/apache/pluto/core/impl/ pluto-util/src/main/java/...
Date Sat, 19 Nov 2005 20:24:05 GMT
Author: ddewolf
Date: Sat Nov 19 12:23:55 2005
New Revision: 345682

URL: http://svn.apache.org/viewcvs?rev=345682&view=rev
Log:
Resolving Action Parameter/Session issue.  CrossContext dispatched reques (not cached request)
must be used for Portlet backing

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/InternalPortletRequest.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/ActionRequestImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/RenderRequestImpl.java
    portals/pluto/trunk/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/impl/FileSystemInstaller.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/InternalPortletRequest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/InternalPortletRequest.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/InternalPortletRequest.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/InternalPortletRequest.java
Sat Nov 19 12:23:55 2005
@@ -29,6 +29,8 @@
 
     void setPortletContext(PortletContext context);
 
+    void setServiceRequest(HttpServletRequest req);
+
     InternalPortletWindow getInternalPortletWindow();
 
     PortletContainer getPortletContainer();

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
Sat Nov 19 12:23:55 2005
@@ -150,7 +150,7 @@
                 request.getAttribute(Constants.PORTLET_RESPONSE);
 
             pRequest.setPortletContext(portletContext);
-
+            pRequest.setServiceRequest(request);
 
             if (method_id == org.apache.pluto.Constants.METHOD_RENDER) {
                 RenderRequestImpl renderRequest =

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/ActionRequestImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/ActionRequestImpl.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/ActionRequestImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/ActionRequestImpl.java
Sat Nov 19 12:23:55 2005
@@ -58,7 +58,7 @@
      * @see org.apache.pluto.core.InternalActionResponse#getPortletInputStream()
      */
     public InputStream getPortletInputStream() throws java.io.IOException {
-        javax.servlet.http.HttpServletRequest servletRequest = (javax.servlet.http.HttpServletRequest)
super.getRequest();
+        HttpServletRequest servletRequest = (HttpServletRequest) getRequest();
 
         if (servletRequest.getMethod().equals("POST")) {
             String contentType = servletRequest.getContentType();

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
Sat Nov 19 12:23:55 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.pluto.core.impl;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.core.InternalPortletRequest;
 import org.apache.pluto.core.InternalPortletWindow;
@@ -24,32 +26,59 @@
 import org.apache.pluto.descriptors.portlet.SupportsDD;
 import org.apache.pluto.util.Enumerator;
 import org.apache.pluto.util.NamespaceMapper;
+import org.apache.pluto.util.StringManager;
 import org.apache.pluto.util.StringUtils;
 import org.apache.pluto.util.impl.NamespaceMapperImpl;
 
-import javax.portlet.*;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpSession;
 import java.io.BufferedReader;
-import java.util.*;
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import java.util.Locale;
+import java.security.Principal;
 
 /**
  * Abstract <code>javax.portlet.PortletRequest</code> implementation.
  * This class also implements InternalPortletRequest.
- * 
+ *
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  */
 public abstract class PortletRequestImpl extends HttpServletRequestWrapper
-implements PortletRequest, InternalPortletRequest {
-	
-	// Private Member Variables ------------------------------------------------
-	
-    /** The parent container within which this request was created. */
+        implements PortletRequest, InternalPortletRequest {
+
+    private static final StringManager EXCEPTIONS =
+            StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
+
+    private static final Log LOG =
+            LogFactory.getLog(PortletRequestImpl.class);
+
+    /**
+     * The parent container within which this request was created.
+     */
     private PortletContainer container = null;
 
-    /** The portlet window which is the target of this portlet request. */
+    /**
+     * The portlet window which is the target of this portlet request.
+     */
     private InternalPortletWindow internalPortletWindow = null;
 
     /**
@@ -58,18 +87,26 @@
      */
     private PortletContext portletContext = null;
 
-    /** The PortalContext within which this request is occuring. */
+    /**
+     * The PortalContext within which this request is occuring.
+     */
     private PortalContext portalContext = null;
 
-    /** Holds the portlet session. */
+    /**
+     * Holds the portlet session.
+     */
     private PortletSession portletSession = null;
 
-    /** Response content types. */
+    /**
+     * Response content types.
+     */
     private Vector contentTypes = null;
 
     private NamespaceMapper mapper = new NamespaceMapperImpl();
 
-    /** Flag indicating if the HTTP-Body has been accessed. */
+    /**
+     * Flag indicating if the HTTP-Body has been accessed.
+     */
     private boolean bodyAccessed = false;
 
     /**
@@ -77,21 +114,21 @@
      * FIXME: the included flag should only exist for a render request.
      */
     private boolean included = false;
-    
-    
+
     // Constructors ------------------------------------------------------------
-    
+
     public PortletRequestImpl(InternalPortletRequest internalPortletRequest) {
         this(internalPortletRequest.getPortletContainer(),
-             internalPortletRequest.getInternalPortletWindow(),
-             internalPortletRequest.getHttpServletRequest());
+                internalPortletRequest.getInternalPortletWindow(),
+                internalPortletRequest.getHttpServletRequest());
     }
-    
+
     /**
      * Create a PortletRequestImpl instance.
-     * @param container  the portlet container.
-     * @param internalPortletWindow  the internal portlet window.
-     * @param servletRequest  the underlying servlet request.
+     *
+     * @param container             the portlet container.
+     * @param internalPortletWindow the internal portlet window.
+     * @param servletRequest        the underlying servlet request.
      */
     public PortletRequestImpl(PortletContainer container,
                               InternalPortletWindow internalPortletWindow,
@@ -102,12 +139,12 @@
         this.portalContext = container.getContainerServices().getPortalContext();
     }
 
-    
     // javax.portlet.PortletRequest Impl ---------------------------------------
-    
+
     /**
      * Determine whether or not the specified WindowState is allowed for this
      * portlet.
+     *
      * @param state the state in question
      * @return true if the state is allowed.
      */
@@ -115,7 +152,7 @@
         Enumeration supportedStates = portalContext.getSupportedWindowStates();
         while (supportedStates.hasMoreElements()) {
             if (supportedStates.nextElement().toString().equals(
-            		state.toString())) {
+                    state.toString())) {
                 return true;
             }
         }
@@ -125,7 +162,7 @@
 
     public boolean isPortletModeAllowed(PortletMode mode) {
         return (isPortletModeAllowedByPortlet(mode)
-        		&& isPortletModeAllowedByPortal(mode));
+                && isPortletModeAllowedByPortal(mode));
     }
 
     public PortletMode getPortletMode() {
@@ -144,41 +181,47 @@
     }
 
     public PortletSession getPortletSession(boolean create) {
-        // check if the session was invalidated.
-        HttpSession httpSession = this.getHttpServletRequest()
-        	.getSession(false);
-
-        if (portletSession != null && httpSession == null) {
-            portletSession = null;
-        } else if (httpSession != null) {
-            create = true;
-        }
-
-        if (create && portletSession == null) {
-            httpSession = this.getHttpServletRequest().getSession(create);
-            if (httpSession != null) {
-                portletSession = new PortletSessionImpl(portletContext,
-                                                        internalPortletWindow,
-                                                        httpSession);
-            }
+        //
+        // It is critical that we don't retrieve the
+        //    portlet session until the cross context
+        //    dispatch has been completed.  If we do
+        //    then we risk having a cached version which
+        //    is invalid for the context within which it
+        //    exists.
+        //
+        if (portletContext == null) {
+            throw new IllegalStateException(
+                    EXCEPTIONS.getString("error.session.illegalState")
+            );
         }
 
+        HttpSession http = getHttpServletRequest().getSession(create);
+        if (http != null && portletSession == null) {
+            portletSession = new PortletSessionImpl(
+                    portletContext,
+                    internalPortletWindow,
+                    http
+            );
+        }
         return portletSession;
     }
 
     public String getProperty(String name) throws IllegalArgumentException {
         if (name == null) {
-            throw new IllegalArgumentException("Property name cannot be null");
+            throw new IllegalArgumentException(
+                EXCEPTIONS.getString("error.propertyName.null")
+            );
         }
 
-        // Get property value from request header.
         String prop = this.getHttpServletRequest().getHeader(name);
         if (prop == null) {
-            // Get property value from PropertyManager
             Map propertyMap = container.getContainerServices()
-                .getPortalCallbackService()
-                .getRequestProperties(getHttpServletRequest(),
-                                      internalPortletWindow);
+                    .getPortalCallbackService()
+                    .getRequestProperties(
+                        getHttpServletRequest(),
+                        internalPortletWindow
+                    );
+
             if (propertyMap != null) {
                 String[] properties = (String[]) propertyMap.get(name);
                 if (properties != null && properties.length > 0) {
@@ -205,8 +248,8 @@
 
         // get properties from PropertyManager
         Map map = container.getContainerServices()
-            .getPortalCallbackService()
-            .getRequestProperties(getHttpServletRequest(), internalPortletWindow);
+                .getPortalCallbackService()
+                .getRequestProperties(getHttpServletRequest(), internalPortletWindow);
 
         if (map != null) {
             String[] properties = (String[]) map.get(name);
@@ -223,13 +266,13 @@
     }
 
     public Enumeration getPropertyNames() {
-        Set v = new HashSet();           
+        Set v = new HashSet();
 
         // get properties from PropertyManager
         Map map = container.getContainerServices()
                 .getPortalCallbackService()
                 .getRequestProperties(getHttpServletRequest(), internalPortletWindow);
-        
+
         if (map != null) {
             v.addAll(map.keySet());
         }
@@ -262,7 +305,7 @@
         return this.getHttpServletRequest().getRemoteUser();
     }
 
-    public java.security.Principal getUserPrincipal() {
+    public Principal getUserPrincipal() {
         return this.getHttpServletRequest().getUserPrincipal();
     }
 
@@ -272,6 +315,7 @@
      * within the deployment descriptor. If no mapping is available, then, and
      * only then, do we check use the actual role name specified against the web
      * application deployment descriptor.
+     *
      * @param roleName the name of the role
      * @return true if it is determined the user has the given role.
      */
@@ -281,8 +325,8 @@
 
         SecurityRoleRefDD ref = null;
         Iterator refs = def.getSecurityRoleRefs().iterator();
-        while(refs.hasNext()) {
-            SecurityRoleRefDD r = (SecurityRoleRefDD)refs.next();
+        while (refs.hasNext()) {
+            SecurityRoleRefDD r = (SecurityRoleRefDD) refs.next();
             if (r.getRoleName().equals(roleName)) {
                 ref = r;
                 break;
@@ -301,21 +345,27 @@
 
     public Object getAttribute(String name) {
         if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
+            throw new IllegalArgumentException(
+                    EXCEPTIONS.getString("error.attributeName.null")
+            );
         }
 
-        Object attribute = this.getHttpServletRequest().getAttribute(
-            mapper.encode(internalPortletWindow.getId(), name));
+        String encodedName = isNameReserved(name) ?
+                name :
+                mapper.encode(internalPortletWindow.getId(), name);
+
+        Object attribute = getHttpServletRequest()
+                .getAttribute(encodedName);
 
         if (attribute == null) {
-            attribute = this.getHttpServletRequest().getAttribute(name);
+            attribute = getHttpServletRequest().getAttribute(name);
         }
         return attribute;
     }
 
     public Enumeration getAttributeNames() {
         Enumeration attributes = this.getHttpServletRequest()
-            .getAttributeNames();
+                .getAttributeNames();
 
         Vector portletAttributes = new Vector();
 
@@ -323,7 +373,7 @@
             String attribute = (String) attributes.nextElement();
 
             String portletAttribute = mapper.decode(
-                internalPortletWindow.getId(), attribute);
+                    internalPortletWindow.getId(), attribute);
 
             if (portletAttribute != null) { // it is in the portlet's namespace
                 portletAttributes.add(portletAttribute);
@@ -348,7 +398,7 @@
         return null;
     }
 
-    public java.util.Enumeration getParameterNames() {
+    public Enumeration getParameterNames() {
         bodyAccessed = true;
 
         Map parameters = this.getHttpServletRequest().getParameterMap();
@@ -357,14 +407,16 @@
 
     public String[] getParameterValues(String name) {
         if (name == null) {
-            throw new IllegalArgumentException("Parameter name == null");
+            throw new IllegalArgumentException(
+                EXCEPTIONS.getString("error.null", "Parameter Name ")
+            );
         }
 
         bodyAccessed = true;
 
         String[] values = (String[]) this.getHttpServletRequest()
-            .getParameterMap()
-            .get(name);
+                .getParameterMap()
+                .get(name);
         if (values != null) {
             values = StringUtils.copy(values);
         }
@@ -374,42 +426,41 @@
     public Map getParameterMap() {
         bodyAccessed = true;
         return StringUtils.copyParameters(
-            this.getHttpServletRequest().getParameterMap());
+                this.getHttpServletRequest().getParameterMap());
     }
 
     public boolean isSecure() {
         return this.getHttpServletRequest().isSecure();
     }
 
-    public void setAttribute(String name, Object o) {
+    public void setAttribute(String name, Object value) {
         if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
+            throw new IllegalArgumentException(
+                    EXCEPTIONS.getString("error.null", "Attribute Name ")
+            );
         }
 
-        if (o == null) {
-            this.removeAttribute(name);
-        } else if (isNameReserved(name)) {
-            // Reserved names go directly in the underlying request
-            getHttpServletRequest().setAttribute(name, o);
+        String encodedName = isNameReserved(name) ?
+                name : mapper.encode(internalPortletWindow.getId(), name);
+
+        if (value == null) {
+            removeAttribute(name);
         } else {
-            this.getHttpServletRequest().setAttribute(
-                mapper.encode(internalPortletWindow.getId(), name), o);
+            getHttpServletRequest().setAttribute(encodedName, value);
         }
     }
 
     public void removeAttribute(String name) {
         if (name == null) {
-            throw new IllegalArgumentException("Attribute name == null");
+            throw new IllegalArgumentException(
+                EXCEPTIONS.getString("error.null", "Attribute Name ")
+            );
         }
-        if (isNameReserved(name)) {
-            // Reserved names go directly in the underlying request.
-            getHttpServletRequest().removeAttribute(name);
-        } else {
 
-            this.getHttpServletRequest().
-                removeAttribute(
-                    mapper.encode(internalPortletWindow.getId(), name));
-        }
+        String encodedName = isNameReserved(name) ?
+                name : mapper.encode(internalPortletWindow.getId(), name);
+
+        getHttpServletRequest().removeAttribute(encodedName);
     }
 
     public String getRequestedSessionId() {
@@ -422,29 +473,29 @@
 
     public String getResponseContentType() {
         Enumeration enumeration = getResponseContentTypes();
-        while(enumeration.hasMoreElements()) {
-            return (String)enumeration.nextElement();
+        while (enumeration.hasMoreElements()) {
+            return (String) enumeration.nextElement();
         }
         return "text/html";
     }
 
     public Enumeration getResponseContentTypes() {
-        if(contentTypes == null) {
+        if (contentTypes == null) {
             contentTypes = new Vector();
             PortletDD dd = internalPortletWindow.getPortletEntity().getPortletDefinition();
             Iterator supports = dd.getSupports().iterator();
-            while(supports.hasNext()) {
-                SupportsDD sup = (SupportsDD)supports.next();
+            while (supports.hasNext()) {
+                SupportsDD sup = (SupportsDD) supports.next();
                 contentTypes.add(sup.getMimeType());
             }
-            if(contentTypes.size() < 1) {
+            if (contentTypes.size() < 1) {
                 contentTypes.add("text/html");
             }
         }
         return contentTypes.elements();
     }
 
-    public java.util.Locale getLocale() {
+    public Locale getLocale() {
         return this.getHttpServletRequest().getLocale();
     }
 
@@ -520,7 +571,7 @@
     }
 
     public BufferedReader getReader()
-        throws java.io.UnsupportedEncodingException, java.io.IOException {
+            throws UnsupportedEncodingException, java.io.IOException {
         if (included) {
             return null;
         } else {
@@ -534,16 +585,16 @@
 
     public String getPathInfo() {
         String attr = (String) super.getAttribute(
-            "javax.servlet.include.path_info");
+                "javax.servlet.include.path_info");
         return (attr != null) ? attr
-               : super.getPathInfo();
+                : super.getPathInfo();
     }
 
     public String getQueryString() {
         String attr = (String) super.getAttribute(
-            "javax.servlet.include.query_string");
+                "javax.servlet.include.query_string");
         return (attr != null) ? attr
-               : super.getQueryString();
+                : super.getQueryString();
     }
 
     public String getPathTranslated() {
@@ -552,9 +603,9 @@
 
     public String getRequestURI() {
         String attr = (String) super.getAttribute(
-            "javax.servlet.include.request_uri");
+                "javax.servlet.include.request_uri");
         return (attr != null) ? attr
-               : super.getRequestURI();
+                : super.getRequestURI();
     }
 
     public StringBuffer getRequestURL() {
@@ -563,12 +614,11 @@
 
     public String getServletPath() {
         String attr = (String) super.getAttribute(
-            "javax.servlet.include.servlet_path");
+                "javax.servlet.include.servlet_path");
         return (attr != null) ? attr
-               : super.getServletPath();
+                : super.getServletPath();
     }
 
-
     //
     //
     // @todo WHY? Do we return null to these emthods?
@@ -592,31 +642,27 @@
     }
 
     public void setCharacterEncoding(String env)
-        throws java.io.UnsupportedEncodingException {
+            throws UnsupportedEncodingException {
         if (bodyAccessed) {
             throw new IllegalStateException(
-                "This method must not be called after the HTTP-Body was accessed !");
+                    "This method must not be called after the HTTP-Body was accessed !");
         }
 
         getHttpServletRequest().setCharacterEncoding(env);
     }
 
-    public javax.servlet.ServletInputStream getInputStream()
-        throws java.io.IOException {
+    public ServletInputStream getInputStream()
+    throws IOException {
         if (included) {
             return null;
         } else {
-            // the super class will ensure that a IllegalStateException is thrown if getReader()
was called earlier
-            javax.servlet.ServletInputStream stream = getHttpServletRequest()
-                .getInputStream();
-
+            ServletInputStream stream = getHttpServletRequest().getInputStream();
             bodyAccessed = true;
-
             return stream;
         }
     }
 
-    public javax.servlet.RequestDispatcher getRequestDispatcher(String path) {
+    public RequestDispatcher getRequestDispatcher(String path) {
         return this.getHttpServletRequest().getRequestDispatcher(path);
     }
 
@@ -626,6 +672,10 @@
         this.portletContext = portletContext;
     }
 
+    public void setServiceRequest(HttpServletRequest req) {
+        setRequest(req);
+    }
+
     public PortletContainer getContainer() {
         return container;
     }
@@ -636,13 +686,13 @@
 
     private boolean isPortletModeAllowedByPortlet(PortletMode mode) {
         PortletDD dd = internalPortletWindow.getPortletEntity()
-            .getPortletDefinition();
+                .getPortletDefinition();
 
         Iterator mimes = dd.getSupports().iterator();
-        while(mimes.hasNext()) {
-            Iterator modes = ((SupportsDD)mimes.next()).getPortletModes().iterator();
-            while(modes.hasNext()) {
-                String m = (String)modes.next();
+        while (mimes.hasNext()) {
+            Iterator modes = ((SupportsDD) mimes.next()).getPortletModes().iterator();
+            while (modes.hasNext()) {
+                String m = (String) modes.next();
                 if (m.equals(mode.toString())) {
                     return true;
                 }
@@ -655,7 +705,7 @@
         Enumeration supportedModes = portalContext.getSupportedPortletModes();
         while (supportedModes.hasMoreElements()) {
             if (supportedModes.nextElement().toString().equals(
-                (mode.toString()))) {
+                    (mode.toString()))) {
                 return true;
             }
         }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
Sat Nov 19 12:23:55 2005
@@ -26,15 +26,26 @@
 import javax.portlet.PortletSession;
 import javax.portlet.PortletSessionUtil;
 import javax.servlet.http.HttpSessionContext;
+import javax.servlet.http.HttpSession;
 import javax.servlet.ServletContext;
 
 import org.apache.pluto.core.InternalPortletWindow;
+import org.apache.pluto.util.StringManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class PortletSessionImpl implements PortletSession,
-                                           javax.servlet.http.HttpSession {
+                                           HttpSession {
+
     private final int DEFAULT_SCOPE = PortletSession.PORTLET_SCOPE;
 
-    private javax.servlet.http.HttpSession httpSession;
+    private static final Log LOG =
+        LogFactory.getLog(PortletSessionImpl.class);
+
+    private static final StringManager EXCEPTIONS =
+        StringManager.getManager(PortletSessionImpl.class.getPackage().getName());
+
+    private HttpSession httpSession;
 
     private PortletContext portletContext = null;
 
@@ -42,19 +53,18 @@
 
     public PortletSessionImpl(PortletContext context,
                               InternalPortletWindow internalPortletWindow,
-                              javax.servlet.http.HttpSession httpSession) {
+                              HttpSession httpSession) {
         this.portletContext = context;
         this.internalPortletWindow = internalPortletWindow;
         this.httpSession = httpSession;
     }
 
-    // javax.portlet.PortletSession and javax.servlet.http.HttpSession implementation -------------
     public Object getAttribute(String name) {
-        return this.getAttribute(name, DEFAULT_SCOPE);
+        return getAttribute(name, DEFAULT_SCOPE);
     }
 
     public Enumeration getAttributeNames() {
-        return this.getAttributeNames(DEFAULT_SCOPE);
+        return getAttributeNames(DEFAULT_SCOPE);
     }
 
     public long getCreationTime() throws java.lang.IllegalStateException {
@@ -86,60 +96,68 @@
     }
 
     public void setAttribute(String name, Object value) {
-        this.setAttribute(name, value, DEFAULT_SCOPE);
+        setAttribute(name, value, DEFAULT_SCOPE);
     }
 
     public void setMaxInactiveInterval(int interval) {
         httpSession.setMaxInactiveInterval(interval);
     }
-    // --------------------------------------------------------------------------------------------
 
-    // javax.portlet.PortletSession implementation ------------------------------------------------
-    public java.lang.Object getAttribute(String name, int scope)
-        throws java.lang.IllegalStateException {
+
+//
+//
+//
+    public Object getAttribute(String name, int scope)
+        throws IllegalStateException {
+
         if (name == null) {
-            throw new IllegalArgumentException("name must not be null");
+            throw new IllegalArgumentException("error.attributeName.null");
         }
+
         if (scope == PortletSession.APPLICATION_SCOPE) {
             return httpSession.getAttribute(name);
-        } else {
-            Object attribute = httpSession.getAttribute(
-                "javax.portlet.p." + internalPortletWindow.getId() + "?" + name);
+        }
+
+        else {
+            String key = createPortletScopedId(name);
+            Object attribute = httpSession.getAttribute(key);
+            if(LOG.isDebugEnabled()) {
+                LOG.debug("Key = "+key);
+                LOG.debug("Value = "+attribute);
+                Enumeration enumer = httpSession.getAttributeNames();
+                while(enumer.hasMoreElements()) {
+                    LOG.debug("All has: "+enumer.nextElement());
+                }
+            }
+
             if (attribute == null) {
-                // not sure, if this should be done for all attributes or only javax.servlet.
-                attribute = httpSession.getAttribute(name);
+               attribute = httpSession.getAttribute(name);
             }
             return attribute;
         }
     }
 
-    public java.util.Enumeration getAttributeNames(int scope) {
+    public Enumeration getAttributeNames(int scope) {
         if (scope == PortletSession.APPLICATION_SCOPE) {
             return httpSession.getAttributeNames();
         } else {
             Enumeration attributes = httpSession.getAttributeNames();
-
             Vector portletAttributes = new Vector();
 
-            /* Fix that ONLY attributes of PORTLET_SCOPE are returned. */
-            int prefix_length = "javax.portlet.p.".length();
-            String portletWindowId = internalPortletWindow.getId().toString();
-
-            while (attributes.hasMoreElements()) {
+            while(attributes.hasMoreElements()) {
                 String attribute = (String) attributes.nextElement();
+                int scp =  PortletSessionUtil.decodeScope(attribute);
+                if(LOG.isDebugEnabled()) {
+                    LOG.debug("Found attribute: "+attribute);
+                    LOG.debug("Scope Determined Portlet?" + (scp == PortletSession.PORTLET_SCOPE));
+                }
 
-                int attributeScope = PortletSessionUtil.decodeScope(attribute);
-
-                if (attributeScope == PortletSession.PORTLET_SCOPE &&
-                    attribute.startsWith(portletWindowId, prefix_length)) {
-                    String portletAttribute = PortletSessionUtil.decodeAttributeName(
-                        attribute);
-
-                    if (portletAttribute != null) { // it is in the portlet's namespace
-                        portletAttributes.add(portletAttribute);
-                    }
+                if(scp == PortletSession.PORTLET_SCOPE) {
+                    portletAttributes.add(
+                        PortletSessionUtil.decodeAttributeName(attribute)
+                    );
                 }
-            }
+           }
             return portletAttributes.elements();
         }
     }
@@ -152,23 +170,34 @@
         if (scope == PortletSession.APPLICATION_SCOPE) {
             httpSession.removeAttribute(name);
         } else {
-            httpSession.removeAttribute(
-                "javax.portlet.p." + internalPortletWindow.getId() + "?" + name);
+            httpSession.removeAttribute(createPortletScopedId(name));
         }
     }
 
     public void setAttribute(java.lang.String name, java.lang.Object value,
                              int scope) throws IllegalStateException {
         if (name == null) {
-            throw new IllegalArgumentException("name must not be null");
+            throw new IllegalArgumentException(
+                EXCEPTIONS.getString("error.attributeName.null")
+            );
         }
+
         if (scope == PortletSession.APPLICATION_SCOPE) {
             httpSession.setAttribute(name, value);
-        } else {
-            httpSession.setAttribute(
-                "javax.portlet.p." + internalPortletWindow.getId() + "?" + name,
-                value);
         }
+        else {
+            httpSession.setAttribute(createPortletScopedId(name),  value);
+        }
+    }
+
+    private StringBuffer createPrefix() {
+        StringBuffer sb = new StringBuffer("javax.portlet.p.");
+        sb.append(internalPortletWindow.getId()).append("?");
+        return sb;
+    }
+
+    private String createPortletScopedId(String name) {
+       return createPrefix().append(name).toString();
     }
 
     public PortletContext getPortletContext() {

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/RenderRequestImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/RenderRequestImpl.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/RenderRequestImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/RenderRequestImpl.java
Sat Nov 19 12:23:55 2005
@@ -13,9 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/* 
-
- */
 
 package org.apache.pluto.core.impl;
 

Modified: portals/pluto/trunk/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties
(original)
+++ portals/pluto/trunk/pluto-container/src/resources/properties/org/apache/pluto/core/impl/LocalStrings.properties
Sat Nov 19 12:23:55 2005
@@ -14,8 +14,11 @@
 #
 ############################################
 
+error.null={0} may not be null
+## Replace the following with the above
 error.contenttype.null=Content Type Not Set
 error.attributeName.null=Attribute Name may not be null.
+error.propertyName.null=Property Name may not be null.
 
 error.session.illegalState=Session may not be retrieved before cross context portlet invocation
 

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/impl/FileSystemInstaller.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/impl/FileSystemInstaller.java?rev=345682&r1=345681&r2=345682&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/impl/FileSystemInstaller.java
(original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/impl/FileSystemInstaller.java
Sat Nov 19 12:23:55 2005
@@ -21,11 +21,8 @@
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Iterator;
-import java.util.Map;
-import java.util.List;
 import java.util.Collection;
 
 /**
@@ -44,6 +41,16 @@
         }
     }
 
+    protected void removeFilesFromDirectory(Collection dependencies, File destination)
+            throws IOException {
+        Iterator it = dependencies.iterator();
+        while(it.hasNext()) {
+            File from = (File)it.next();
+            File delete = new File(destination, from.getName());
+            delete.delete();
+        }
+    }
+
     protected void copyFileToDirectory(File file, File destination)
     throws IOException {
         FileUtils.copyFileToDirectory(file, destination);
@@ -100,8 +107,29 @@
 
     protected abstract File getWebAppDir(InstallationConfig config);
 
-    public void uninstall(InstallationConfig config) {
-    }
+    public void uninstall(InstallationConfig config)
+    throws ManagementException {
+        File endorsedDir = getEndorsedDir(config);
+        File sharedDir = getSharedDir(config);
+        File domainDir = getWebAppDir(config);
+
+        endorsedDir.mkdirs();
+        sharedDir.mkdirs();
+        domainDir.mkdirs();
+
+        try {
+            removeFilesFromDirectory(config.getEndorsedDependencies(), endorsedDir);
+            removeFilesFromDirectory(config.getSharedDependencies(), sharedDir);
+            removeFilesFromDirectory(config.getPortletApplications().values(),  domainDir);
+
+            File delete = new File(domainDir, config.getPortalApplication().getName());
+            delete.delete();
+        }
+        catch(IOException io) {
+            throw new ManagementException("Unable to remove files. ", io, config.getInstallationDirectory());
+        }
+
+   }
 
     public abstract boolean isValidInstallationDirectory(File installDir);
 }



Mime
View raw message