Thursday, April 16, 2009

URL encoding spaces in WCM_GLOBAL_CONTEXT with %20 will fail.

Problem
The IBM Web Content Management (WCM) local rendering portlet will always render the default content configured to it .However. if you want to overwrite a WCM local rendering portlet with new content, place the following string at the end of the link to the page:

?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/library/site/sitename/content


If the WCM library, site, site area, or content contains spaces in the name , using "%20" as URL encoding for spaces fails to render the specified content in WCM_GLOBAL_CONTEXT and therefore, the local rendering portlet will render the default content.

Example:
The library name is "Intranet library". Encoding this library name is "Intranet%20library". WCM_GLOBAL_CONTEXT is used with the following URL encoding:

?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/Intranet%20library/site/sitename/new_content

Clicking the link with "WCM_GLOBAL_CONTEXT" added will cause the local rendering portlet to render only the default content. It will fail to render new_content from "Intranet library".

Exceptions in the systemOut.log would be:
com.aptrix.pluto.renderer.BadPathInfoException: IWKPL1453X: Exception occured while processing request: /Intranet%20library/site/sitearea/new_content/

at

com.aptrix.pluto.renderer.RenderContext.generateContext(RenderContext.java:488)

at com.aptrix.pluto.renderer.RenderContext.(RenderContext.java:294)
at

com.ibm.workplace.wcm.api.WCM_RenderingContext.createRenderContext(WCM_RenderingContext.java:866)

at

com.ibm.workplace.wcm.api.WCM_RenderingContext.getRenderContext(WCM_RenderingContext.java:395)

at

com.ibm.workplace.wcm.api.WCM_RenderingContext.getContent(WCM_RenderingContext.java:988)
...

Symptom
In the above example, "Intranet%20library" will be encoded again to "Intranet%2520library", where "%25" is the encoded value for "%". This means that "%25" will lead to the new encoded string, "Intranet%2520library".


Since there is no library named "Intranet%20library" (the decoded value of "Intranet%2520GSC"), it will fail.

Resolving the problem
Use the plus sign ("+") instead of "%20".
For example, use following URL encoding in WCM_GLOBAL_CONTEXT:

?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/Intranet+library/site/sitename/new_content

This will overwrite the default content of the local rendering portlet with new_content from Intranet library.