portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edalqu...@apache.org
Subject svn commit: r679140 - in /portals/pluto/trunk: 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/java/org/apache/p...
Date Wed, 23 Jul 2008 17:47:08 GMT
Author: edalquist
Date: Wed Jul 23 10:47:08 2008
New Revision: 679140

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

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

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/OptionalContainerServices.java
Wed Jul 23 10:47:08 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/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultOptionalContainerServices.java
Wed Jul 23 10:47:08 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/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java?rev=679140&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
(added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
Wed Jul 23 10:47:08 2008
@@ -0,0 +1,205 @@
+/*
+ * 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.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+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<String> getAttributeNames(PortletRequest portletRequest, HttpServletRequest
httpServletRequest, PortletWindow portletWindow) {
+        final Enumeration<String> attributes = httpServletRequest.getAttributeNames();
+
+        final List<String> portletAttributes = new LinkedList<String>();
+        while (attributes.hasMoreElements()) {
+            final String attribute = 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 Collections.enumeration(portletAttributes);
+    }
+
+    /* (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<String, String> createUserInfoMap(PortletRequest portletRequest,
PortletWindow portletWindow) {
+        final Map<String, String> userInfoMap = new HashMap<String, String>();
+        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<String, String> 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<UserAttributeDD> mappedUserAttributes = dd.getUserAttribute();
+            for (final UserAttributeDD userAttrDD : mappedUserAttributes) {
+                final String mappedName = userAttrDD.getName();
+                final String 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/trunk/pluto-container/src/main/java/org/apache/pluto/core/DefaultRequestAttributeService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
Wed Jul 23 10:47:08 2008
@@ -56,24 +56,18 @@
 import org.apache.pluto.Constants;
 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.PortletURLProvider;
-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;
 
 
 /**
@@ -115,9 +109,6 @@
     /** Response content types. */
     private Vector contentTypes;
     
-    /** TODO: javadoc */
-    private NamespaceMapper mapper = new NamespaceMapperImpl();
-
     /** FIXME: do we really need this?
      * Flag indicating if the HTTP-Body has been accessed. */
     private boolean bodyAccessed = false;
@@ -434,80 +425,17 @@
     			return null;
     		}
     	}
-        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();
+        final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
+        final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
+        return requestAttributeService.getAttributeNames(this, this.getHttpServletRequest(),
this.internalPortletWindow);
     }
-
-    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.getUserAttribute().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);
-    }
-
     
     public String getParameter(String name) {
     	ArgumentUtility.validateNotNull("parameterName", name);
@@ -582,21 +510,17 @@
     }
 
     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() {
@@ -745,16 +669,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)) {
             return true;

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java?rev=679140&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
(added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
Wed Jul 23 10:47:08 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<String> 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/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/RequestAttributeService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/UserInfoService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/UserInfoService.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/UserInfoService.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/spi/optional/UserInfoService.java
Wed Jul 23 10:47:08 2008
@@ -38,7 +38,8 @@
      *
      * @deprecated use {@link #getUserInfo(PortletRequest, PortletWindow)}
      */
-    Map getUserInfo(PortletRequest request) throws PortletContainerException;
+    @Deprecated
+    Map<String, String> getUserInfo(PortletRequest request) throws PortletContainerException;
 
     /**
      * Retrieve the user attribues associated with the given
@@ -53,5 +54,5 @@
      * @return A map of names and values of user information attributes
      *         for a particular authenticated user. null if the user is not authenticated.
      */
-    Map getUserInfo(PortletRequest request, PortletWindow window) throws PortletContainerException;
+    Map<String, String> getUserInfo(PortletRequest request, PortletWindow window) throws
PortletContainerException;
 }
\ No newline at end of file

Added: portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java?rev=679140&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java
(added)
+++ portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/DefaultRequestAttributeServiceTest.java
Wed Jul 23 10:47:08 2008
@@ -0,0 +1,18 @@
+/*
+ * 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;
+

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

Modified: portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java
(original)
+++ portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/internal/impl/PortletRequestImplTest.java
Wed Jul 23 10:47:08 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;
@@ -28,11 +26,12 @@
 import org.apache.pluto.OptionalContainerServices;
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.RequiredContainerServices;
+import org.apache.pluto.core.DefaultRequestAttributeService;
 import org.apache.pluto.core.PortletContainerImpl;
 import org.apache.pluto.internal.InternalPortletRequest;
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.spi.CCPPProfileService;
-import org.apache.pluto.spi.optional.UserInfoService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.jmock.Mock;
 import org.jmock.cglib.MockObjectTestCase;
 
@@ -50,7 +49,7 @@
     private Mock mockServices = null;
     private Mock mockCCPPProfileService = null;
     private Mock mockOptionalServices = null;
-    private Mock mockUserInfoService = null;
+    private Mock mockRequestAttributeService = null;
     private Mock mockPortalContext = null;
     private Mock mockPortletContext = null;
     private Mock mockHttpServletRequest = null;
@@ -68,8 +67,8 @@
         mockServices = mock( RequiredContainerServices.class );
         mockCCPPProfileService = mock( CCPPProfileService.class );
         mockOptionalServices = mock( OptionalContainerServices.class );
-        mockUserInfoService = mock( UserInfoService.class );
         mockPortalContext = mock( PortalContext.class );
+        mockRequestAttributeService = mock( RequestAttributeService.class );
         mockPortletContext = mock( PortletContext.class );
         mockContainer = mock( PortletContainerImpl.class,
                 new Class[] { String.class, RequiredContainerServices.class, OptionalContainerServices.class
},
@@ -79,6 +78,7 @@
 
         // Constructor expectations for RenderRequestImpl
         mockContainer.expects( once() ).method( "getRequiredContainerServices" ).will( returnValue(
mockServices.proxy() ) );
+        mockContainer.expects( once() ).method( "getOptionalContainerServices" ).will( returnValue(
mockOptionalServices.proxy() ) );
         mockServices.expects( once() ).method( "getPortalContext" ).will( returnValue( mockPortalContext.proxy()
) );
     }
 
@@ -102,6 +102,10 @@
         
         mockContainer.expects(once()).method("getRequiredContainerServices").will(returnValue(
mockServices.proxy() ));
         
+        mockContainer.expects( once() ).method( "getOptionalContainerServices" ).will( returnValue(
mockOptionalServices.proxy() ) );
+        
+        mockOptionalServices.expects( exactly(2) ).method( "getRequestAttributeService" ).will(
returnValue( new DefaultRequestAttributeService( (OptionalContainerServices)mockOptionalServices.proxy()
) ) ); //mockRequestAttributeService.proxy() ) );
+        
         mockHttpServletRequest.expects(once()).method("removeAttribute");
         mockHttpServletRequest.expects(once()).method("setAttribute");
 
@@ -131,23 +135,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/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java?rev=679140&r1=679139&r2=679140&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
(original)
+++ portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
Wed Jul 23 10:47:08 2008
@@ -24,11 +24,12 @@
 import org.apache.pluto.spi.CCPPProfileService;
 import org.apache.pluto.spi.PortalCallbackService;
 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.PortletEnvironmentService;
 import org.apache.pluto.spi.optional.PortletRegistryService;
-import org.apache.pluto.spi.optional.PortletInvokerService;
+import org.apache.pluto.spi.optional.RequestAttributeService;
 import org.apache.pluto.spi.optional.UserInfoService;
 
 /**
@@ -117,5 +118,8 @@
     	return null;
     }
 
+    public RequestAttributeService getRequestAttributeService() {
+        return null;
+    }
 }
 



Mime
View raw message