use of org.structr.api.graph.GraphProperties in project structr by structr.
the class BoltDatabaseService method setProperty.
// ----- interface GraphProperties -----
@Override
public void setProperty(final String name, final Object value) {
final Properties properties = getProperties();
boolean hasChanges = false;
if (value == null) {
if (properties.containsKey(name)) {
properties.remove(name);
hasChanges = true;
}
} else {
properties.setProperty(name, value.toString());
hasChanges = true;
}
if (hasChanges) {
final File propertiesFile = new File(databasePath + "/graph.properties");
try (final Writer writer = new FileWriter(propertiesFile)) {
properties.store(writer, "Created by Structr at " + new Date());
} catch (IOException ioex) {
logger.warn("Unable to write properties file", ioex);
}
}
}
use of org.structr.api.graph.GraphProperties in project structr by structr.
the class StructrApp method getGlobalSetting.
@Override
public <T> T getGlobalSetting(final String key, final T defaultValue) throws FrameworkException {
final DatabaseService service = getDatabaseService();
if (service != null) {
final GraphProperties config = service.getGlobalProperties();
T value = null;
if (config != null) {
value = (T) config.getProperty(key);
}
if (value == null) {
return defaultValue;
}
return value;
}
return defaultValue;
}
Aggregations