List of usage examples for javax.servlet UnavailableException UnavailableException
public UnavailableException(String msg)
From source file:org.vfny.geoserver.config.MultipleActionServlet.java
/** * <p>Parses one module config file.</p> * * @param digester Digester instance that does the parsing * @param path The path to the config file to parse. * * @throws UnavailableException if file cannot be read or parsed * @since Struts 1.2/*from ww w . jav a 2 s . c o m*/ */ protected void parseModuleConfigFile(Digester digester, String path) throws UnavailableException { InputStream input = null; try { Resource[] resources = WebApplicationContextUtils.getWebApplicationContext(getServletContext()) .getResources(path); final int length = resources.length; for (int i = 0; i < length; i++) { URL url = resources[i].getURL(); /*getServletContext().getResource(path)*/ ; // If the config isn't in the servlet context, try the class loader // which allows the config files to be stored in a jar if (url == null) { url = getClass().getResource(path); } if (url == null) { String msg = internal.getMessage("configMissing", path); log.error(msg); throw new UnavailableException(msg); } InputSource is = new InputSource(url.toExternalForm()); input = url.openStream(); is.setByteStream(input); digester.parse(is); } } catch (MalformedURLException e) { handleConfigException(path, e); } catch (IOException e) { handleConfigException(path, e); } catch (SAXException e) { handleConfigException(path, e); } finally { if (input != null) { try { input.close(); } catch (IOException e) { throw new UnavailableException(e.getMessage()); } } } }
From source file:org.vfny.geoserver.config.MultipleActionServlet.java
/** * <p>Simplifies exception handling in the <code>parseModuleConfigFile</code> method.<p> * @param path/* ww w. java 2 s . co m*/ * @param e * @throws UnavailableException as a wrapper around Exception */ private void handleConfigException(String path, Exception e) throws UnavailableException { String msg = internal.getMessage("configParse", path); log.error(msg, e); throw new UnavailableException(msg); }
From source file:org.vfny.geoserver.config.web.MultipleActionServlet.java
/** * <p>Parses one module config file.</p> * * @param digester Digester instance that does the parsing * @param path The path to the config file to parse. * @param config//from www . j a va2 s . c o m * * @throws UnavailableException if file cannot be read or parsed * @since Struts 1.2 */ protected void parseModuleConfigFile(Digester digester, String path, ModuleConfig config) throws UnavailableException { InputStream input = null; Resource[] resources = null; try { resources = WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getResources(path); } catch (IOException ex) { handleConfigException(path, ex); } final int length = resources.length; for (int i = 0; i < length; i++) { try { URL url = resources[i].getURL(); /*getServletContext().getResource(path)*/ ; // If the config isn't in the servlet context, try the class loader // which allows the config files to be stored in a jar if (url == null) { url = getClass().getResource(path); } if (url == null) { String msg = internal.getMessage("configMissing", path); log.error(msg); throw new UnavailableException(msg); } InputSource is = new InputSource(url.toExternalForm()); input = url.openStream(); is.setByteStream(input); digester.parse(is); } catch (MalformedURLException e) { handleConfigException(path, e); } catch (IOException e) { handleConfigException(path, e); } catch (SAXException e) { handleConfigException(path, e); } finally { if (input != null) { try { input.close(); if ((length > 1) && (i < (length - 1))) { digester.push(config); } } catch (IOException e) { throw new UnavailableException(e.getMessage()); } } } } }