Package org.apache.turbine.util

Examples of org.apache.turbine.util.TurbineException


                results[0] = new BigDecimal(rs.getString(1)); // next_id
                results[1] = new BigDecimal(rs.getString(2)); // quantity
            }
            else
            {
                throw new TurbineException("The table "+tableName+
                    " does not have a proper entry in the ID_TABLE");
            }
        }
        finally
        {
View Full Code Here


        }
        catch( InstantiationException e )
        {
            // Shutdown of a nonexistent class was requested.
            // This does not hurt anything, so we log the error and continue.
            error(new TurbineException("Shutdown of a nonexistent class " +
                    className + " was requested", e));
        }
    }
View Full Code Here

        /** template name with relative path */
        String relativeTemplateName = getRelativeTemplateName(filename);
       
        if (relativeTemplateName == null)
        {
            throw new TurbineException(
            "Template " + filename + " not found in template paths");
        }
       
        // get the RequestDispatcher for the JSP
        RequestDispatcher dispatcher = data.getServletContext()
        .getRequestDispatcher(relativeTemplateName);
       
        try
        {
            if (isForward)
            {
                // forward the request to the JSP
                dispatcher.forward( data.getRequest(), data.getResponse() );
            }
            else
            {
                data.getOut().flush();
                // include the JSP
                dispatcher.include( data.getRequest(), data.getResponse() );
            }
        }
        catch(Exception e)
        {
            // as JSP service is in Alpha stage, let's try hard to send the error
            // message to the browser, to speed up debugging
            try
            {
                data.getOut().print("Error encountered processing a template: "+filename);
                e.printStackTrace(data.getOut());
            }
            catch(IOException ignored)
            {
            }   

            // pass the exception to the caller according to the general
            // contract for tamplating services in Turbine
            throw new TurbineException(
                "Error encountered processing a template:" + filename, e);
        }
    }
View Full Code Here

        throws TurbineException
    {
        String contentType = req.getHeader(CONTENT_TYPE);
        if(!contentType.startsWith(MULTIPART_FORM_DATA))
        {
            throw new TurbineException("the request doesn't contain a " +
                MULTIPART_FORM_DATA + " stream");
        }
        int requestSize = req.getContentLength();
        if(requestSize == -1)
        {
            throw new TurbineException("the request was rejected because " +
                "it's size is unknown");
        }
        if(requestSize > TurbineUpload.getSizeMax())
        {
            throw new TurbineException("the request was rejected because " +
                "it's size exceeds allowed range");
        }

        try
        {
            byte[] boundary = contentType.substring(
                                contentType.indexOf("boundary=")+9).getBytes();
            InputStream input = (InputStream)req.getInputStream();
           
            MultipartStream multi = new MultipartStream(input, boundary);
            boolean nextPart = multi.skipPreamble();
            while(nextPart)
            {
                Map headers = parseHeaders(multi.readHeaders());
                String fieldName = getFieldName(headers);
                if (fieldName != null)
                {
                    String subContentType = getHeader(headers, CONTENT_TYPE);
                    if (subContentType != null && subContentType
                                                .startsWith(MULTIPART_MIXED))
                    {
                        // Multiple files.
                        byte[] subBoundary =
                            subContentType.substring(
                                subContentType
                                .indexOf("boundary=")+9).getBytes();
                        multi.setBoundary(subBoundary);
                        boolean nextSubPart = multi.skipPreamble();
                        while (nextSubPart)
                        {
                            headers = parseHeaders(multi.readHeaders());
                            if (getFileName(headers) != null)
                            {
                                FileItem item = createItem(path, headers,
                                                           requestSize);
                                OutputStream os = item.getOutputStream();
                                try
                                {
                                    multi.readBodyData(os);
                                }
                                finally
                                {
                                    os.close();
                                }
                                params.append(getFieldName(headers), item);
                            }
                            else
                            {
                                // Ignore anything but files inside
                                // multipart/mixed.
                                multi.discardBodyData();
                            }
                            nextSubPart = multi.readBoundary();
                        }
                        multi.setBoundary(boundary);
                    }
                    else
                    {
                        if (getFileName(headers) != null)
                        {
                            // A single file.
                            FileItem item = createItem(path, headers,
                                                       requestSize);
                            OutputStream os = item.getOutputStream();
                            try
                            {
                                multi.readBodyData(os);
                            }
                            finally
                            {
                                os.close();
                            }
                            params.append(getFieldName(headers), item);
                        }
                        else
                        {
                            // A form field.
                            FileItem item = createItem(path, headers,
                                                       requestSize);
                            OutputStream os = item.getOutputStream();
                            try
                            {
                                multi.readBodyData(os);
                            }
                            finally
                            {
                                os.close();
                            }
                            params.append(getFieldName(headers),
                                          new String(item.get()));
                        }
                    }
                }
                else
                {
                    // Skip this part.
                    multi.discardBodyData();
                }
                nextPart = multi.readBoundary();
            }
        }
        catch(IOException e)
        {
            throw new TurbineException("Processing of " + MULTIPART_FORM_DATA
                                       + " request failed", e);
        }
    }
