[ 
https://issues.apache.org/jira/browse/COCOON-2072?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Francesco Chicchiricco updated COCOON-2072:
-------------------------------------------

          Description: 
A FAQ here: 
http://wiki.java.net/bin/view/Portlet/JSR168FAQ#Is_there_a_hack_to_get_set_cooki
 says that some JSR-168 containers provide their javax.portlet.PortletRequest 
implementation with cookies, even thought embedded in a string.

Looking at sources of Jakarta Pluto 
(org.apache.pluto.internal.impl.PortletRequestImpl) and Sun's Open Portal - 
free version of Sun JES Portal Server - 
(com.sun.portal.portlet.impl.PortletRequestImpl), I found that this is true for 
both.

See attached a simple org.apache.cocoon.components.modules.input.CookieModule 
extension that can handle all that above, providing cookie access to portlets.


  was:
A FAQ here: 
http://wiki.java.net/bin/view/Portlet/JSR168FAQ#Is_there_a_hack_to_get_set_cooki
 says that some JSR-168 containers provide their javax.portlet.PortletRequest 
implementation with cookies, even thought embedded in a string.

Looking at sources of Jakarta Pluto 
(org.apache.pluto.internal.impl.PortletRequestImpl) and Sun's Open Portal - 
free version of Sun JES Portal Server - 
(com.sun.portal.portlet.impl.PortletRequestImpl), I found that this is true for 
both.

So, I wrote a simple org.apache.cocoon.components.modules.input.CookieModule 
extension that can handle all that above, providing cookie access to portlets:

Here's the code:

public class PortletAwareCookieModule extends CookieModule {

        final protected String COOKIE = "cookie";

        @Override
        protected Map getCookieMap(Map objectModel) {
                if 
(!objectModel.containsKey(PortletObjectModelHelper.PORTLET_REQUEST_OBJECT))
                        return super.getCookieMap(objectModel);

                PortletRequest portletRequest =
                                
PortletObjectModelHelper.getPortletRequest(objectModel);
                String cookieList = portletRequest.getProperty(COOKIE);
                StringTokenizer cookieTok = new StringTokenizer(cookieList,
                                ";");
                String[] cookieParts = null;
                Map<String, HttpCookie> cookieMap = new HashMap<String, 
HttpCookie>();
                while (cookieTok.hasMoreTokens()) {
                        cookieParts = cookieTok.nextToken()
                                        .trim()
                                        .split("=");
                        cookieMap.put(cookieParts[0],
                                        new HttpCookie(cookieParts[0],
                                                        cookieParts[1]));
                }

                return cookieMap;
        }

}

    Affects Version/s: 2.1.11

> JSR.168 Portlet-aware CookieModule
> ----------------------------------
>
>                 Key: COCOON-2072
>                 URL: https://issues.apache.org/jira/browse/COCOON-2072
>             Project: Cocoon
>          Issue Type: Improvement
>          Components: Blocks: Portal
>    Affects Versions: 2.1.11
>            Reporter: Francesco Chicchiricco
>         Attachments: PortletAwareCookieModule.java
>
>
> A FAQ here: 
> http://wiki.java.net/bin/view/Portlet/JSR168FAQ#Is_there_a_hack_to_get_set_cooki
>  says that some JSR-168 containers provide their javax.portlet.PortletRequest 
> implementation with cookies, even thought embedded in a string.
> Looking at sources of Jakarta Pluto 
> (org.apache.pluto.internal.impl.PortletRequestImpl) and Sun's Open Portal - 
> free version of Sun JES Portal Server - 
> (com.sun.portal.portlet.impl.PortletRequestImpl), I found that this is true 
> for both.
> See attached a simple org.apache.cocoon.components.modules.input.CookieModule 
> extension that can handle all that above, providing cookie access to portlets.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to