Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.ResourceNotFoundException


            if (resultRepresentation == null) {
                resultRepresentation = this.defaultRepresentation;

                if (resultRepresentation == null) {
                    throw new ResourceNotFoundException(
                            "Could not locate resource '" + name + "'");
                }

                result = resultRepresentation.getStream();
            } else {
                result = resultRepresentation.getStream();
            }
        } catch (IOException ioe) {
            throw new ResourceNotFoundException(ioe);
        }

        return result;
    }
View Full Code Here


  {
    InputStream result = null;
       
    if (name == null || name.length() == 0)
    {
      throw new ResourceNotFoundException ("No template name provided");
    }
       
    try
    {
      if (!name.startsWith("/"))
        name = "/" + name;

      result = getContext().getResourceAsStream( name );
    }
    catch( NullPointerException npe)
    {
      String msg = "WebappResourceLoader.getResourceStream(): " + name;
      if (mContext == null)
      {
        mLogger.info("WebappResourceLoader("+name+"): ServletContext is null");
        msg += "\n\tServletContext is null";
      }
      throw new ResourceNotFoundException(msg);
    }
    catch( Exception fnfe )
    {
      /*
       *  log and convert to a general Velocity ResourceNotFoundException
       */           
      throw new ResourceNotFoundException( fnfe.getMessage() );
    }
       
    return result;
  }
View Full Code Here

                rreq.setPage(page);
            }
           
            // Still no page ID, then we have a problem
            if ( page == null ) {
                throw new ResourceNotFoundException("Page not found");
            }

            // this sets up the page we want to render
            outty = prepareForPageExecution(ctx, rreq, response, page);
           
View Full Code Here

        throws ResourceNotFoundException {
       
        mLogger.debug("Looking up resource named ... "+name);
       
        if (name == null || name.length() < 1) {
            throw new ResourceNotFoundException("Need to specify a template name!");
        }
       
        try {
            // parse the name ... theme templates name are <theme>:<template>
            String[] split = name.split(":", 2);
            if(split.length < 2)
                throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                throw new ResourceNotFoundException("Template ["+split[1]+
                        "] doesn't seem to be part of theme ["+split[0]+"]");
           
            mLogger.debug("Resource found!");
           
            // return the input stream
            return new ByteArrayInputStream(template.getContents().getBytes("UTF-8"));
           
        } catch (UnsupportedEncodingException uex) {
            // We expect UTF-8 in all JRE installation.
            // This rethrows as a Runtime exception after logging.
            mLogger.error(uex);
            throw new RuntimeException(uex);
          
        } catch (ThemeNotFoundException tnfe) {
            String msg = "ThemeResourceLoader Error: " + tnfe.getMessage();
            mLogger.error(msg, tnfe);
            throw new ResourceNotFoundException(msg);
           
        } catch (RollerException re) {
            String msg = "RollerResourceLoader Error: " + re.getMessage();
            mLogger.error( msg, re );
            throw new ResourceNotFoundException(msg);
        }
    }
View Full Code Here

     */
    public InputStream getResourceStream(String name)
            throws ResourceNotFoundException {
       
        if (name == null || name.length() == 0) {
            throw new ResourceNotFoundException("Need to specify a template name!");
        }
       
        try {
            WeblogTemplate page =
                    RollerFactory.getRoller().getUserManager().getPage(name);
           
            if (page == null) {
                throw new ResourceNotFoundException(
                        "RollerResourceLoader: page \"" +
                        name + "\" not found");
            }
            return new ByteArrayInputStream( page.getContents().getBytes("UTF-8") );
        } catch (UnsupportedEncodingException uex) {
            // This should never actually happen.  We expect UTF-8 in all JRE installation.
            // This rethrows as a Runtime exception after logging.
            mLogger.error(uex);
            throw new RuntimeException(uex);
        } catch (RollerException re) {
            String msg = "RollerResourceLoader Error: " +
                    "database problem trying to load resource " + name;
            mLogger.error( msg, re );
            throw new ResourceNotFoundException(msg);
        }
    }
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 ClassLoaderUtils.getResourceAsStream(name, StrutsResourceLoader.class);
        } catch (Exception e) {
            throw new ResourceNotFoundException(e.getMessage());
        }
    }
View Full Code Here

            getLog().info( "Created template " + f );
        }

        catch ( ResourceNotFoundException rnfe )
        {
            throw new ResourceNotFoundException( "Template not found. ( " + templateDirectory + "/" + template + " )" );
        }
        catch ( VelocityException ve )
        {
            throw new VelocityException( ve.toString() );
        }
View Full Code Here

        if (logger.isDebugEnabled()) {
          logger.debug("Could not find Velocity resource: " + resource);
        }
      }
    }
    throw new ResourceNotFoundException(
        "Could not find resource [" + source + "] in Spring resource loader path");
  }
View Full Code Here

        if (logger.isDebugEnabled()) {
          logger.debug("Could not find Velocity resource: " + resource);
        }
      }
    }
    throw new ResourceNotFoundException(
        "Could not find resource [" + source + "] in Spring resource loader path");
  }
View Full Code Here

          "Can't found plugin[%s],template [%s] load failure.",
          pluginName, name));
    }
    URL url = bundle.getResource(path);
    if (url == null) {
      throw new ResourceNotFoundException(
          "BundleResourceLoader : cannot find " + name);
    }
    InputStream ufs;
    try {
      ufs = url.openStream();
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.