Package org.apache.turbine.util

Examples of org.apache.turbine.util.TurbineException


                            ((Recyclable) instance).recycle();
                        }
                    }
                    catch (Exception x)
                    {
                        throw new TurbineException(
                                "Recycling failed for " + instance.getClass().getName(), x);
                    }
                }
            }
            return instance;
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 > getSizeMax())
        {
            throw new TurbineException("the request was rejected because " +
                    "it's size exceeds allowed range");
        }

        try
        {
            List fileList = fileUpload
                    .parseRequest(req,
                            getSizeThreshold(),
                            getSizeMax(),
                            path);

            if (fileList != null)
            {
                for (Iterator it = fileList.iterator(); it.hasNext();)
                {
                    FileItem fi = (FileItem) it.next();
                    if (fi.isFormField())
                    {
                        log.debug("Found an simple form field: " + fi.getFieldName() +", adding value " + fi.getString());

                        String value = null;
                        try
                        {
                            value = fi.getString(params.getCharacterEncoding());
                        }
                        catch (UnsupportedEncodingException e)
                        {
                            log.error(params.getCharacterEncoding()
                                    + " encoding is not supported."
                                    + "Used the default when reading form data.");
                            value = fi.getString();
                        }
                        params.add(fi.getFieldName(), value);
                    }
                    else
                    {
                        log.debug("Found an uploaded file: " + fi.getFieldName());
                        log.debug("It has " + fi.getSize() + " Bytes and is " + (fi.isInMemory() ? "" : "not ") + "in Memory");
                        log.debug("Adding FileItem as " + fi.getFieldName() + " to the params");
                        params.add(fi.getFieldName(), fi);
                    }
                }
            }
        }
        catch (FileUploadException e)
        {
            throw new TurbineException(e);
        }
    }
View Full Code Here

            {
                // we should have an IP
                StringTokenizer stok = new StringTokenizer(addr, ".");
                if (stok.countTokens() != 4)
                {
                    throw new TurbineException(errorString + addr);
                }
                // this is meant to insure that id's made from ip addresses
                // will not conflict with MAC id's. I think MAC addresses
                // will never have the highest bit set.  Though this should
                // be investigated further.
                address[0] = (byte) 255;
                address[1] = (byte) 255;
                int i = 2;
                try
                {
                    while (stok.hasMoreTokens())
                    {
                        address[i++] =
                                Integer.valueOf(stok.nextToken(),
                                        16).byteValue();
                    }
                }
                catch (Exception e)
                {
                    throw new TurbineException(errorString + addr, e);
                }
            }
            else if (addr.indexOf(":") > 0)
            {
                // we should have a MAC
                StringTokenizer stok = new StringTokenizer(addr, ":");
                if (stok.countTokens() != 6)
                {
                    throw new TurbineException(errorString + addr);
                }
                int i = 0;
                try
                {
                    while (stok.hasMoreTokens())
                    {
                        address[i++] = Byte.parseByte(stok.nextToken(), 16);
                    }
                }
                catch (Exception e)
                {
                    throw new TurbineException(errorString + addr, e);
                }
            }
            else
            {
                throw new TurbineException(errorString + addr);
            }
        }
    }
View Full Code Here

        /** template name with relative path */
        String relativeTemplateName = getRelativeTemplateName(templateName);

        if (StringUtils.isEmpty(relativeTemplateName))
        {
            throw new TurbineException(
                "Template " + templateName + " 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: "
                    + templateName);
                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: " + templateName, e);
        }
    }
View Full Code Here

        }
        catch (Exception e)
        {
            String errorMessage = "Problem updating Scheduled Job: " + je.getTask();
            log.error(errorMessage, e);
            throw new TurbineException(errorMessage, e);
        }
    }
View Full Code Here

        // Get the specified configuration.
        String[] cfg = (String[]) configurations.get(key);
        if (cfg == null)
        {
            throw new TurbineException("RunTime configuration '" + key + "' is undefined");
        }

        TurbineRunData data;
        try
        {
            data = (TurbineRunData) pool.getInstance(cfg[0]);
            data.setParameterParser((ParameterParser) pool.getInstance(cfg[1]));
            data.setCookieParser((CookieParser) pool.getInstance(cfg[2]));
        }
        catch (ClassCastException x)
        {
            throw new TurbineException("RunData configuration '" + key + "' is illegal", x);
        }

        // Set the request and response.
        data.setRequest(req);
        data.setResponse(res);
View Full Code Here

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

            if (screen == null)
            {
                String errMsg = "Couldn't map Template "
                    + template + " to any Screen class!";
                log.error(errMsg);
                throw new TurbineException(errMsg);
            }
            data.setScreen(screen);
        }
    }
View Full Code Here

                    {
                        data.getPage().setDoctype(new Doctype.Html40Frameset());
                    }
                    else
                    {
                        throw new TurbineException(errMsg);
                    }
                    break;
                }
            case 2:
                {
                    data.getPage()
                        .setDoctype(new Doctype()
                                    .setIdentifier((String) doctypeProperty.get(0))
                                    .setUri((String) doctypeProperty.get(1)));
                    break;
                }
            default:
                {
                    throw new TurbineException(errMsg);
                }
            }
        }
    }
View Full Code Here

        }
        catch (TorqueException e)
        {
            String errorMessage = "Error retrieving job from persistent storage.";
            log.error(errorMessage, e);
            throw new TurbineException(errorMessage, e);
        }
    }
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.