[ 
https://issues.apache.org/jira/browse/PB-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641201#action_12641201
 ] 

Antony Stubbs commented on PB-84:
---------------------------------

While we're at improving this code, may I also suggest something along the 
following lines? To help with error resolution...

{code}
        /** The portlet scope namespace as defined in PLT. 15.3. */
        private static final String PORTLET_SCOPE_NAMESPACE = 
"javax.portlet.p.";

        /**
         * The attribute name of the portlet winow id test, to be stored in the 
portlet session.
         */
    public static String PORTLET_WINDOW_ID = 
"org.apache.portals.bridges.util.portlet_window_id";
    
{code}

and

{code}
...
                                        final String[] nameRef = new String[1]; 
// array so that it can be accessed within anonymous class yet changed later
...
                                        // check that the attribute name was 
prefixed properly / as expected
                                        if 
(nameRef[0].startsWith(PORTLET_SCOPE_NAMESPACE) && nameRef[0].contains("?"))
                                        {
                                                portletWindowId = 
nameRef[0].substring(PORTLET_SCOPE_NAMESPACE.length(),
                                                        
nameRef[0].indexOf('?'));
                                                System.out.println(" --> found 
- PORTLET_WINDOW_ID = " + portletWindowId);
                                                
session.setAttribute(PORTLET_WINDOW_ID, portletWindowId,
                                                        
PortletSession.PORTLET_SCOPE);
                                        }
                                        else
                                        {
                                                throw new RuntimeException(
                                                        "Window ID attribute 
not prefixed with PORTLET_SCOPE_NAMESPACE. "
                                                                + "Make sure 
the portlet container stores the attribute in PORTLET_SCOPE_NAMESPACE "
                                                                + "and prefix's 
the name with the PORTLET NAMESPACE.");
                                        }
{code}

> CCE in PortletWindowUtils.getPortletWindowId
> --------------------------------------------
>
>                 Key: PB-84
>                 URL: https://issues.apache.org/jira/browse/PB-84
>             Project: Portals Bridges
>          Issue Type: Bug
>          Components: common
>    Affects Versions: 1.0
>         Environment: Mac OS, Wicket Portlets, OpenPortal Portlet Container
>            Reporter: Tim Boudreau
>         Attachments: portals-bridges-common-1.0.4.jar
>
>
> I'm trying to get wicket portlet support working over OpenPortal.  I've 
> hacked together implementations of ServletContextProvider and 
> PortletResourceURLFactory - just required exposing WicketFilter from the 
> Application to get the necessary data.  I can deploy a portlet, but...
> I'm getting this exception. 
> java.lang.ClassCastException: java.lang.Double
>         at 
> org.apache.portals.bridges.util.PortletWindowUtils.getPortletWindowId(PortletWindowUtils.java:45)
> Looking at the code, this seems like a clear bug:  The method casts to String 
> here:
> (String)session.getAttribute(PORTLET_WINDOW_ID);
> and if null fills in the value with an instance of Double.  If it's going to 
> put a Double there, it should probably not expect a String - this exception 
> will occur any time this method is called twice for a PortletSession, it will 
> throw the CCE the second time it is called.
> Since the value is not used, probably simply changing it to 
>         Object portletWindowId = session.getAttribute(PORTLET_WINDOW_ID);
> would fix it.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to