cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap/patterns PatternMatcher.java PatternTranslator.java
Date Sun, 27 Feb 2000 05:45:20 GMT
pier        00/02/26 21:45:20

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
               src/org/apache/cocoon/generators Tag: xml-cocoon2
                        FileGenerator.java
               src/org/apache/cocoon/serializers Tag: xml-cocoon2
                        XMLSerializer.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java CocoonServletRequest.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        GenericProcessor.java
               src/org/apache/cocoon/sitemap/patterns Tag: xml-cocoon2
                        PatternMatcher.java PatternTranslator.java
  Log:
  [Cocoon 2.0] Tons o' bugs. Fixing in progress.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.5   +9 -3      xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4.2.4
  retrieving revision 1.4.2.5
  diff -u -r1.4.2.4 -r1.4.2.5
  --- Cocoon.java	2000/02/27 03:43:24	1.4.2.4
  +++ Cocoon.java	2000/02/27 05:45:17	1.4.2.5
  @@ -15,6 +15,7 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import org.apache.arch.Component;
  +import org.apache.arch.Composer;
   import org.apache.arch.ComponentManager;
   import org.apache.arch.ComponentNotFoundException;
   import org.apache.arch.ComponentNotAccessibleException;
  @@ -34,7 +35,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.4.2.4 $ $Date: 2000/02/27 03:43:24 $
  + * @version CVS $Revision: 1.4.2.5 $ $Date: 2000/02/27 05:45:17 $
    */
   public class Cocoon
   implements Component, Configurable, ComponentManager, Modifiable, Processor,
  @@ -93,16 +94,21 @@
           if (role==null) throw new ComponentNotFoundException("Null role");
           if (role.equals("cocoon")) return(this);
           Class c=(Class)this.components.get(role);
  -        if (c==null) throw new ComponentNotFoundException("Can't find "+role);
  +        if (c==null)
  +            throw new ComponentNotFoundException("Can't find component "+role);
           try {
               Component comp=(Component)c.newInstance();
               if (comp instanceof Configurable) {
                   Configuration conf=(Configuration)this.configurations.get(role);
                   if (conf!=null) ((Configurable)comp).setConfiguration(conf);
               }
  +            if (comp instanceof Composer)
  +                ((Composer)comp).setComponentManager(this);
               return(comp);
           } catch (Exception e) {
  -            throw new ComponentNotAccessibleException("Can't access "+role, e);
  +            throw new ComponentNotAccessibleException("Can't access class "+
  +                        c.getName()+" with role "+role+" due to a "+
  +                        e.getClass().getName()+"("+e.getMessage()+")",e);
           }
       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      xml-cocoon/src/org/apache/cocoon/generators/Attic/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generators/Attic/FileGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- FileGenerator.java	2000/02/27 03:41:49	1.1.2.1
  +++ FileGenerator.java	2000/02/27 05:45:18	1.1.2.2
  @@ -17,9 +17,9 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/02/27 03:41:49 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 05:45:18 $
    */
  -public abstract class FileGenerator extends ComposerGenerator {
  +public class FileGenerator extends ComposerGenerator {
   
       /**
        * Generate XML data.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.3   +2 -1      xml-cocoon/src/org/apache/cocoon/serializers/Attic/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serializers/Attic/XMLSerializer.java,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- XMLSerializer.java	2000/02/27 01:33:07	1.1.4.2
  +++ XMLSerializer.java	2000/02/27 05:45:18	1.1.4.3
  @@ -21,7 +21,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.2 $ $Date: 2000/02/27 01:33:07 $
  + * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 05:45:18 $
    */
   public class XMLSerializer extends AbstractSerializer implements XMLConsumer {
       /** The namespaces table */
  @@ -60,6 +60,7 @@
        */
       public void startDocument()
       throws SAXException {
  +        super.response.setContentType("text/xml");
           this.print("<?xml version=\"1.0\"?>\n");
       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.4   +37 -11    xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.3
  retrieving revision 1.1.4.4
  diff -u -r1.1.4.3 -r1.1.4.4
  --- CocoonServlet.java	2000/02/27 03:42:11	1.1.4.3
  +++ CocoonServlet.java	2000/02/27 05:45:19	1.1.4.4
  @@ -18,6 +18,7 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.arch.config.ConfigurationException;
  +import org.apache.arch.ComponentNotAccessibleException;
   import org.apache.cocoon.Cocoon;
   import org.apache.cocoon.ProcessingException;
   import org.xml.sax.SAXException;
  @@ -27,7 +28,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 03:42:11 $
  + * @version CVS $Revision: 1.1.4.4 $ $Date: 2000/02/27 05:45:19 $
    */
   public class CocoonServlet extends HttpServlet {
       private Cocoon cocoon=null;
  @@ -83,12 +84,12 @@
   
           // Check if cocoon was initialized
           if (this.cocoon==null) {
  -            res.setContentType("text/html");
               res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +            res.setContentType("text/html");
               out.println("<html><head>");
  -            out.println("<title>Cocoon: Not initialized</title>");
  +            out.println("<title>Cocoon Version 2.0: Not initialized</title>");
               out.println("<body>");
  -            out.println("<center><h1>Cocoon: Not initialized</h1></center>");
  +            out.println("<center><h1>Cocoon 2.0: Not initialized</h1></center>");
               out.println("<hr>");
               out.print("Try to <a href=\"");
               out.print(req.getScheme()+"://"+req.getServerName()+":");
  @@ -101,6 +102,12 @@
                   Exception nested=((SAXException)this.exception).getException();
                   out.println("<hr>");
                   this.printException(out,nested);
  +            } else if (exception instanceof ComponentNotAccessibleException) {
  +                out.println("Component not accessible<br>");
  +                Exception nested=this.exception;
  +                nested=((ComponentNotAccessibleException)nested).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
               }
               out.println("<hr></body></html>");
               out.flush();
  @@ -109,31 +116,50 @@
           // We got it... Process the request
           String uri=req.getPathInfo();
           if (uri!=null) try {
  +            // Strip the leading '/' character
  +            if ((uri.length()>0)&&(uri.charAt(0)=='/')) uri=uri.substring(1);
               CocoonServletRequest request=new CocoonServletRequest(req,uri);
               CocoonServletResponse response=new CocoonServletResponse(res);
  -            if (!this.cocoon.process(request,response,out))
  -                res.sendError(res.SC_NOT_FOUND);
  -        } catch (Exception e) {
  +            if (!this.cocoon.process(request,response,out)) {
  +            res.setStatus(res.SC_NOT_FOUND);
               res.setContentType("text/html");
  +            out.println("<html><head>");
  +            out.println("<title>Cocoon Version 2.0: Not Found</title>");
  +            out.println("<body>");
  +            out.println("<center><h1>Cocoon 2.0: Not Found</h1></center>");
  +            out.println("<hr>");
  +            out.print("The requested URI \""+req.getRequestURI());
  +            out.print("\" was not found.");
  +            out.println("<!-- PATH_INFO=\""+req.getPathInfo()+"\" -->");
  +            out.println("<hr></body></html>");
  +            }
  +        } catch (Exception e) {
               res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +            res.setContentType("text/html");
               out.println("<html><head>");
  -            out.println("<title>Cocoon: Exception</title>");
  +            out.println("<title>Cocoon Version 2.0: Exception</title>");
               out.println("<body>");
  -            out.println("<center><h1>Cocoon: Exception</h1></center>");
  +            out.println("<center><h1>Cocoon 2.0: Exception</h1></center>");
               out.println("<hr>");
               this.printException(out,e);
               if (exception instanceof SAXException) {
                   Exception nested=((SAXException)this.exception).getException();
                   out.println("<hr>");
                   this.printException(out,nested);
  +            } else if (exception instanceof ComponentNotAccessibleException) {
  +                out.println("Component not accessible<br>");
  +                Exception nested=this.exception;
  +                nested=((ComponentNotAccessibleException)nested).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
               }
               out.println("<hr></body></html>");
           } else {
               res.setContentType("text/html");
               out.println("<html><head>");
  -            out.println("<title>Cocoon: Version 2.0</title>");
  +            out.println("<title>Cocoon Version 2.0</title>");
               out.println("<body>");
  -            out.println("<center><h1>Cocoon: Version 2.0</h1></center>");
  +            out.println("<center><h1>Cocoon 2.0: Version 2.0</h1></center>");
               out.println("<hr>");
               if (reloaded) out.println("Configurations reloaded.<br>");
               out.println("Ready to process requests...");
  
  
  
  1.1.4.3   +5 -5      xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletRequest.java
  
  Index: CocoonServletRequest.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServletRequest.java,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- CocoonServletRequest.java	2000/02/27 01:33:08	1.1.4.2
  +++ CocoonServletRequest.java	2000/02/27 05:45:19	1.1.4.3
  @@ -15,7 +15,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.2 $ $Date: 2000/02/27 01:33:08 $
  + * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 05:45:19 $
    */
   public class CocoonServletRequest implements Request {
       
  @@ -27,12 +27,12 @@
       /**
        * Create a new instance of this <code>CocoonServletRequest</code>
        */
  -    protected CocoonServletRequest(HttpServletRequest req, String uri) {
  +    protected CocoonServletRequest(HttpServletRequest r, String u) {
           super();
  -        if ((request==null)||(uri==null))
  +        if ((r==null)||(u==null))
               throw new IllegalArgumentException("Null parameter specified");
  -        this.request=req;
  -        this.uri=uri;
  +        this.request=r;
  +        this.uri=u;
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +5 -3      xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java
  
  Index: GenericProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- GenericProcessor.java	2000/02/27 01:33:09	1.1.2.2
  +++ GenericProcessor.java	2000/02/27 05:45:19	1.1.2.3
  @@ -34,7 +34,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:09 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 05:45:19 $
    */
   public class GenericProcessor implements Composer, Configurable, Processor {
   
  @@ -96,7 +96,7 @@
           c=conf.getConfiguration("serializer");
           if (c==null)
               throw new ConfigurationException("Serializer not specified",conf);
  -        this.generator="serializer:"+c.getAttribute("name");
  +        this.serializer="serializer:"+c.getAttribute("name");
           // Set up the filters vetctor
           Enumeration e=conf.getConfigurations("filter");
           while (e.hasMoreElements()) {
  @@ -116,10 +116,11 @@
           if (!this.matcher.match(req.getUri())) return(false);
           String src=null;
           if (this.targetTranslator!=null) {
  -            if ((src=this.targetTranslator.translate(req.getUri()))!=null)
  +            if ((src=this.targetTranslator.translate(req.getUri()))==null)
                   throw new ProcessingException("Error translating \""+
                                                 req.getUri()+"\"");
           }
  +if (this.serializer==null) throw new NullPointerException("SER");
           Serializer s=(Serializer)this.manager.getComponent(this.serializer);
           s.setup(req,res,src,null);
           s.setOutputStream(out);
  @@ -131,6 +132,7 @@
               f.setConsumer(current);
               current=f;
           }
  +if (this.generator==null) throw new NullPointerException("GEN");
           Generator g=(Generator)this.manager.getComponent(this.generator);
           g.setConsumer(current);
           g.setup(req,res,src,null);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +8 -5      xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java
  
  Index: PatternMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- PatternMatcher.java	2000/02/27 01:33:10	1.1.2.2
  +++ PatternMatcher.java	2000/02/27 05:45:20	1.1.2.3
  @@ -24,7 +24,7 @@
    * 
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:10 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 05:45:20 $
    */
   public class PatternMatcher {
   
  @@ -58,7 +58,9 @@
        * Match the specified <code>String</code> against the configured pattern.
        */
       public boolean match(String data) {
  -        if ((data==null)||(this.sourcePattern==null)) return(false);
  +        if (data==null) throw new NullPointerException("Null data");
  +        if (this.sourcePattern==null)
  +            throw new IllegalStateException("Null internals");
           return(this.matchPattern(data.toCharArray(),this.sourcePattern));
       }
   
  @@ -186,9 +188,10 @@
   
               // Check if we reached the end of the expression
               if(expr[end]==MATCH_END) {
  -                // If also the data buffer is finished we have a match
  -                if(off+end-exprpos!=buff.length) return(false);
  -                else return(true);
  +                // If the data buffer is finished we have a match
  +                if(off+end-exprpos==buff.length) return(true);
  +                // Otherwise there is no match
  +                return(true);
               }
   
               // Set the current data buffer position to the first character
  
  
  
  1.1.2.3   +11 -8     xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java
  
  Index: PatternTranslator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- PatternTranslator.java	2000/02/27 01:33:10	1.1.2.2
  +++ PatternTranslator.java	2000/02/27 05:45:20	1.1.2.3
  @@ -19,7 +19,7 @@
    * 
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:10 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 05:45:20 $
    */
   public class PatternTranslator extends PatternMatcher {
   
  @@ -66,12 +66,13 @@
        * <code>String</code> is returned.
        */
       public String translate(String data) {
  -        if (!super.match(data)) return(null);
  +        if (data==null) throw new NullPointerException("Null data");
           if (this.identityTranslation) return(data);
  -        if ((this.targetPattern!=null) ||
  -            (super.sourcePattern==null) ||
  -            (data==null)) return(null);
  +        if ((this.targetPattern==null) || (super.sourcePattern==null))
  +            throw new IllegalStateException("Null internals");
  +        if (!super.match(data)) throw new IllegalArgumentException("No match");
           char x[]=data.toCharArray();
  +        
           return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
       }
   
  @@ -163,9 +164,11 @@
   
               // Check if we reached the end of the expression
               if(expr[end]==MATCH_END) {
  -                // If also the data buffer is finished we have a match
  -                if(off+end-exprpos!=buff.length) return(null);
  -                else return(new String(rslt,0,rsltpos));
  +                // If the data buffer is finished we have a match
  +                if(off+end-exprpos==buff.length)
  +                    return(new String(rslt,0,rsltpos));
  +                // Otherwise return the null string
  +                return(null);
               }
   
               // Set the current data buffer position to the first character
  
  
  

Mime
View raw message