morciuch    2003/06/30 11:57:26

  Modified:    src/java/org/apache/jetspeed/portal/portlets
                        NewRSSPortlet.java
  Log:
  Enhanced the exception handling for cases when rss contains no title and/or 
description.
  
  Revision  Changes    Path
  1.20      +27 -6     
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java
  
  Index: NewRSSPortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- NewRSSPortlet.java        28 Jun 2003 18:15:45 -0000      1.19
  +++ NewRSSPortlet.java        30 Jun 2003 18:57:26 -0000      1.20
  @@ -169,6 +169,7 @@
               isrc.setSystemId( url );
               isrc.setEncoding("UTF-8");
               this.document = parser.parse( isrc );
  +            this.setMetainfo(document);
   
           } catch ( Throwable t )
           {
  @@ -180,6 +181,16 @@
               throw new PortletException( t.getMessage() );
           }
   
  +
  +    }
  +
  +    /**
  +     * Parse out title and description
  +     * 
  +     * @param document
  +     */
  +    private void setMetainfo(Document document) throws PortletException
  +    {
           //Determine title and description for this portlet
           String title = null;
           String description = null;
  @@ -199,19 +210,29 @@
   
           if ( tn == null ) {
               throw new PortletException( ERROR_NOT_VALID );
  -        } else {
  -            title = tn.getFirstChild().getNodeValue();
  +        } 
  +        else 
  +        {
  +            Node fc = tn.getFirstChild();
  +            if (fc != null)
  +            {
  +                title = fc.getNodeValue();
  +            }
           }
   
           Node dn = getNode( channel, "description" );
   
  -        if ( dn != null ) {
  -            description = dn.getFirstChild().getNodeValue();
  +        if ( dn != null ) 
  +        {
  +            Node fc = dn.getFirstChild();
  +            if (fc != null)
  +            {
  +                description = fc.getNodeValue();
  +            }
           }
   
           this.setTitle( title );
           this.setDescription( description );
  -
       }
   
       /**
  
  
  

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

Reply via email to