You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ed...@apache.org on 2008/07/23 19:41:30 UTC

svn commit: r679137 - in /portals/pluto/branches/pluto-1.1.x: pluto-container/src/main/java/org/apache/pluto/ pluto-container/src/main/java/org/apache/pluto/core/ pluto-container/src/main/java/org/apache/pluto/internal/impl/ pluto-container/src/main/ja...

Author: edalquist
Date: Wed Jul 23 10:41:30 2008
New Revision: 679137

URL: http://svn.apache.org/viewvc?rev=679137&view=rev
Log:
PLUTO-489 refactor request attribute handling into a optional spi

Added:
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java   (with props)
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java   (with props)
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java   (with props)
Modified:
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
    portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java
    portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java

Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java?rev=679137&r1=679136&r2=679137&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java Wed Jul 23 10:41:30 2008
@@ -22,6 +22,7 @@
 import org.apache.pluto.spi.optional.PortletRegistryService;
 import org.apache.pluto.spi.optional.PortletInfoService;
 import org.apache.pluto.spi.optional.PortalAdministrationService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.apache.pluto.spi.optional.UserInfoService;
 
 /**
@@ -94,5 +95,13 @@
      * @return user info service
      */
     UserInfoService getUserInfoService();
+    
+    /**
+     * Returns the request attribute service implementation used by the
+     * container.
+     * 
+     * @return request attribute service
+     */
+    RequestAttributeService getRequestAttributeService();    
 
 }

Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java?rev=679137&r1=679136&r2=679137&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java Wed Jul 23 10:41:30 2008
@@ -17,12 +17,13 @@
 package org.apache.pluto.core;
 
 import org.apache.pluto.OptionalContainerServices;
-import org.apache.pluto.spi.optional.PortletPreferencesService;
+import org.apache.pluto.spi.optional.PortalAdministrationService;
 import org.apache.pluto.spi.optional.PortletEnvironmentService;
+import org.apache.pluto.spi.optional.PortletInfoService;
 import org.apache.pluto.spi.optional.PortletInvokerService;
+import org.apache.pluto.spi.optional.PortletPreferencesService;
 import org.apache.pluto.spi.optional.PortletRegistryService;
