You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by "Craig Doremus (JIRA)" <ji...@apache.org> on 2006/04/15 14:40:01 UTC

[jira] Resolved: (PLUTO-201) Null pointer returned by PortletEntity.getDefaultPreferences() when portlet/portlet-preferences section is missing or empty in portlet.xml

     [ http://issues.apache.org/jira/browse/PLUTO-201?page=all ]
     
Craig Doremus resolved PLUTO-201:
---------------------------------

    Resolution: Cannot Reproduce

This appears to be fixed for a while

> Null pointer returned by PortletEntity.getDefaultPreferences()  when portlet/portlet-preferences section is missing or empty in portlet.xml
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: PLUTO-201
>          URL: http://issues.apache.org/jira/browse/PLUTO-201
>      Project: Pluto
>         Type: Bug

>   Components: portlet container
>     Versions: 1.1.0-alpha1
>  Environment: Windows XP Pro Dual Xeon 3Ghz 2GB RAM
> Java 1.5.0-b64
>     Reporter: Timothy Matthews
>     Priority: Minor

>
> The following two example portlets entries in portlets.xml will cause getDefaultPreferences() to return null ( which is prohibited according to the comment block preceding the method), or to throw a NullPointerException.
> Example 1 (No preferences block, results in null being returned):
> 	<portlet>
> 		<portlet-name>XYZ Portlet</portlet-name>
> 		<portlet-class>
> 			com.xyz.portlet
> 		</portlet-class>
> 		<expiration-cache>0</expiration-cache>
> 		<supports>
> 			<mime-type>text/html</mime-type>
> 			<portlet-mode>EDIT</portlet-mode>
> 			<portlet-mode>VIEW</portlet-mode>
> 			<portlet-mode>HELP</portlet-mode>
> 		</supports>
> 		<resource-bundle>XYZPortletRB</resource-bundle>
> 		<portlet-info>
> 			<title>XYZ Portlet</title>
> 		</portlet-info>
> <!--note the absence of <portlet-preferences> here-->
> 	</portlet>
> Example 2 (empty preferences block, results in NullPointerException):
> 	<portlet>
> 		<portlet-name>XYZ Portlet</portlet-name>
> 		<portlet-class>
> 			com.xyz.portlet
> 		</portlet-class>
> 		<expiration-cache>0</expiration-cache>
> 		<supports>
> 			<mime-type>text/html</mime-type>
> 			<portlet-mode>EDIT</portlet-mode>
> 			<portlet-mode>VIEW</portlet-mode>
> 			<portlet-mode>HELP</portlet-mode>
> 		</supports>
> 		<resource-bundle>XYZPortletRB</resource-bundle>
> 		<portlet-info>
> 			<title>XYZ Portlet</title>
> 		</portlet-info>
> 		<portlet-preferences/>
> 	</portlet>
> The following bug fix is suggested:
>     /**
>      * Returns all preferences of this portlet The return value cannot be NULL.
>      * @return the preference set
>      */
>     public PortletPreference[] getDefaultPreferences() {
>         if(prefs == null) {
>             PortletDD dd = getPortletDefinition();
>             PortletPreferencesDD ppdd = dd.getPortletPreferences();
>             if (ppdd != null && ppdd.getPortletPreferences()!=null) {
>                 prefs = new PortletPreference[ppdd.getPortletPreferences().size()];
>                 Iterator pds = ppdd.getPortletPreferences().iterator();
>                 for(int i=0;pds.hasNext();i++) {
>                     PortletPreferenceDD pd = (PortletPreferenceDD)pds.next();
>                     prefs[i] = new PortletPreferenceImpl(
>                         pd.getName(), new String[] { pd.getValue()}
>                     );
>                 }
>             } else {
>                prefs=new PortletPreference[0];
>             }
>         } 
>         return prefs;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira