use of org.springframework.util.DefaultPropertiesPersister in project POL-POM-5 by PlayOnLinux.
the class JavaFxSettingsManager method save.
/**
* saves settings to settings file
*/
public void save() {
JavaFxSettings javaFxSettings = load();
try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
persister.store(javaFxSettings.getProperties(), outputStream, "Phoenicis JavaFX User JavaFxSettings");
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.springframework.util.DefaultPropertiesPersister in project POL-POM-5 by PhoenicisOrg.
the class JavaFxSettingsManager method save.
/**
* saves settings to settings file
*/
public void save() {
JavaFxSettings javaFxSettings = load();
try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
persister.store(javaFxSettings.getProperties(), outputStream, "Phoenicis JavaFX User JavaFxSettings");
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.springframework.util.DefaultPropertiesPersister in project POL-POM-5 by PhoenicisOrg.
the class SettingsManager method save.
public void save() {
Settings settings = load();
try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
persister.store(settings.getProperties(), outputStream, "Phoenicis User Settings");
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.springframework.util.DefaultPropertiesPersister in project Clownfish by rawdog71.
the class Main method bootstrap_update.
/**
* Checks the applications.properties file and runs the bootstrap routine when the bootstrap parameter is set to 1
* Fetches the database (MySQL) parameters from applications.properties and runs the sql-bootstrap.sql script
* The script creates the database user for reading/writing (user=clownfish), creates all tables and initializes some tables with data
*/
public static void bootstrap_update() {
InputStream fis = null;
try {
Properties props = new Properties();
String propsfile = "application.properties";
fis = new FileInputStream(propsfile);
if (null != fis) {
props.load(fis);
}
String dbclass = props.getProperty("app.datasource.driverClassName");
String dburl = props.getProperty("app.datasource.url");
String dbuser = props.getProperty("app.datasource.username");
String dbpassword = props.getProperty("app.datasource.password");
String path = new File(".").getCanonicalPath();
File bootstrapDirectory = new File(path);
File[] files = bootstrapDirectory.listFiles();
Arrays.sort(files);
for (int i = 0; i < files.length; i++) {
if (files[i].getName().startsWith("bootstrap_")) {
InputStream is = null;
try {
Properties boot_props = new Properties();
is = new FileInputStream(files[i]);
if (null != is) {
boot_props.load(is);
}
int bootstrap = Integer.parseInt(boot_props.getProperty("bootstrap"));
String version = boot_props.getProperty("version");
String bootstrapfile = boot_props.getProperty("bootstrapfile");
if (1 == bootstrap) {
bootstrap = 0;
AnsiConsole.systemInstall();
System.out.println(ansi().fg(GREEN));
System.out.println("BOOTSTRAPPING UPDATE VERSION " + version);
System.out.println(ansi().reset());
JDBCUtil jdbcutil = new JDBCUtil(dbclass, dburl, dbuser, dbpassword);
ScriptRunner runner = new ScriptRunner(jdbcutil.getConnection(), false, false);
runner.runScript(new BufferedReader(new FileReader(bootstrapfile)));
File f = new File(files[i].getName());
OutputStream out = new FileOutputStream(f);
boot_props.setProperty("bootstrap", String.valueOf(bootstrap));
DefaultPropertiesPersister p = new DefaultPropertiesPersister();
p.store(boot_props, out, "Bootstrap properties");
}
} catch (FileNotFoundException ex) {
LOGGER.error(ex.getMessage());
} catch (IOException | SQLException ex) {
LOGGER.error(ex.getMessage());
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
}
}
}
} catch (FileNotFoundException ex) {
LOGGER.error(ex.getMessage());
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
} finally {
try {
if (null != fis) {
fis.close();
}
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
}
}
use of org.springframework.util.DefaultPropertiesPersister in project POL-POM-5 by PlayOnLinux.
the class SettingsManager method save.
public void save() {
Settings settings = load();
try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) {
DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
persister.store(settings.getProperties(), outputStream, "Phoenicis User Settings");
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations