use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class AbstractPropertyFileHandler method saveAll.
public void saveAll(Properties properties) throws ConfigurationError {
lock.writeLock().lock();
try {
Properties p = load();
properties.stringPropertyNames().forEach(key -> p.setProperty(key, properties.getProperty(key)));
save(p);
} catch (IOException e) {
throw new ConfigurationError(ERROR_WRITING_MESSAGE, e);
} finally {
lock.writeLock().unlock();
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class AbstractPropertyFileHandler method delete.
public void delete(String m) throws ConfigurationError {
lock.writeLock().lock();
try {
Properties p = load();
p.remove(m);
save(p);
} catch (IOException e) {
throw new ConfigurationError(ERROR_WRITING_MESSAGE, e);
} finally {
lock.writeLock().unlock();
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class SettingValueFactory method newBooleanSettingValue.
/**
* Constructs a new {@code Boolean} setting value from the supplied key and string value.
*
* @param key the setting key
* @param stringValue the value as string
*
* @return the implementation specific {@code SettingValue}
*/
default SettingValue<Boolean> newBooleanSettingValue(String key, String stringValue) {
Boolean value;
if (nullOrEmpty(stringValue)) {
return newBooleanSettingValue(key, Boolean.FALSE);
}
String lc = stringValue.trim().toLowerCase(Locale.ROOT);
switch(lc) {
case "true":
case "yes":
case "on":
case "1":
return newBooleanSettingValue(key, Boolean.TRUE);
case "false":
case "no":
case "off":
case "0":
return newBooleanSettingValue(key, Boolean.FALSE);
default:
throw new ConfigurationError(String.format("'%s' is not a valid boolean value", stringValue));
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class SettingsServiceImpl method configure.
private void configure(Object object, boolean persist) throws ConfigurationError {
Class<?> clazz = object.getClass();
if (clazz.getAnnotation(Configurable.class) == null) {
return;
}
LOG.debug("Configuring object {}", object);
for (Method method : clazz.getMethods()) {
Setting s = method.getAnnotation(Setting.class);
if (s != null) {
String key = s.value();
if (key == null || key.isEmpty()) {
throw new ConfigurationError(String.format("Invalid value for @Setting: '%s'", key));
} else if (getDefinitionByKey(key) == null && s.required()) {
throw noSettingDefinitionFound(key);
} else if (method.getParameterTypes().length != 1) {
throw new ConfigurationError(String.format("Method %s annotated with @Setting in %s has a invalid method signature", method, clazz));
} else if (!Modifier.isPublic(method.getModifiers())) {
throw new ConfigurationError(String.format("Non-public method %s annotated with @Setting in %s", method, clazz));
} else {
configure(new ConfigurableObject(method, object, key, s.required()), persist);
}
}
}
}
use of org.n52.faroe.ConfigurationError in project arctic-sea by 52North.
the class OwsServiceProviderFactory method create.
@Override
protected OwsServiceProvider create(Locale language) throws ConfigurationError {
// TODO organisation name is missing
String organisationName = null;
OwsOnlineResource onlineResource = null;
if (site != null) {
onlineResource = new OwsOnlineResource(site);
}
OwsCode roleCode = null;
if (role != null) {
roleCode = new OwsCode(role, roleCodespace);
}
OwsOnlineResource providerSite = null;
if (onlineResoureHref != null) {
providerSite = new OwsOnlineResource(onlineResoureHref, onlineResoureTitle);
}
OwsAddress address = null;
if (anyNonNull(deliveryPoint, city, administrativeArea, postalCode, country, electronicMailAddress)) {
address = new OwsAddress(deliveryPoint, city, administrativeArea, postalCode, country, electronicMailAddress);
}
OwsPhone owsPhone = null;
if (anyNonNull(phone, facsimile)) {
owsPhone = new OwsPhone(phone, facsimile);
}
OwsContact contactInfo = null;
if (anyNonNull(owsPhone, address, onlineResource, hoursOfService, contactInstructions)) {
contactInfo = new OwsContact(owsPhone, address, onlineResource, hoursOfService, contactInstructions);
}
OwsResponsibleParty serviceContact = new OwsResponsibleParty(individualName, organisationName, positionName, contactInfo, roleCode);
return new OwsServiceProvider(name, providerSite, serviceContact);
}
Aggregations