portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r607448 [8/36] - in /portals/pluto/branches/pluto-1.1.x: ./ assembly/src/main/assembly/ assembly/src/main/resources/ maven-pluto-plugin/ maven-pluto-plugin/src/main/java/org/apache/pluto/maven/ pluto-ant-tasks/ pluto-ant-tasks/src/assemble/...
Date Sat, 29 Dec 2007 17:20:42 GMT
Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java Sat Dec 29 09:20:23 2007
@@ -1,360 +1,360 @@
-/*
+/*
  * 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.internal.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.PreferencesValidator;
-import javax.portlet.ReadOnlyException;
-import javax.portlet.ValidatorException;
-
-import org.apache.pluto.Constants;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletContainerException;
-import org.apache.pluto.util.StringManager;
-import org.apache.pluto.internal.InternalPortletPreference;
-import org.apache.pluto.internal.InternalPortletRequest;
-import org.apache.pluto.internal.InternalPortletWindow;
-import org.apache.pluto.internal.PortletEntity;
-import org.apache.pluto.spi.optional.PortletPreferencesService;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-
-/**
- * Implementation of the <code>javax.portlet.PortletPreferences</code>
- * interface.
- *
- * @see PortletPreferences
- * @see PortletPreferenceImpl
- *
- */
-public class PortletPreferencesImpl implements PortletPreferences {
-
-	/** Logger. */
-    private static final Log LOG = LogFactory.getLog(PortletPreferencesImpl.class);
-
-    private static final StringManager EXCEPTIONS = StringManager.getManager(
-    		PortletPreferencesImpl.class.getPackage().getName());
-
-
-    // Private Member Variables ------------------------------------------------
-
-    /** The portlet preferences service provided by the portal. */
-    private final PortletPreferencesService preferencesService;
-
-    private final InternalPortletWindow window;
-
-    private final InternalPortletRequest request;
-
-    /**
-     * Default portlet preferences retrieved from portlet.xml, and used for
-     * resetting portlet preferences.
-     */
-    private final InternalPortletPreference[] defaultPreferences;
-
-    /**
-     * Current portlet preferences: key is the preference name as a string,
-     * value is the PortletPreference instance.
-     */
-    private final Map preferences = new HashMap();
-
-    /** Current method used for managing these preferences. */
-    private final Integer methodId;
-
-
-    // Constructor -------------------------------------------------------------
-
-    /**
-     * Constructs an instance.
-     * @param container  the portlet container.
-     * @param window  the internal portlet window.
-     * @param request  the internal portlet request.
-     * @param methodId  the request method ID: render request or action request.
-     */
-    public PortletPreferencesImpl(PortletContainer container,
-                                  InternalPortletWindow window,
-                                  InternalPortletRequest request,
-                                  Integer methodId) {
-        this.window = window;
-        this.request = request;
-        this.methodId = methodId;
-
-        // Get the portlet preferences service from container.
-        preferencesService = container.getOptionalContainerServices()
-        		.getPortletPreferencesService();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Using PortletPreferencesService: "
-            		+ preferencesService.getClass().getName());
-        }
-
-        // Put default portlet preferences into preferences map.
-        PortletEntity entity = window.getPortletEntity();
-        defaultPreferences = entity.getDefaultPreferences();
-        for (int i = 0; i < defaultPreferences.length; i++) {
-            preferences.put(defaultPreferences[i].getName(),
-                            defaultPreferences[i].clone());
-        }
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Loaded default preferences: " + toString());
-        }
-
-        // Merge stored portlet preferences into preferences map.
-        try {
-        	InternalPortletPreference[] storedPreferences = preferencesService
-            		.getStoredPreferences(window, request);
-            for (int i = 0; i < storedPreferences.length; i++) {
-            	if (LOG.isDebugEnabled()) {
-            		LOG.debug("Merging stored preference: "
-            				+ storedPreferences[i].getName());
-            	}
-                preferences.put(storedPreferences[i].getName(),
-                                storedPreferences[i]);
-            }
-        	// Store the preferences retrieved from portlet.xml.
-            //   Portlet preferences are stored everytime when a
-            //   PortletPreferencesImpl instance is created.
-            //   So here we do not check the portlet request method ID.
-        	internalStore();
-
-        } catch (PortletContainerException ex) {
-            LOG.error("Error retrieving preferences.", ex);
-            //TODO: Rethrow up the stack????
-        } catch (IOException ex) {
-            LOG.error("Error retrieving preferences.", ex);
-            //TODO: Rethrow up the stack????
-        } catch (ValidatorException ex) {
-            LOG.warn("ValidatorException initializing portlet preferences. "
-            		+ "This is not illegal at this point "
-            		+ "since we are just retreiving from portlet.xml.", ex);
-        }
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Merged stored preferences: " + toString());
-        }
-    }
-
-
-    // PortletPreferences Impl -------------------------------------------------
-
-    public boolean isReadOnly(String key) {
-        if (key == null) {
-            throw new IllegalArgumentException(
-            		EXCEPTIONS.getString("error.null", "Preference key "));
-        }
-        InternalPortletPreference pref = (InternalPortletPreference)
-        		preferences.get(key);
-        return (pref != null && pref.isReadOnly());
-    }
-
-    public String getValue(String key, String defaultValue) {
-        String[] values = getValues(key, new String[] { defaultValue });
-        String value = null;
-        if (values != null && values.length > 0) {
-        	value = values[0];
-        }
-        if (value == null) {
-        	value = defaultValue;
-        }
-        return value;
-    }
-
-    public String[] getValues(String key, String[] defaultValues) {
-        if (key == null) {
-            throw new IllegalArgumentException(
-            		EXCEPTIONS.getString("error.null", "Preference key "));
-        }
-        String[] values = null;
-        InternalPortletPreference pref = (InternalPortletPreference)
-        		preferences.get(key);
-        if (pref != null) {
-            values = pref.getValues();
-        }
-        if (values == null) {
-            values = defaultValues;
-        }
-        return values;
-    }
-
-    public void setValue(String key, String value) throws ReadOnlyException {
-        if (isReadOnly(key)) {
-            throw new ReadOnlyException(EXCEPTIONS.getString(
-            		"error.preference.readonly", key));
-        }
-        InternalPortletPreference pref = (InternalPortletPreference)
-        		preferences.get(key);
-        if (pref != null) {
-            pref.setValues(new String[] { value });
-        } else {
-            pref = new PortletPreferenceImpl(key, new String[] { value });
-            preferences.put(key, pref);
-        }
-    }
-
-    public void setValues(String key, String[] values) throws ReadOnlyException {
-        if (isReadOnly(key)) {
-            throw new ReadOnlyException(EXCEPTIONS.getString(
-            		"error.preference.readonly"));
-        }
-        InternalPortletPreference pref = (InternalPortletPreference)
-        		preferences.get(key);
-        if (pref != null) {
-            pref.setValues(values);
-        } else {
-            pref = new PortletPreferenceImpl(key, values);
-            preferences.put(key, pref);
-        }
-    }
-
-    public Enumeration getNames() {
-        return new Vector(preferences.keySet()).elements();
-    }
-
-    public Map getMap() {
-        Map map = new HashMap();
-        Iterator it = preferences.keySet().iterator();
-        while (it.hasNext()) {
-        	InternalPortletPreference pref = (InternalPortletPreference)
-        			preferences.get(it.next());
-            map.put(pref.getName(),
-                    pref.getValues() != null ? pref.getValues().clone() : null);
-        }
-        return Collections.unmodifiableMap(map);
-    }
-
-    public void reset(String key) throws ReadOnlyException {
-    	// Read-only preferences cannot be reset.
-        if (isReadOnly(key)) {
-            throw new ReadOnlyException(EXCEPTIONS.getString(
-            		"error.preference.readonly", "Preference key "));
-        }
-        // Try to reset preference to the default values.
-        boolean resetDone = false;
-        for (int i = 0; !resetDone && i < defaultPreferences.length; i++) {
-        	if (key.equals(defaultPreferences[i].getName())) {
-        		if (LOG.isDebugEnabled()) {
-        			LOG.debug("Resetting preference for key: " + key);
-        		}
-        		preferences.put(key,
-        				defaultPreferences[i].clone());
-        		resetDone = true;
-        	}
-        }
-        // Remove preference if default values are not defined (PLT.14.1).
-        if (!resetDone) {
-        	if (LOG.isDebugEnabled()) {
-        		LOG.debug("Resetting preference to null for key: " + key);
-        	}
-        	preferences.remove(key);
-        }
-    }
-
-    /**
-     * Stores the portlet preferences to a persistent storage. This method
-     * should only be invoked within <code>processAction()</code> method.
-     *
-     * @see #internalStore()
-     *
-     * @throws IllegalStateException  if this method is not invoked within
-     *         <code>processAction()</code> method.
-     * @throws ValidatorException  if the portlet preferences are not valid.
-     * @throws IOException  if an error occurs with the persistence mechanism.
-     */
-    public void store() throws IOException, ValidatorException {
-        if (!Constants.METHOD_ACTION.equals(methodId)) {
-            throw new IllegalStateException(
-                	"store is only allowed inside a processAction call.");
-        }
-        internalStore();
-    }
-
-
-    // Private Methods ---------------------------------------------------------
-
-    /**
-     * Stores the portlet preferences to a persistent storage. If a preferences
-     * validator is defined for this portlet, this method firstly validates the
-     * portlet preferences.
-     * <p>
-     * This method is invoked internally, thus it does not check the portlet
-     * request method ID (METHOD_RENDER or METHOD_ACTION).
-     * </p>
-     * @throws ValidatorException  if the portlet preferences are not valid.
-     * @throws IOException  if an error occurs with the persistence mechanism.
-     */
-    private void internalStore() throws IOException, ValidatorException {
-        // Validate the preferences before storing, if a validator is defined.
-        //   If the preferences cannot pass the validation,
-        //   an ValidatorException will be thrown out.
-        PreferencesValidator validator = window.getPortletEntity()
-        		.getPreferencesValidator();
-        if (validator != null) {
-        	validator.validate(this);
-        }
-        // Store the portlet preferences.
-        InternalPortletPreference[] prefs = (InternalPortletPreference[])
-        		(new ArrayList(preferences.values())).toArray(
-        				new InternalPortletPreference[preferences.size()]);
-        try {
-        	preferencesService.store(window, request, prefs);
-        } catch (PortletContainerException ex) {
-            LOG.error("Error storing preferences.", ex);
-            throw new IOException("Error storing perferences: " + ex.getMessage());
-        }
-    }
-
-
-    // Object Methods ----------------------------------------------------------
-
-    /**
-     * Returns the string representation of this object. Preferences are
-     * separated by ';' character, while values in one preference are separated
-     * by ',' character.
-     * @return the string representation of this object.
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-    	StringBuffer buffer = new StringBuffer();
-    	buffer.append(getClass().getName()).append("[");
-    	for (Enumeration en = getNames(); en.hasMoreElements(); ) {
-    		String name = (String) en.nextElement();
-    		buffer.append(name);
-    		buffer.append("(readOnly:").append(isReadOnly(name)).append(")=");
-    		String[] values = getValues(name, null);
-    		if (values != null) {
-	    		for (int i = 0; i < values.length; i++) {
-	    			buffer.append(values[i]);
-	    			if (i < values.length - 1) {
-	    				buffer.append(",");
-	    			}
-				}
-    		} else {
-    			buffer.append("NULL");
-    		}
-    		buffer.append(";");
-    	}
-    	buffer.append("]");
-    	return buffer.toString();
-    }
-
-}
+ * 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.internal.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.portlet.PortletPreferences;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ReadOnlyException;
+import javax.portlet.ValidatorException;
+
+import org.apache.pluto.Constants;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.util.StringManager;
+import org.apache.pluto.internal.InternalPortletPreference;
+import org.apache.pluto.internal.InternalPortletRequest;
+import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.PortletEntity;
+import org.apache.pluto.spi.optional.PortletPreferencesService;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+/**
+ * Implementation of the <code>javax.portlet.PortletPreferences</code>
+ * interface.
+ *
+ * @see PortletPreferences
+ * @see PortletPreferenceImpl
+ *
+ */
+public class PortletPreferencesImpl implements PortletPreferences {
+
+	/** Logger. */
+    private static final Log LOG = LogFactory.getLog(PortletPreferencesImpl.class);
+
+    private static final StringManager EXCEPTIONS = StringManager.getManager(
+    		PortletPreferencesImpl.class.getPackage().getName());
+
+
+    // Private Member Variables ------------------------------------------------
+
+    /** The portlet preferences service provided by the portal. */
+    private final PortletPreferencesService preferencesService;
+
+    private final InternalPortletWindow window;
+
+    private final InternalPortletRequest request;
+
+    /**
+     * Default portlet preferences retrieved from portlet.xml, and used for
+     * resetting portlet preferences.
+     */
+    private final InternalPortletPreference[] defaultPreferences;
+
+    /**
+     * Current portlet preferences: key is the preference name as a string,
+     * value is the PortletPreference instance.
+     */
+    private final Map preferences = new HashMap();
+
+    /** Current method used for managing these preferences. */
+    private final Integer methodId;
+
+
+    // Constructor -------------------------------------------------------------
+
+    /**
+     * Constructs an instance.
+     * @param container  the portlet container.
+     * @param window  the internal portlet window.
+     * @param request  the internal portlet request.
+     * @param methodId  the request method ID: render request or action request.
+     */
+    public PortletPreferencesImpl(PortletContainer container,
+                                  InternalPortletWindow window,
+                                  InternalPortletRequest request,
+                                  Integer methodId) {
+        this.window = window;
+        this.request = request;
+        this.methodId = methodId;
+
+        // Get the portlet preferences service from container.
+        preferencesService = container.getOptionalContainerServices()
+        		.getPortletPreferencesService();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using PortletPreferencesService: "
+            		+ preferencesService.getClass().getName());
+        }
+
+        // Put default portlet preferences into preferences map.
+        PortletEntity entity = window.getPortletEntity();
+        defaultPreferences = entity.getDefaultPreferences();
+        for (int i = 0; i < defaultPreferences.length; i++) {
+            preferences.put(defaultPreferences[i].getName(),
+                            defaultPreferences[i].clone());
+        }
+        if (LOG.isDebugEnabled()) {
+        	LOG.debug("Loaded default preferences: " + toString());
+        }
+
+        // Merge stored portlet preferences into preferences map.
+        try {
+        	InternalPortletPreference[] storedPreferences = preferencesService
+            		.getStoredPreferences(window, request);
+            for (int i = 0; i < storedPreferences.length; i++) {
+            	if (LOG.isDebugEnabled()) {
+            		LOG.debug("Merging stored preference: "
+            				+ storedPreferences[i].getName());
+            	}
+                preferences.put(storedPreferences[i].getName(),
+                                storedPreferences[i]);
+            }
+        	// Store the preferences retrieved from portlet.xml.
+            //   Portlet preferences are stored everytime when a
+            //   PortletPreferencesImpl instance is created.
+            //   So here we do not check the portlet request method ID.
+        	internalStore();
+
+        } catch (PortletContainerException ex) {
+            LOG.error("Error retrieving preferences.", ex);
+            //TODO: Rethrow up the stack????
+        } catch (IOException ex) {
+            LOG.error("Error retrieving preferences.", ex);
+            //TODO: Rethrow up the stack????
+        } catch (ValidatorException ex) {
+            LOG.warn("ValidatorException initializing portlet preferences. "
+            		+ "This is not illegal at this point "
+            		+ "since we are just retreiving from portlet.xml.", ex);
+        }
+        if (LOG.isDebugEnabled()) {
+        	LOG.debug("Merged stored preferences: " + toString());
+        }
+    }
+
+
+    // PortletPreferences Impl -------------------------------------------------
+
+    public boolean isReadOnly(String key) {
+        if (key == null) {
+            throw new IllegalArgumentException(
+            		EXCEPTIONS.getString("error.null", "Preference key "));
+        }
+        InternalPortletPreference pref = (InternalPortletPreference)
+        		preferences.get(key);
+        return (pref != null && pref.isReadOnly());
+    }
+
+    public String getValue(String key, String defaultValue) {
+        String[] values = getValues(key, new String[] { defaultValue });
+        String value = null;
+        if (values != null && values.length > 0) {
+        	value = values[0];
+        }
+        if (value == null) {
+        	value = defaultValue;
+        }
+        return value;
+    }
+
+    public String[] getValues(String key, String[] defaultValues) {
+        if (key == null) {
+            throw new IllegalArgumentException(
+            		EXCEPTIONS.getString("error.null", "Preference key "));
+        }
+        String[] values = null;
+        InternalPortletPreference pref = (InternalPortletPreference)
+        		preferences.get(key);
+        if (pref != null) {
+            values = pref.getValues();
+        }
+        if (values == null) {
+            values = defaultValues;
+        }
+        return values;
+    }
+
+    public void setValue(String key, String value) throws ReadOnlyException {
+        if (isReadOnly(key)) {
+            throw new ReadOnlyException(EXCEPTIONS.getString(
+            		"error.preference.readonly", key));
+        }
+        InternalPortletPreference pref = (InternalPortletPreference)
+        		preferences.get(key);
+        if (pref != null) {
+            pref.setValues(new String[] { value });
+        } else {
+            pref = new PortletPreferenceImpl(key, new String[] { value });
+            preferences.put(key, pref);
+        }
+    }
+
+    public void setValues(String key, String[] values) throws ReadOnlyException {
+        if (isReadOnly(key)) {
+            throw new ReadOnlyException(EXCEPTIONS.getString(
+            		"error.preference.readonly"));
+        }
+        InternalPortletPreference pref = (InternalPortletPreference)
+        		preferences.get(key);
+        if (pref != null) {
+            pref.setValues(values);
+        } else {
+            pref = new PortletPreferenceImpl(key, values);
+            preferences.put(key, pref);
+        }
+    }
+
+    public Enumeration getNames() {
+        return new Vector(preferences.keySet()).elements();
+    }
+
+    public Map getMap() {
+        Map map = new HashMap();
+        Iterator it = preferences.keySet().iterator();
+        while (it.hasNext()) {
+        	InternalPortletPreference pref = (InternalPortletPreference)
+        			preferences.get(it.next());
+            map.put(pref.getName(),
+                    pref.getValues() != null ? pref.getValues().clone() : null);
+        }
+        return Collections.unmodifiableMap(map);
+    }
+
+    public void reset(String key) throws ReadOnlyException {
+    	// Read-only preferences cannot be reset.
+        if (isReadOnly(key)) {
+            throw new ReadOnlyException(EXCEPTIONS.getString(
+            		"error.preference.readonly", "Preference key "));
+        }
+        // Try to reset preference to the default values.
+        boolean resetDone = false;
+        for (int i = 0; !resetDone && i < defaultPreferences.length; i++) {
+        	if (key.equals(defaultPreferences[i].getName())) {
+        		if (LOG.isDebugEnabled()) {
+        			LOG.debug("Resetting preference for key: " + key);
+        		}
+        		preferences.put(key,
+        				defaultPreferences[i].clone());
+        		resetDone = true;
+        	}
+        }
+        // Remove preference if default values are not defined (PLT.14.1).
+        if (!resetDone) {
+        	if (LOG.isDebugEnabled()) {
+        		LOG.debug("Resetting preference to null for key: " + key);
+        	}
+        	preferences.remove(key);
+        }
+    }
+
+    /**
+     * Stores the portlet preferences to a persistent storage. This method
+     * should only be invoked within <code>processAction()</code> method.
+     *
+     * @see #internalStore()
+     *
+     * @throws IllegalStateException  if this method is not invoked within
+     *         <code>processAction()</code> method.
+     * @throws ValidatorException  if the portlet preferences are not valid.
+     * @throws IOException  if an error occurs with the persistence mechanism.
+     */
+    public void store() throws IOException, ValidatorException {
+        if (!Constants.METHOD_ACTION.equals(methodId)) {
+            throw new IllegalStateException(
+                	"store is only allowed inside a processAction call.");
+        }
+        internalStore();
+    }
+
+
+    // Private Methods ---------------------------------------------------------
+
+    /**
+     * Stores the portlet preferences to a persistent storage. If a preferences
+     * validator is defined for this portlet, this method firstly validates the
+     * portlet preferences.
+     * <p>
+     * This method is invoked internally, thus it does not check the portlet
+     * request method ID (METHOD_RENDER or METHOD_ACTION).
+     * </p>
+     * @throws ValidatorException  if the portlet preferences are not valid.
+     * @throws IOException  if an error occurs with the persistence mechanism.
+     */
+    private void internalStore() throws IOException, ValidatorException {
+        // Validate the preferences before storing, if a validator is defined.
+        //   If the preferences cannot pass the validation,
+        //   an ValidatorException will be thrown out.
+        PreferencesValidator validator = window.getPortletEntity()
+        		.getPreferencesValidator();
+        if (validator != null) {
+        	validator.validate(this);
+        }
+        // Store the portlet preferences.
+        InternalPortletPreference[] prefs = (InternalPortletPreference[])
+        		(new ArrayList(preferences.values())).toArray(
+        				new InternalPortletPreference[preferences.size()]);
+        try {
+        	preferencesService.store(window, request, prefs);
+        } catch (PortletContainerException ex) {
+            LOG.error("Error storing preferences.", ex);
+            throw new IOException("Error storing perferences: " + ex.getMessage());
+        }
+    }
+
+
+    // Object Methods ----------------------------------------------------------
+
+    /**
+     * Returns the string representation of this object. Preferences are
+     * separated by ';' character, while values in one preference are separated
+     * by ',' character.
+     * @return the string representation of this object.
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+    	StringBuffer buffer = new StringBuffer();
+    	buffer.append(getClass().getName()).append("[");
+    	for (Enumeration en = getNames(); en.hasMoreElements(); ) {
+    		String name = (String) en.nextElement();
+    		buffer.append(name);
+    		buffer.append("(readOnly:").append(isReadOnly(name)).append(")=");
+    		String[] values = getValues(name, null);
+    		if (values != null) {
+	    		for (int i = 0; i < values.length; i++) {
+	    			buffer.append(values[i]);
+	    			if (i < values.length - 1) {
+	    				buffer.append(",");
+	    			}
+				}
+    		} else {
+    			buffer.append("NULL");
+    		}
+    		buffer.append(";");
+    	}
+    	buffer.append("]");
+    	return buffer.toString();
+    }
+
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java?rev=607448&r1=607447&r2=607448&view=diff
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java Sat Dec 29 09:20:23 2007
@@ -1,123 +1,123 @@
-/*
+/*
  * 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.internal.impl;
-
-import org.apache.pluto.internal.InternalRenderRequest;
-import org.apache.pluto.internal.InternalRenderResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-
-/**
- * Implementation of the <code>PortletRequestDispatcher</code> interface.
- * The portlet request dispatcher is used to dispatch <b>RenderRequest</b> and
- * <b>RenderResponse</b> to a URI. Note that ActionRequest and ActionResponse
- * can never be dispatched.
- *
- */
-public class PortletRequestDispatcherImpl implements PortletRequestDispatcher {
-
-	/** Logger. */
-    private static final Log LOG = LogFactory.getLog(PortletRequestDispatcherImpl.class);
-
-
-    // Private Member Variables ------------------------------------------------
-
-    /** The nested servlet request dispatcher instance. */
-    private final RequestDispatcher requestDispatcher;
-
-    /** The included query string. */
-    private String queryString;
-
-
-    // Constructors ------------------------------------------------------------
-
-    /**
-     * Creates an instance. This constructor should be called to construct a
-     * named dispatcher.
-     * @param requestDispatcher  the servlet request dispatcher.
-     * @see javax.portlet.PortletContext#getNamedDispatcher(String)
-     */
-    public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher) {
-        this.requestDispatcher = requestDispatcher;
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Named dispatcher created.");
-        }
-    }
-
-    /**
-     * Creates an instance. This constructor should be called to construct a
-     * portlet request dispatcher.
-     * @param requestDispatcher  the servlet request dispatcher.
-     * @param queryString  the included query string.
-     * @see javax.portlet.PortletContext#getRequestDispatcher(String)
-     */
-    public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher,
-                                        String queryString) {
-        this(requestDispatcher);
-        this.queryString = queryString;
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Request dispatcher created.");
-        }
-    }
-
-
-    // PortletRequestDispatcher Impl -------------------------------------------
-
-    public void include(RenderRequest request, RenderResponse response)
-    throws PortletException, IOException {
-
-        InternalRenderRequest internalRequest = (InternalRenderRequest)
-                InternalImplConverter.getInternalRequest(request);
-        InternalRenderResponse internalResponse = (InternalRenderResponse)
-                InternalImplConverter.getInternalResponse(response);
-
-        boolean isIncluded = (internalRequest.isIncluded()
-        		|| internalResponse.isIncluded());
-        try {
-        	internalRequest.setIncluded(true);
-        	internalRequest.setIncludedQueryString(queryString);
-        	internalResponse.setIncluded(true);
-
-            requestDispatcher.include(
-            		(HttpServletRequest) internalRequest,
-            		(HttpServletResponse) internalResponse);
-        } catch (IOException ex) {
-            throw ex;
-        } catch (ServletException ex) {
-            if (ex.getRootCause() != null) {
-                throw new PortletException(ex.getRootCause());
-            } else {
-                throw new PortletException(ex);
-            }
-        } finally {
-        	internalRequest.setIncluded(isIncluded);
-        	internalResponse.setIncluded(isIncluded);
-        }
-    }
-
-}
+ * 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.internal.impl;
+
+import org.apache.pluto.internal.InternalRenderRequest;
+import org.apache.pluto.internal.InternalRenderResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+
+/**
+ * Implementation of the <code>PortletRequestDispatcher</code> interface.
+ * The portlet request dispatcher is used to dispatch <b>RenderRequest</b> and
+ * <b>RenderResponse</b> to a URI. Note that ActionRequest and ActionResponse
+ * can never be dispatched.
+ *
+ */
+public class PortletRequestDispatcherImpl implements PortletRequestDispatcher {
+
+	/** Logger. */
+    private static final Log LOG = LogFactory.getLog(PortletRequestDispatcherImpl.class);
+
+
+    // Private Member Variables ------------------------------------------------
+
+    /** The nested servlet request dispatcher instance. */
+    private final RequestDispatcher requestDispatcher;
+
+    /** The included query string. */
+    private String queryString;
+
+
+    // Constructors ------------------------------------------------------------
+
+    /**
+     * Creates an instance. This constructor should be called to construct a
+     * named dispatcher.
+     * @param requestDispatcher  the servlet request dispatcher.
+     * @see javax.portlet.PortletContext#getNamedDispatcher(String)
+     */
+    public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher) {
+        this.requestDispatcher = requestDispatcher;
+        if (LOG.isDebugEnabled()) {
+        	LOG.debug("Named dispatcher created.");
+        }
+    }
+
+    /**
+     * Creates an instance. This constructor should be called to construct a
+     * portlet request dispatcher.
+     * @param requestDispatcher  the servlet request dispatcher.
+     * @param queryString  the included query string.
+     * @see javax.portlet.PortletContext#getRequestDispatcher(String)
+     */
+    public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher,
+                                        String queryString) {
+        this(requestDispatcher);
+        this.queryString = queryString;
+        if (LOG.isDebugEnabled()) {
+        	LOG.debug("Request dispatcher created.");
+        }
+    }
+
+
+    // PortletRequestDispatcher Impl -------------------------------------------
+
+    public void include(RenderRequest request, RenderResponse response)
+    throws PortletException, IOException {
+
+        InternalRenderRequest internalRequest = (InternalRenderRequest)
+                InternalImplConverter.getInternalRequest(request);
+        InternalRenderResponse internalResponse = (InternalRenderResponse)
+                InternalImplConverter.getInternalResponse(response);
+
+        boolean isIncluded = (internalRequest.isIncluded()
+        		|| internalResponse.isIncluded());
+        try {
+        	internalRequest.setIncluded(true);
+        	internalRequest.setIncludedQueryString(queryString);
+        	internalResponse.setIncluded(true);
+
+            requestDispatcher.include(
+            		(HttpServletRequest) internalRequest,
+            		(HttpServletResponse) internalResponse);
+        } catch (IOException ex) {
+            throw ex;
+        } catch (ServletException ex) {
+            if (ex.getRootCause() != null) {
+                throw new PortletException(ex.getRootCause());
+            } else {
+                throw new PortletException(ex);
+            }
+        } finally {
+        	internalRequest.setIncluded(isIncluded);
+        	internalResponse.setIncluded(isIncluded);
+        }
+    }
+
+}