View Full Code Here

                }
            }
        }
        catch(ClassNotFoundException cnfe)
        {
            throw new TurbineException ("UploadFile action was attempted and a handler has not been"+
                                   " registered in the TurbineResources.properties, so com.oreilly.servlet.Multipart was tried" +
                                   " and has not been installed.  Turbine uses a class from this package to" +
                                   " parse and save the file from the POST data.  You must supply a class" +
                                   " to use UploadFile.  com.oreilly.servlet is available as part of purchase of" +
                                   " Jason Hunter's Java Servlet Programming book.");
        }
        catch(Exception e)
        {
            throw new TurbineException("Failed to perform file upload using O'Reilly uploader", e);
        }
    }
View Full Code Here

            {
                TurbineUpload.parseRequest(req, this);
            }
            catch(TurbineException e)
            {
                Log.error(new TurbineException("File upload failed", e));
            }
        }

        Enumeration names = req.getParameterNames();
        if ( names != null )
View Full Code Here

        "This method cannot be used with an uninitialized ComboKey";
    public void setValue(String[] keys) throws TurbineException
    {
        if ( this.key == null )
        {
            throw new TurbineException(errMsg);
            /*
            this.key = new SimpleKey[keys.length];           
            for ( int i=0; i<keys.length; i++ )
            {
                this.key[i] = new SimpleKey(keys[i]);
            }
            */
        }
        else
        {
            for ( int i=0; i<this.key.length; i++ )
            {
                if ( this.key[i] == null && keys[i] != null )
                {
                    throw new TurbineException(errMsg);
                    // this.key[i] = new SimpleKey( keys[i] );
                }
                else
                {
                    this.key[i].setValue( keys[i] );
View Full Code Here

            indexOfSep = keys.indexOf(SEPARATOR);
        }

        if ( this.key == null )
        {
            throw new TurbineException(errMsg);
            /*
            this.key = new SimpleKey[tmpKeys.size()];           
            for ( int i=0; i<this.key.length; i++ )
            {
                this.key[i] = new SimpleKey( (String)tmpKeys.get(i) );
            }
            */
        }
        else
        {
            for ( int i=0; i<this.key.length; i++ )
            {
                if ( this.key[i] == null && tmpKeys.get(i) != null )
                {
                    throw new TurbineException(errMsg);
                    // this.key[i] = new SimpleKey( (String)tmpKeys.get(i) );
                }
                else
                {
                    this.key[i].setValue( (String)tmpKeys.get(i) );
View Full Code Here

    private static final void renderingError(String filename, Exception e)
        throws TurbineException
    {
        String err = "Error rendering Velocity template: " + filename;
        Log.error(err + ": " + e.getMessage());
        throw new TurbineException(err, e);
    }
View Full Code Here

            {
                mask = new RE(param);
            }
            catch (org.apache.regexp.RESyntaxException e)
            {
                throw new TurbineException(e);
            }
            maskMessage = constraint.getMessage();
        }

        constraint = (Constraint)paramMap.get("minLength");
View Full Code Here

TOP

Related Classes of org.apache.turbine.util.TurbineException

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.