Search in sources :

Example 1 with DefaultPropertiesPersister

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();
    }
}
Also used : DefaultPropertiesPersister(org.springframework.util.DefaultPropertiesPersister) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 2 with DefaultPropertiesPersister

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();
    }
}
Also used : DefaultPropertiesPersister(org.springframework.util.DefaultPropertiesPersister) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 3 with DefaultPropertiesPersister

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();
    }
}
Also used : DefaultPropertiesPersister(org.springframework.util.DefaultPropertiesPersister) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 4 with DefaultPropertiesPersister

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());
        }
    }
}
Also used : SQLException(java.sql.SQLException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) JDBCUtil(io.clownfish.clownfish.jdbc.JDBCUtil) IOException(java.io.IOException) Properties(java.util.Properties) ScriptRunner(io.clownfish.clownfish.jdbc.ScriptRunner) FileInputStream(java.io.FileInputStream) DefaultPropertiesPersister(org.springframework.util.DefaultPropertiesPersister) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File)

Example 5 with DefaultPropertiesPersister

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();
    }
}
Also used : DefaultPropertiesPersister(org.springframework.util.DefaultPropertiesPersister) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Aggregations

DefaultPropertiesPersister (org.springframework.util.DefaultPropertiesPersister)8 File (java.io.File)7 FileOutputStream (java.io.FileOutputStream)7 IOException (java.io.IOException)7 OutputStream (java.io.OutputStream)7 SAPConnection (de.destrukt.sapconnection.SAPConnection)1 CfClassCompiler (io.clownfish.clownfish.compiler.CfClassCompiler)1 CfClassLoader (io.clownfish.clownfish.compiler.CfClassLoader)1 AuthTokenList (io.clownfish.clownfish.datamodels.AuthTokenList)1 HibernateInit (io.clownfish.clownfish.datamodels.HibernateInit)1 GzipSwitch (io.clownfish.clownfish.interceptor.GzipSwitch)1 DatatableDeleteProperties (io.clownfish.clownfish.jdbc.DatatableDeleteProperties)1 DatatableNewProperties (io.clownfish.clownfish.jdbc.DatatableNewProperties)1 DatatableProperties (io.clownfish.clownfish.jdbc.DatatableProperties)1 DatatableUpdateProperties (io.clownfish.clownfish.jdbc.DatatableUpdateProperties)1 JDBCUtil (io.clownfish.clownfish.jdbc.JDBCUtil)1 ScriptRunner (io.clownfish.clownfish.jdbc.ScriptRunner)1 EmailProperties (io.clownfish.clownfish.mail.EmailProperties)1 RPY_TABLE_READ (io.clownfish.clownfish.sap.RPY_TABLE_READ)1 BufferedReader (java.io.BufferedReader)1