Propchange: portals/pluto/branches/pluto-1.1.x/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=607448&r1=607447&r2=607448&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 Sat Dec 29 09:20:23 2007
@@ -1,692 +1,692 @@
-/*
- * 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.internal.impl;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-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;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.portlet.PortalContext;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletMode;
-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 org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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.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.
- * This class also implements InternalPortletRequest.
- *
- */
-public abstract class PortletRequestImpl extends HttpServletRequestWrapper
-    implements PortletRequest, InternalPortletRequest {
-
-    /**
-     * Logger.
-     */
-    private static final Log LOG = LogFactory.getLog(PortletRequestImpl.class);
-
-    private static final StringManager EXCEPTIONS =
-        StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
-
-    // Private Member Variables ------------------------------------------------
-
-    /**
-     * The parent container within which this request was created.
-     */
-    private PortletContainer container;
-
-    /**
-     * The portlet window which is the target of this portlet request.
-     */
-    private InternalPortletWindow internalPortletWindow;
-
-    /**
-     * The PortletContext associated with this Request. This PortletContext must
-     * be initialized from within the <code>PortletServlet</code>.
-     */
-    private PortletContext portletContext;
-
-    /**
-     * The PortalContext within which this request is occuring.
-     */
-    private PortalContext portalContext;
-
-    /**
-     * The portlet session.
-     */
-    private PortletSession portletSession;
-
-    /**
-     * Response content types.
-     */
-    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.
-     */
-    private boolean bodyAccessed = false;
-
-    // Constructors ------------------------------------------------------------
-
-    public PortletRequestImpl(InternalPortletRequest internalPortletRequest) {
-        this(internalPortletRequest.getPortletContainer(),
-            internalPortletRequest.getInternalPortletWindow(),
-            internalPortletRequest.getHttpServletRequest());
-    }
-
-    /**
-     * Creates a PortletRequestImpl instance.
-     *
-     * @param container             the portlet container.
-     * @param internalPortletWindow the internal portlet window.
-     * @param servletRequest        the underlying servlet request.
-     */
-    public PortletRequestImpl(PortletContainer container,
-                              InternalPortletWindow internalPortletWindow,
-                              HttpServletRequest servletRequest) {
-        super(servletRequest);
-        this.container = container;
-        this.internalPortletWindow = internalPortletWindow;
-        this.portalContext = container.getRequiredContainerServices().getPortalContext();
-    }
-
-    // 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.
-     */
-    public boolean isWindowStateAllowed(WindowState state) {
-        for (Enumeration en = portalContext.getSupportedWindowStates();
-             en.hasMoreElements();) {
-            if (en.nextElement().toString().equals(state.toString())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public boolean isPortletModeAllowed(PortletMode mode) {
-        return (isPortletModeAllowedByPortlet(mode)
-            && isPortletModeAllowedByPortal(mode));
-    }
-
-    public PortletMode getPortletMode() {
-        return internalPortletWindow.getPortletMode();
-    }
-
-    public WindowState getWindowState() {
-        return internalPortletWindow.getWindowState();
-    }
-
-    public PortletSession getPortletSession() {
-        return getPortletSession(true);
-    }
-
-    /**
-     * Returns the portlet session.
-     * <p/>
-     * Note that since portlet request instance is created everytime the portlet
-     * container receives an incoming request, the portlet session instance held
-     * by the request instance is also re-created for each incoming request.
-     * </p>
-     */
-    public PortletSession getPortletSession(boolean create) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Retreiving portlet session (create=" + create + ")");
-        }
-        //
-        // 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"));
-        }
-        //
-        // We must make sure that if the session has been invalidated (perhaps
-        //   through setMaxIntervalTimeout()) and the underlying request
-        //   returns null that we no longer use the cached version.
-        // We have to check (ourselves) if the session has exceeded its max
-        //   inactive interval. If so, we should invalidate the underlying
-        //   HttpSession and recreate a new one (if the create flag is set to
-        //   true) -- We just cannot depend on the implementation of
-        //   javax.servlet.http.HttpSession!
-        //
-        HttpSession httpSession = getHttpServletRequest().getSession(create);
-        if (httpSession != null) {
-            // HttpSession is not null does NOT mean that it is valid.
-            int maxInactiveInterval = httpSession.getMaxInactiveInterval();
-            if (maxInactiveInterval >= 0) {    // < 0 => Never expires.
-                long maxInactiveTime = httpSession.getMaxInactiveInterval() * 1000L;
-                long currentInactiveTime = System.currentTimeMillis()
-                    - httpSession.getLastAccessedTime();
-                if (currentInactiveTime > maxInactiveTime) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("The underlying HttpSession is expired and "
-                            + "should be invalidated.");
-                    }
-                    httpSession.invalidate();
-                    httpSession = getHttpServletRequest().getSession(create);
-                }
-            }
-        }
-
-        if (httpSession == null) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("The underlying HttpSession is not available: "
-                    + "no session will be returned.");
-            }
-            return null;
-        }
-
-        //
-        // If we reach here, we are sure that the underlying HttpSession is
-        //   available. If we haven't created and cached a portlet session
-        //   instance, we will create and cache one now.
-        //
-        if (portletSession == null) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Creating new portlet session...");
-            }
-            portletSession = new PortletSessionImpl(
-                portletContext,
-                internalPortletWindow,
-                httpSession);
-        }
-        return portletSession;
-    }
-
-    public String getProperty(String name) throws IllegalArgumentException {
-        ArgumentUtility.validateNotNull("propertyName", name);
-        String property = this.getHttpServletRequest().getHeader(name);
-        if (property == null) {
-            Map propertyMap = container.getRequiredContainerServices()
-                .getPortalCallbackService()
-                .getRequestProperties(
-                    getHttpServletRequest(),
-                    internalPortletWindow);
-
-            if (propertyMap != null) {
-                String[] properties = (String[]) propertyMap.get(name);
-                if (properties != null && properties.length > 0) {
-                    property = properties[0];
-                }
-            }
-        }
-        return property;
-    }
-
-    public Enumeration getProperties(String name) {
-        ArgumentUtility.validateNotNull("propertyName", name);
-        Set v = new HashSet();
-        Enumeration props = this.getHttpServletRequest().getHeaders(name);
-        if (props != null) {
-            while (props.hasMoreElements()) {
-                v.add(props.nextElement());
-            }
-        }
-
-        // get properties from PropertyManager
-        Map map = container.getRequiredContainerServices()
-            .getPortalCallbackService()
-            .getRequestProperties(
-                getHttpServletRequest(),
-                internalPortletWindow);
-
-        if (map != null) {
-            String[] properties = (String[]) map.get(name);
-
-            if (properties != null) {
-                // add properties to vector
-                for (int i = 0; i < properties.length; i++) {
-                    v.add(properties[i]);
-                }
-            }
-        }
-
-        return new Enumerator(v.iterator());
-    }
-
-    public Enumeration getPropertyNames() {
-        Set v = new HashSet();
-
-        // get properties from PropertyManager
-        Map map = container.getRequiredContainerServices()
-            .getPortalCallbackService()
-            .getRequestProperties(getHttpServletRequest(), internalPortletWindow);
-
-        if (map != null) {
-            v.addAll(map.keySet());
-        }
-
-        // get properties from request header
-        Enumeration props = this.getHttpServletRequest().getHeaderNames();
-        if (props != null) {
-            while (props.hasMoreElements()) {
-                v.add(props.nextElement());
-            }
-        }
-
-        return new Enumerator(v.iterator());
-    }
-
-    public PortalContext getPortalContext() {
-        return container.getRequiredContainerServices().getPortalContext();
-    }
-
-    public String getAuthType() {
-        return this.getHttpServletRequest().getAuthType();
-    }
-
-    public String getContextPath() {
-        String contextPath = internalPortletWindow.getContextPath();
-        if ("/".equals(contextPath)) {
-            contextPath = "";
-        }
-        return contextPath;
-    }
-
-    public String getRemoteUser() {
-        return this.getHttpServletRequest().getRemoteUser();
-    }
-
-    public Principal getUserPrincipal() {
-        return this.getHttpServletRequest().getUserPrincipal();
-    }
-
-    /**
-     * Determines whether a user is mapped to the specified role.  As specified
-     * in PLT-20-3, we must reference the &lt;security-role-ref&gt; mappings
-     * 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.
-     */
-    public boolean isUserInRole(String roleName) {
-        PortletEntity entity = internalPortletWindow.getPortletEntity();
-        PortletDD def = entity.getPortletDefinition();
-
-        SecurityRoleRefDD ref = null;
-        Iterator refs = def.getSecurityRoleRefs().iterator();
-        while (refs.hasNext()) {
-            SecurityRoleRefDD r = (SecurityRoleRefDD) refs.next();
-            if (r.getRoleName().equals(roleName)) {
-                ref = r;
-                break;
-            }
-        }
-
-        String link;
-        if (ref != null && ref.getRoleLink() != null) {
-            link = ref.getRoleLink();
-        } else {
-            link = roleName;
-        }
-
-        return this.getHttpServletRequest().isUserInRole(link);
-    }
-
-    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;
-    }
-
-    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 {
-
-            PortletAppDD dd = container.getOptionalContainerServices()
-                .getPortletRegistryService()
-                .getPortletApplicationDescriptor(internalPortletWindow.getContextPath());
-
-            Map allMap = container.getOptionalContainerServices()
-            	//PLUTO-388 fix:
-            	//The PortletWindow is currently ignored in the implementing class
-            	// See: org.apache.pluto.core.DefaultUserInfoService
-            	.getUserInfoService().getUserInfo( this, this.internalPortletWindow );
-
-            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);
-    }
-
-    public String getParameter(String name) {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        String[] values = (String[]) baseGetParameterMap().get(name);
-        if (values != null && values.length > 0) {
-            return values[0];
-        } else {
-            return null;
-        }
-    }
-
-    public Enumeration getParameterNames() {
-        return Collections.enumeration(baseGetParameterMap().keySet());
-    }
-
-    public String[] getParameterValues(String name) {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        String[] values = (String[]) baseGetParameterMap().get(name);
-        if (values != null) {
-            values = StringUtils.copy(values);
-        }
-        return values;
-    }
-
-    public Map getParameterMap() {
-        return StringUtils.copyParameters(baseGetParameterMap());
-    }
-
-    public boolean isSecure() {
-        return this.getHttpServletRequest().isSecure();
-    }
-
-    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);
-        }
-    }
-
-    public void removeAttribute(String name) {
-        ArgumentUtility.validateNotNull("attributeName", name);
-        String encodedName = isNameReserved(name) ?
-            name : mapper.encode(internalPortletWindow.getId(), name);
-        getHttpServletRequest().removeAttribute(encodedName);
-    }
-
-    public String getRequestedSessionId() {
-        return this.getHttpServletRequest().getRequestedSessionId();
-    }
-
-    public boolean isRequestedSessionIdValid() {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug(" ***** IsRequestedSessionIdValid? " + getHttpServletRequest().isRequestedSessionIdValid());
-        }
-        return getHttpServletRequest().isRequestedSessionIdValid();
-    }
-
-    public String getResponseContentType() {
-        Enumeration enumeration = getResponseContentTypes();
-        while (enumeration.hasMoreElements()) {
-            return (String) enumeration.nextElement();
-        }
-        return "text/html";
-    }
-
-    public Enumeration getResponseContentTypes() {
-        if (contentTypes == null) {
-            contentTypes = new Vector();
-            PortletDD dd = internalPortletWindow.getPortletEntity().getPortletDefinition();
-            Iterator supports = dd.getSupports().iterator();
-            while (supports.hasNext()) {
-                SupportsDD sup = (SupportsDD) supports.next();
-                contentTypes.add(sup.getMimeType());
-            }
-            if (contentTypes.size() < 1) {
-                contentTypes.add("text/html");
-            }
-        }
-        return contentTypes.elements();
-    }
-
-    public Locale getLocale() {
-        return this.getHttpServletRequest().getLocale();
-    }
-
-    public Enumeration getLocales() {
-        return this.getHttpServletRequest().getLocales();
-    }
-
-    public String getScheme() {
-        return this.getHttpServletRequest().getScheme();
-    }
-
-    public String getServerName() {
-        return this.getHttpServletRequest().getServerName();
-    }
-
-    public int getServerPort() {
-        return this.getHttpServletRequest().getServerPort();
-    }
-
-    // Protected Methods -------------------------------------------------------
-
-    /**
-     * The base method that returns the parameter map in this portlet request.
-     * All parameter-related methods call this base method. Subclasses may just
-     * overwrite this protected method to change behavior of all parameter-
-     * related methods.
-     *
-     * @return the base parameter map from which parameters are retrieved.
-     */
-    protected Map baseGetParameterMap() {
-        bodyAccessed = true;
-        return this.getHttpServletRequest().getParameterMap();
-    }
-
-    protected void setBodyAccessed() {
-        bodyAccessed = true;
-    }
-
-    // InternalPortletRequest Impl ---------------------------------------------
-
-    public InternalPortletWindow getInternalPortletWindow() {
-        return internalPortletWindow;
-    }
-
-    public PortletContainer getPortletContainer() {
-        return container;
-    }
-
-    public HttpServletRequest getHttpServletRequest() {
-        return (HttpServletRequest) super.getRequest();
-    }
-
-    public void init(PortletContext portletContext, HttpServletRequest req) {
-        this.portletContext = portletContext;
-        setRequest(req);
-    }
-
-    /**
-     * TODO: Implement this properly.  Not required now
-     */
-    public void release() {
-        // TODO:
-    }
-
-    // TODO: Additional Methods of HttpServletRequestWrapper -------------------
-
-    public BufferedReader getReader()
-        throws UnsupportedEncodingException, IOException {
-        // the super class will ensure that a IllegalStateException is thrown
-        //   if getInputStream() was called earlier
-        BufferedReader reader = getHttpServletRequest().getReader();
-        bodyAccessed = true;
-        return reader;
-    }
-
-    public ServletInputStream getInputStream() throws IOException {
-        ServletInputStream stream = getHttpServletRequest().getInputStream();
-        bodyAccessed = true;
-        return stream;
-    }
-
-    public RequestDispatcher getRequestDispatcher(String path) {
-        return getHttpServletRequest().getRequestDispatcher(path);
-    }
-
-    /**
-     * TODO: why check bodyAccessed?
-     */
-    public void setCharacterEncoding(String encoding)
-        throws UnsupportedEncodingException {
-        if (bodyAccessed) {
-            throw new IllegalStateException("Cannot set character encoding "
-                + "after HTTP body is accessed.");
-        }
-        super.setCharacterEncoding(encoding);
-    }
-
-    // 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;
-        }
-
-        PortletDD dd = internalPortletWindow.getPortletEntity()
-            .getPortletDefinition();
-
-        Iterator mimes = dd.getSupports().iterator();
-        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;
-                }
-            }
-        }
-        return false;
-    }
-
-    private boolean isPortletModeAllowedByPortal(PortletMode mode) {
-        Enumeration supportedModes = portalContext.getSupportedPortletModes();
-        while (supportedModes.hasMoreElements()) {
-            if (supportedModes.nextElement().toString().equals(
-                (mode.toString()))) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private boolean isPortletModeMandatory(PortletMode mode) {
-        return PortletMode.VIEW.equals(mode) || PortletMode.EDIT.equals(mode) || PortletMode.HELP.equals(mode);
-    }
-}
+/*
+ * 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.internal.impl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+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;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletMode;
+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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.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.
+ * This class also implements InternalPortletRequest.
+ *
+ */
+public abstract class PortletRequestImpl extends HttpServletRequestWrapper
+    implements PortletRequest, InternalPortletRequest {
+
+    /**
+     * Logger.
+     */
+    private static final Log LOG = LogFactory.getLog(PortletRequestImpl.class);
+
+    private static final StringManager EXCEPTIONS =
+        StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
+
+    // Private Member Variables ------------------------------------------------
+
+    /**
+     * The parent container within which this request was created.
+     */
+    private PortletContainer container;
+
+    /**
+     * The portlet window which is the target of this portlet request.
+     */
+    private InternalPortletWindow internalPortletWindow;
+
+    /**
+     * The PortletContext associated with this Request. This PortletContext must
+     * be initialized from within the <code>PortletServlet</code>.
+     */
+    private PortletContext portletContext;
+
+    /**
+     * The PortalContext within which this request is occuring.
+     */
+    private PortalContext portalContext;
+
+    /**
+     * The portlet session.
+     */
+    private PortletSession portletSession;
+
+    /**
+     * Response content types.
+     */
+    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.
+     */
+    private boolean bodyAccessed = false;
+
+    // Constructors ------------------------------------------------------------
+
+    public PortletRequestImpl(InternalPortletRequest internalPortletRequest) {
+        this(internalPortletRequest.getPortletContainer(),
+            internalPortletRequest.getInternalPortletWindow(),
+            internalPortletRequest.getHttpServletRequest());
+    }
+
+    /**
+     * Creates a PortletRequestImpl instance.
+     *
+     * @param container             the portlet container.
+     * @param internalPortletWindow the internal portlet window.
+     * @param servletRequest        the underlying servlet request.
+     */
+    public PortletRequestImpl(PortletContainer container,
+                              InternalPortletWindow internalPortletWindow,
+                              HttpServletRequest servletRequest) {
+        super(servletRequest);
+        this.container = container;
+        this.internalPortletWindow = internalPortletWindow;
+        this.portalContext = container.getRequiredContainerServices().getPortalContext();
+    }
+
+    // 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.
+     */
+    public boolean isWindowStateAllowed(WindowState state) {
+        for (Enumeration en = portalContext.getSupportedWindowStates();
+             en.hasMoreElements();) {
+            if (en.nextElement().toString().equals(state.toString())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean isPortletModeAllowed(PortletMode mode) {
+        return (isPortletModeAllowedByPortlet(mode)
+            && isPortletModeAllowedByPortal(mode));
+    }
+
+    public PortletMode getPortletMode() {
+        return internalPortletWindow.getPortletMode();
+    }
+
+    public WindowState getWindowState() {
+        return internalPortletWindow.getWindowState();
+    }
+
+    public PortletSession getPortletSession() {
+        return getPortletSession(true);
+    }
+
+    /**
+     * Returns the portlet session.
+     * <p/>
+     * Note that since portlet request instance is created everytime the portlet
+     * container receives an incoming request, the portlet session instance held
+     * by the request instance is also re-created for each incoming request.
+     * </p>
+     */
+    public PortletSession getPortletSession(boolean create) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Retreiving portlet session (create=" + create + ")");
+        }
+        //
+        // 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"));
+        }
+        //
+        // We must make sure that if the session has been invalidated (perhaps
+        //   through setMaxIntervalTimeout()) and the underlying request
+        //   returns null that we no longer use the cached version.
+        // We have to check (ourselves) if the session has exceeded its max
+        //   inactive interval. If so, we should invalidate the underlying
+        //   HttpSession and recreate a new one (if the create flag is set to
+        //   true) -- We just cannot depend on the implementation of
+        //   javax.servlet.http.HttpSession!
+        //
+        HttpSession httpSession = getHttpServletRequest().getSession(create);
+        if (httpSession != null) {
+            // HttpSession is not null does NOT mean that it is valid.
+            int maxInactiveInterval = httpSession.getMaxInactiveInterval();
+            if (maxInactiveInterval >= 0) {    // < 0 => Never expires.
+                long maxInactiveTime = httpSession.getMaxInactiveInterval() * 1000L;
+                long currentInactiveTime = System.currentTimeMillis()
+                    - httpSession.getLastAccessedTime();
+                if (currentInactiveTime > maxInactiveTime) {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("The underlying HttpSession is expired and "
+                            + "should be invalidated.");
+                    }
+                    httpSession.invalidate();
+                    httpSession = getHttpServletRequest().getSession(create);
+                }
+            }
+        }
+
+        if (httpSession == null) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("The underlying HttpSession is not available: "
+                    + "no session will be returned.");
+            }
+            return null;
+        }
+
+        //
+        // If we reach here, we are sure that the underlying HttpSession is
+        //   available. If we haven't created and cached a portlet session
+        //   instance, we will create and cache one now.
+        //
+        if (portletSession == null) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Creating new portlet session...");
+            }
+            portletSession = new PortletSessionImpl(
+                portletContext,
+                internalPortletWindow,
+                httpSession);
+        }
+        return portletSession;
+    }
+
+    public String getProperty(String name) throws IllegalArgumentException {
+        ArgumentUtility.validateNotNull("propertyName", name);
+        String property = this.getHttpServletRequest().getHeader(name);
+        if (property == null) {
+            Map propertyMap = container.getRequiredContainerServices()
+                .getPortalCallbackService()
+                .getRequestProperties(
+                    getHttpServletRequest(),
+                    internalPortletWindow);
+
+            if (propertyMap != null) {
+                String[] properties = (String[]) propertyMap.get(name);
+                if (properties != null && properties.length > 0) {
+                    property = properties[0];
+                }
+            }
+        }
+        return property;
+    }
+
+    public Enumeration getProperties(String name) {
+        ArgumentUtility.validateNotNull("propertyName", name);
+        Set v = new HashSet();
+        Enumeration props = this.getHttpServletRequest().getHeaders(name);
+        if (props != null) {
+            while (props.hasMoreElements()) {
+                v.add(props.nextElement());
+            }
+        }
+
+        // get properties from PropertyManager
+        Map map = container.getRequiredContainerServices()
+            .getPortalCallbackService()
+            .getRequestProperties(
+                getHttpServletRequest(),
+                internalPortletWindow);
+
+        if (map != null) {
+            String[] properties = (String[]) map.get(name);
+
+            if (properties != null) {
+                // add properties to vector
+                for (int i = 0; i < properties.length; i++) {
+                    v.add(properties[i]);
+                }
+            }
+        }
+
+        return new Enumerator(v.iterator());
+    }
+
+    public Enumeration getPropertyNames() {
+        Set v = new HashSet();
+
+        // get properties from PropertyManager
+        Map map = container.getRequiredContainerServices()
+            .getPortalCallbackService()
+            .getRequestProperties(getHttpServletRequest(), internalPortletWindow);
+
+        if (map != null) {
+            v.addAll(map.keySet());
+        }
+
+        // get properties from request header
+        Enumeration props = this.getHttpServletRequest().getHeaderNames();
+        if (props != null) {
+            while (props.hasMoreElements()) {
+                v.add(props.nextElement());
+            }
+        }
+
+        return new Enumerator(v.iterator());
+    }
+
+    public PortalContext getPortalContext() {
+        return container.getRequiredContainerServices().getPortalContext();
+    }
+
+    public String getAuthType() {
+        return this.getHttpServletRequest().getAuthType();
+    }
+
+    public String getContextPath() {
+        String contextPath = internalPortletWindow.getContextPath();
+        if ("/".equals(contextPath)) {
+            contextPath = "";
+        }
+        return contextPath;
+    }
+
+    public String getRemoteUser() {
+        return this.getHttpServletRequest().getRemoteUser();
+    }
+
+    public Principal getUserPrincipal() {
+        return this.getHttpServletRequest().getUserPrincipal();
+    }
+
+    /**
+     * Determines whether a user is mapped to the specified role.  As specified
+     * in PLT-20-3, we must reference the &lt;security-role-ref&gt; mappings
+     * 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.
+     */
+    public boolean isUserInRole(String roleName) {
+        PortletEntity entity = internalPortletWindow.getPortletEntity();
+        PortletDD def = entity.getPortletDefinition();
+
+        SecurityRoleRefDD ref = null;
+        Iterator refs = def.getSecurityRoleRefs().iterator();
+        while (refs.hasNext()) {
+            SecurityRoleRefDD r = (SecurityRoleRefDD) refs.next();
+            if (r.getRoleName().equals(roleName)) {
+                ref = r;
+                break;
+            }
+        }
+
+        String link;
+        if (ref != null && ref.getRoleLink() != null) {
+            link = ref.getRoleLink();
+        } else {
+            link = roleName;
+        }
+
+        return this.getHttpServletRequest().isUserInRole(link);
+    }
+
+    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;
+    }
+
+    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 {
+
+            PortletAppDD dd = container.getOptionalContainerServices()
+                .getPortletRegistryService()
+                .getPortletApplicationDescriptor(internalPortletWindow.getContextPath());
+
+            Map allMap = container.getOptionalContainerServices()
+            	//PLUTO-388 fix:
+            	//The PortletWindow is currently ignored in the implementing class
+            	// See: org.apache.pluto.core.DefaultUserInfoService
+            	.getUserInfoService().getUserInfo( this, this.internalPortletWindow );
+
+            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);
+    }
+
+    public String getParameter(String name) {
+        ArgumentUtility.validateNotNull("parameterName", name);
+        String[] values = (String[]) baseGetParameterMap().get(name);
+        if (values != null && values.length > 0) {
+            return values[0];
+        } else {
+            return null;
+        }
+    }
+
+    public Enumeration getParameterNames() {
+        return Collections.enumeration(baseGetParameterMap().keySet());
+    }
+
+    public String[] getParameterValues(String name) {
+        ArgumentUtility.validateNotNull("parameterName", name);
+        String[] values = (String[]) baseGetParameterMap().get(name);
+        if (values != null) {
+            values = StringUtils.copy(values);
+        }
+        return values;
+    }
+
+    public Map getParameterMap() {
+        return StringUtils.copyParameters(baseGetParameterMap());
+    }
+
+    public boolean isSecure() {
+        return this.getHttpServletRequest().isSecure();
+    }
+
+    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);
+        }
+    }
+
+    public void removeAttribute(String name) {
+        ArgumentUtility.validateNotNull("attributeName", name);
+        String encodedName = isNameReserved(name) ?
+            name : mapper.encode(internalPortletWindow.getId(), name);
+        getHttpServletRequest().removeAttribute(encodedName);
+    }
+
+    public String getRequestedSessionId() {
+        return this.getHttpServletRequest().getRequestedSessionId();
+    }
+
+    public boolean isRequestedSessionIdValid() {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(" ***** IsRequestedSessionIdValid? " + getHttpServletRequest().isRequestedSessionIdValid());
+        }
+        return getHttpServletRequest().isRequestedSessionIdValid();
+    }
+
+    public String getResponseContentType() {
+        Enumeration enumeration = getResponseContentTypes();
+        while (enumeration.hasMoreElements()) {
+            return (String) enumeration.nextElement();
+        }
+        return "text/html";
+    }
+
+    public Enumeration getResponseContentTypes() {
+        if (contentTypes == null) {
+            contentTypes = new Vector();
+            PortletDD dd = internalPortletWindow.getPortletEntity().getPortletDefinition();
+            Iterator supports = dd.getSupports().iterator();
+            while (supports.hasNext()) {
+                SupportsDD sup = (SupportsDD) supports.next();
+                contentTypes.add(sup.getMimeType());
+            }
+            if (contentTypes.size() < 1) {
+                contentTypes.add("text/html");
+            }
+        }
+        return contentTypes.elements();
+    }
+
+    public Locale getLocale() {
+        return this.getHttpServletRequest().getLocale();
+    }
+
+    public Enumeration getLocales() {
+        return this.getHttpServletRequest().getLocales();
+    }
+
+    public String getScheme() {
+        return this.getHttpServletRequest().getScheme();
+    }
+
+    public String getServerName() {
+        return this.getHttpServletRequest().getServerName();
+    }
+
+    public int getServerPort() {
+        return this.getHttpServletRequest().getServerPort();
+    }
+
+    // Protected Methods -------------------------------------------------------
+
+    /**
+     * The base method that returns the parameter map in this portlet request.
+     * All parameter-related methods call this base method. Subclasses may just
+     * overwrite this protected method to change behavior of all parameter-
+     * related methods.
+     *
+     * @return the base parameter map from which parameters are retrieved.
+     */
+    protected Map baseGetParameterMap() {
+        bodyAccessed = true;
+        return this.getHttpServletRequest().getParameterMap();
+    }
+
+    protected void setBodyAccessed() {
+        bodyAccessed = true;
+    }
+
+    // InternalPortletRequest Impl ---------------------------------------------
+
+    public InternalPortletWindow getInternalPortletWindow() {
+        return internalPortletWindow;
+    }
+
+    public PortletContainer getPortletContainer() {
+        return container;
+    }
+
+    public HttpServletRequest getHttpServletRequest() {
+        return (HttpServletRequest) super.getRequest();
+    }
+
+    public void init(PortletContext portletContext, HttpServletRequest req) {
+        this.portletContext = portletContext;
+        setRequest(req);
+    }
+
+    /**
+     * TODO: Implement this properly.  Not required now
+     */
+    public void release() {
+        // TODO:
+    }
+
+    // TODO: Additional Methods of HttpServletRequestWrapper -------------------
+
+    public BufferedReader getReader()
+        throws UnsupportedEncodingException, IOException {
+        // the super class will ensure that a IllegalStateException is thrown
+        //   if getInputStream() was called earlier
+        BufferedReader reader = getHttpServletRequest().getReader();
+        bodyAccessed = true;
+        return reader;
+    }
+
+    public ServletInputStream getInputStream() throws IOException {
+        ServletInputStream stream = getHttpServletRequest().getInputStream();
+        bodyAccessed = true;
+        return stream;
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path) {
+        return getHttpServletRequest().getRequestDispatcher(path);
+    }
+
+    /**
+     * TODO: why check bodyAccessed?
+     */
+    public void setCharacterEncoding(String encoding)
+        throws UnsupportedEncodingException {
+        if (bodyAccessed) {
+            throw new IllegalStateException("Cannot set character encoding "
+                + "after HTTP body is accessed.");
+        }
+        super.setCharacterEncoding(encoding);
+    }
+
+    // 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;
+        }
+
+        PortletDD dd = internalPortletWindow.getPortletEntity()
+            .getPortletDefinition();
+
+        Iterator mimes = dd.getSupports().iterator();
+        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;
+                }
+            }
+        }
+        return false;
+    }
+
+    private boolean isPortletModeAllowedByPortal(PortletMode mode) {
+        Enumeration supportedModes = portalContext.getSupportedPortletModes();
+        while (supportedModes.hasMoreElements()) {
+            if (supportedModes.nextElement().toString().equals(
+                (mode.toString()))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean isPortletModeMandatory(PortletMode mode) {
+        return PortletMode.VIEW.equals(mode) || PortletMode.EDIT.equals(mode) || PortletMode.HELP.equals(mode);
+    }
+}



Mime
View raw message