Search in sources :

Example 1 with GraphProperties

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);
        }
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) GraphProperties(org.structr.api.graph.GraphProperties) Properties(java.util.Properties) File(java.io.File) Writer(java.io.Writer) FileWriter(java.io.FileWriter) Date(java.util.Date)

Example 2 with GraphProperties

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;
}
Also used : GraphProperties(org.structr.api.graph.GraphProperties) DatabaseService(org.structr.api.DatabaseService)

Aggregations

GraphProperties (org.structr.api.graph.GraphProperties)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Date (java.util.Date)1 Properties (java.util.Properties)1 DatabaseService (org.structr.api.DatabaseService)1