Package org.apache.cocoon

Examples of org.apache.cocoon.ProcessingException


        this.response = ObjectModelHelper.getResponse(objectModel);

        try {
            this.inputSource = this.resolver.resolveURI(super.source);
        } catch (SourceException se) {
            throw new ProcessingException("Could not retrieve source '"+super.source+"'", se);
        }

        String systemId = inputSource.getURI();
        if (!systemId.startsWith("file:")) {
          throw new ResourceNotFoundException(systemId + " does not denote a directory");
View Full Code Here


            String throwException = (String) this.settings.get( "throw-exception",
                                                                param.getParameter( "throw-exception", null ) );
            if ( throwException != null &&
                 ( throwException.equalsIgnoreCase( "true" ) || throwException.equalsIgnoreCase( "yes" ) ) ) {
                throw new ProcessingException("Could not add record",e);
            }
        } finally {
            if (conn != null) {
                try {
                    conn.close();
View Full Code Here

     * Generates the output from JSP page.
     */
    public void generate() throws IOException, ProcessingException {
        // ensure that we are running in a servlet environment
        if (this.source == null) {
            throw new ProcessingException("JSPReader: source JSP is not specified");
        }

        HttpServletResponse httpResponse =
            (HttpServletResponse)this.objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
        HttpServletRequest httpRequest =
            (HttpServletRequest)this.objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
        ServletContext httpContext =
            (ServletContext)this.objectModel.get(HttpEnvironment.HTTP_SERVLET_CONTEXT);

        if (httpResponse == null || httpRequest == null || httpContext == null) {
            throw new ProcessingException("JSPReader can be used only in a Servlet/JSP environment");
        }

        JSPEngine engine = null;
        try {

            // FIXME (KP): Should we exclude not supported protocols, say 'context'?
            String url = this.source;

            // absolute path is processed as is
            if (!url.startsWith("/")) {
                // get current request path
                String servletPath = httpRequest.getServletPath();
                // remove file part
                servletPath = servletPath.substring(0, servletPath.lastIndexOf('/') + 1);
                url = servletPath + url;
            }

            engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE);

            if (this.getLogger().isDebugEnabled()) {
                this.getLogger().debug("JSPReader executing JSP:" + url);
            }

            byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext);
            // FIXME (KP): Make buffer size configurable
            byte[] buffer = new byte[8192];
            int length = -1;

            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            while ((length = bais.read(buffer)) > -1) {
                out.write(buffer, 0, length);
            }
            bais.close();
            bais = null;
            out.flush();
            //
        } catch (ServletException e) {
            throw new ProcessingException("ServletException in JSPReader.generate()",e.getRootCause());
        } catch (IOException e) {
            throw new ProcessingException("IOException JSPReader.generate()",e);
        } catch (ProcessingException e) {
            throw e;
        } catch (Exception e) {
            throw new ProcessingException("Exception JSPReader.generate()",e);
        } finally {
            if (engine != null) this.manager.release(engine);
        }
    }
View Full Code Here

                this.loadResourceParameters = appHandler.getLoadResourceParameters();
                this.saveResourceParameters = appHandler.getSaveResourceParameters();
            }

        } catch (ComponentException ce) {
            throw new ProcessingException("Unable to lookup the resource connector.", ce);
        } finally {
            manager.release(authManager);
        }
    }
View Full Code Here

     *  If the node does not exists, <CODE>null</CODE> is returned.
     */
    public DocumentFragment getXML(String path)
    throws ProcessingException {
        if (path == null) {
            throw new ProcessingException("getXML: Path is required");
        }
        if (path.startsWith("/") == false) path = '/' + path;

        DocumentFragment frag = null;

View Full Code Here

                throw new IOException("Content-type was not specified for this request");
            } else if (contentType.startsWith("application/x-www-form-urlencoded") ||
                contentType.startsWith("multipart/form-data")) {
                String requested = parameters.getParameter(FORM_NAME, null);
                if (requested == null) {
                    throw new ProcessingException(
                        "HtmlGenerator with no \"src\" parameter expects a sitemap parameter called '" +
                        FORM_NAME + "' for handling form data"
                );
                }
View Full Code Here

            throw new ResourceNotFoundException("Could not get resource "
                + this.inputSource.getURI(), e);
        } catch (SAXException e){
            throw e;
        } catch (Exception e){
            throw new ProcessingException("Exception in HTMLGenerator.generate()",e);
        }
    }
View Full Code Here

     *  If the path is not existent it is created.
     */
    public void setXML(String path, DocumentFragment fragment)
    throws ProcessingException {
        if (path == null) {
            throw new ProcessingException("setXML: Path is required");
        }
        if (path.startsWith("/") == false) path = '/' + path;

        if ( path.equals("/") ) {
            // set all is not allowed with "/"
            throw new ProcessingException("Path '/' is not allowed");

        } else if ( path.startsWith("/authentication") ) {

            this.cleanParametersCache();
            this.authContext.setXML('/' + this.handlerName + path, fragment);

        } else if (path.equals("/application") == true
                   || path.startsWith("/application/") == true) {

            if (this.applicationName == null) {
                throw new ProcessingException("Application is required");
            }
            String appPath;
            if (path.equals("/application") == true) {
                appPath = "/";
            } else {
View Full Code Here

     * in the same way as setXML.
     */
    public void appendXML(String path, DocumentFragment fragment)
    throws ProcessingException {
        if (path == null) {
            throw new ProcessingException("appendXML: Path is required");
        }
        if (path.startsWith("/") == false) path = '/' + path;

        if ( path.equals("/") ) {
            // set all is not allowed with "/"
            throw new ProcessingException("Path '/' is not allowed");

        } else if ( path.startsWith("/authentication") ) {

            this.cleanParametersCache();
            this.authContext.appendXML('/' + this.handlerName + path, fragment);

        } else if (path.equals("/application") == true
                   || path.startsWith("/application/") == true) {

            if (this.applicationName == null) {
                throw new ProcessingException("Application is required");
            }
            String appPath;
            if (path.equals("/application") == true) {
                appPath = "/";
            } else {
View Full Code Here

     * by the path.
     */
    public void removeXML(String path)
    throws ProcessingException {
        if (path == null) {
            throw new ProcessingException("removeXML: Path is required");
        }
        if (path.startsWith("/") == false) path = '/' + path;

        if (path.equals("/") == true) {
            this.cleanParametersCache();
            this.authContext.removeXML("/" + this.handlerName);

        } else if (path.startsWith("/authentication") == true) {

            this.cleanParametersCache();
            this.authContext.removeXML("/" + this.handlerName + path);

        } else if (path.equals("/application") == true
                   || path.startsWith("/application/") == true) {
            if (this.applicationName == null) {
                throw new ProcessingException("removeXML: Application is required for path " + path);
            }
            String appPath;
            if (path.equals("/application") == true) {
                appPath = "/";
            } else {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.ProcessingException

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.