use of java.util.InvalidPropertiesFormatException in project OpenAM by OpenRock.
the class BasicClientTypesManager method initManager.
/**
* Initializes the <code>ClientTypesManager</code>.
*/
public void initManager() {
Properties clientProps = new Properties();
InputStream is = null;
try {
is = this.getClass().getResourceAsStream(PROPS_FILE);
clientProps.load(is);
} catch (Exception ex) {
debug.error(CLASS_NAME + " unable to load properties file" + PROPS_FILE, ex);
} finally {
try {
is.close();
} catch (IOException ioe) {
debug.error(CLASS_NAME + " unable to close property file");
}
}
if (clientProps != null && !clientProps.isEmpty()) {
try {
processProps(clientProps);
} catch (InvalidPropertiesFormatException ipfe) {
debug.error(CLASS_NAME + " init unable to process properties file", ipfe);
return;
}
}
if (debug.messageEnabled()) {
debug.message(CLASS_NAME + " basic CDM framework loaded with " + clientsData);
}
}
use of java.util.InvalidPropertiesFormatException in project OpenAM by OpenRock.
the class BasicClientTypesManager method processProps.
/**
* Utility method used to parse the properties file that configures this client
* types manager.
* A simple entry in the properties file would look like this:
*
* <code>
* clients=genericHtml,...
* genericHtml_name=Generic HTML
* genericHtml_attributes=filePath=html,contentType=text/html,cookieSupport=true,genericHtml=true,...
* </code>
*
* The clients are the names of the different client types
* For each client type, there is a list of attributes;
*
* _attributes is a comma delimited list of attributes for the client type
*
* @param props The properties file to parse
* @throws InvalidPropertiesFormatException
*/
protected void processProps(Properties props) throws InvalidPropertiesFormatException {
String statGroupsNames = props.getProperty(CLIENTS);
if (statGroupsNames == null) {
throw new InvalidPropertiesFormatException("Unable to find " + CLIENTS + " property.");
}
StringTokenizer st = new StringTokenizer(statGroupsNames, COMMA);
while (st.hasMoreTokens()) {
populateClient(st.nextToken(), props);
}
}
use of java.util.InvalidPropertiesFormatException in project jdk8u_jdk by JetBrains.
the class PropertiesDefaultHandler method load.
public void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException {
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
use of java.util.InvalidPropertiesFormatException in project traccar by tananaev.
the class Config method load.
void load(String file) throws IOException {
try {
Properties mainProperties = new Properties();
try (InputStream inputStream = new FileInputStream(file)) {
mainProperties.loadFromXML(inputStream);
}
String defaultConfigFile = mainProperties.getProperty("config.default");
if (defaultConfigFile != null) {
try (InputStream inputStream = new FileInputStream(defaultConfigFile)) {
properties.loadFromXML(inputStream);
}
}
// override defaults
properties.putAll(mainProperties);
useEnvironmentVariables = Boolean.parseBoolean(System.getenv("CONFIG_USE_ENVIRONMENT_VARIABLES")) || Boolean.parseBoolean(properties.getProperty("config.useEnvironmentVariables"));
} catch (InvalidPropertiesFormatException e) {
throw new RuntimeException("Configuration file is not a valid XML document", e);
}
}
use of java.util.InvalidPropertiesFormatException in project traccar by traccar.
the class Config method load.
void load(String file) throws IOException {
try {
Properties mainProperties = new Properties();
try (InputStream inputStream = new FileInputStream(file)) {
mainProperties.loadFromXML(inputStream);
}
String defaultConfigFile = mainProperties.getProperty("config.default");
if (defaultConfigFile != null) {
try (InputStream inputStream = new FileInputStream(defaultConfigFile)) {
properties.loadFromXML(inputStream);
}
}
// override defaults
properties.putAll(mainProperties);
useEnvironmentVariables = Boolean.parseBoolean(System.getenv("CONFIG_USE_ENVIRONMENT_VARIABLES")) || Boolean.parseBoolean(properties.getProperty("config.useEnvironmentVariables"));
} catch (InvalidPropertiesFormatException e) {
throw new RuntimeException("Configuration file is not a valid XML document", e);
}
}
Aggregations