Author: mwringe
Date: 2010-11-05 11:17:57 -0400 (Fri, 05 Nov 2010)
New Revision: 4956
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java
Log:
GTNWSRP-97: We need to check if the resource ID is an encoded resource ID or an actual
resource ID (actual will occur when a producer writes the url based on tokens). Update
tests to include a check for this situation.
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java 2010-11-05
12:32:07 UTC (rev 4955)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java 2010-11-05
15:17:57 UTC (rev 4956)
@@ -251,17 +251,24 @@
*/
public static Map<String, String> decodeResource(String resourceInfo)
{
- Map<String, String[]> resourceParameters =
StateString.decodeOpaqueValue(resourceInfo);
-
Map<String, String> resource = new HashMap<String, String>();
+
+ if (resourceInfo != null &&
resourceInfo.startsWith(StateString.JBPNS_PREFIX))
+ {
+ Map<String, String[]> resourceParameters =
StateString.decodeOpaqueValue(resourceInfo);
- for (Map.Entry<String, String[]> entry : resourceParameters.entrySet())
- {
- if (entry.getValue() != null && entry.getValue().length > 0)
+ for (Map.Entry<String, String[]> entry : resourceParameters.entrySet())
{
- resource.put(entry.getKey(), entry.getValue()[0]);
+ if (entry.getValue() != null && entry.getValue().length > 0)
+ {
+ resource.put(entry.getKey(), entry.getValue()[0]);
+ }
}
}
+ else //we are not dealing with an encoded resource ID but an actual resource ID
+ {
+ resource.put(WSRP2RewritingConstants.RESOURCE_ID, resourceInfo);
+ }
return resource;
}
Modified:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java 2010-11-05
12:32:07 UTC (rev 4955)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java 2010-11-05
15:17:57 UTC (rev 4956)
@@ -96,6 +96,19 @@
assertNull(resourceMap.get(WSRPRewritingConstants.RESOURCE_URL));
assertEquals("false",
resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION));
}
+
+ public void testResourceIDToken()
+ {
+ //Test what happens in the case where the url is created via token wsrp rewriting
on the producer side
+ //In this case the resource ID will not be an encoded resource map.
+
+ Map<String, String> resourceMap =
WSRPResourceURL.decodeResource("resource_123");
+ String resourceID = resourceMap.get(WSRP2RewritingConstants.RESOURCE_ID);
+ assertEquals("resource_123", resourceID);
+
+ assertNull(resourceMap.get(WSRPRewritingConstants.RESOURCE_URL));
+ assertNull(resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION));
+ }
public void testResources()
{