use of org.audit4j.core.exception.ConfigurationException in project audit4j-core by audit4j.
the class YAMLConfigProvider method generateConfig.
/**
* {@inheritDoc}
*/
@Override
public void generateConfig(T config, String filePath) throws ConfigurationException {
YamlWriter writer;
try {
writer = new YamlWriter(new FileWriter(filePath));
writer.getConfig().setClassTag(clazz.getSimpleName(), clazz);
writer.write(Configuration.DEFAULT);
writer.close();
} catch (IOException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002");
}
}
use of org.audit4j.core.exception.ConfigurationException in project audit4j-core by audit4j.
the class YAMLConfigProvider method readConfig.
/**
* {@inheritDoc}
*
* @see org.audit4j.core.ConfigProvider#readConfig(java.io.InputStream)
*/
@SuppressWarnings("unchecked")
@Override
public T readConfig(InputStream fileAsStream) throws ConfigurationException {
InputStreamReader streamReader = new InputStreamReader(fileAsStream);
try {
YamlReader reader = new YamlReader(streamReader);
reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
return (T) reader.read();
} catch (YamlException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002", e);
}
}
use of org.audit4j.core.exception.ConfigurationException in project audit4j-core by audit4j.
the class YAMLConfigProvider method readConfig.
/**
* {@inheritDoc}
*
* @see org.audit4j.core.ConfigProvider#readConfig(java.lang.String)
*/
@SuppressWarnings("unchecked")
@Override
public T readConfig(String filePath) throws ConfigurationException {
try {
YamlReader reader = new YamlReader(new FileReader(filePath));
reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
return (T) reader.read();
} catch (FileNotFoundException e) {
throw new ConfigurationException("Configuration Exception", "CONF_001", e);
} catch (YamlException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002", e);
}
}
Aggregations