Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.ResourceNotFoundException


  @Override
  public InputStream getResourceAsStream(String name) {
    byte[] b = findPluginResource(name);
    if (b == null) {
      throw new ResourceNotFoundException(name);
    }
    return new ByteArrayInputStream(b);
  }
View Full Code Here


     */
    public synchronized InputStream getResourceStream(String name)
            throws ResourceNotFoundException {

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

        try {
            if (!name.startsWith("/"))
                name = "/" + name;

            return servletContext.getResourceAsStream(name);
        }
        catch (Exception fnfe) {
            /*
             *  log and convert to a general Velocity ResourceNotFoundException
             */

            throw new ResourceNotFoundException(fnfe.getMessage());
        }
    }
View Full Code Here

     */
    public InputStream getResourceStream(String source) throws ResourceNotFoundException {
        try {
            return resourceLoader.getResource(source).getInputStream();
        } catch (IOException ioe) {
            throw new ResourceNotFoundException("Could not get stream for resource '" + source + "'", ioe);
        }
    }
View Full Code Here

                String path = paths.get(i);
                return new FileInputStream(path + "/" + template);
            } catch (FileNotFoundException e) { }
        }

        throw new ResourceNotFoundException(template);
    }
View Full Code Here

                {
                    log.debug(msg);
                }
                if (required)
                {
                    throw new ResourceNotFoundException(msg);
                }
            }
            else
            {
                read(inputStream);
View Full Code Here

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

        }

        // if we still haven't found one
        if (inputStream == null)
        {
            throw new ResourceNotFoundException("Could not find file at: "+path);
        }
        return inputStream;
    }
View Full Code Here

*/
public class StrutsResourceLoader extends ClasspathResourceLoader {

    public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException {
        if ((name == null) || (name.length() == 0)) {
            throw new ResourceNotFoundException("No template name provided");
        }

        if (name.startsWith("/")) {
            name = name.substring(1);
        }

        try {
            return ClassLoaderUtil.getResourceAsStream(name, StrutsResourceLoader.class);
        } catch (Exception e) {
            throw new ResourceNotFoundException(e);
        }
    }
View Full Code Here

public class VelocityBundleResourceLoader extends ClasspathResourceLoader {

    public synchronized InputStream getResourceStream(String name)
            throws ResourceNotFoundException {
        if ((name == null) || (name.length() == 0)) {
            throw new ResourceNotFoundException("No template name provided");
        }

        if (name.startsWith("/")) {
            name = name.substring(1);
        }

        try {
            return DefaultBundleAccessor.getInstance().loadResourceAsStream(name);
        } catch (Exception e) {
            throw new ResourceNotFoundException(e.getMessage());
        }
    }
View Full Code Here

   * @throws Exception
   */
  private Template getTemplate( String[] path, String fn )
    throws Exception
  {
    ResourceNotFoundException rnfe = null;
   
    for (String p: path)
    {
      if (p == null)
        continue;
     
//      System.out.println( "trying to load template "+(p+fn) );
      try
      {
        if (Velocity.resourceExists( p+fn ))
          return Velocity.getTemplate( p+fn );
      }
      catch ( ResourceNotFoundException e )
      {
        rnfe = e;
      }
      catch ( Exception e )
      {
        System.out.println( "ignoring "+e);
      }
    }
   
    if (rnfe != null)
      throw rnfe;
   
    throw new ResourceNotFoundException("could not find resource: "+fn);
  }
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.