cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/acting ServerPagesAction.java RequestParameterExistsAction.java SessionInvalidatorAction.java SessionPropagatorAction.java ResourceExistsAction.java SessionStateAction.java ScriptAction.java SessionIsValidAction.java SessionValidatorAction.java RequestParamAction.java SendmailAction.java
Date Wed, 11 Sep 2002 08:26:45 GMT
cziegeler    2002/09/11 01:26:45

  Modified:    src/java/org/apache/cocoon/acting ServerPagesAction.java
                        RequestParameterExistsAction.java
                        SessionInvalidatorAction.java
                        SessionPropagatorAction.java
                        ResourceExistsAction.java SessionStateAction.java
                        ScriptAction.java SessionIsValidAction.java
                        SessionValidatorAction.java RequestParamAction.java
                        SendmailAction.java
  Log:
  Some more logging and exception handling updates
  
  Revision  Changes    Path
  1.9       +4 -6      xml-cocoon2/src/java/org/apache/cocoon/acting/ServerPagesAction.java
  
  Index: ServerPagesAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/ServerPagesAction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServerPagesAction.java	31 Jul 2002 13:13:21 -0000	1.8
  +++ ServerPagesAction.java	11 Sep 2002 08:26:44 -0000	1.9
  @@ -154,7 +154,9 @@
           String source, Parameters parameters)
         throws Exception {
   
  -        getLogger().debug("serverpage source: " + source);
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("serverpage source: " + source);
  +        }
   
           String outputKey = parameters.getParameter("output-attribute", null);
           Map resultMap = new HashMap();
  @@ -188,10 +190,6 @@
               // Let the XSP do it's stuff
               generator.generate();
               success = objectModel.get(ACTION_SUCCESS_OBJECT);
  -
  -        } catch (Exception e) {
  -            getLogger().warn("serverpage error", e);
  -            throw e;
   
           } finally {
               // Release generator
  
  
  
  1.8       +217 -127  xml-cocoon2/src/java/org/apache/cocoon/acting/RequestParameterExistsAction.java
  
  Index: RequestParameterExistsAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/RequestParameterExistsAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RequestParameterExistsAction.java	22 Feb 2002 06:59:26 -0000	1.7
  +++ RequestParameterExistsAction.java	11 Sep 2002 08:26:44 -0000	1.8
  @@ -109,149 +109,239 @@
               String source,
               Parameters parameters
               )
  -    throws Exception
  -    {
  +    throws Exception {
           Request request = ObjectModelHelper.getRequest(objectModel);
  -        if (request == null) {
  -          getLogger().error("RequestInfoAction: no request object!");
  -          return(null);
  -        }
           HashMap results = new HashMap();
  -    HashMap items = new HashMap();
  -    int wildcards = 0;
  -
  -    // check default parameters for existence
  -    getLogger().debug("checking default parameters");
  -    Iterator reqParams = settings.values().iterator();
  -    while ( reqParams.hasNext() ) {
  -        String paramName = (String) reqParams.next();
  -        StringParts sp = splitParameter( paramName );
  -        if ( sp != null ) {
  -        // wildcard: special care required (deferred until later)
  -        items.put( new Integer( wildcards++ ), sp );
  -        getLogger().debug("(default) deferring "+paramName);
  -        } else {
  -        String paramValue = request.getParameter( paramName );
  -        if ( paramValue == null ) {
  -            return null;
  -        }
  -        results.put( paramName, paramValue );
  -        }
  -    }
  +        HashMap items = new HashMap();
  +        int wildcards = 0;
   
  -    // check parameters for existence
  -    getLogger().debug("checking sitemap parameters");
  -    String params = parameters.getParameter( "parameters", null) ;
  -    if ( params != null ) {
  -        StringTokenizer st = new StringTokenizer( params );
  -        while ( st.hasMoreTokens() ) {
  -        String paramName = st.nextToken();
  -        StringParts sp = splitParameter( paramName );
  -        if ( sp != null ) {
  -            // wildcard: special care required (deferred until later)
  -            items.put(new Integer(wildcards++), sp );
  -            getLogger().debug("deferring "+paramName);
  -        } else {
  -
  -            String paramValue = request.getParameter( paramName );
  -            if ( paramValue == null ) {
  -            return null;
  +        // check default parameters for existence
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("checking default parameters");
  +        }
  +        Iterator reqParams = settings.values().iterator();
  +        while (reqParams.hasNext()) {
  +            String paramName = (String) reqParams.next();
  +            StringParts sp = splitParameter(paramName);
  +            if (sp != null) {
  +                // wildcard: special care required (deferred until later)
  +                items.put(new Integer(wildcards++), sp);
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug("(default) deferring " + paramName);
  +                }
  +            } else {
  +                String paramValue = request.getParameter(paramName);
  +                if (paramValue == null) {
  +                    return null;
  +                }
  +                results.put(paramName, paramValue);
               }
  -            results.put( paramName, paramValue );
  -        }
           }
  -    }
   
  -    if ( wildcards != 0 ) {
  -        // special care for parameters with wildcard
  -        //
  -        getLogger().debug("deferred checking for parameters: "+wildcards);
  -
  -        // first one
  -        //
  -        getLogger().debug(" checking first");
  -        HashMap values = new HashMap();
  -        StringParts sp1 = (StringParts) items.get( new Integer( 0 ) );
  -        getLogger().debug("  Parameter is ["+sp1.prefix+" * "+sp1.pstfix+"] ");
  -        Enumeration requestParams = request.getParameterNames();
  -        Boolean dummy = new Boolean( true );
  -        while ( requestParams.hasMoreElements() ) {
  -        String paramName = (String) requestParams.nextElement();
  -        String match = getMatch( paramName, sp1 );
  -        if ( match != null ) {
  -            getLogger().debug("  value is >"+match+"< "+ sp1.prefix.length()+" "+ paramName.length()+ " " +sp1.pstfix.length());
  -            values.put( match, dummy );
  -            sp1.count++;
  -            getLogger().debug("   Parameter "+sp1.prefix+"*"+sp1.pstfix+" matches "+paramName+" ("+sp1.count+" so far)");
  -
  -            String paramValue = request.getParameter( paramName );
  -            if ( paramValue == null ) {
  -            return null;
  +        // check parameters for existence
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("checking sitemap parameters");
  +        }
  +        String params = parameters.getParameter("parameters", null);
  +        if (params != null) {
  +            StringTokenizer st = new StringTokenizer(params);
  +            while (st.hasMoreTokens()) {
  +                String paramName = st.nextToken();
  +                StringParts sp = splitParameter(paramName);
  +                if (sp != null) {
  +                    // wildcard: special care required (deferred until later)
  +                    items.put(new Integer(wildcards++), sp);
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug("deferring " + paramName);
  +                    }
  +                } else {
  +
  +                    String paramValue = request.getParameter(paramName);
  +                    if (paramValue == null) {
  +                        return null;
  +                    }
  +                    results.put(paramName, paramValue);
  +                }
               }
  -            results.put( paramName, paramValue );
  -        }
  -        }
  -
  -        if ( sp1.count == 0 ) {
  -        getLogger().debug("   Parameter "+sp1.prefix+"*"+sp1.pstfix+" matches "+sp1.count);
  -        return null;
           }
   
  +        if (wildcards != 0) {
  +            // special care for parameters with wildcard
  +            //
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("deferred checking for parameters: " + wildcards);
  +            }
   
  -        // all other ones
  -        //
  -        getLogger().debug(" checking others");
  -        requestParams = request.getParameterNames();
  -        while ( requestParams.hasMoreElements() ) {
  -        String paramName = (String) requestParams.nextElement();
  -        getLogger().debug("  checking request parameter "+paramName);
  -        for ( int i = wildcards-1; i > 0; i-- ) {
  -            getLogger().debug("   checking against "+i);
  -            StringParts sp = (StringParts) items.get( new Integer( i ) );
  -            String match = getMatch( paramName, sp );
  -            getLogger().debug("   Parameter is ["+sp.prefix+" * "+sp.pstfix+"] ");
  -            if ( match != null ) {
  -            getLogger().debug("   Parameter "+sp.prefix+"*"+sp.pstfix+" matches "+paramName+" ("+sp.count+" so far)");
  -            if ( values.containsKey( match ) ) {
  -                sp.count++;
  -                getLogger().debug("   "+paramName+" (verified)");
  +            // first one
  +            //
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug(" checking first");
  +            }
  +            HashMap values = new HashMap();
  +            StringParts sp1 = (StringParts) items.get(new Integer(0));
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug(
  +                    "  Parameter is [" + sp1.prefix + " * " + sp1.pstfix + "] ");
  +            }
  +            Enumeration requestParams = request.getParameterNames();
  +            Boolean dummy = new Boolean(true);
  +            while (requestParams.hasMoreElements()) {
  +                String paramName = (String) requestParams.nextElement();
  +                String match = getMatch(paramName, sp1);
  +                if (match != null) {
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "  value is >"
  +                            + match
  +                            + "< "
  +                            + sp1.prefix.length()
  +                            + " "
  +                            + paramName.length()
  +                            + " "
  +                            + sp1.pstfix.length());
  +                    }
  +                    values.put(match, dummy);
  +                    sp1.count++;
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "   Parameter "
  +                            + sp1.prefix
  +                            + "*"
  +                            + sp1.pstfix
  +                            + " matches "
  +                            + paramName
  +                            + " ("
  +                            + sp1.count
  +                            + " so far)");
  +                    }
  +                    String paramValue = request.getParameter(paramName);
  +                    if (paramValue == null) {
  +                        return null;
  +                    }
  +                    results.put(paramName, paramValue);
  +                }
  +            }
   
  -                String paramValue = request.getParameter( paramName );
  -                if ( paramValue == null ) {
  +            if (sp1.count == 0) {
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug(
  +                       "   Parameter "
  +                        + sp1.prefix
  +                        + "*"
  +                        + sp1.pstfix
  +                        + " matches "
  +                        + sp1.count);
  +                }
                   return null;
  +            }
  +
  +            // all other ones
  +            //
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug(" checking others");
  +            }
  +            requestParams = request.getParameterNames();
  +            while (requestParams.hasMoreElements()) {
  +                String paramName = (String) requestParams.nextElement();
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug("  checking request parameter " + paramName);
  +                }
  +                for (int i = wildcards - 1; i > 0; i--) {
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug("   checking against " + i);
  +                    }
  +                    StringParts sp = (StringParts) items.get(new Integer(i));
  +                    String match = getMatch(paramName, sp);
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "   Parameter is ["
  +                            + sp.prefix
  +                            + " * "
  +                            + sp.pstfix
  +                            + "] ");
  +                    }
  +                    if (match != null) {
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger().debug(
  +                                "   Parameter "
  +                                    + sp.prefix
  +                                    + "*"
  +                                    + sp.pstfix
  +                                    + " matches "
  +                                    + paramName
  +                                    + " ("
  +                                    + sp.count
  +                                    + " so far)");
  +                        }
  +                        if (values.containsKey(match)) {
  +                            sp.count++;
  +                            if (this.getLogger().isDebugEnabled()) {
  +                                getLogger().debug(
  +                                "   " + paramName + " (verified)");
  +                            }
  +                            String paramValue = request.getParameter(paramName);
  +                            if (paramValue == null) {
  +                                return null;
  +                            }
  +                            results.put(paramName, paramValue);
  +
  +                        } else {
  +                            if (this.getLogger().isDebugEnabled()) {
  +                                getLogger().debug(
  +                                    "Match "
  +                                    + match
  +                                    + "not found for "
  +                                    + sp1.prefix
  +                                    + "*"
  +                                    + sp1.pstfix
  +                                    + " but for "
  +                                    + sp.prefix
  +                                    + "*"
  +                                    + sp.pstfix);
  +                            }
  +                            return null;
  +                        }
  +                    }
                   }
  -                results.put( paramName, paramValue );
  +            }
   
  -            } else {
  -                getLogger().debug("Match " + match + "not found for "
  -                          + sp1.prefix + "*" + sp1.pstfix + " but for "
  -                          + sp.prefix + "*" + sp.pstfix);
  -                return null;
  +            // since we enforce that only matches are counted, that exist for
  +            // the first parameter as well, check if every parameter has an
  +            // equal number of matches.
  +            //
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("checking number of matches");
               }
  +            for (int i = wildcards - 1; i > 0; i--) {
  +                StringParts sp = (StringParts) items.get(new Integer(i));
  +                if (sp.count != sp1.count) {
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "Found "
  +                            + sp.count
  +                            + " matches for "
  +                            + sp.prefix
  +                            + "*"
  +                            + sp.pstfix
  +                            + " but expected "
  +                            + sp1.count);
  +                    }
  +                    return null;
  +                } else {
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "Found "
  +                            + sp.count
  +                            + " matches for "
  +                            + sp.prefix
  +                            + "*"
  +                            + sp.pstfix
  +                            + " as expected");
  +                    }
  +                }
               }
  -        }
  -        }
   
  -        // since we enforce that only matches are counted, that exist for
  -        // the first parameter as well, check if every parameter has an
  -        // equal number of matches.
  -        //
  -        getLogger().debug("checking number of matches");
  -        for ( int i = wildcards-1; i > 0; i-- ) {
  -        StringParts sp = (StringParts) items.get( new Integer( i ) );
  -        if ( sp.count != sp1.count ) {
  -            getLogger().debug("Found " + sp.count + " matches for "
  -                      + sp.prefix + "*" + sp.pstfix + " but expected "
  -                      + sp1.count);
  -            return null;
  -        } else {
  -            getLogger().debug("Found " + sp.count + " matches for "
  -                      + sp.prefix + "*" + sp.pstfix + " as expected");
           }
  -        }
  -
  -    }
  -
   
           return Collections.unmodifiableMap(results);
       }
  
  
  
  1.8       +7 -9      xml-cocoon2/src/java/org/apache/cocoon/acting/SessionInvalidatorAction.java
  
  Index: SessionInvalidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionInvalidatorAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SessionInvalidatorAction.java	22 Feb 2002 06:59:26 -0000	1.7
  +++ SessionInvalidatorAction.java	11 Sep 2002 08:26:44 -0000	1.8
  @@ -79,19 +79,17 @@
               Parameters parameters) throws Exception {
           Request req = ObjectModelHelper.getRequest(objectModel);
   
  -        /* check request validity */
  -        if (req == null) {
  -            getLogger ().debug ("SESSIONINVALIDATOR: no request object");
  -            return null;
  -        }
  -
           /* check session validity */
           Session session = req.getSession (false);
           if (session != null) {
               session.invalidate ();
  -            getLogger ().debug ("SESSIONINVALIDATOR: session invalidated");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger ().debug ("SESSIONINVALIDATOR: session invalidated");
  +            }
           } else {
  -            getLogger ().debug ("SESSIONINVALIDATOR: no session object");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger ().debug ("SESSIONINVALIDATOR: no session object");
  +            }
           }
   
           return EMPTY_MAP; // cut down on object creation
  
  
  
  1.8       +48 -43    xml-cocoon2/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java
  
  Index: SessionPropagatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionPropagatorAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SessionPropagatorAction.java	22 Feb 2002 06:59:26 -0000	1.7
  +++ SessionPropagatorAction.java	11 Sep 2002 08:26:44 -0000	1.8
  @@ -102,63 +102,68 @@
           Request req = ObjectModelHelper.getRequest(objectModel);
           HashMap actionMap = new HashMap ();
   
  -    HashMap isDone = new HashMap();
  -    Integer dummy = new Integer(1);
  -
  -        if (req == null) {
  -            getLogger ().debug ("SESSIONPROPAGATOR: no request object");
  -            return null;
  -        }
  +        HashMap isDone = new HashMap();
  +        Integer dummy = new Integer(1);
   
           /* check session validity */
           Session session = req.getSession (false);
           if (session == null) {
  -            getLogger ().debug ("SESSIONPROPAGATOR: no session object");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger ().debug ("SESSIONPROPAGATOR: no session object");
  +            }
               return null;
           }
   
           try {
   
  -        String[] names = parameters.getNames();
  +            String[] names = parameters.getNames();
   
  -        // parameters
  -        for (int i=0; i<names.length; i++) {
  -        String sessionParamName = names[i];
  -                if (sessionParamName == null ||
  -            "".equals (sessionParamName.trim ()))
  +            // parameters
  +            for (int i = 0; i < names.length; i++) {
  +                String sessionParamName = names[i];
  +                if (sessionParamName == null
  +                    || "".equals(sessionParamName.trim()))
                       return null;
  -        isDone.put(sessionParamName, dummy);
  -        String value = parameters.getParameter(sessionParamName);
  -                getLogger().debug ("SESSIONPROPAGATOR: propagating value "
  +                isDone.put(sessionParamName, dummy);
  +                String value = parameters.getParameter(sessionParamName);
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug(
  +                    "SESSIONPROPAGATOR: propagating value "
                           + value
                           + " to session attribute "
                           + sessionParamName);
  -                session.setAttribute (sessionParamName, value);
  -                actionMap.put (sessionParamName, value);
  -        }
  -
  -        // defaults, that are not overridden
  -        for (int i=0; i<defaults.length; i++) {
  -        if (! isDone.containsKey(defaults[i])) {
  -            String sessionParamName = (String) defaults[i];
  -            if (sessionParamName == null ||
  -            "".equals (sessionParamName.trim ()))
  -            return null;
  -            isDone.put(sessionParamName, dummy);
  -            String value = parameters.getParameter(sessionParamName);
  -            getLogger().debug ("SESSIONPROPAGATOR: propagating value "
  -                       + value
  -                       + " to session attribute "
  -                       + sessionParamName);
  -            session.setAttribute (sessionParamName, value);
  -            actionMap.put (sessionParamName, value);
  -        }
  -        }
  -            getLogger().debug ("SESSIONPROPAGATOR: all params propagated "
  -                    + "to session");
  -            return Collections.unmodifiableMap (actionMap);
  +                }
  +                session.setAttribute(sessionParamName, value);
  +                actionMap.put(sessionParamName, value);
  +            }
  +
  +            // defaults, that are not overridden
  +            for (int i = 0; i < defaults.length; i++) {
  +                if (!isDone.containsKey(defaults[i])) {
  +                    String sessionParamName = (String) defaults[i];
  +                    if (sessionParamName == null
  +                        || "".equals(sessionParamName.trim()))
  +                        return null;
  +                    isDone.put(sessionParamName, dummy);
  +                    String value = parameters.getParameter(sessionParamName);
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            "SESSIONPROPAGATOR: propagating value "
  +                                + value
  +                                + " to session attribute "
  +                                + sessionParamName);
  +                    }  
  +                    session.setAttribute(sessionParamName, value);
  +                    actionMap.put(sessionParamName, value);
  +                }
  +            }
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug(
  +                    "SESSIONPROPAGATOR: all params propagated " + "to session");
  +            }
  +            return Collections.unmodifiableMap(actionMap);
           } catch (Exception e) {
  -            getLogger().debug ("exception: ", e);
  +            getLogger().warn("exception: ", e);
           }
           return null;
       }
  
  
  
  1.7       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/acting/ResourceExistsAction.java
  
  Index: ResourceExistsAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/ResourceExistsAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ResourceExistsAction.java	7 Jun 2002 13:15:09 -0000	1.6
  +++ ResourceExistsAction.java	11 Sep 2002 08:26:44 -0000	1.7
  @@ -77,7 +77,7 @@
               src = resolver.resolveURI(urlstring);
               src.getInputStream();
           } catch (Exception e) {
  -            getLogger().debug("ResourceExistsAction: exception: ",e);
  +            getLogger().warn("ResourceExistsAction: exception: ",e);
               return null;
           } finally {
               resolver.release( src );
  
  
  
  1.8       +78 -60    xml-cocoon2/src/java/org/apache/cocoon/acting/SessionStateAction.java
  
  Index: SessionStateAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionStateAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SessionStateAction.java	30 Jun 2002 23:26:57 -0000	1.7
  +++ SessionStateAction.java	11 Sep 2002 08:26:44 -0000	1.8
  @@ -115,7 +115,9 @@
    * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
    * @version CVS $Id$
    */
  -public class SessionStateAction extends AbstractConfigurableAction implements ThreadSafe {
  +public class SessionStateAction
  +    extends AbstractConfigurableAction
  +    implements ThreadSafe {
   
       protected String statekey = "org.apache.cocoon.SessionState";
       protected String newstate = null;
  @@ -125,74 +127,90 @@
       /**
        * Configures the Action.
        */
  -    public void configure(Configuration conf) throws ConfigurationException
  -    {
  -    super.configure(conf);
  -
  -    if (settings.containsKey("state-key-prefix"))
  -        statekey = (String) settings.get("state-key-prefix");
  -    if (settings.containsKey("new-state"))
  -        newstate = (String) settings.get("new-state");
  -    if (settings.containsKey("sub-levels"))
  -        sublevels = Integer.parseInt((String) settings.get("sub-levels"));
  -    if (settings.containsKey("state-level"))
  -        mylevel = Integer.parseInt((String) settings.get("state-level"));
  -    }
  -
  -
  -    public Map 	act (Redirector redirector,
  -             SourceResolver resolver,
  -             Map objectModel,
  -             String src,
  -             Parameters par) throws Exception
  -    {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +    public void configure(Configuration conf) throws ConfigurationException {
  +        super.configure(conf);
   
  -    // read local settings
  -    newstate = par.getParameter("new-state", newstate);
  -    statekey = par.getParameter("state-key", statekey);
  -    sublevels = par.getParameterAsInteger("sublevels", sublevels);
  -    mylevel = par.getParameterAsInteger("state-level", mylevel);
  -
  -    if (newstate == null ) {
  -        getLogger().error("new-state is null");
  -        return null;
  +        if (settings.containsKey("state-key-prefix"))
  +            statekey = (String) settings.get("state-key-prefix");
  +        if (settings.containsKey("new-state"))
  +            newstate = (String) settings.get("new-state");
  +        if (settings.containsKey("sub-levels"))
  +            sublevels = Integer.parseInt((String) settings.get("sub-levels"));
  +        if (settings.containsKey("state-level"))
  +            mylevel = Integer.parseInt((String) settings.get("state-level"));
       }
   
  +    public Map act(
  +        Redirector redirector,
  +        SourceResolver resolver,
  +        Map objectModel,
  +        String src,
  +        Parameters par)
  +        throws Exception {
  +            
  +        Request request = ObjectModelHelper.getRequest(objectModel);
   
  -        if (request != null) {
  -           Session session = request.getSession (false);
  -
  -            if (session != null && request.isRequestedSessionIdValid()) {
  -        String oldstate = null;
  -        if (sublevels == 0) {
  -            oldstate = (String) session.getAttribute(statekey);
  -            session.setAttribute(statekey, newstate);
  -            getLogger().debug(statekey+"="+newstate);
  -
  -        } else { // sublevels != 0
  -            oldstate = (String) session.getAttribute( statekey + Integer.toString(mylevel) );
  -            for (int i=mylevel+1; i<=sublevels; i++) {
  -            session.removeAttribute( statekey+Integer.toString(i) );
  -            getLogger().debug("remove "+statekey+Integer.toString(i));
  +        // read local settings
  +        newstate = par.getParameter("new-state", newstate);
  +        statekey = par.getParameter("state-key", statekey);
  +        sublevels = par.getParameterAsInteger("sublevels", sublevels);
  +        mylevel = par.getParameterAsInteger("state-level", mylevel);
  +
  +        if (newstate == null) {
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().error("new-state is null");
               }
  -            session.setAttribute( statekey + Integer.toString(mylevel), newstate);
  -            getLogger().debug(statekey+Integer.toString(mylevel)+"="+newstate);
  +            return null;
           }
  -        getLogger().debug("transition " + oldstate + " -> " + newstate);
   
  -        HashMap map = new HashMap(1);
  -        map.put("newstate", newstate);
  -        return map;
  +        if (request != null) {
  +            Session session = request.getSession(false);
   
  -        } else {
  -                getLogger().warn("A session object was not present or no longer valid");
  -        return null;
  +            if (session != null && request.isRequestedSessionIdValid()) {
  +                String oldstate = null;
  +                if (sublevels == 0) {
  +                    oldstate = (String) session.getAttribute(statekey);
  +                    session.setAttribute(statekey, newstate);
  +                    if (this.getLogger().isDebugEnabled()) {
  +                         getLogger().debug(statekey + "=" + newstate);
  +                    }
  +
  +                } else { // sublevels != 0
  +                    oldstate =
  +                        (String) session.getAttribute(
  +                            statekey + Integer.toString(mylevel));
  +                    for (int i = mylevel + 1; i <= sublevels; i++) {
  +                        session.removeAttribute(statekey + Integer.toString(i));
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger().debug(
  +                                "remove " + statekey + Integer.toString(i));
  +                        }
  +                    }
  +                    session.setAttribute(
  +                        statekey + Integer.toString(mylevel),
  +                        newstate);
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                            statekey + Integer.toString(mylevel) + "=" + newstate);
  +                    }
  +                }
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug("transition " + oldstate + " -> " + newstate);
  +                }
  +
  +                HashMap map = new HashMap(1);
  +                map.put("newstate", newstate);
  +                return map;
  +
  +            } else {
  +                getLogger().warn(
  +                    "A session object was not present or no longer valid");
  +                return null;
               }
           } else {
  -        getLogger().warn("No request object");
  -        return null;
  -    }
  +            getLogger().warn("No request object");
  +            return null;
  +        }
   
       }
   }
  
  
  
  1.10      +7 -3      xml-cocoon2/src/java/org/apache/cocoon/acting/ScriptAction.java
  
  Index: ScriptAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/ScriptAction.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ScriptAction.java	7 Jun 2002 13:15:09 -0000	1.9
  +++ ScriptAction.java	11 Sep 2002 08:26:44 -0000	1.10
  @@ -131,14 +131,18 @@
               mgr.registerBean("scriptaction", this );
               mgr.registerBean("manager", this.manager );
   
  -            getLogger().debug("BSFManager execution begining");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("BSFManager execution begining");
  +            }
   
               // Execute the script
   
               mgr.exec(BSFManager.getLangFromFilename(systemID), systemID, 0, 0,
                       IOUtils.getStringFromReader(in));
   
  -            getLogger().debug("BSFManager execution complete");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("BSFManager execution complete");
  +            }
   
               // Figure out what to return
               // TODO: decide on a more robust communication method
  
  
  
  1.8       +7 -8      xml-cocoon2/src/java/org/apache/cocoon/acting/SessionIsValidAction.java
  
  Index: SessionIsValidAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionIsValidAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SessionIsValidAction.java	21 Mar 2002 04:09:19 -0000	1.7
  +++ SessionIsValidAction.java	11 Sep 2002 08:26:44 -0000	1.8
  @@ -79,19 +79,18 @@
               Parameters parameters) throws Exception {
           Request req = ObjectModelHelper.getRequest(objectModel);
   
  -        if (req == null) {
  -            getLogger().debug("No request object");
  -            return null;
  -        }
  -
           /* check session validity */
           Session session = req.getSession (false);
           if (session == null) {
  -            getLogger().debug("No session object");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("No session object");
  +            }
               return null;
           }
           if (!req.isRequestedSessionIdValid()) {
  -            getLogger().debug("Requested session id is invalid");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("Requested session id is invalid");
  +            }
               return null;
           }
   
  
  
  
  1.10      +32 -16    xml-cocoon2/src/java/org/apache/cocoon/acting/SessionValidatorAction.java
  
  Index: SessionValidatorAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SessionValidatorAction.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SessionValidatorAction.java	25 Aug 2002 08:49:17 -0000	1.9
  +++ SessionValidatorAction.java	11 Sep 2002 08:26:44 -0000	1.10
  @@ -112,15 +112,13 @@
       public Map act (Redirector redirector, SourceResolver resolver, Map objectModel, String src,
               Parameters parameters) throws Exception {
           Request req = ObjectModelHelper.getRequest(objectModel);
  -        if (req == null) {
  -            getLogger ().debug ("No request object");
  -            return null;
  -        }
   
           /* check session validity */
           Session session = req.getSession (false);
           if (session == null) {
  -            getLogger ().debug ("No session object");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger ().debug ("No session object");
  +            }
               return null;
           }
   
  @@ -145,8 +143,10 @@
                * old obsoleted method
                */
               if (valstr != null && !"".equals (valstr.trim ())) {
  -                getLogger ().debug ("Validating parameters "
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger ().debug ("Validating parameters "
                           + "as specified via 'validate' parameter");
  +                }
                   /* get list of params to be validated */
                   String[] rparams = Tokenizer.tokenize (valstr, ",", false);
   
  @@ -158,7 +158,9 @@
                   for (int i = 0; i < rparams.length; i ++) {
                       name = rparams[i];
                       if (name == null || "".equals (name.trim ())) {
  -                        getLogger ().debug ("Wrong syntax of the 'validate' parameter");
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger ().debug ("Wrong syntax of the 'validate' parameter");
  +                        }
                           return null;
                       }
                       name = name.trim ();
  @@ -169,7 +171,9 @@
                       result = validateParameter (name, null, desc,
                               params, false);
                       if (!result.isOK()) {
  -                        getLogger().debug ("Validation failed for parameter " + name);
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger().debug ("Validation failed for parameter " + name);
  +                        }
                           return null;
                       }
                       session.setAttribute (name, result.getObject());
  @@ -180,8 +184,10 @@
                * new set-based method
                */
               if (valsetstr != null && !"".equals (valsetstr.trim ())) {
  -                getLogger ().debug ("Validating parameters "
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger ().debug ("Validating parameters "
                           + "from given constraint-set " + valsetstr);
  +                }
                   Configuration cset = null;
                   String setname = null;
                   int j = 0;
  @@ -194,9 +200,11 @@
                       }
                   }
                   if (!found) {
  -                    getLogger ().debug ("Given set "
  +                    if (this.getLogger().isDebugEnabled()) {
  +                        getLogger ().debug ("Given set "
                               + valsetstr
                               + " does not exist in a description file");
  +                    }
                       return null;
                   }
                   cset = csets[j];
  @@ -207,15 +215,19 @@
                   ValidatorActionHelper result = null;
                   String name = null;
                   HashMap params = new HashMap (set.length);
  -                getLogger ().debug ("Given set "
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger ().debug ("Given set "
                           + valsetstr
                           + " contains " + set.length + " rules");
  +                }
                   /* put required params into hash */
                   for (int i = 0; i < set.length; i ++) {
                       name = set[i].getAttribute ("name", "");
                       if ("".equals (name.trim ())) {
  -                        getLogger ().debug ("Wrong syntax "
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger ().debug ("Wrong syntax "
                                   + " of 'validate' children nr. " + i);
  +                        }
                           return null;
                       }
                       name = name.trim ();
  @@ -226,17 +238,21 @@
                       result = validateParameter(name, set[i],
                               desc, params, false);
                       if (!result.isOK()) {
  -                        getLogger().debug("Validation failed for parameter " + name);
  +                        if (this.getLogger().isDebugEnabled()) {
  +                            getLogger().debug("Validation failed for parameter " + name);
  +                        }
                           return null;
                       }
                       session.setAttribute (name, result.getObject());
                       actionMap.put (name, result.getObject());
                   }
               }
  -            getLogger().debug("All session params validated");
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("All session params validated");
  +            }
               return Collections.unmodifiableMap (actionMap);
           } catch (Exception e) {
  -            getLogger().debug ("exception: ", e);
  +            getLogger().warn ("exception: ", e);
           }
           return null;
       }
  
  
  
  1.7       +1 -5      xml-cocoon2/src/java/org/apache/cocoon/acting/RequestParamAction.java
  
  Index: RequestParamAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/RequestParamAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RequestParamAction.java	22 Feb 2002 06:59:26 -0000	1.6
  +++ RequestParamAction.java	11 Sep 2002 08:26:44 -0000	1.7
  @@ -135,10 +135,6 @@
       {
   
           Request request = ObjectModelHelper.getRequest(objectModel);
  -        if (request == null) {
  -          getLogger().error("RequestInfoAction: no request object!");
  -          return(null);
  -        }
   
           Map map = new HashMap();
   
  
  
  
  1.7       +101 -70   xml-cocoon2/src/java/org/apache/cocoon/acting/SendmailAction.java
  
  Index: SendmailAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/SendmailAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SendmailAction.java	22 Feb 2002 06:59:26 -0000	1.6
  +++ SendmailAction.java	11 Sep 2002 08:26:44 -0000	1.7
  @@ -93,80 +93,111 @@
    * @author <a href="mailto:balld@apache.org">Donald Ball</a>
    * @version CVS $Id$
    */
  -public class SendmailAction extends AbstractAction implements ThreadSafe, Configurable {
  -
  -  Properties default_properties = null;
  -
  -  public void configure(Configuration conf) throws ConfigurationException {
  -    getLogger().debug("SendmailAction: init");
  -    default_properties = new Properties();
  -    default_properties.put("mail.smtp.host",conf.getAttribute("smtphost", "127.0.0.1"));
  -    getLogger().debug("SendmailAction: using "+default_properties.get("mail.smtp.host")+" as the smtp server");
  -  }
  -
  -  public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
  -    try {
  -      getLogger().debug("SendmailAction: act start");
  -      Request request = ObjectModelHelper.getRequest(objectModel);
  -      Properties properties = new Properties(default_properties);
  -      if (parameters.isParameter("smtphost")) {
  -        properties.put("mail.smtp.host",parameters.getParameter("smtphost",null));
  -        getLogger().debug("SendmailAction: overriding default smtp server, using "+properties.get("mail.smtp.host"));
  -      }
  -      Session session = Session.getDefaultInstance(properties,null);
  -      Message message = new MimeMessage(session);
  -      String from = null;
  -      String to = null;
  -      String subject = null;
  -      String body = null;
  -      try {
  -        if (parameters.isParameter("from")) {
  -          from = parameters.getParameter("from",null);
  -        } else if ((from = request.getParameter("from")) == null) {
  -          throw new SendmailActionException("no from address");
  +public class SendmailAction
  +    extends AbstractAction
  +    implements ThreadSafe, Configurable {
  +
  +    Properties default_properties = null;
  +
  +    public void configure(Configuration conf) throws ConfigurationException {
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug("SendmailAction: init");
           }
  -        message.setFrom(new InternetAddress(from));
  -      } catch (AddressException e) {
  -        throw new SendmailActionException("invalid from address: "+from+": "+e.getMessage());
  -      }
  -      try {
  -        if (parameters.isParameter("to")) {
  -          to = parameters.getParameter("to",null);
  -        } else if ((to = request.getParameter("to")) == null) {
  -          throw new SendmailActionException("no to address");
  +        default_properties = new Properties();
  +        default_properties.put(
  +            "mail.smtp.host",
  +            conf.getAttribute("smtphost", "127.0.0.1"));
  +        if (this.getLogger().isDebugEnabled()) {
  +            getLogger().debug(
  +                "SendmailAction: using "
  +                + default_properties.get("mail.smtp.host")
  +                + " as the smtp server");
           }
  -        message.setRecipient(Message.RecipientType.TO,new InternetAddress(to));
  -      } catch (AddressException e) {
  -        throw new SendmailActionException("invalid to address: "+to+": "+e.getMessage());
  -      }
  -      if (parameters.isParameter("subject")) {
  -        subject = parameters.getParameter("subject",null);
  -      } else if ((subject = request.getParameter("subject")) == null) {
  -        throw new SendmailActionException("no subject");
  -      }
  -      message.setSubject(subject);
  -      if (parameters.isParameter("body")) {
  -        body = parameters.getParameter("body",null);
  -      } else if ((body = request.getParameter("body")) == null) {
  -        throw new SendmailActionException("no body");
  -      }
  -      message.setText(body);
  -      message.setSentDate(new Date());
  -      Transport.send(message);
  -      getLogger().debug("SendmailAction: act stop");
  -      return EMPTY_MAP;
  -    } catch (SendmailActionException e) {
  -      getLogger().error("SendmailAction: "+e.getMessage());
  -      return EMPTY_MAP;
       }
  -  }
   
  -  class SendmailActionException extends Exception {
  -
  -    public SendmailActionException(String message) {
  -      super(message);
  +    public Map act(
  +        Redirector redirector,
  +        SourceResolver resolver,
  +        Map objectModel,
  +        String source,
  +        Parameters parameters)
  +        throws Exception {
  +        try {
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("SendmailAction: act start");
  +            }
  +            Request request = ObjectModelHelper.getRequest(objectModel);
  +            Properties properties = new Properties(default_properties);
  +            if (parameters.isParameter("smtphost")) {
  +                properties.put(
  +                    "mail.smtp.host",
  +                    parameters.getParameter("smtphost", null));
  +                if (this.getLogger().isDebugEnabled()) {
  +                    getLogger().debug(
  +                        "SendmailAction: overriding default smtp server, using "
  +                        + properties.get("mail.smtp.host"));
  +                }
  +            }
  +            Session session = Session.getDefaultInstance(properties, null);
  +            Message message = new MimeMessage(session);
  +            String from = null;
  +            String to = null;
  +            String subject = null;
  +            String body = null;
  +            try {
  +                if (parameters.isParameter("from")) {
  +                    from = parameters.getParameter("from", null);
  +                } else if ((from = request.getParameter("from")) == null) {
  +                    throw new SendmailActionException("no from address");
  +                }
  +                message.setFrom(new InternetAddress(from));
  +            } catch (AddressException e) {
  +                throw new SendmailActionException(
  +                    "invalid from address: " + from + ": " + e.getMessage());
  +            }
  +            try {
  +                if (parameters.isParameter("to")) {
  +                    to = parameters.getParameter("to", null);
  +                } else if ((to = request.getParameter("to")) == null) {
  +                    throw new SendmailActionException("no to address");
  +                }
  +                message.setRecipient(
  +                    Message.RecipientType.TO,
  +                    new InternetAddress(to));
  +            } catch (AddressException e) {
  +                throw new SendmailActionException(
  +                    "invalid to address: " + to + ": " + e.getMessage());
  +            }
  +            if (parameters.isParameter("subject")) {
  +                subject = parameters.getParameter("subject", null);
  +            } else if ((subject = request.getParameter("subject")) == null) {
  +                throw new SendmailActionException("no subject");
  +            }
  +            message.setSubject(subject);
  +            if (parameters.isParameter("body")) {
  +                body = parameters.getParameter("body", null);
  +            } else if ((body = request.getParameter("body")) == null) {
  +                throw new SendmailActionException("no body");
  +            }
  +            message.setText(body);
  +            message.setSentDate(new Date());
  +            Transport.send(message);
  +            if (this.getLogger().isDebugEnabled()) {
  +                getLogger().debug("SendmailAction: act stop");
  +            }
  +            return EMPTY_MAP;
  +        } catch (SendmailActionException e) {
  +            getLogger().error("SendmailAction: " + e.getMessage());
  +            return EMPTY_MAP;
  +        }
       }
   
  -  }
  +    class SendmailActionException extends Exception {
  +
  +        public SendmailActionException(String message) {
  +            super(message);
  +        }
  +
  +    }
   
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message