Author: julien_viet
Date: 2010-09-20 08:13:48 -0400 (Mon, 20 Sep 2010)
New Revision: 4253
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/ContainerURL.java
components/pc/trunk/portal/src/main/java/org/gatein/pc/portal/jsp/taglib/PortletURLTag.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/BaseURLImpl.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/PortletURLImpl.java
Log:
GTNPC-29 : Basic support for URL properties
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/ContainerURL.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/ContainerURL.java 2010-09-20
11:43:54 UTC (rev 4252)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/ContainerURL.java 2010-09-20
12:13:48 UTC (rev 4253)
@@ -22,6 +22,8 @@
*/
package org.gatein.pc.api;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -48,4 +50,12 @@
* @return the navigational state
*/
StateString getNavigationalState();
+
+ /**
+ * Returns a set of properties associated with this URL. The returned map cannot be
modified.
+ *
+ * @return the property map
+ */
+ Map<String, String> getProperties();
+
}
Modified:
components/pc/trunk/portal/src/main/java/org/gatein/pc/portal/jsp/taglib/PortletURLTag.java
===================================================================
---
components/pc/trunk/portal/src/main/java/org/gatein/pc/portal/jsp/taglib/PortletURLTag.java 2010-09-20
11:43:54 UTC (rev 4252)
+++
components/pc/trunk/portal/src/main/java/org/gatein/pc/portal/jsp/taglib/PortletURLTag.java 2010-09-20
12:13:48 UTC (rev 4253)
@@ -33,6 +33,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.util.Collections;
import java.util.Map;
import java.io.IOException;
@@ -124,6 +125,11 @@
{
return ws;
}
+
+ public Map<String, String> getProperties()
+ {
+ return Collections.emptyMap();
+ }
};
try
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/BaseURLImpl.java 2010-09-20
11:43:54 UTC (rev 4252)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/BaseURLImpl.java 2010-09-20
12:13:48 UTC (rev 4253)
@@ -31,6 +31,8 @@
import javax.portlet.BaseURL;
import javax.portlet.PortletSecurityException;
import javax.portlet.PortletURLGenerationListener;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.io.Writer;
import java.io.IOException;
@@ -126,25 +128,21 @@
return url.getParameters();
}
- public void addProperty(String s, String s1)
+ public void addProperty(String key, String value)
{
- if (s == null)
- {
- throw new IllegalArgumentException("property name cannot be null");
- }
-
- //TODO:
-
+ // We only support mono valued properties
+ setProperty(key, value);
}
- public void setProperty(String s, String s1)
+ public void setProperty(String key, String value)
{
- if (s == null)
+ if (key == null)
{
throw new IllegalArgumentException("property name cannot be null");
}
- //TODO:
+ //
+ getContainerURL().setProperty(key, value);
}
private InternalContainerURL blah()
@@ -212,6 +210,46 @@
protected static abstract class InternalContainerURL implements ContainerURL
{
+ /** . */
+ static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
+
+ /** . */
+ private Map<String, String> properties;
+
+ protected InternalContainerURL()
+ {
+ this.properties = EMPTY_MAP;
+ }
+
+ protected InternalContainerURL(InternalContainerURL that)
+ {
+ this.properties = that.properties.isEmpty() ? EMPTY_MAP : new HashMap<String,
String>(this.properties);
+ }
+
+ public final Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ private void setProperty(String key, String value)
+ {
+ if (value == null)
+ {
+ if (properties.size() > 0)
+ {
+ properties.remove(key);
+ }
+ }
+ else
+ {
+ if (properties == EMPTY_MAP)
+ {
+ properties = new HashMap<String, String>();
+ }
+ properties.put(key, value);
+ }
+ }
+
protected abstract void setParameter(String name, String value);
protected abstract void setParameter(String name, String[] values);
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/PortletURLImpl.java 2010-09-20
11:43:54 UTC (rev 4252)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/PortletURLImpl.java 2010-09-20
12:13:48 UTC (rev 4253)
@@ -164,6 +164,9 @@
protected InternalPortletURL(InternalPortletURL original)
{
+ super(original);
+
+ //
this.windowState = original.windowState;
this.portletMode = original.portletMode;
}
Show replies by date