cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/session-fw/java/org/apache/cocoon/components/language/markup/xsp XSPSessionFwHelper.java
Date Thu, 09 Oct 2003 07:18:36 GMT
cziegeler    2003/10/09 00:18:36

  Modified:    src/blocks/session-fw/java/org/apache/cocoon/components/language/markup/xsp
                        XSPSessionFwHelper.java
  Log:
  Hopefully fixing NPE when the path does not exist
  
  Revision  Changes    Path
  1.2       +27 -27    cocoon-2.1/src/blocks/session-fw/java/org/apache/cocoon/components/language/markup/xsp/XSPSessionFwHelper.java
  
  Index: XSPSessionFwHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/session-fw/java/org/apache/cocoon/components/language/markup/xsp/XSPSessionFwHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSPSessionFwHelper.java	3 Sep 2003 13:13:27 -0000	1.1
  +++ XSPSessionFwHelper.java	9 Oct 2003 07:18:36 -0000	1.2
  @@ -68,34 +68,34 @@
    * @since 2.1.1
    */
   public class XSPSessionFwHelper {
  -    /** GetXML Fragment from the given session context and path
  -      *
  -      *
  -      * @param session The Session object
  -      * @param context The Session context tha define where to search
  -      * @param path The parameter path
  -      * @param defaultValue Value to substitute in absence of the required Fragment
  -     **/
  -     public static DocumentFragment getXML(ComponentManager cm, String context, String
path) throws ProcessingException {
   
  -         SessionManager sm = null;
  -         DocumentFragment df = null;
  +    /** GetXML Fragment from the given session context and path
  +     *
  +     *
  +     * @param session The Session object
  +     * @param context The Session context tha define where to search
  +     * @param path The parameter path
  +     * @param defaultValue Value to substitute in absence of the required Fragment
  +    **/
  +    public static Object getXML(ComponentManager cm, String context, String path) throws
ProcessingException {
   
  -         try {
  -             // Start looking up the manager
  -             sm = (SessionManager)cm.lookup(SessionManager.ROLE);
  -             // Make our work
  -             df = sm.getContextFragment(context, path);
  -             if (sm != null) {
  -                 cm.release((Component)sm);
  -             }
  -         } catch (ComponentException ce) {
  -             throw new ProcessingException("Error during lookup of SessionManager component.",
ce);
  -         } finally {
  -             // End releasing the sessionmanager
  -		     cm.release((Component)sm);
  -	     }
  -         return df;
  +        SessionManager sessionManager = null;
  +        try {
  +            // Start looking up the manager
  +            sessionManager = (SessionManager)cm.lookup(SessionManager.ROLE);
  +            // Get the fragment
  +            DocumentFragment df = sessionManager.getContextFragment(context, path);
  +            if ( df != null ) {
  +                return df;
  +            } else {
  +                return "";
  +            }
  +        } catch (ComponentException ce) {
  +            throw new ProcessingException("Error during lookup of SessionManager component.",
ce);
  +        } finally {
  +            // End releasing the sessionmanager
  +		    cm.release((Component)sessionManager);
  +	    }
        }
   }
   
  
  
  

Mime
View raw message