-import org.apache.pluto.spi.optional.PortletInfoService;
-import org.apache.pluto.spi.optional.PortalAdministrationService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.apache.pluto.spi.optional.UserInfoService;
 
 /**
@@ -40,6 +41,7 @@
     private PortletInfoService portletInfoService;
     private PortalAdministrationService portalAdministrationService;
     private UserInfoService userInfoService;
+    private RequestAttributeService requestAttributeService;
 
 
     /**
@@ -54,6 +56,7 @@
         portletInfoService = new DefaultPortletInfoService();
         portalAdministrationService = new DefaultPortalAdministrationService();
         userInfoService = new DefaultUserInfoService();
+        requestAttributeService = new DefaultRequestAttributeService(this);
     }
 
     /**
@@ -92,9 +95,13 @@
             portalAdministrationService = root.getPortalAdministrationService();
         }
 
-		 if(root.getUserInfoService() != null) {
-			 userInfoService = root.getUserInfoService();
-		 }
+		if(root.getUserInfoService() != null) {
+		    userInfoService = root.getUserInfoService();
+		}
+
+        if(root.getRequestAttributeService() != null) {
+            requestAttributeService = root.getRequestAttributeService();
+        }
 
     }
 
@@ -130,5 +137,8 @@
         return userInfoService;
     }
 
+    public RequestAttributeService getRequestAttributeService() {
+        return requestAttributeService;
+    }
 }
 

Added: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java?rev=679137&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java Wed Jul 23 10:41:30 2008
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.pluto.core;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.portlet.PortletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.OptionalContainerServices;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.PortletWindowID;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.UserAttributeDD;
+import org.apache.pluto.spi.optional.PortletRegistryService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
+import org.apache.pluto.spi.optional.UserInfoService;
+import org.apache.pluto.util.NamespaceMapper;
+import org.apache.pluto.util.impl.NamespaceMapperImpl;
+
+/**
+ * Delegates request attribute storage and retrieval to the passed HttpServletRequest. Also includes logic for retrieving
+ * and filtering the {@link PortletRequest#USER_INFO} Map in {@link #createUserInfoMap(PortletRequest, PortletWindow)}
+ * 
+ * @author Eric Dalquist
+ * @version $Revision$
+ */
+public class DefaultRequestAttributeService implements RequestAttributeService {
+    private static final Log LOG = LogFactory.getLog(DefaultRequestAttributeService.class);
+
+    
+    private final NamespaceMapper mapper = new NamespaceMapperImpl();
+
+    private OptionalContainerServices optionalContainerServices;
+    
+    public DefaultRequestAttributeService() {
+    }
+    
+    public DefaultRequestAttributeService(OptionalContainerServices optionalContainerServices) {
+        this.optionalContainerServices = optionalContainerServices;
+    }
+    
+    public OptionalContainerServices getOptionalContainerServices() {
+        return optionalContainerServices;
+    }
+    public void setOptionalContainerServices(OptionalContainerServices optionalContainerServices) {
+        this.optionalContainerServices = optionalContainerServices;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.spi.optional.RequestAttributeService#getAttribute(javax.portlet.PortletRequest, javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow, java.lang.String)
+     */
+    public Object getAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name) {
+        if (PortletRequest.USER_INFO.equals(name)) {
+            return this.createUserInfoMap(portletRequest, portletWindow);
+        }
+        
+        final String encodedName = this.encodeAttributeName(portletWindow, name);
+
+        final Object attribute = httpServletRequest.getAttribute(encodedName);
+        if (attribute != null) {
+            return attribute;
+        }
+        
+        return httpServletRequest.getAttribute(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.spi.optional.RequestAttributeService#getAttributeNames(javax.portlet.PortletRequest, javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow)
+     */
+    public Enumeration getAttributeNames(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow) {
+        final Enumeration attributes = httpServletRequest.getAttributeNames();
+
+        final Vector portletAttributes = new Vector();
+        while (attributes.hasMoreElements()) {
+            final String attribute = (String) attributes.nextElement();
+
+            final String portletAttribute;
+            if (this.isNameReserved(attribute)) {
+                portletAttribute = attribute;
+            }
+            else {
+                final PortletWindowID portletWindowId = portletWindow.getId();
+                portletAttribute = this.mapper.decode(portletWindowId, attribute);
+            }
+
+            if (portletAttribute != null) { // it is in the portlet's namespace
+                portletAttributes.add(portletAttribute);
+            }
+        }
+        
+        //TODO should PortletRequest.USER_INFO be added?
+
+        return portletAttributes.elements();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.spi.optional.RequestAttributeService#removeAttribute(javax.portlet.PortletRequest, javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow, java.lang.String)
+     */
+    public void removeAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name) {
+        final String encodedName = this.encodeAttributeName(portletWindow, name);
+        
+        httpServletRequest.removeAttribute(encodedName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.spi.optional.RequestAttributeService#setAttribute(javax.portlet.PortletRequest, javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow, java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name, Object value) {
+        final String encodedName = this.encodeAttributeName(portletWindow, name);
+        
+        if (value == null) {
+            httpServletRequest.removeAttribute(name);
+        }
+        else {
+            httpServletRequest.setAttribute(encodedName, value);
+        }
+    }
+
+    /**
+     * Is this attribute name a reserved name (by the J2EE spec)?. Reserved
+     * names begin with "java." or "javax.".
+     *
+     * @return true if the name is reserved.
+     */
+    protected boolean isNameReserved(String name) {
+        return name.startsWith("java.") || name.startsWith("javax.");
+    }
+
+    /**
+     * Encodes the attribute name using the portlet window id if it is not reserved 
+     */
+    protected String encodeAttributeName(PortletWindow portletWindow, String name) {
+        final String encodedName;
+        if (this.isNameReserved(name)) {
+            encodedName = name;
+        }
+        else {
+            final PortletWindowID portletWindowId = portletWindow.getId();
+            encodedName = this.mapper.encode(portletWindowId, name);
+        }
+        return encodedName;
+    }
+
+    /**
+     * Retrieves the UserInfoService from the OptionalContainerServices, gets the user-info Map
+     * and fitlers it for the attributes in the portlet descriptor.
+     */
+    protected Map createUserInfoMap(PortletRequest portletRequest, PortletWindow portletWindow) {
+        final Map userInfoMap = new HashMap();
+        try {
+            final UserInfoService userInfoService = this.optionalContainerServices.getUserInfoService();
+
+            //PLUTO-388 fix:
+            //The PortletWindow is currently ignored in the implementing class
+            // See: org.apache.pluto.core.DefaultUserInfoService
+            final Map allMap = userInfoService.getUserInfo(portletRequest, portletWindow);
+
+            //PLUTO-477 null attribute maps are ok
+            if (null == allMap) {
+                return null;
+            }
+
+            final PortletRegistryService portletRegistryService = optionalContainerServices.getPortletRegistryService();
+            final PortletAppDD dd = portletRegistryService.getPortletApplicationDescriptor(portletWindow.getContextPath());
+
+            final List mappedUserAttributes = dd.getUserAttributes();
+            for (final Iterator mappedAttrItr = mappedUserAttributes.iterator(); mappedAttrItr.hasNext(); ) {
+                final UserAttributeDD userAttrDD = (UserAttributeDD) mappedAttrItr.next();
+                final String mappedName = userAttrDD.getName();
+                final Object value = allMap.get(mappedName);
+                if (value != null) {
+                    userInfoMap.put(mappedName, value);
+                }
+            }
+        }
+        catch (PortletContainerException e) {
+            LOG.warn("Unable to retrieve user attribute map for user " + portletRequest.getRemoteUser() + ".  Returning null.");
+            return null;
+        }
+
+        return Collections.unmodifiableMap(userInfoMap);
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=679137&r1=679136&r2=679137&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java Wed Jul 23 10:41:30 2008
@@ -22,7 +22,6 @@
 import java.security.Principal;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Locale;
@@ -46,23 +45,17 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.OptionalContainerServices;
 import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.descriptors.common.SecurityRoleRefDD;
-import org.apache.pluto.descriptors.portlet.PortletAppDD;
 import org.apache.pluto.descriptors.portlet.PortletDD;
 import org.apache.pluto.descriptors.portlet.SupportsDD;
-import org.apache.pluto.descriptors.portlet.UserAttributeDD;
 import org.apache.pluto.internal.InternalPortletRequest;
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.internal.PortletEntity;
-import org.apache.pluto.spi.optional.PortletRegistryService;
-import org.apache.pluto.spi.optional.UserInfoService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.apache.pluto.util.ArgumentUtility;
 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;
 
 /**
  * Abstract <code>javax.portlet.PortletRequest</code> implementation.
@@ -114,11 +107,6 @@
     private Vector contentTypes;
 
     /**
-     * TODO: javadoc
-     */
-    private final NamespaceMapper mapper = new NamespaceMapperImpl();
-
-    /**
      * FIXME: do we really need this?
      * Flag indicating if the HTTP-Body has been accessed.
      */
@@ -398,77 +386,15 @@
     public Object getAttribute(String name) {
         ArgumentUtility.validateNotNull("attributeName", name);
 
-        if (PortletRequest.USER_INFO.equals(name)) {
-            return createUserInfoMap();
-        }
-
-        String encodedName = isNameReserved(name) ?
-            name :
-            mapper.encode(internalPortletWindow.getId(), name);
-
-        Object attribute = getHttpServletRequest()
-            .getAttribute(encodedName);
-
-        if (attribute == null) {
-            attribute = getHttpServletRequest().getAttribute(name);
-        }
-        return attribute;
+        final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
+        final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
+        return requestAttributeService.getAttribute(this, this.getHttpServletRequest(), this.internalPortletWindow, name);
     }
 
     public Enumeration getAttributeNames() {
-        Enumeration attributes = this.getHttpServletRequest()
-            .getAttributeNames();
-
-        Vector portletAttributes = new Vector();
-
-        while (attributes.hasMoreElements()) {
-            String attribute = (String) attributes.nextElement();
-            
-            //Fix for PLUTO-369
-            String portletAttribute = isNameReserved(attribute) ?
-            		attribute :
-            	mapper.decode(
-                internalPortletWindow.getId(), attribute);
-
-            if (portletAttribute != null) { // it is in the portlet's namespace
-                portletAttributes.add(portletAttribute);
-            }
-        }
-
-        return portletAttributes.elements();
-    }
-
-    public Map createUserInfoMap() {
-        Map userInfoMap = new HashMap();
-        try {
-
-            final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
-            final UserInfoService userInfoService = optionalContainerServices.getUserInfoService();
-            
-            //PLUTO-388 fix:
-            //The PortletWindow is currently ignored in the implementing class
-            // See: org.apache.pluto.core.DefaultUserInfoService
-            final Map allMap = userInfoService.getUserInfo( this, this.internalPortletWindow );
-            
-            //PLUTO-477 null attribute maps are ok
-            if (null == allMap) {
-                return null;
-            }
-            
-            final PortletRegistryService portletRegistryService = optionalContainerServices.getPortletRegistryService();
-            final PortletAppDD dd = portletRegistryService.getPortletApplicationDescriptor(internalPortletWindow.getContextPath());
-
-            Iterator i = dd.getUserAttributes().iterator();
-            while(i.hasNext()) {
-                UserAttributeDD udd = (UserAttributeDD)i.next();
-                userInfoMap.put(udd.getName(), allMap.get(udd.getName()));
-            }
-        } catch (PortletContainerException e) {
-            LOG.warn("Unable to retrieve user attribute map for user " + getRemoteUser() + ".  Returning null.");
-            return null;
-        }
-
-        return Collections.unmodifiableMap(userInfoMap);
+        final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
+        final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
+        return requestAttributeService.getAttributeNames(this, this.getHttpServletRequest(), this.internalPortletWindow);
     }
 
     public String getParameter(String name) {
@@ -504,20 +430,18 @@
 
     public void setAttribute(String name, Object value) {
         ArgumentUtility.validateNotNull("attributeName", name);
-        String encodedName = isNameReserved(name) ?
-            name : mapper.encode(internalPortletWindow.getId(), name);
-        if (value == null) {
-            removeAttribute(name);
-        } else {
-            getHttpServletRequest().setAttribute(encodedName, value);
-        }
+
+        final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
+        final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
+        requestAttributeService.setAttribute(this, this.getHttpServletRequest(), this.internalPortletWindow, name, value);
     }
 
     public void removeAttribute(String name) {
         ArgumentUtility.validateNotNull("attributeName", name);
-        String encodedName = isNameReserved(name) ?
-            name : mapper.encode(internalPortletWindow.getId(), name);
-        getHttpServletRequest().removeAttribute(encodedName);
+
+        final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
+        final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
+        requestAttributeService.removeAttribute(this, this.getHttpServletRequest(), this.internalPortletWindow, name);
     }
 
     public String getRequestedSessionId() {
@@ -655,15 +579,6 @@
 
     // Private Methods ---------------------------------------------------------
 
-    /**
-     * Is this attribute name a reserved name (by the J2EE spec)?. Reserved
-     * names begin with "java." or "javax.".
-     *
-     * @return true if the name is reserved.
-     */
-    private boolean isNameReserved(String name) {
-        return name.startsWith("java.") || name.startsWith("javax.");
-    }
 
     private boolean isPortletModeAllowedByPortlet(PortletMode mode) {
         if (isPortletModeMandatory(mode)) {

Added: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java?rev=679137&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java Wed Jul 23 10:41:30 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.pluto.spi.optional;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.pluto.PortletWindow;
+
+/**
+ * Interface for attribute manipulation on a request
+ * 
+ * @author Eric Dalquist
+ * @version $Revision$
+ */
+public interface RequestAttributeService {
+    /**
+     * Retrieve the named attribute for the HttpServletRequest and PortletWindow
+     */
+    public Object getAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name);
+    
+    /**
+     * Get an Enumeration of all available attribute names for the HttpServletRequest and PortletWindow
+     */
+    public Enumeration getAttributeNames(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow);
+    
+    /**
+     * Set an attribute for the HttpServletRequest and PortletWindow
+     */
+    public void setAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name, Object value);
+    
+    /**
+     * Remove a named attribute for the HttpServletRequest and PortletWindow
+     */
+    public void removeAttribute(PortletRequest portletRequest, HttpServletRequest httpServletRequest, PortletWindow portletWindow, String name);
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java?rev=679137&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java Wed Jul 23 10:41:30 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.pluto.core;
+
+import java.util.Map;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.pluto.OptionalContainerServices;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.RequiredContainerServices;
+import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.spi.optional.UserInfoService;
+import org.jmock.Mock;
+import org.jmock.cglib.MockObjectTestCase;
+
+/**
+ * @author Eric Dalquist
+ * @version $Revision$
+ */
+public class DefaultRequestAttributeServiceTest extends MockObjectTestCase {
+    private Mock mockOptionalServices = null;
+    private Mock mockUserInfoService = null;
+    private Mock mockPortletRequest = null;
+
+    private InternalPortletWindow window = null;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp( ) throws Exception
+    {
+        super.setUp();
+
+        // Create mocks
+        mockOptionalServices = mock( OptionalContainerServices.class );
+        mockUserInfoService = mock( UserInfoService.class );
+        window = (InternalPortletWindow) mock( InternalPortletWindow.class ).proxy();
+        mockPortletRequest = mock( PortletRequest.class );
+    }
+    
+    /**
+     * Test for PLUTO-477
+     */
+    public void testUnAuthenticatedCreateUserInfoMap() throws Exception {
+        this.mockUserInfoService.expects(once()).method("getUserInfo").will(returnValue(null));
+        
+        this.mockOptionalServices.expects(once()).method("getUserInfoService").will(returnValue(this.mockUserInfoService.proxy()));
+        
+        final DefaultRequestAttributeService requestAttributeService = new DefaultRequestAttributeService();
+        requestAttributeService.setOptionalContainerServices((OptionalContainerServices)this.mockOptionalServices.proxy());
+
+        final Map userInfoMap = requestAttributeService.createUserInfoMap((PortletRequest)this.mockPortletRequest.proxy(), this.window);
+        assertNull(userInfoMap);
+    }
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java?rev=679137&r1=679136&r2=679137&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java Wed Jul 23 10:41:30 2008
@@ -16,8 +16,6 @@
  */
 package org.apache.pluto.internal.impl;
 
-import java.util.Map;
-
 import javax.portlet.PortalContext;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletPreferences;
@@ -47,8 +45,6 @@
     // Mock Objects
     private Mock mockContainer = null;
     private Mock mockServices = null;
-    private Mock mockOptionalServices = null;
-    private Mock mockUserInfoService = null;
     private Mock mockPortalContext = null;
     private Mock mockPortletContext = null;
     private Mock mockHttpServletRequest = null;
@@ -64,8 +60,6 @@
 
         // Create mocks
         mockServices = mock( RequiredContainerServices.class );
-        mockOptionalServices = mock( OptionalContainerServices.class );
-        mockUserInfoService = mock( UserInfoService.class );
         mockPortalContext = mock( PortalContext.class );
         mockPortletContext = mock( PortletContext.class );
         mockContainer = mock( PortletContainerImpl.class,
@@ -119,23 +113,6 @@
         PortletSession s = request.getPortletSession( true );
     }
     
-    /**
-     * Test for PLUTO-477
-     */
-    public void testUnAuthenticatedCreateUserInfoMap() throws Exception {
-        this.mockUserInfoService.expects(once()).method("getUserInfo").will(returnValue(null));
-        
-        this.mockOptionalServices.expects(once()).method("getUserInfoService").will(returnValue(this.mockUserInfoService.proxy()));
-        
-        this.mockContainer.expects(once()).method("getOptionalContainerServices").will(returnValue(this.mockOptionalServices.proxy()));
-        
-        final TestPortletRequestImpl portletRequest = new TestPortletRequestImpl((PortletContainer)this.mockContainer.proxy(), 
-                                                                                 this.window, 
-                                                                                 (HttpServletRequest)this.mockHttpServletRequest.proxy());
-        final Map userInfoMap = portletRequest.createUserInfoMap();
-        assertNull(userInfoMap);
-    }
-    
     private static class TestPortletRequestImpl extends PortletRequestImpl {
         public TestPortletRequestImpl(InternalPortletRequest internalPortletRequest) {
             super(internalPortletRequest);

Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java?rev=679137&r1=679136&r2=679137&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java Wed Jul 23 10:41:30 2008
@@ -28,6 +28,7 @@
 import org.apache.pluto.spi.optional.PortletInvokerService;
 import org.apache.pluto.spi.optional.PortletPreferencesService;
 import org.apache.pluto.spi.optional.PortletRegistryService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.apache.pluto.spi.optional.UserInfoService;
 
 /**
@@ -108,5 +109,9 @@
     public UserInfoService getUserInfoService() {
         return null;
     }
+
+    public RequestAttributeService getRequestAttributeService() {
+        return null;
+    }
 }