List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException
public ConfigurationException(Throwable cause)
ConfigurationException
with specified nested Throwable
. From source file:com.manydesigns.elements.configuration.CommonsConfigurationUtils.java
public static void save(Configuration configuration) throws ConfigurationException { FileConfiguration fileConfiguration = getWritableFileConfiguration(configuration); if (fileConfiguration == null) { throw new ConfigurationException("Cannot save configuration"); } else {//from ww w . ja v a 2 s . c o m fileConfiguration.save(); } }
From source file:de.sub.goobi.metadaten.copier.MetadataSelector.java
/** * Factory method to create a metadata selector. Depending on the path, the * required implementation will be constructed. * * @param path/*from w w w .j a v a 2s . com*/ * path to create a metadata selector from. * @return a metadata selector instance representing the given paht * @throws ConfigurationException * if the path cannot be evaluated */ public static MetadataSelector create(String path) throws ConfigurationException { if (path.startsWith(METADATA_SEPARATOR)) { return new LocalMetadataSelector(path); } if (path.startsWith(METADATA_PATH_SEPARATOR)) { if (path.indexOf(METADATA_SEPARATOR) == 1) { return new LocalMetadataSelector(path.substring(1)); } else { return new MetadataPathSelector(path); } } throw new ConfigurationException( "Cannot create metadata selector: Path must start with \"@\" or \"/\", but is: " + path); }
From source file:de.sub.goobi.metadaten.copier.StringSelector.java
/** * Creates a new string selector with a static string value. * * @param text/*from w w w . j av a 2s. c o m*/ * String, in quotes * @throws ConfigurationException * if the string isnt enclosed in quotes */ public StringSelector(String text) throws ConfigurationException { if (!text.endsWith("\"")) { throw new ConfigurationException("String must be enclosed in double quotes (\"\"), but is: " + text); } this.text = text.substring(1, text.length() - 1); }
From source file:com.linkedin.pinot.server.conf.NettyServerConfig.java
public NettyServerConfig(Configuration serverNettyConfig) throws ConfigurationException { _serverNettyConfig = serverNettyConfig; if (!_serverNettyConfig.containsKey(NETTY_SERVER_PORT)) { throw new ConfigurationException("Cannot find Key : " + NETTY_SERVER_PORT); }/* ww w .j a va 2s . com*/ }
From source file:com.linkedin.pinot.core.query.config.QueryPlannerConfig.java
private void checkRequiredKeys() throws ConfigurationException { for (String keyString : REQUIRED_KEYS) { if (!_queryPlannerConfig.containsKey(keyString)) { throw new ConfigurationException("Cannot find required key : " + keyString); }/* www . java 2 s . c o m*/ } }
From source file:de.sub.goobi.metadaten.copier.DataCopyrule.java
/** * Factory method to create a class implementing the metadata copy rule * referenced by a given command string/*ww w . j a va 2s . com*/ * * @param command * A space-separated string consisting of subject (aka. patiens), * operator (aka. agens) and (optional) objects (depending on * what objects the operator requires). * @return a class implementing the metadata copy rule referenced * @throws ConfigurationException * if the operator cannot be resolved or the number of arguments * doesnt match */ public static DataCopyrule createFor(String command) throws ConfigurationException { List<String> arguments = Arrays.asList(command.split("\\s+")); String operator; try { operator = arguments.get(1); } catch (IndexOutOfBoundsException e) { throw new ConfigurationException("Missing operator (second argument) in line: " + command); } Class<? extends DataCopyrule> ruleClass = AVAILABLE_RULES.get(operator); if (ruleClass == null) { throw new ConfigurationException("Unknown operator: " + operator); } DataCopyrule ruleImplementation; try { ruleImplementation = ruleClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e.getMessage(), e); } ruleImplementation.setSubject(arguments.get(0)); if (ruleImplementation.getMaxObjects() > 0) { List<String> objects = arguments.subList(2, arguments.size()); if (objects.size() < ruleImplementation.getMinObjects()) { throw new ConfigurationException("Too few arguments in line: " + command); } if (objects.size() > ruleImplementation.getMaxObjects()) { throw new ConfigurationException("Too many arguments in line: " + command); } ruleImplementation.setObjects(objects); } return ruleImplementation; }
From source file:de.sub.goobi.metadaten.copier.LocalMetadataSelector.java
/** * Creates a new LocalMetadataSelector.//w w w .j a v a 2s. c om * * @param path * Path to metadatum, must consist of an @? character followed * by a metadata element name, i.e. @TitleDocMain? * @throws ConfigurationException * if the metadata path doesnt start with an @? character */ public LocalMetadataSelector(String path) throws ConfigurationException { if (!path.startsWith(METADATA_SEPARATOR)) { throw new ConfigurationException( "Cannot create local metadata selector: Path must start with \"@\", but is: " + path); } selector.setName(path.substring(1)); }
From source file:de.sub.goobi.metadaten.copier.DataSelector.java
/** * Factory method to create a DataSelector. * * @param path//from www . j a v a2 s . c o m * path to the data object to access * @return a subclass implementing the data selector required for the given * path * @throws ConfigurationException * if the path cannot be evaluated */ public static DataSelector create(String path) throws ConfigurationException { if (path.startsWith(METADATA_PATH_SEPARATOR) || path.startsWith(METADATA_SEPARATOR)) { return MetadataSelector.create(path); } if (path.startsWith(VARIABLE_REFERENCE)) { return new VariableSelector(path); } if (path.startsWith(STRING_MARK)) { return new StringSelector(path); } if (path.startsWith(RESPECTIVE_DESTINATION_REFERENCE)) { return new DestinationReferenceSelector(path); } throw new ConfigurationException( "Cannot create data selector: Path must start with \"@\", \"/\" or \"$\", but is: " + path); }
From source file:edu.kit.dama.ui.simon.SimonPortlet.java
@Override protected void init(VaadinRequest request) { try {/*from w w w . j a v a2s. c o m*/ String path = DataManagerSettings.getSingleton() .getStringProperty(DataManagerSettings.SIMON_CONFIG_LOCATION_ID, null); if (path == null || !new File(path).exists()) { throw new ConfigurationException("Configuration element '" + DataManagerSettings.SIMON_CONFIG_LOCATION_ID + "' is not set or not a valid directory."); } File configLocation = new File(path); SimonConfigurator.getSingleton().setConfigLocation(configLocation); } catch (ConfigurationException ex) { LOGGER.error("Failed to initialize SimpleMonitoring", ex); } setContent(new SimonMainPanel()); setWidth("1024px"); setHeight("800px"); }
From source file:de.sub.goobi.metadaten.copier.DestinationReferenceSelector.java
/** * Creates a new DestinationReferenceSelector. * * @param path/*from w w w. ja va2s. c om*/ * reference to resolve * @throws ConfigurationException * if the path is syntactically wrong */ public DestinationReferenceSelector(String path) throws ConfigurationException { Matcher pathSplitter = DESTINATION_REFERENCE_SELECTOR_SCHEME.matcher(path); if (!pathSplitter.find()) { throw new ConfigurationException("Invalid destination reference selector: " + path); } this.index = Integer.parseInt(pathSplitter.group(1)); this.nextSelector = MetadataSelector.create(pathSplitter.group(2)); }