You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2007/11/19 17:56:32 UTC
svn commit: r596365 [5/5] - in /myfaces/portlet-bridge/trunk:
api/src/main/java/javax/portlet/faces/
api/src/main/java/javax/portlet/faces/component/
impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/
impl/src/main/java/org/apache/myfa...
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java Mon Nov 19 08:56:29 2007
@@ -1,340 +1,340 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * Helper class for different portlet external context maps
- */
-public abstract class PortletAbstractMap implements Map
-{
- static final String ILLEGAL_ARGUMENT = "Only supported in a portlet environment";
-
- private Set mKeySet;
- private Collection mValues;
- private Set mEntrySet;
-
- public void clear()
- {
- List names = new ArrayList();
- for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
- {
- names.add(e.nextElement());
- }
-
- for (Iterator it = names.iterator(); it.hasNext();)
- {
- removeAttribute((String) it.next());
- }
- }
-
- public boolean containsKey(Object key)
- {
- return getAttribute(key.toString()) != null;
- }
-
- public boolean containsValue(Object findValue)
- {
- if (findValue == null)
- {
- return false;
- }
-
- for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
- {
- Object value = getAttribute((String) e.nextElement());
- if (findValue.equals(value))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public Set entrySet()
- {
- return mEntrySet != null ? mEntrySet : (mEntrySet = new EntrySet());
- }
-
- public Object get(Object key)
- {
- return getAttribute(key.toString());
- }
-
- public boolean isEmpty()
- {
- return !getAttributeNames().hasMoreElements();
- }
-
- public Set keySet()
- {
- return mKeySet != null ? mKeySet : (mKeySet = new KeySet());
- }
-
- public Object put(Object key, Object value)
- {
- String localKey = key.toString();
- Object retval = getAttribute(localKey);
- setAttribute(localKey, value);
- return retval;
- }
-
- public void putAll(Map t)
- {
- for (Iterator it = t.entrySet().iterator(); it.hasNext();)
- {
- Entry entry = (Entry) it.next();
- setAttribute(entry.getKey().toString(), entry.getValue());
- }
- }
-
- public Object remove(Object key)
- {
- String localKey = key.toString();
- Object retval = getAttribute(localKey);
- removeAttribute(localKey);
- return retval;
- }
-
- public int size()
- {
- int size = 0;
- for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
- {
- size++;
- e.nextElement();
- }
- return size;
- }
-
- public Collection values()
- {
- return mValues != null ? mValues : (mValues = new Values());
- }
-
- protected abstract Object getAttribute(String key);
-
- protected abstract void setAttribute(String key, Object value);
-
- protected abstract void removeAttribute(String key);
-
- protected abstract Enumeration getAttributeNames();
-
- private class KeySet extends AbstractSet
- {
- @Override
- public Iterator iterator()
- {
- return new KeyIterator();
- }
-
- @Override
- public boolean isEmpty()
- {
- return PortletAbstractMap.this.isEmpty();
- }
-
- @Override
- public int size()
- {
- return PortletAbstractMap.this.size();
- }
-
- @Override
- public boolean contains(Object o)
- {
- return containsKey(o);
- }
-
- @Override
- public boolean remove(Object o)
- {
- return PortletAbstractMap.this.remove(o) != null;
- }
-
- @Override
- public void clear()
- {
- PortletAbstractMap.this.clear();
- }
- }
-
- private class KeyIterator implements Iterator
- {
- protected final Enumeration mEnum = getAttributeNames();
- protected Object mKey;
-
- public void remove()
- {
- if (mKey == null)
- {
- throw new NoSuchElementException();
- }
- PortletAbstractMap.this.remove(mKey);
- }
-
- public boolean hasNext()
- {
- return mEnum.hasMoreElements();
- }
-
- public Object next()
- {
- return mKey = mEnum.nextElement();
- }
- }
-
- private class Values extends KeySet
- {
- @Override
- public Iterator iterator()
- {
- return new ValuesIterator();
- }
-
- @Override
- public boolean contains(Object o)
- {
- return containsValue(o);
- }
-
- @Override
- public boolean remove(Object o)
- {
- if (o == null)
- {
- return false;
- }
-
- for (Iterator it = iterator(); it.hasNext();)
- {
- if (o.equals(it.next()))
- {
- it.remove();
- return true;
- }
- }
-
- return false;
- }
- }
-
- private class ValuesIterator extends KeyIterator
- {
- @Override
- public Object next()
- {
- super.next();
- return get(mKey);
- }
- }
-
- private class EntrySet extends KeySet
- {
- @Override
- public Iterator iterator()
- {
- return new EntryIterator();
- }
-
- @Override
- public boolean contains(Object o)
- {
- if (!(o instanceof Entry))
- {
- return false;
- }
-
- Entry entry = (Entry) o;
- Object key = entry.getKey();
- Object value = entry.getValue();
- if (key == null || value == null)
- {
- return false;
- }
-
- return value.equals(get(key));
- }
-
- @Override
- public boolean remove(Object o)
- {
- if (!(o instanceof Entry))
- {
- return false;
- }
-
- Entry entry = (Entry) o;
- Object key = entry.getKey();
- Object value = entry.getValue();
- if (key == null || value == null || !value.equals(get(key)))
- {
- return false;
- }
-
- return PortletAbstractMap.this.remove(((Entry) o).getKey()) != null;
- }
- }
-
- private class EntryIterator extends KeyIterator
- {
- @Override
- public Object next()
- {
- super.next();
- return new EntrySetEntry(mKey);
- }
- }
-
- private class EntrySetEntry implements Entry
- {
- private final Object mKey;
-
- public EntrySetEntry(Object currentKey)
- {
- mKey = currentKey;
- }
-
- public Object getKey()
- {
- return mKey;
- }
-
- public Object getValue()
- {
- return get(mKey);
- }
-
- public Object setValue(Object value)
- {
- return put(mKey, value);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * Helper class for different portlet external context maps
+ */
+public abstract class PortletAbstractMap implements Map
+{
+ static final String ILLEGAL_ARGUMENT = "Only supported in a portlet environment";
+
+ private Set mKeySet;
+ private Collection mValues;
+ private Set mEntrySet;
+
+ public void clear()
+ {
+ List names = new ArrayList();
+ for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+
+ for (Iterator it = names.iterator(); it.hasNext();)
+ {
+ removeAttribute((String) it.next());
+ }
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return getAttribute(key.toString()) != null;
+ }
+
+ public boolean containsValue(Object findValue)
+ {
+ if (findValue == null)
+ {
+ return false;
+ }
+
+ for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+ {
+ Object value = getAttribute((String) e.nextElement());
+ if (findValue.equals(value))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Set entrySet()
+ {
+ return mEntrySet != null ? mEntrySet : (mEntrySet = new EntrySet());
+ }
+
+ public Object get(Object key)
+ {
+ return getAttribute(key.toString());
+ }
+
+ public boolean isEmpty()
+ {
+ return !getAttributeNames().hasMoreElements();
+ }
+
+ public Set keySet()
+ {
+ return mKeySet != null ? mKeySet : (mKeySet = new KeySet());
+ }
+
+ public Object put(Object key, Object value)
+ {
+ String localKey = key.toString();
+ Object retval = getAttribute(localKey);
+ setAttribute(localKey, value);
+ return retval;
+ }
+
+ public void putAll(Map t)
+ {
+ for (Iterator it = t.entrySet().iterator(); it.hasNext();)
+ {
+ Entry entry = (Entry) it.next();
+ setAttribute(entry.getKey().toString(), entry.getValue());
+ }
+ }
+
+ public Object remove(Object key)
+ {
+ String localKey = key.toString();
+ Object retval = getAttribute(localKey);
+ removeAttribute(localKey);
+ return retval;
+ }
+
+ public int size()
+ {
+ int size = 0;
+ for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+ {
+ size++;
+ e.nextElement();
+ }
+ return size;
+ }
+
+ public Collection values()
+ {
+ return mValues != null ? mValues : (mValues = new Values());
+ }
+
+ protected abstract Object getAttribute(String key);
+
+ protected abstract void setAttribute(String key, Object value);
+
+ protected abstract void removeAttribute(String key);
+
+ protected abstract Enumeration getAttributeNames();
+
+ private class KeySet extends AbstractSet
+ {
+ @Override
+ public Iterator iterator()
+ {
+ return new KeyIterator();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return PortletAbstractMap.this.isEmpty();
+ }
+
+ @Override
+ public int size()
+ {
+ return PortletAbstractMap.this.size();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ return containsKey(o);
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ return PortletAbstractMap.this.remove(o) != null;
+ }
+
+ @Override
+ public void clear()
+ {
+ PortletAbstractMap.this.clear();
+ }
+ }
+
+ private class KeyIterator implements Iterator
+ {
+ protected final Enumeration mEnum = getAttributeNames();
+ protected Object mKey;
+
+ public void remove()
+ {
+ if (mKey == null)
+ {
+ throw new NoSuchElementException();
+ }
+ PortletAbstractMap.this.remove(mKey);
+ }
+
+ public boolean hasNext()
+ {
+ return mEnum.hasMoreElements();
+ }
+
+ public Object next()
+ {
+ return mKey = mEnum.nextElement();
+ }
+ }
+
+ private class Values extends KeySet
+ {
+ @Override
+ public Iterator iterator()
+ {
+ return new ValuesIterator();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ return containsValue(o);
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ if (o == null)
+ {
+ return false;
+ }
+
+ for (Iterator it = iterator(); it.hasNext();)
+ {
+ if (o.equals(it.next()))
+ {
+ it.remove();
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ private class ValuesIterator extends KeyIterator
+ {
+ @Override
+ public Object next()
+ {
+ super.next();
+ return get(mKey);
+ }
+ }
+
+ private class EntrySet extends KeySet
+ {
+ @Override
+ public Iterator iterator()
+ {
+ return new EntryIterator();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ if (!(o instanceof Entry))
+ {
+ return false;
+ }
+
+ Entry entry = (Entry) o;
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ if (key == null || value == null)
+ {
+ return false;
+ }
+
+ return value.equals(get(key));
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ if (!(o instanceof Entry))
+ {
+ return false;
+ }
+
+ Entry entry = (Entry) o;
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ if (key == null || value == null || !value.equals(get(key)))
+ {
+ return false;
+ }
+
+ return PortletAbstractMap.this.remove(((Entry) o).getKey()) != null;
+ }
+ }
+
+ private class EntryIterator extends KeyIterator
+ {
+ @Override
+ public Object next()
+ {
+ super.next();
+ return new EntrySetEntry(mKey);
+ }
+ }
+
+ private class EntrySetEntry implements Entry
+ {
+ private final Object mKey;
+
+ public EntrySetEntry(Object currentKey)
+ {
+ mKey = currentKey;
+ }
+
+ public Object getKey()
+ {
+ return mKey;
+ }
+
+ public Object getValue()
+ {
+ return get(mKey);
+ }
+
+ public Object setValue(Object value)
+ {
+ return put(mKey, value);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java Mon Nov 19 08:56:29 2007
@@ -1,88 +1,88 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.Enumeration;
-
-import javax.portlet.PortletContext;
-
-/**
- * Map of portlet context attributes
- */
-public class PortletApplicationMap extends PortletAbstractMap
-{
- private final PortletContext mPortletContext;
-
- public PortletApplicationMap(Object context)
- {
- if (context instanceof PortletContext)
- {
- mPortletContext = (PortletContext) context;
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public Object getAttribute(String key)
- {
- if (mPortletContext != null)
- {
- return mPortletContext.getAttribute(key);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public void setAttribute(String key, Object value)
- {
- if (mPortletContext != null)
- {
- mPortletContext.setAttribute(key, value);
- }
- }
-
- @Override
- public void removeAttribute(String key)
- {
- if (mPortletContext != null)
- {
- mPortletContext.removeAttribute(key);
- }
- }
-
- @Override
- public Enumeration getAttributeNames()
- {
- if (mPortletContext != null)
- {
- return mPortletContext.getAttributeNames();
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortletContext;
+
+/**
+ * Map of portlet context attributes
+ */
+public class PortletApplicationMap extends PortletAbstractMap
+{
+ private final PortletContext mPortletContext;
+
+ public PortletApplicationMap(Object context)
+ {
+ if (context instanceof PortletContext)
+ {
+ mPortletContext = (PortletContext) context;
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ if (mPortletContext != null)
+ {
+ return mPortletContext.getAttribute(key);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ if (mPortletContext != null)
+ {
+ mPortletContext.setAttribute(key, value);
+ }
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ if (mPortletContext != null)
+ {
+ mPortletContext.removeAttribute(key);
+ }
+ }
+
+ @Override
+ public Enumeration getAttributeNames()
+ {
+ if (mPortletContext != null)
+ {
+ return mPortletContext.getAttributeNames();
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java Mon Nov 19 08:56:29 2007
@@ -1,82 +1,82 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.Enumeration;
-
-import javax.portlet.PortletContext;
-
-/**
- * Map of portlet context init params
- */
-public class PortletInitParameterMap extends PortletAbstractMap
-{
- private final PortletContext mPortletContext;
-
- public PortletInitParameterMap(Object context)
- {
- if (context instanceof PortletContext)
- {
- mPortletContext = (PortletContext) context;
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public Object getAttribute(String key)
- {
- if (mPortletContext != null)
- {
- return mPortletContext.getInitParameter(key);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public void setAttribute(String key, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void removeAttribute(String key)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Enumeration getAttributeNames()
- {
- if (mPortletContext != null)
- {
- return mPortletContext.getInitParameterNames();
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortletContext;
+
+/**
+ * Map of portlet context init params
+ */
+public class PortletInitParameterMap extends PortletAbstractMap
+{
+ private final PortletContext mPortletContext;
+
+ public PortletInitParameterMap(Object context)
+ {
+ if (context instanceof PortletContext)
+ {
+ mPortletContext = (PortletContext) context;
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ if (mPortletContext != null)
+ {
+ return mPortletContext.getInitParameter(key);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Enumeration getAttributeNames()
+ {
+ if (mPortletContext != null)
+ {
+ return mPortletContext.getInitParameterNames();
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java Mon Nov 19 08:56:29 2007
@@ -1,59 +1,59 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.Enumeration;
-
-/**
- * Map of portlet request headers
- */
-public class PortletRequestHeaderMap extends PortletAbstractMap
-{
- private final PortletRequestHeaders mPortletRequestHeaders;
-
- public PortletRequestHeaderMap(PortletRequestHeaders portletRequestHeaders)
- {
- mPortletRequestHeaders = portletRequestHeaders;
- }
-
- @Override
- protected Object getAttribute(String key)
- {
- return mPortletRequestHeaders.getHeader(key);
- }
-
- @Override
- protected void setAttribute(String key, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void removeAttribute(String key)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Enumeration getAttributeNames()
- {
- return mPortletRequestHeaders.getHeaderNames();
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.Enumeration;
+
+/**
+ * Map of portlet request headers
+ */
+public class PortletRequestHeaderMap extends PortletAbstractMap
+{
+ private final PortletRequestHeaders mPortletRequestHeaders;
+
+ public PortletRequestHeaderMap(PortletRequestHeaders portletRequestHeaders)
+ {
+ mPortletRequestHeaders = portletRequestHeaders;
+ }
+
+ @Override
+ protected Object getAttribute(String key)
+ {
+ return mPortletRequestHeaders.getHeader(key);
+ }
+
+ @Override
+ protected void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected Enumeration getAttributeNames()
+ {
+ return mPortletRequestHeaders.getHeaderNames();
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java Mon Nov 19 08:56:29 2007
@@ -1,81 +1,81 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Map of portlet request header values
- */
-public class PortletRequestHeaderValuesMap extends PortletAbstractMap
-{
- private final PortletRequestHeaders mPortletRequestHeaders;
- private final Map mValueCache = new HashMap();
-
- public PortletRequestHeaderValuesMap(PortletRequestHeaders portletRequestHeaders)
- {
- mPortletRequestHeaders = portletRequestHeaders;
- }
-
- @Override
- protected Object getAttribute(String key)
- {
- Object ret = mValueCache.get(key);
- if (ret == null)
- {
- mValueCache.put(key, ret = toArray(mPortletRequestHeaders.getHeaders(key)));
- }
- return ret;
- }
-
- @Override
- protected void setAttribute(String key, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void removeAttribute(String key)
- {
- throw new UnsupportedOperationException("");
- }
-
- @Override
- protected Enumeration getAttributeNames()
- {
- return mPortletRequestHeaders.getHeaderNames();
- }
-
- private String[] toArray(Enumeration e)
- {
- List ret = new ArrayList();
-
- while (e.hasMoreElements())
- {
- ret.add(e.nextElement());
- }
-
- return (String[]) ret.toArray(new String[ret.size()]);
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Map of portlet request header values
+ */
+public class PortletRequestHeaderValuesMap extends PortletAbstractMap
+{
+ private final PortletRequestHeaders mPortletRequestHeaders;
+ private final Map mValueCache = new HashMap();
+
+ public PortletRequestHeaderValuesMap(PortletRequestHeaders portletRequestHeaders)
+ {
+ mPortletRequestHeaders = portletRequestHeaders;
+ }
+
+ @Override
+ protected Object getAttribute(String key)
+ {
+ Object ret = mValueCache.get(key);
+ if (ret == null)
+ {
+ mValueCache.put(key, ret = toArray(mPortletRequestHeaders.getHeaders(key)));
+ }
+ return ret;
+ }
+
+ @Override
+ protected void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException("");
+ }
+
+ @Override
+ protected Enumeration getAttributeNames()
+ {
+ return mPortletRequestHeaders.getHeaderNames();
+ }
+
+ private String[] toArray(Enumeration e)
+ {
+ List ret = new ArrayList();
+
+ while (e.hasMoreElements())
+ {
+ ret.add(e.nextElement());
+ }
+
+ return (String[]) ret.toArray(new String[ret.size()]);
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java Mon Nov 19 08:56:29 2007
@@ -1,259 +1,259 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import javax.portlet.PortletRequest;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Locale;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.faces.Bridge;
-
-public class PortletRequestHeaders
-{
- private PortletRequest mPortletRequest = null;
- private List mHeaderNames = null;
- private Map mHeaders = null;
-
- public PortletRequestHeaders(PortletRequest request)
- {
- mPortletRequest = request;
- }
-
- public java.lang.String getHeader(java.lang.String name)
- {
- // initialize the header map if it hasn't been already
- initHeaderMap();
-
- List headerVals = (List) mHeaders.get(name.toUpperCase());
- return headerVals == null ? null : (String) headerVals.get(0);
- }
-
- public java.util.Enumeration getHeaders(java.lang.String name)
- {
- // initialize the header map if it hasn't been already
- initHeaderMap();
-
- List headerVals = (List) mHeaders.get(name.toUpperCase());
- return Collections.enumeration(headerVals == null ? Collections.EMPTY_LIST : headerVals);
- }
-
- public java.util.Enumeration getHeaderNames()
- {
- // initialize the header map if it hasn't been already
- initHeaderMap();
-
- return Collections.enumeration(mHeaderNames);
- }
-
- /**
- * Does 'lazy' initialization of Map of 'properties', i.e. mime headers.
- */
- protected boolean initHeaderMap()
- {
- if (mHeaders != null)
- {
- return false;
- }
-
- mHeaders = Collections.EMPTY_MAP;
- mHeaderNames = Collections.EMPTY_LIST;
-
- Enumeration props = mPortletRequest.getPropertyNames();
- Enumeration values = null;
- StringBuffer property = null;
-
- while (props != null && props.hasMoreElements())
- {
- String name = (String) props.nextElement();
- values = mPortletRequest.getProperties(name);
- while (values != null && values.hasMoreElements())
- {
- addProperty(name, (String) values.nextElement());
- }
- }
-
- // if they don't already exist, now add in the the required (HTTP)
- // headers to ensure compatibility with servlets
- if (!containsHeader(mHeaderNames, "ACCEPT"))
- {
- values = mPortletRequest.getResponseContentTypes();
- if (property == null)
- {
- property = new StringBuffer(64);
- }
- else
- {
- property.setLength(0);
- }
- boolean addComma = false;
- while (values != null && values.hasMoreElements())
- {
- String s = (String) values.nextElement();
- if (s != null)
- {
- if (addComma)
- {
- property = property.append(',');
- }
- else
- {
- addComma = true;
- }
- property = property.append(s);
- }
- }
-
- if (addComma)
- {
- addProperty("ACCEPT", property.toString());
- }
- }
-
- if (!containsHeader(mHeaderNames, "ACCEPT-LANGUAGE"))
- {
- values = mPortletRequest.getLocales();
- if (property == null)
- {
- property = new StringBuffer(64);
- }
- else
- {
- property.setLength(0);
- }
- boolean addComma = false;
- while (values != null && values.hasMoreElements())
- {
- Locale l = (Locale) values.nextElement();
- if (l != null)
- {
- if (addComma)
- {
- property = property.append(',');
- }
- else
- {
- addComma = true;
- }
- String s = l.getLanguage();
- // only add if language not empty
- if (s.length() > 0)
- {
- property = property.append(s);
- s = l.getCountry();
- if (s.length() > 0)
- {
- property = property.append('-');
- property = property.append(s);
- }
- }
- }
- }
-
- if (addComma)
- {
- addProperty("ACCEPT-LANGUAGE", property.toString());
- }
- }
-
- if ((Bridge.PortletPhase) mPortletRequest.getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE) == Bridge.PortletPhase.ActionPhase)
- {
-
- if (!containsHeader(mHeaderNames, "CONTENT-TYPE"))
- {
- String contentType = ((ActionRequest) mPortletRequest).getContentType();
- String charset = ((ActionRequest) mPortletRequest).getCharacterEncoding();
-
- if (contentType != null)
- {
- if (property == null)
- {
- property = new StringBuffer(64);
- }
- else
- {
- property.setLength(0);
- }
-
- property = property.append(contentType);
- if (charset != null)
- {
- property = property.append("; charset=");
- property = property.append(charset);
- }
- addProperty("CONTENT-TYPE", property.toString());
- }
- }
-
- if (!containsHeader(mHeaderNames, "CONTENT-LENGTH"))
- {
- int contentLength = ((ActionRequest) mPortletRequest).getContentLength();
-
- if (contentLength != -1)
- {
- addProperty("CONTENT-LENGTH", String.valueOf(contentLength));
- }
- }
-
- }
-
- return true;
- }
-
- private boolean containsHeader(List headerNames, String key)
- {
- Iterator i = headerNames.iterator();
- while (i.hasNext())
- {
- String name = (String) i.next();
- if (key.toUpperCase().equals(name.toUpperCase()))
- {
- return true;
- }
- }
- return false;
- }
-
- protected final void addProperty(String name, String value)
- {
- if (mHeaders == Collections.EMPTY_MAP)
- {
- mHeaders = new HashMap(40);
- mHeaderNames = new ArrayList(30);
- }
- // Store against UPPER CASE key to make case-insensitive
- String upperName = name.toUpperCase();
- List propertyList = (List) mHeaders.get(upperName);
- if (propertyList == null)
- {
- propertyList = new ArrayList(4);
- mHeaders.put(upperName, propertyList);
- mHeaderNames.add(name);
- }
- propertyList.add(value);
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import javax.portlet.PortletRequest;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.faces.Bridge;
+
+public class PortletRequestHeaders
+{
+ private PortletRequest mPortletRequest = null;
+ private List mHeaderNames = null;
+ private Map mHeaders = null;
+
+ public PortletRequestHeaders(PortletRequest request)
+ {
+ mPortletRequest = request;
+ }
+
+ public java.lang.String getHeader(java.lang.String name)
+ {
+ // initialize the header map if it hasn't been already
+ initHeaderMap();
+
+ List headerVals = (List) mHeaders.get(name.toUpperCase());
+ return headerVals == null ? null : (String) headerVals.get(0);
+ }
+
+ public java.util.Enumeration getHeaders(java.lang.String name)
+ {
+ // initialize the header map if it hasn't been already
+ initHeaderMap();
+
+ List headerVals = (List) mHeaders.get(name.toUpperCase());
+ return Collections.enumeration(headerVals == null ? Collections.EMPTY_LIST : headerVals);
+ }
+
+ public java.util.Enumeration getHeaderNames()
+ {
+ // initialize the header map if it hasn't been already
+ initHeaderMap();
+
+ return Collections.enumeration(mHeaderNames);
+ }
+
+ /**
+ * Does 'lazy' initialization of Map of 'properties', i.e. mime headers.
+ */
+ protected boolean initHeaderMap()
+ {
+ if (mHeaders != null)
+ {
+ return false;
+ }
+
+ mHeaders = Collections.EMPTY_MAP;
+ mHeaderNames = Collections.EMPTY_LIST;
+
+ Enumeration props = mPortletRequest.getPropertyNames();
+ Enumeration values = null;
+ StringBuffer property = null;
+
+ while (props != null && props.hasMoreElements())
+ {
+ String name = (String) props.nextElement();
+ values = mPortletRequest.getProperties(name);
+ while (values != null && values.hasMoreElements())
+ {
+ addProperty(name, (String) values.nextElement());
+ }
+ }
+
+ // if they don't already exist, now add in the the required (HTTP)
+ // headers to ensure compatibility with servlets
+ if (!containsHeader(mHeaderNames, "ACCEPT"))
+ {
+ values = mPortletRequest.getResponseContentTypes();
+ if (property == null)
+ {
+ property = new StringBuffer(64);
+ }
+ else
+ {
+ property.setLength(0);
+ }
+ boolean addComma = false;
+ while (values != null && values.hasMoreElements())
+ {
+ String s = (String) values.nextElement();
+ if (s != null)
+ {
+ if (addComma)
+ {
+ property = property.append(',');
+ }
+ else
+ {
+ addComma = true;
+ }
+ property = property.append(s);
+ }
+ }
+
+ if (addComma)
+ {
+ addProperty("ACCEPT", property.toString());
+ }
+ }
+
+ if (!containsHeader(mHeaderNames, "ACCEPT-LANGUAGE"))
+ {
+ values = mPortletRequest.getLocales();
+ if (property == null)
+ {
+ property = new StringBuffer(64);
+ }
+ else
+ {
+ property.setLength(0);
+ }
+ boolean addComma = false;
+ while (values != null && values.hasMoreElements())
+ {
+ Locale l = (Locale) values.nextElement();
+ if (l != null)
+ {
+ if (addComma)
+ {
+ property = property.append(',');
+ }
+ else
+ {
+ addComma = true;
+ }
+ String s = l.getLanguage();
+ // only add if language not empty
+ if (s.length() > 0)
+ {
+ property = property.append(s);
+ s = l.getCountry();
+ if (s.length() > 0)
+ {
+ property = property.append('-');
+ property = property.append(s);
+ }
+ }
+ }
+ }
+
+ if (addComma)
+ {
+ addProperty("ACCEPT-LANGUAGE", property.toString());
+ }
+ }
+
+ if ((Bridge.PortletPhase) mPortletRequest.getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE) == Bridge.PortletPhase.ActionPhase)
+ {
+
+ if (!containsHeader(mHeaderNames, "CONTENT-TYPE"))
+ {
+ String contentType = ((ActionRequest) mPortletRequest).getContentType();
+ String charset = ((ActionRequest) mPortletRequest).getCharacterEncoding();
+
+ if (contentType != null)
+ {
+ if (property == null)
+ {
+ property = new StringBuffer(64);
+ }
+ else
+ {
+ property.setLength(0);
+ }
+
+ property = property.append(contentType);
+ if (charset != null)
+ {
+ property = property.append("; charset=");
+ property = property.append(charset);
+ }
+ addProperty("CONTENT-TYPE", property.toString());
+ }
+ }
+
+ if (!containsHeader(mHeaderNames, "CONTENT-LENGTH"))
+ {
+ int contentLength = ((ActionRequest) mPortletRequest).getContentLength();
+
+ if (contentLength != -1)
+ {
+ addProperty("CONTENT-LENGTH", String.valueOf(contentLength));
+ }
+ }
+
+ }
+
+ return true;
+ }
+
+ private boolean containsHeader(List headerNames, String key)
+ {
+ Iterator i = headerNames.iterator();
+ while (i.hasNext())
+ {
+ String name = (String) i.next();
+ if (key.toUpperCase().equals(name.toUpperCase()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected final void addProperty(String name, String value)
+ {
+ if (mHeaders == Collections.EMPTY_MAP)
+ {
+ mHeaders = new HashMap(40);
+ mHeaderNames = new ArrayList(30);
+ }
+ // Store against UPPER CASE key to make case-insensitive
+ String upperName = name.toUpperCase();
+ List propertyList = (List) mHeaders.get(upperName);
+ if (propertyList == null)
+ {
+ propertyList = new ArrayList(4);
+ mHeaders.put(upperName, propertyList);
+ mHeaderNames.add(name);
+ }
+ propertyList.add(value);
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java Mon Nov 19 08:56:29 2007
@@ -1,90 +1,90 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.Enumeration;
-
-import javax.portlet.PortletRequest;
-
-/**
- * Map of portlet request attributes
- */
-public class PortletRequestMap extends PortletAbstractMap
-{
- private final PortletRequest mPortletRequest;
-
- public PortletRequestMap(Object request)
- {
- if (request instanceof PortletRequest)
- {
- mPortletRequest = (PortletRequest) request;
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public Object getAttribute(String key)
- {
- if (mPortletRequest != null)
- {
- return mPortletRequest.getAttribute(key);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public void setAttribute(String key, Object value)
- {
- if (mPortletRequest != null)
- {
-
- mPortletRequest.setAttribute(key, value);
-
- }
- }
-
- @Override
- public void removeAttribute(String key)
- {
- if (mPortletRequest != null)
- {
- mPortletRequest.removeAttribute(key);
- }
- }
-
- @Override
- public Enumeration getAttributeNames()
- {
- if (mPortletRequest != null)
- {
- return mPortletRequest.getAttributeNames();
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * Map of portlet request attributes
+ */
+public class PortletRequestMap extends PortletAbstractMap
+{
+ private final PortletRequest mPortletRequest;
+
+ public PortletRequestMap(Object request)
+ {
+ if (request instanceof PortletRequest)
+ {
+ mPortletRequest = (PortletRequest) request;
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ if (mPortletRequest != null)
+ {
+ return mPortletRequest.getAttribute(key);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ if (mPortletRequest != null)
+ {
+
+ mPortletRequest.setAttribute(key, value);
+
+ }
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ if (mPortletRequest != null)
+ {
+ mPortletRequest.removeAttribute(key);
+ }
+ }
+
+ @Override
+ public Enumeration getAttributeNames()
+ {
+ if (mPortletRequest != null)
+ {
+ return mPortletRequest.getAttributeNames();
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java Mon Nov 19 08:56:29 2007
@@ -1,117 +1,117 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-
-/**
- * Map of portlet request params
- */
-public class PortletRequestParameterMap extends PortletAbstractMap
-{
- private final PortletRequest mPortletRequest;
- private final Map mInternalAttributes;
-
- public PortletRequestParameterMap(Object request, Map internal)
- {
- if (request instanceof PortletRequest)
- {
- mPortletRequest = (PortletRequest) request;
- if (internal == null)
- {
- mInternalAttributes = Collections.EMPTY_MAP;
- }
- else
- {
- mInternalAttributes = internal;
- }
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public Object getAttribute(String key)
- {
- if (mPortletRequest != null)
- {
- Object value = mInternalAttributes.get(key);
- if (value != null)
- {
- return value;
- }
-
- return mPortletRequest.getParameter(key);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public void setAttribute(String key, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void removeAttribute(String key)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Enumeration getAttributeNames()
- {
- if (mPortletRequest != null)
- {
- // merged list of internal parameters & request parameters
- List attrNames = new ArrayList(5);
-
- Enumeration requestAttrNames = mPortletRequest.getParameterNames();
- while (requestAttrNames.hasMoreElements())
- {
- attrNames.add(requestAttrNames.nextElement());
- }
-
- for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
- {
- Entry entry = (Entry) i.next();
- attrNames.add(entry.getKey());
- }
-
- return Collections.enumeration(attrNames);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * Map of portlet request params
+ */
+public class PortletRequestParameterMap extends PortletAbstractMap
+{
+ private final PortletRequest mPortletRequest;
+ private final Map mInternalAttributes;
+
+ public PortletRequestParameterMap(Object request, Map internal)
+ {
+ if (request instanceof PortletRequest)
+ {
+ mPortletRequest = (PortletRequest) request;
+ if (internal == null)
+ {
+ mInternalAttributes = Collections.EMPTY_MAP;
+ }
+ else
+ {
+ mInternalAttributes = internal;
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ if (mPortletRequest != null)
+ {
+ Object value = mInternalAttributes.get(key);
+ if (value != null)
+ {
+ return value;
+ }
+
+ return mPortletRequest.getParameter(key);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Enumeration getAttributeNames()
+ {
+ if (mPortletRequest != null)
+ {
+ // merged list of internal parameters & request parameters
+ List attrNames = new ArrayList(5);
+
+ Enumeration requestAttrNames = mPortletRequest.getParameterNames();
+ while (requestAttrNames.hasMoreElements())
+ {
+ attrNames.add(requestAttrNames.nextElement());
+ }
+
+ for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
+ {
+ Entry entry = (Entry) i.next();
+ attrNames.add(entry.getKey());
+ }
+
+ return Collections.enumeration(attrNames);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java Mon Nov 19 08:56:29 2007
@@ -1,117 +1,117 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-
-/**
- * Map of portlet request param values
- */
-public class PortletRequestParameterValuesMap extends PortletAbstractMap
-{
- private final PortletRequest mPortletRequest;
- private final Map mInternalAttributes;
-
- public PortletRequestParameterValuesMap(Object request, Map internal)
- {
- if (request instanceof PortletRequest)
- {
- mPortletRequest = (PortletRequest) request;
- if (internal == null)
- {
- mInternalAttributes = Collections.EMPTY_MAP;
- }
- else
- {
- mInternalAttributes = internal;
- }
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public Object getAttribute(String key)
- {
- if (mPortletRequest != null)
- {
- Object value = mInternalAttributes.get(key);
- if (value != null)
- {
- return value;
- }
-
- return mPortletRequest.getParameterValues(key);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- public void setAttribute(String key, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void removeAttribute(String key)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Enumeration getAttributeNames()
- {
- if (mPortletRequest != null)
- {
- // merged list of internal parameters & request parameters
- List attrNames = new ArrayList(5);
-
- Enumeration requestAttrNames = mPortletRequest.getParameterNames();
- while (requestAttrNames.hasMoreElements())
- {
- attrNames.add(requestAttrNames.nextElement());
- }
-
- for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
- {
- Entry entry = (Entry) i.next();
- attrNames.add(entry.getKey());
- }
-
- return Collections.enumeration(attrNames);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+/**
+ * Map of portlet request param values
+ */
+public class PortletRequestParameterValuesMap extends PortletAbstractMap
+{
+ private final PortletRequest mPortletRequest;
+ private final Map mInternalAttributes;
+
+ public PortletRequestParameterValuesMap(Object request, Map internal)
+ {
+ if (request instanceof PortletRequest)
+ {
+ mPortletRequest = (PortletRequest) request;
+ if (internal == null)
+ {
+ mInternalAttributes = Collections.EMPTY_MAP;
+ }
+ else
+ {
+ mInternalAttributes = internal;
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ if (mPortletRequest != null)
+ {
+ Object value = mInternalAttributes.get(key);
+ if (value != null)
+ {
+ return value;
+ }
+
+ return mPortletRequest.getParameterValues(key);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Enumeration getAttributeNames()
+ {
+ if (mPortletRequest != null)
+ {
+ // merged list of internal parameters & request parameters
+ List attrNames = new ArrayList(5);
+
+ Enumeration requestAttrNames = mPortletRequest.getParameterNames();
+ while (requestAttrNames.hasMoreElements())
+ {
+ attrNames.add(requestAttrNames.nextElement());
+ }
+
+ for (Iterator i = mInternalAttributes.entrySet().iterator(); i.hasNext();)
+ {
+ Entry entry = (Entry) i.next();
+ attrNames.add(entry.getKey());
+ }
+
+ return Collections.enumeration(attrNames);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+}
Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java Mon Nov 19 08:56:29 2007
@@ -1,136 +1,136 @@
-/* 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.myfaces.portlet.faces.util.map;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.faces.Bridge;
-
-/**
- * Map of portlet session attributes
- */
-public class PortletSessionMap extends PortletAbstractMap
-{
-
- private final PortletRequest mPortletRequest;
- private final int mScope;
-
- public PortletSessionMap(Object request)
- {
- if (request != null && request instanceof PortletRequest)
- {
- mPortletRequest = (PortletRequest) request;
- mScope = PortletSession.PORTLET_SCOPE;
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- public PortletSessionMap(Object request, int scope)
- {
- if (request != null && request instanceof PortletRequest)
- {
- mPortletRequest = (PortletRequest) request;
- mScope = scope;
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- @Override
- protected Object getAttribute(String key)
- {
- PortletSession portletSession = mPortletRequest.getPortletSession(true);
-
- if (key.equals(Bridge.APPLICATION_SCOPE_MAP))
- {
- return getAppScopeMap(portletSession);
- }
- else
- {
- return portletSession.getAttribute(key, mScope);
- }
- }
-
- @Override
- protected void setAttribute(String key, Object value)
- {
- if (mPortletRequest != null)
- {
- mPortletRequest.getPortletSession(true).setAttribute(key, value, mScope);
- }
- }
-
- @Override
- protected void removeAttribute(String key)
- {
- if (mPortletRequest != null)
- {
- PortletSession portletSession = mPortletRequest.getPortletSession(false);
-
- if (portletSession != null)
- {
- portletSession.removeAttribute(key, mScope);
- }
- }
- }
-
- @Override
- protected Enumeration getAttributeNames()
- {
- if (mPortletRequest != null)
- {
- PortletSession portletSession = mPortletRequest.getPortletSession(false);
- ;
- return portletSession == null ? Collections.enumeration(Collections.EMPTY_LIST)
- : portletSession.getAttributeNames(mScope);
- }
- else
- {
- throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
- }
- }
-
- private Map getAppScopeMap(PortletSession portletSession)
- {
- if (mScope != PortletSession.PORTLET_SCOPE)
- {
- return null;
- }
-
- Map m = (Map) portletSession.getAttribute(Bridge.APPLICATION_SCOPE_MAP);
-
- if (m == null)
- {
- m = new PortletSessionMap(mPortletRequest, PortletSession.APPLICATION_SCOPE);
- portletSession.setAttribute(Bridge.APPLICATION_SCOPE_MAP, m);
- }
- return m;
- }
-
-}
+/* 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.myfaces.portlet.faces.util.map;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.faces.Bridge;
+
+/**
+ * Map of portlet session attributes
+ */
+public class PortletSessionMap extends PortletAbstractMap
+{
+
+ private final PortletRequest mPortletRequest;
+ private final int mScope;
+
+ public PortletSessionMap(Object request)
+ {
+ if (request != null && request instanceof PortletRequest)
+ {
+ mPortletRequest = (PortletRequest) request;
+ mScope = PortletSession.PORTLET_SCOPE;
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ public PortletSessionMap(Object request, int scope)
+ {
+ if (request != null && request instanceof PortletRequest)
+ {
+ mPortletRequest = (PortletRequest) request;
+ mScope = scope;
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ @Override
+ protected Object getAttribute(String key)
+ {
+ PortletSession portletSession = mPortletRequest.getPortletSession(true);
+
+ if (key.equals(Bridge.APPLICATION_SCOPE_MAP))
+ {
+ return getAppScopeMap(portletSession);
+ }
+ else
+ {
+ return portletSession.getAttribute(key, mScope);
+ }
+ }
+
+ @Override
+ protected void setAttribute(String key, Object value)
+ {
+ if (mPortletRequest != null)
+ {
+ mPortletRequest.getPortletSession(true).setAttribute(key, value, mScope);
+ }
+ }
+
+ @Override
+ protected void removeAttribute(String key)
+ {
+ if (mPortletRequest != null)
+ {
+ PortletSession portletSession = mPortletRequest.getPortletSession(false);
+
+ if (portletSession != null)
+ {
+ portletSession.removeAttribute(key, mScope);
+ }
+ }
+ }
+
+ @Override
+ protected Enumeration getAttributeNames()
+ {
+ if (mPortletRequest != null)
+ {
+ PortletSession portletSession = mPortletRequest.getPortletSession(false);
+ ;
+ return portletSession == null ? Collections.enumeration(Collections.EMPTY_LIST)
+ : portletSession.getAttributeNames(mScope);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
+ }
+ }
+
+ private Map getAppScopeMap(PortletSession portletSession)
+ {
+ if (mScope != PortletSession.PORTLET_SCOPE)
+ {
+ return null;
+ }
+
+ Map m = (Map) portletSession.getAttribute(Bridge.APPLICATION_SCOPE_MAP);
+
+ if (m == null)
+ {
+ m = new PortletSessionMap(mPortletRequest, PortletSession.APPLICATION_SCOPE);
+ portletSession.setAttribute(Bridge.APPLICATION_SCOPE_MAP, m);
+ }
+ return m;
+ }
+
+}