List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException
public ConfigurationException(Throwable cause)
ConfigurationException
with specified nested Throwable
. From source file:org.parosproxy.paros.model.Session.java
/** * Import a context from the specified file * @param file/*from w ww . ja v a 2 s . com*/ * @return * @throws ConfigurationException * @throws ClassNotFoundException * @throws InstantiationException * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException * @throws NoSuchMethodException * @throws SecurityException */ public Context importContext(File file) throws ConfigurationException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { ZapXmlConfiguration config = new ZapXmlConfiguration(file); Context c = this.getNewContext(config.getString(Context.CONTEXT_CONFIG_NAME)); c.setDescription(Context.CONTEXT_CONFIG_DESC); c.setInScope(config.getBoolean(Context.CONTEXT_CONFIG_INSCOPE)); for (Object obj : config.getList(Context.CONTEXT_CONFIG_INC_REGEXES)) { c.addIncludeInContextRegex(obj.toString()); } for (Object obj : config.getList(Context.CONTEXT_CONFIG_EXC_REGEXES)) { c.addExcludeFromContextRegex(obj.toString()); } TechSet techSet = new TechSet(); for (Object obj : config.getList(Context.CONTEXT_CONFIG_TECH_INCLUDE)) { techSet.include(new Tech(obj.toString())); } for (Object obj : config.getList(Context.CONTEXT_CONFIG_TECH_EXCLUDE)) { techSet.exclude(new Tech(obj.toString())); } c.setTechSet(techSet); String urlParserClass = config.getString(Context.CONTEXT_CONFIG_URLPARSER_CLASS); if (urlParserClass == null) { // Can happen due to a bug in 2.4.0 where is was saved using the wrong name :( urlParserClass = config.getString(Context.CONTEXT_CONFIG_URLPARSER); } Class<?> cl = ExtensionFactory.getAddOnLoader().loadClass(urlParserClass); if (cl == null) { throw new ConfigurationException("Failed to load URL parser for context " + urlParserClass); } else { ParameterParser parser = (ParameterParser) cl.getConstructor().newInstance(); parser.init(config.getString(Context.CONTEXT_CONFIG_URLPARSER_CONFIG)); parser.setContext(c); c.setUrlParamParser(parser); } String postParserClass = config.getString(Context.CONTEXT_CONFIG_POSTPARSER_CLASS); String postParserConfig = config.getString(Context.CONTEXT_CONFIG_POSTPARSER_CONFIG); if (postParserClass == null) { // Can happen due to a bug in 2.4.0 where is was saved using the wrong name :( postParserClass = config.getString(urlParserClass); postParserConfig = config.getString(Context.CONTEXT_CONFIG_URLPARSER_CONFIG); } cl = ExtensionFactory.getAddOnLoader().loadClass(postParserClass); if (cl == null) { throw new ConfigurationException("Failed to load POST parser for context " + postParserClass); } else { ParameterParser parser = (ParameterParser) cl.getConstructor().newInstance(); parser.init(postParserConfig); parser.setContext(c); c.setPostParamParser(parser); } for (Object obj : config.getList(Context.CONTEXT_CONFIG_DATA_DRIVEN_NODES)) { c.addDataDrivenNodes(new StructuralNodeModifier(obj.toString())); } model.importContext(c, config); c.restructureSiteTree(); Model.getSingleton().getSession().saveContext(c); return c; }
From source file:org.qucosa.camel.component.opus4.Opus4DataSource.java
private String getConfigValueOrThrowException(Configuration conf, String key) throws ConfigurationException { String val = conf.getString(key, null); if (val == null) { throw new ConfigurationException("No config value for " + key); }/*from w w w . j av a2 s .co m*/ return val; }
From source file:org.qucosa.migration.processors.PurgeFedoraObject.java
private String getConfigValueOrThrowException(String key) throws ConfigurationException { String val = config.getString(key, null); if (val == null) { throw new ConfigurationException("No config value for " + key); }// ww w.j a v a 2s . c o m return val; }
From source file:org.qucosa.migration.routes.TransformationRouteBuilder.java
private String getConfigValueOrThrowException(String key) throws ConfigurationException { String val = configuration.getString(key, null); if (val == null) { throw new ConfigurationException("No config value for " + key); }/* w ww. ja v a2s .co m*/ return val; }
From source file:org.sonar.server.configuration.ConfigurationFactory.java
protected String autodetectWebappDeployDirectory(ServletContextEvent sce) { String webAppPublicDirPath = sce.getServletContext().getRealPath("/deploy/"); if (webAppPublicDirPath == null) { throw new ConfigurationException("Web app directory not found : /deploy/"); }// w ww .j a v a 2 s .co m File file = new File(webAppPublicDirPath); if (!file.exists()) { throw new ConfigurationException("Web app directory not found : " + file); } return file.toString(); }
From source file:org.speechforge.cairo.server.config.CairoConfig.java
private int getConfigIndex(String name) throws ConfigurationException { List<String> resourceNames = _config.getList("resources.resource.name"); for (int i = 0; i < resourceNames.size(); i++) { String resourceName = resourceNames.get(i); if (resourceName.equalsIgnoreCase(name)) { return i; }/*from w ww . j av a 2 s. c o m*/ } throw new ConfigurationException("Specified name \"" + name + "\" not found in configuration!"); }
From source file:org.speechforge.cairo.server.config.ReceiverConfig.java
/** * TODOC//from w ww. ja va 2 s . com * @param index * @param config * @throws ConfigurationException */ public ReceiverConfig(int index, XMLConfiguration config) throws ConfigurationException { super(index, config); try { try { String sphinxConfigURL = config.getString("resources.resource(" + index + ").sphinxConfigURL"); if (sphinxConfigURL != null && sphinxConfigURL.length() > 0) { _sphinxConfigURL = new URL(sphinxConfigURL); } } catch (NoSuchElementException e) { // ignore } if (_sphinxConfigURL == null) { _sphinxConfigURL = this.getClass().getResource("/config/sphinx-config.xml"); if (_sphinxConfigURL == null) { throw new ConfigurationException( "Sphinx config URL not found in either cairo config file or cairo classpath!"); } else if (_logger.isDebugEnabled()) { _logger.debug("SphinxConfigURL: " + _sphinxConfigURL); } } try { String sphinxRecorderConfigURL = config .getString("resources.resource(" + index + ").sphinxRecorderConfigURL"); if (sphinxRecorderConfigURL != null && sphinxRecorderConfigURL.length() > 0) { _sphinxRecorderConfigURL = new URL(sphinxRecorderConfigURL); } } catch (NoSuchElementException e) { // ignore } if (_sphinxRecorderConfigURL == null) { _sphinxRecorderConfigURL = this.getClass().getResource("/config/sphinx-recorder-config.xml"); if (_sphinxRecorderConfigURL == null) { throw new ConfigurationException( "Sphinx recorder config URL not found in either cairo config file or cairo classpath!"); } else if (_logger.isDebugEnabled()) { _logger.debug("SphinxRecorderConfigURL: " + _sphinxRecorderConfigURL); } } _baseGrammarDir = new File(config.getString("resources.resource(" + index + ").baseGrammarDir")); ensureDir(_baseGrammarDir); _baseRecordingDir = new File(config.getString("resources.resource(" + index + ").baseRecordingDir")); ensureDir(_baseRecordingDir); _recorderEngines = config.getInt("resources.resource(" + index + ").recorderEngines"); } catch (RuntimeException e) { throw new ConfigurationException(e.getMessage(), e); } catch (MalformedURLException e) { throw new ConfigurationException(e.getMessage(), e); } }
From source file:org.speechforge.cairo.server.config.ResourceConfig.java
/** * TODOC//w w w. ja v a 2s . com * @param dir * @throws ConfigurationException */ public static void ensureDir(File dir) throws ConfigurationException { // try to create directory if it does not exist if (!dir.exists() && !dir.mkdirs()) { throw new ConfigurationException("Could not create directory: " + dir.getAbsolutePath()); } // make sure dir is actually a directory if (!dir.isDirectory()) { throw new ConfigurationException("The specified path is not a directory: " + dir.getAbsolutePath()); } }
From source file:org.topology.bgp_ls.config.impl.ConfigurationImpl.java
void addPeer(PeerConfiguration peerConfig) throws ConfigurationException { if (peerMap.containsKey(peerConfig.getPeerName())) throw new ConfigurationException("duplicate peer name " + peerConfig.getPeerName()); PeerConfigurationTimer peerConfigTimer = (PeerConfigurationTimer) SingletonRegistry .getInstance(FixedDefaultsPeerConfigurationTimer.class.getName()); setupPeerTimers(peerConfig, peerConfigTimer); CapabilitiesList caps = new CapabilitiesList(); caps.addRequiredCapability(new AutonomousSystem4Capability(peerConfig.getLocalAS())); caps.addRequiredCapability(//from w w w. j av a2 s . c om new MultiProtocolCapability(AddressFamily.BGP_LS, SubsequentAddressFamily.NLRI_BGP_LS)); peerConfig.setCapabilities(caps); peerMap.put(peerConfig.getPeerName(), peerConfig); }
From source file:org.topology.bgp_ls.config.impl.ConfigurationParserImpl.java
public Configuration parseConfiguration(XMLConfiguration configuration) throws ConfigurationException { ConfigurationImpl configImpl = new ConfigurationImpl(); List<HierarchicalConfiguration> bgpServerNodes = configuration.configurationsAt("BgpServer"); List<HierarchicalConfiguration> httpServerNodes = configuration.configurationsAt("HttpServer"); List<HierarchicalConfiguration> bgpPeerNodes = configuration.configurationsAt("BgpPeers.BgpPeer"); List<HierarchicalConfiguration> routingProcessorNodes = configuration.configurationsAt("RoutingProcessor"); if (bgpServerNodes.size() > 1) throw new ConfigurationException("Duplicate <BgpServer /> element"); else if (bgpServerNodes.size() == 1) { configImpl.setBgpServerConfiguration(bgpServerConfigurationParser.parseConfig(bgpServerNodes.get(0))); }//from www .j ava 2s. c o m if (httpServerNodes.size() > 1) throw new ConfigurationException("Duplicate <HttpServer /> element"); else if (httpServerNodes.size() == 1) configImpl .setHttpServerConfiguration(httpServerConfigurationParser.parseConfig(httpServerNodes.get(0))); if (routingProcessorNodes.size() > 1) throw new ConfigurationException("Duplicate <RoutingProcessor /> element"); else if (routingProcessorNodes.size() == 1) configImpl.setRoutingProcessorConfiguration( routingConfigurationParser.parseConfiguration(routingProcessorNodes.get(0))); for (HierarchicalConfiguration bgpPeerNode : bgpPeerNodes) { configImpl.addPeer(peerConfigurationParser.parseConfiguration(bgpPeerNode)); } return configImpl; }