portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jf...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules LocalizedFieldRule.java
Date Thu, 11 Mar 2004 23:12:08 GMT
jford       2004/03/11 15:12:08

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager/rules
                        LocalizedFieldRule.java
  Log:
  Checks for null objects.
  Push null onto stack when no metadata found
  
  Revision  Changes    Path
  1.4       +37 -26    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules/LocalizedFieldRule.java
  
  Index: LocalizedFieldRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/rules/LocalizedFieldRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalizedFieldRule.java	11 Mar 2004 19:21:06 -0000	1.3
  +++ LocalizedFieldRule.java	11 Mar 2004 23:12:08 -0000	1.4
  @@ -22,7 +22,6 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.om.common.GenericMetadata;
   import org.apache.jetspeed.om.common.LocalizedField;
  -import org.apache.jetspeed.om.common.impl.LocalizedFieldImpl;
   import org.xml.sax.Attributes;
   
   /**
  @@ -48,45 +47,57 @@
               digester.getLogger().debug("Setting localized field " + name);
           
           GenericMetadata metadata = (GenericMetadata)digester.peek();
  -        
  -        LocalizedField child = metadata.createLocalizedField(); 
  -
  -        if(name.equals("metadata"))
  -        {
  -            String nameAttr = attributes.getValue("name");
  -            child.setName(nameAttr);
  -        }
  -        else
  -        {
  -            child.setName(name);
  -        }
  -        String language = attributes.getValue("xml:lang");
  -        Locale locale = null;
  -        if(language == null)
  -        {
  -            locale = new Locale("en");
  +        if(metadata != null)
  +        {        
  +	        LocalizedField child = metadata.createLocalizedField(); 
  +	
  +	        if(name.equals("metadata"))
  +	        {
  +	            String nameAttr = attributes.getValue("name");
  +	            child.setName(nameAttr);
  +	        }
  +	        else
  +	        {
  +	            child.setName(name);
  +	        }
  +	        String language = attributes.getValue("xml:lang");
  +	        Locale locale = null;
  +	        if(language == null)
  +	        {
  +	            locale = new Locale("en");
  +	        }
  +	        else
  +	        {
  +	            locale = new Locale(language);
  +	        }
  +	
  +	        child.setLocale(locale);
  +	        digester.push(child);
           }
           else
           {
  -            locale = new Locale(language);
  +            digester.push(null);
           }
  -
  -        child.setLocale(locale);
  -        digester.push(child);
       }
   
       public void body(String namespace, String name, String text)
       throws Exception
       {
           LocalizedField child = (LocalizedField) digester.peek(0);
  -        child.setValue(text);
  +        if(child != null)
  +        {    
  +            child.setValue(text);
  +        }
       }
   
       public void end(String namespace, String name)
       throws Exception
       {
           LocalizedField child = (LocalizedField) digester.pop();
  -        GenericMetadata metadata = (GenericMetadata)digester.peek();
  -        metadata.addField(child);
  +        if(child != null)
  +        {    
  +            GenericMetadata metadata = (GenericMetadata)digester.peek();
  +            metadata.addField(child);
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message