Package org.apache.cocoon.components.notification

Examples of org.apache.cocoon.components.notification.SimpleNotifyingBean


     *
     * @param file being unavailable
     * @exception IOException if an error occurs
     */
    private void resourceUnavailable(String file, String uri) throws IOException {
        SimpleNotifyingBean n = new SimpleNotifyingBean(this);
        n.setType("resource-not-found");
        n.setTitle("Resource not Found");
        n.setSource("Cocoon commandline (Main.java)");
        n.setMessage("Page Not Available.");
        n.setDescription("The requested resource couldn't be found.");
        n.addExtraDescription(Notifying.EXTRA_REQUESTURI, uri);
        n.addExtraDescription("missing-file", file.toString());

        PrintStream out = new PrintStream(dest.getOutputStream(file));
        Notifier.notify(n, out, "text/html");
        out.flush();
        out.close();
View Full Code Here


        // Check if cocoon was initialized
        if (this.cocoon == null) {
            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);

            SimpleNotifyingBean n= new SimpleNotifyingBean(this);
            n.setType("fatal");
            n.setTitle("Internal servlet error");
            n.setSource("Cocoon servlet");
            n.setMessage("Cocoon was not initialized.");
            n.setDescription("Cocoon was not initialized. Cannot process request.");
            n.addExtraDescription("request-uri", request.getRequestURI());
            res.setContentType(Notifier.notify(n, res.getOutputStream()));

            return;
        }

        // We got it... Process the request
        String uri = request.getServletPath();
        if (uri == null) {
            uri = "";
        }
        String pathInfo = request.getPathInfo();
        if (pathInfo != null) {
            // VG: WebLogic fix: Both uri and pathInfo starts with '/'
            // This problem exists only in WL6.1sp2, not in WL6.0sp2 or WL7.0b.
            if (uri.length() > 0 && uri.charAt(0) == '/') {
                uri = uri.substring(1);
            }
            uri += pathInfo;
        }

        if (uri.length() == 0) {
            /* empty relative URI
                 -> HTTP-redirect from /cocoon to /cocoon/ to avoid
                    StringIndexOutOfBoundsException when calling
                    "".charAt(0)
               else process URI normally
            */
            String prefix = request.getRequestURI();

            if (prefix == null) {
                prefix = "";
            }

            res.sendRedirect(res.encodeRedirectURL(prefix + "/"));
            return;
        }

        String contentType = null;
        ContextMap ctxMap = null;
        try {
            try {
                if (uri.charAt(0) == '/') {
                    uri = uri.substring(1);
                }

                Environment env = this.getEnvironment(uri, request, res);

                // Initialize a fresh log context containing the object model : it
                // will be used by the CocoonLogFormatter
                ctxMap = ContextMap.getCurrentContext();
                // Add thread name (default content for empty context)
                String threadName = Thread.currentThread().getName();
                ctxMap.set("threadName", threadName);
                // Add the object model
                ctxMap.set("objectModel", env.getObjectModel());
                // Add a unique request id (threadName + currentTime
                ctxMap.set("request-id", threadName + System.currentTimeMillis());

                if (this.cocoon.process(env)) {
                    contentType = env.getContentType();
                } else {
                    // Should not get here!
                    // means SC_NOT_FOUND
                    res.sendError(res.SC_NOT_FOUND);

                    SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                    n.setType("error");
                    n.setTitle("Resource not found");
                    n.setSource("Cocoon servlet");
                    n.setMessage("The requested resource not found.");
                    n.setDescription("The requested URI \""
                                     + request.getRequestURI()
                                     + "\" was not found.");
                    n.addExtraDescription("request-uri", request.getRequestURI());
                    n.addExtraDescription("path-info", uri);
                    // send the notification but don't include it in the output stream
                    // as the status SC_NOT_FOUND is enough
                    res.setContentType(Notifier.notify(n, (OutputStream)null));
                }
            } catch (ResourceNotFoundException rse) {
                if (log.isWarnEnabled()) {
                    log.warn("The resource was not found", rse);
                }

                res.sendError(res.SC_NOT_FOUND);

                SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                n.setType("resource-not-found");
                n.setTitle("Resource not found");
                n.setSource("Cocoon servlet");
                n.setMessage("Resource not found");
                n.setDescription("The requested URI \""
                                 + request.getRequestURI()
                                 + "\" was not found.");
                n.addExtraDescription("request-uri", request.getRequestURI());
                n.addExtraDescription("path-info", uri);
                StringWriter writer = new StringWriter();
                rse.printStackTrace(new PrintWriter(writer));
                n.addExtraDescription("stack-trace",writer.toString());
                // send the notification but don't include it in the output stream
                // as the status SC_NOT_FOUND is enough
                res.setContentType(Notifier.notify(n, (OutputStream)null));

            } catch (ConnectionResetException cre) {
                if (log.isWarnEnabled()) {
                    log.warn("The connection was reset", cre);
                }

                SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                n.setType("error");
                n.setTitle("Resource not found");
                n.setSource("Cocoon servlet");
                n.setMessage("Resource not found");
                n.setDescription("The requested URI \""
                                 + request.getRequestURI()
                                 + "\" was not found.");
                n.addExtraDescription("request-uri", request.getRequestURI());
                n.addExtraDescription("path-info", uri);
                // send the notification but don't include it in the output stream
                // as the connection was reset anyway
                res.setContentType(Notifier.notify(n, (OutputStream)null));
            } catch (Exception e) {
                if (log.isErrorEnabled()) {
View Full Code Here

            //String brokenFile = NetUtils.decodePath(destinationURI);

            if (brokenLinkExtension != null) {
                target.setExtraExtension(brokenLinkExtension);
            }
            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not Found");
            n.setSource("Cocoon commandline (Main.java)");
            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = getSource(target);
            try {
                OutputStream stream = source.getOutputStream();
View Full Code Here

     *
     * @param file being unavailable
     * @exception IOException if an error occurs
     */
    private void resourceUnavailable(String file, String uri) throws IOException {
        SimpleNotifyingBean n = new SimpleNotifyingBean(this);
        n.setType("resource-not-found");
        n.setTitle("Resource not Found");
        n.setSource("Cocoon commandline (Main.java)");
        n.setMessage("Page Not Available.");
        n.setDescription("The requested resource couldn't be found.");
        n.addExtraDescription(Notifying.EXTRA_REQUESTURI, uri);
        n.addExtraDescription("missing-file", file.toString());

        PrintStream out = new PrintStream(dest.getOutputStream(file));
        Notifier.notify(n, out, "text/html");
        out.flush();
        out.close();
View Full Code Here

            //String brokenFile = NetUtils.decodePath(destinationURI);

            if (this.brokenLinkExtension != null) {
                target.setExtraExtension(this.brokenLinkExtension);
            }
            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not Found");
            n.setSource("Cocoon commandline (Main.java)");
            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = this.getSource(target);
            OutputStream stream = null;
            PrintStream out = null;
            try {
View Full Code Here

        // Check if cocoon was initialized
        if (this.cocoon == null) {
            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);

            SimpleNotifyingBean n= new SimpleNotifyingBean(this);
            n.setType("fatal");
            n.setTitle("Internal servlet error");
            n.setSource("Cocoon servlet");
            n.setMessage("Cocoon was not initialized.");
            n.setDescription("Cocoon was not initialized. Cannot process request.");
            n.addExtraDescription("request-uri", request.getRequestURI());
            res.setContentType(Notifier.notify(n, res.getOutputStream()));

            return;
        }

        // We got it... Process the request
        String uri = request.getServletPath();
        if (uri == null) {
            uri = "";
        }
        String pathInfo = request.getPathInfo();
        if (pathInfo != null) {
            uri += pathInfo;
        }

        if (uri.length() == 0) {
            /* empty relative URI
                 -> HTTP-redirect from /cocoon to /cocoon/ to avoid
                    StringIndexOutOfBoundsException when calling
                    "".charAt(0)
               else process URI normally
            */
            String prefix = request.getRequestURI();

            if (prefix == null) {
                prefix = "";
            }

            res.sendRedirect(res.encodeRedirectURL(prefix + "/"));
            return;
        }

        String contentType = null;
        try {
            if (uri.charAt(0) == '/') {
                uri = uri.substring(1);
            }

            Environment env = this.getEnvironment(uri, request, res);

            // Initialize a fresh log context containing the object model : it
            // will be used by the CocoonLogFormatter
            ContextMap ctxMap = org.apache.log.ContextMap.getCurrentContext();
            ctxMap.clear();
            // Add thread name (default content for empty context)
            String threadName = Thread.currentThread().getName();
            ctxMap.set("threadName", threadName);
            // Add the object model
            ctxMap.set("objectModel", env.getObjectModel());
            // Add a unique request id (threadName + currentTime
            ctxMap.set("request-id", threadName + System.currentTimeMillis());

            if (this.cocoon.process(env)) {
                contentType = env.getContentType();
            } else {
                // Should not get here!
                // means SC_NOT_FOUND
                res.sendError(res.SC_NOT_FOUND);

                SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                n.setType("error");
                n.setTitle("Resource not found");
                n.setSource("Cocoon servlet");
                n.setMessage("The requested resource not found.");
                n.setDescription("The requested URI \""
                                 + request.getRequestURI()
                                 + "\" was not found.");
                n.addExtraDescription("request-uri", request.getRequestURI());
                n.addExtraDescription("path-info", uri);
                // send the notification but don't include it in the output stream
                // as the status SC_NOT_FOUND is enough
                res.setContentType(Notifier.notify(n, (OutputStream)null));
            }
        } catch (ResourceNotFoundException rse) {
            if (log.isWarnEnabled()) {
                log.warn("The resource was not found", rse);
            }

            res.sendError(res.SC_NOT_FOUND);

            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not found");
            n.setSource("Cocoon servlet");
            n.setMessage("Resource not found");
            n.setDescription("The requested URI \""
                             + request.getRequestURI()
                             + "\" was not found.");
            n.addExtraDescription("request-uri", request.getRequestURI());
            n.addExtraDescription("path-info", uri);
            // send the notification but don't include it in the output stream
            // as the status SC_NOT_FOUND is enough
            res.setContentType(Notifier.notify(n, (OutputStream)null));

        } catch (ConnectionResetException cre) {
            if (log.isWarnEnabled()) {
                log.warn("The connection was reset", cre);
            }

            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("error");
            n.setTitle("Resource not found");
            n.setSource("Cocoon servlet");
            n.setMessage("Resource not found");
            n.setDescription("The requested URI \""
                             + request.getRequestURI()
                             + "\" was not found.");
            n.addExtraDescription("request-uri", request.getRequestURI());
            n.addExtraDescription("path-info", uri);
            // send the notification but don't include it in the output stream
            // as the connection was reset anyway
            res.setContentType(Notifier.notify(n, (OutputStream)null));
        } catch (Exception e) {
            if (log.isErrorEnabled()) {
View Full Code Here

        // Check if cocoon was initialized
        if (this.cocoon == null) {
          if(manageExceptions){
            res.reset();

            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("fatal");
            n.setTitle("Internal servlet error");
            n.setSource("Cocoon servlet");
            n.setMessage("Cocoon was not initialized.");
            n.setDescription("Cocoon was not initialized. Cannot process request.");
            n.addExtraDescription("request-uri", request.getRequestURI());

            res.setContentType("text/html");
            res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            Notifier.notify(n, res.getOutputStream(), "text/html");
         }
         else{
           res.sendError
            (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
             "The Cocoon engine said it failed to process the request for an unknown reason." );
            res.flushBuffer();
            return;
         }

        }

        // We got it... Process the request
        String uri = request.getServletPath();
        if (uri == null) {
            uri = "";
        }
        String pathInfo = request.getPathInfo();
        if (pathInfo != null) {
            // VG: WebLogic fix: Both uri and pathInfo starts with '/'
            // This problem exists only in WL6.1sp2, not in WL6.0sp2 or WL7.0b.
            if (uri.length() > 0 && uri.charAt(0) == '/') {
                uri = uri.substring(1);
            }
            uri += pathInfo;
        }

        if (uri.length() == 0) {
            /* empty relative URI
                 -> HTTP-redirect from /cocoon to /cocoon/ to avoid
                    StringIndexOutOfBoundsException when calling
                    "".charAt(0)
               else process URI normally
            */
            String prefix = request.getRequestURI();

            if (prefix == null) {
                prefix = "";
            }

            res.sendRedirect(res.encodeRedirectURL(prefix + "/"));
            return;
        }

        String contentType = null;
        ContextMap ctxMap = null;
        try {
            try {
                if (uri.charAt(0) == '/') {
                    uri = uri.substring(1);
                }

                Environment env = this.getEnvironment(uri, request, res);

                // Initialize a fresh log context containing the object model : it
                // will be used by the CocoonLogFormatter
                ctxMap = ContextMap.getCurrentContext();
                // Add thread name (default content for empty context)
                String threadName = Thread.currentThread().getName();
                ctxMap.set("threadName", threadName);
                // Add the object model
                ctxMap.set("objectModel", env.getObjectModel());
                // Add a unique request id (threadName + currentTime
                ctxMap.set("request-id", threadName + System.currentTimeMillis());

                if (this.cocoon.process(env)) {
                    contentType = env.getContentType();
                } else {
                    //NKB Should not get here?
                    log.fatalError("The Cocoon engine said it failed to process the request for an unknown reason.");

                    if(manageExceptions){
                      res.reset();

                      SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                      n.setType("error");
                      n.setTitle("Cocoon confusion");
                      n.setSource("Cocoon servlet");
                      n.setMessage("Cocoon engine failed in process.");
                      n.setDescription("The Cocoon engine said it failed to process the request for an unknown reason.");
                      n.addExtraDescription("request-uri", request.getRequestURI());
                      n.addExtraDescription("path-info", uri);

                      res.setContentType("text/html");
                      res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                      Notifier.notify(n, res.getOutputStream(), "text/html");
                    }
                    else{
                      res.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "The Cocoon engine said it failed to process the request for an unknown reason." );
                      res.flushBuffer();
                      return;
                    }

                }
            } catch (ResourceNotFoundException rse) {
                if (log.isWarnEnabled()) {
                    log.warn("The resource was not found", rse);
                }

                if(manageExceptions){
                  res.reset();

                  SimpleNotifyingBean n = new SimpleNotifyingBean(this);
                  n.setType("resource-not-found");
                  n.setTitle("Resource not found");
                  n.setSource("Cocoon servlet");
                  n.setMessage("Resource not found");
                  n.setDescription("The requested URI \""
                                   + request.getRequestURI()
                                   + "\" was not found.");
                  n.addExtraDescription("request-uri", request.getRequestURI());
                  n.addExtraDescription("path-info", uri);

                  res.setContentType("text/html");
                  res.setStatus(HttpServletResponse.SC_NOT_FOUND);
                  Notifier.notify(n, res.getOutputStream(), "text/html");
                  }
View Full Code Here

            //String brokenFile = NetUtils.decodePath(destinationURI);

            if (this.brokenLinkExtension != null) {
                target.setExtraExtension(this.brokenLinkExtension);
            }
            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not Found");
            n.setSource("Cocoon commandline (Main.java)");
            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = this.getSource(target);
            OutputStream stream = null;
            PrintStream out = null;
            try {
View Full Code Here

            //String brokenFile = NetUtils.decodePath(destinationURI);

            if (brokenLinkExtension != null) {
                target.setExtraExtension(brokenLinkExtension);
            }
            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not Found");
            n.setSource("Cocoon commandline (Main.java)");
            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = getSource(target);
            try {
                OutputStream stream = source.getOutputStream();
View Full Code Here

        if (brokenLinkGenerate) {
            String brokenFile = NetUtils.decodePath(filename);
            if (brokenLinkExtension != null) {
                brokenFile = brokenFile + brokenLinkExtension;
            }
            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
            n.setType("resource-not-found");
            n.setTitle("Resource not Found");
            n.setSource("Cocoon commandline (Main.java)");
            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, uri);
            n.addExtraDescription("missing-file", uri);

            ModifiableSource source = target.getSource(filename);
            try {
                OutputStream stream = source.getOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.notification.SimpleNotifyingBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.