Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.ResourceNotFoundException


                else
                {
                    String msg = "DataSourceResourceLoader: could not find resource "
                              + name + " while " + operation;
                    log.error(msg);
                    throw new ResourceNotFoundException(msg);
                }
            }
            catch (SQLException sqle)
            {
                String msg = "DataSourceResourceLoader: database problem while "
View Full Code Here


        if ( template == null )
        {
            String msg = "Velocity.mergeTemplate() was unable to load template '"
                           + templateName + "'";
            getLog().error(msg);
            throw new ResourceNotFoundException(msg);
        }
        else
        {
            template.merge(context, writer);
            return true;
View Full Code Here

        else
        {
            /*
             *  is == null, therefore we have some kind of file issue
             */
            errorCondition = new ResourceNotFoundException("Unknown resource error for resource " + name );
            throw errorCondition;
        }
    }
View Full Code Here

        /*
         * Return null if we can't find a resource.
         */
        if (resource.getData() == null)
        {
            throw new ResourceNotFoundException("Unable to find resource '" + resourceName + "'");
        }

        /*
         *  some final cleanup
         */
 
View Full Code Here

    {
        InputStream result = null;

        if (name == null || name.length() == 0)
        {
            throw new ResourceNotFoundException ("WebappLoader : No template name provided");
        }

        /* since the paths always ends in '/',
         * make sure the name never starts with one */
        while (name.startsWith("/"))
        {
            name = name.substring(1);
        }

        Exception exception = null;
        for (int i = 0; i < paths.length; i++)
        {
            String path = paths[i] + name;
            try
            {
                result = servletContext.getResourceAsStream(path);

                /* save the path and exit the loop if we found the template */
                if (result != null)
                {
                    templatePaths.put(name, paths[i]);
                    break;
                }
            }
            catch (NullPointerException npe)
            {
                /* no servletContext was set, whine about it! */
                throw npe;
            }
            catch (Exception e)
            {
                /* only save the first one for later throwing */
                if (exception == null)
                {
                    if (log.isDebugEnabled())
                    {
                        log.debug("WebappResourceLoader: Could not load "+path, e);
                    }
                    exception = e;
                }
            }
        }

        /* if we never found the template */
        if (result == null)
        {
            String msg = "WebappLoader : Resource '" + name + "' not found.";

            /* convert to a general Velocity ResourceNotFoundException */
            if (exception == null)
            {
                throw new ResourceNotFoundException(msg);
            }
            else
            {
                msg += "  Due to: " + exception;
                throw new ResourceNotFoundException(msg, exception);
            }
        }

        return result;
    }
View Full Code Here

    {
        InputStream result = null;

        if (name == null || name.length() == 0)
        {
            throw new ResourceNotFoundException ("WebappLoader : No template name provided");
        }

        /* since the paths always ends in '/',
         * make sure the name never starts with one */
        while (name.startsWith("/"))
        {
            name = name.substring(1);
        }

        Exception exception = null;
        for (int i = 0; i < paths.length; i++)
        {
            String path = paths[i] + name;
            try
            {
                result = servletContext.getResourceAsStream(path);

                /* save the path and exit the loop if we found the template */
                if (result != null)
                {
                    templatePaths.put(name, paths[i]);
                    break;
                }
            }
            catch (NullPointerException npe)
            {
                /* no servletContext was set, whine about it! */
                throw npe;
            }
            catch (Exception e)
            {
                /* only save the first one for later throwing */
                if (exception == null)
                {
                    if (log.isDebugEnabled())
                    {
                        log.debug("WebappResourceLoader: Could not load "+path, e);
                    }
                    exception = e;
                }
            }
        }

        /* if we never found the template */
        if (result == null)
        {
            String msg = "WebappLoader : Resource '" + name + "' not found.";

            /* convert to a general Velocity ResourceNotFoundException */
            if (exception == null)
            {
                throw new ResourceNotFoundException(msg);
            }
            else
            {
                msg += "  Due to: " + exception;
                throw new ResourceNotFoundException(msg, exception);
            }
        }

        return result;
    }
View Full Code Here

    @Override
    public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException {
        InputStream result = null;
       
        if (name == null || name.length() == 0) {
            throw new ResourceNotFoundException ("No template name provided");
        }
       
        URL url = getResource(name);
        if (url != null) {
            try {
                result = url.openStream();
            } catch (Exception e) {
                _logger.error("Error opening stream", e);
                throw new ResourceNotFoundException(e.getMessage());
            }
        } else {
            throw new ResourceNotFoundException("Resource '" + name + "' count not be found");
        }
       
        return result;
    }
View Full Code Here

        {
            String msg = "Did not find resource at: "+path;
            if (required)
            {
                getLog().error(msg);
                throw new ResourceNotFoundException(msg);
            }
            debug(msg);
            return null;
        }
        return inputStream;
View Full Code Here

            {
                String msg = "Did not find resource at: "+path;
                if (required)
                {
                    getLog().error(msg);
                    throw new ResourceNotFoundException(msg);
                }
                else
                {
                    debug(msg);
                }
View Full Code Here

            return new ByteArrayInputStream( out.toByteArray() );
        }
        catch ( IOException ioe )
        {
            throw new ResourceNotFoundException( "cannot read resource", ioe );
        }
        finally
        {
            IOUtil.close( in );
        }
View Full Code Here

TOP

Related Classes of org.apache.velocity.exception.ResourceNotFoundException

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.