Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

In this page you can find the example usage for java.util Properties get.

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:edu.indiana.lib.osid.base.loader.OsidLoader.java

/**
 * Returns an instance of the org.osid.OsidManager of the OSID specified by the OSID
 * package org.osid.OsidManager interface name and the implementation package name.
 * The implementation class name is constructed from the SID package
 * Manager interface name. A configuration file name is constructed in a
 * similar manner and if the file exists it is loaded into the
 * implementation's org.osid.OsidManager's configuration.
 *
 * <p>// w  w w  . j  a va  2  s .  c o  m
 * Example:  To load an implementation of the org.osid.Filing OSID
 * implemented in a package "xyz", one would use:
 * </p>
 *
 * <p>
 * org.osid.filing.FilingManager fm =
 * (org.osid.filing.FilingManager)org.osid.OsidLoader.getManager(
 * </p>
 *
 * <p>
 * "org.osid.filing.FilingManager" ,
 * </p>
 *
 * <p>
 * "xyz" ,
 * </p>
 *
 * <p>
 * new org.osid.OsidContext());
 * </p>
 *
 * @param osidPackageManagerName osidPackageManagerName is a fully
 *        qualified org.osid.OsidManager interface name
 * @param implPackageName implPackageName is a fully qualified
 *        implementation package name
 * @param context
 * @param additionalConfiguration
 *
 * @return org.osid.OsidManager
 *
 * @throws org.osid.OsidException An exception with one of the following
 *         messages defined in org.osid.OsidException:  {@link
 *         org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
 *         {@link org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT},
 *         {@link org.osid.OsidException#VERSION_ERROR VERSION_ERROR},
 *         ={@link org.osid.OsidException#INTERFACE_NOT_FOUND
 *         INTERFACE_NOT_FOUND}, ={@link
 *         org.osid.OsidException#MANAGER_NOT_FOUND MANAGER_NOT_FOUND},
 *         ={@link org.osid.OsidException#MANAGER_INSTANTIATION_ERROR
 *         MANAGER_INSTANTIATION_ERROR}, ={@link
 *         org.osid.OsidException#ERROR_ASSIGNING_CONTEXT
 *         ERROR_ASSIGNING_CONTEXT}, ={@link
 *         org.osid.OsidException#ERROR_ASSIGNING_CONFIGURATION
 *         ERROR_ASSIGNING_CONFIGURATION}
 */
public static org.osid.OsidManager getManager(String osidPackageManagerName, String implPackageName,
        org.osid.OsidContext context, java.util.Properties additionalConfiguration)
        throws org.osid.OsidException {

    try {
        if ((null != context) && (null != osidPackageManagerName) && (null != implPackageName)) {

            String osidInterfaceName = osidPackageManagerName;
            String className = makeClassName(osidPackageManagerName);
            String managerClassName = makeFullyQualifiedClassName(implPackageName, className);

            Class osidInterface = Class.forName(osidInterfaceName);

            if (null != osidInterface) {
                Class managerClass = Class.forName(managerClassName);

                if (null != managerClass) {
                    if (osidInterface.isAssignableFrom(managerClass)) {
                        org.osid.OsidManager manager = (org.osid.OsidManager) managerClass.newInstance();

                        if (null != manager) {
                            try {
                                manager.osidVersion_2_0();
                            } catch (Throwable ex) {
                                throw new org.osid.OsidException(org.osid.OsidException.VERSION_ERROR);
                            }

                            try {
                                manager.assignOsidContext(context);
                            } catch (Exception ex) {
                                throw new org.osid.OsidException(
                                        org.osid.OsidException.ERROR_ASSIGNING_CONTEXT);
                            }

                            try {
                                java.util.Properties configuration = getConfiguration(manager);

                                if (null == configuration) {
                                    configuration = new java.util.Properties();
                                }

                                if (null != additionalConfiguration) {
                                    java.util.Enumeration enumer = additionalConfiguration.propertyNames();

                                    while (enumer.hasMoreElements()) {
                                        java.io.Serializable key = (java.io.Serializable) enumer.nextElement();

                                        if (null != key) {
                                            java.io.Serializable value = (java.io.Serializable) additionalConfiguration
                                                    .get(key);

                                            if (null != value) {
                                                configuration.put(key, value);
                                            }
                                        }
                                    }
                                }

                                manager.assignConfiguration(configuration);

                                return manager;
                            } catch (Exception ex) {
                                throw new org.osid.OsidException(
                                        org.osid.OsidException.ERROR_ASSIGNING_CONFIGURATION);
                            }
                        }

                        throw new org.osid.OsidException(org.osid.OsidException.MANAGER_INSTANTIATION_ERROR);
                    }

                    throw new org.osid.OsidException(org.osid.OsidException.MANAGER_NOT_OSID_IMPLEMENTATION);
                }

                throw new org.osid.OsidException(org.osid.OsidException.MANAGER_NOT_FOUND);
            }

            throw new org.osid.OsidException(org.osid.OsidException.INTERFACE_NOT_FOUND);
        }

        throw new org.osid.OsidException(org.osid.OsidException.NULL_ARGUMENT);
    } catch (org.osid.OsidException oex) {
        oex.printStackTrace();
        throw new org.osid.OsidException(oex.getMessage());
    } catch (java.lang.Throwable ex) {
        ex.printStackTrace();
        throw new org.osid.OsidException(org.osid.OsidException.OPERATION_FAILED);
    }
}

From source file:bboss.org.apache.velocity.runtime.RuntimeInstance.java

/**
 * Add all the properties in props to the RuntimeInstance properties
 *///from   w w w . j  a  v a2 s  .com
public void setProperties(Properties props) {
    Enumeration en = props.keys();
    while (en.hasMoreElements()) {
        String key = en.nextElement().toString();
        setProperty(key, props.get(key));
    }
}

From source file:org.testeditor.fixture.swt.SwtBotFixture.java

/**
 * //from w  w w  . j  a v a2s  .c  o  m
 * @param proprtyFileName
 *            of the property file.
 * @param propertyKey
 *            the key of the property wich should be checked in the config.
 * @param propertyValue
 *            the value of the property to be mached to the value of the
 *            property key.
 * @return true if the value according to the key in the files is equals to
 *         propertyValue.
 * @throws IOException
 *             on error reading proprty file
 */
public boolean checkInProprtyValue(String proprtyFileName, String propertyKey, String propertyValue)
        throws IOException {
    Properties properties = new Properties();
    FileInputStream inputStream = new FileInputStream(proprtyFileName);
    properties.load(inputStream);
    inputStream.close();
    boolean found = properties.get(propertyKey).equals(propertyValue);
    LOGGER.info("Property search in " + proprtyFileName + " with key " + propertyKey + " and value: "
            + propertyValue + " is: " + found);
    return found;
}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.ConnectorFactoryIcfImpl.java

/**
 * Test if provided file is connector bundle
 * /*from   w w  w  .java  2 s.  c  o m*/
 * @param file
 *            tested file
 * @return boolean
 */
private Boolean isThisJarFileBundle(File file) {
    // Startup tests
    if (null == file) {
        throw new IllegalArgumentException("No file is providied for bundle test.");
    }

    // Skip all processing if it is not a file
    if (!file.isFile()) {
        LOGGER.debug("This {} is not a file", file.getAbsolutePath());
        return false;
    }

    Properties prop = new Properties();
    JarFile jar = null;
    // Open jar file
    try {
        jar = new JarFile(file);
    } catch (IOException ex) {
        LOGGER.debug("Unable to read jar file: " + file.getAbsolutePath() + " [" + ex.getMessage() + "]");
        return false;
    }

    // read jar file
    InputStream is;
    try {
        JarEntry entry = new JarEntry("META-INF/MANIFEST.MF");
        is = jar.getInputStream(entry);
    } catch (IOException ex) {
        LOGGER.debug("Unable to fine MANIFEST.MF in jar file: " + file.getAbsolutePath() + " ["
                + ex.getMessage() + "]");
        return false;
    }

    // Parse jar file
    try {
        prop.load(is);
    } catch (IOException ex) {
        LOGGER.debug("Unable to parse jar file: " + file.getAbsolutePath() + " [" + ex.getMessage() + "]");
        return false;
    } catch (NullPointerException ex) {
        LOGGER.debug("Unable to parse jar file: " + file.getAbsolutePath() + " [" + ex.getMessage() + "]");
        return false;
    }

    // Test if it is a connector
    if (null != prop.get("ConnectorBundle-Name")) {
        LOGGER.info("Discovered ICF bundle in JAR: " + prop.get("ConnectorBundle-Name") + " version: "
                + prop.get("ConnectorBundle-Version"));
        return true;
    }

    LOGGER.debug("Provided file {} is not iCF bundle jar", file.getAbsolutePath());
    return false;
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * Prints a Label / Reports from a command
 * @param cmdAction the command//from  ww w . j  a  v a 2s.co m
 */
protected void printReport(final CommandAction cmdAction) {
    // Get the original set of params
    Properties params = cmdAction.getProperties();
    if (params == null) {
        params = new Properties();
    }

    // No add the additional params
    String paramList = cmdAction.getPropertyAsString("params");
    if (StringUtils.isNotEmpty(paramList)) {
        params.putAll(UIHelper.parseProperties(paramList));
    }

    String impStr = params.getProperty("isimport");
    String rsDropStr = params.getProperty("hasrsdropparam");
    RecordSet spRep = (RecordSet) params.get("spreport");
    if (spRep != null) {
        //SpReport was clicked. Just Run it
        CommandAction runner = new CommandAction(REPORTS, RUN_REPORT, cmdAction);
        CommandDispatcher.dispatch(runner);
        return;
    }

    boolean canRunWithoutRS = spRep != null
            || (impStr != null && impStr.equals("1") && rsDropStr != null && rsDropStr.equals("0"));
    if (cmdAction.getData() instanceof RecordSetIFace || canRunWithoutRS) {
        RecordSetIFace recordSet = cmdAction.getData() instanceof RecordSetIFace
                ? (RecordSetIFace) cmdAction.getData()
                : null;

        // XXX For the Demo and until I revist a generalized way of associating a default set of reports and labels
        // to To things. One way to get here with a null title is to click on the Labels btn from the search results
        if (recordSet != null && recordSet.getDbTableId() != null && recordSet.getDbTableId() == 1
                && cmdAction.getPropertyAsString("title") == null) {
            cmdAction.setProperty("file", "fish_label.jrxml");
            cmdAction.setProperty("title", "Fish Labels");

        } else if (recordSet != null && recordSet.getDbTableId() != null && recordSet.getDbTableId() == 52
                && cmdAction.getPropertyAsString("title") == null) {
            // XXX For the Demo and until I revist a generalized way of associating a default set of reports and labels
            // to To things. One way to get here with a null title is to click on the Labels btn from the search results
            cmdAction.setProperty("file", "LoanInvoice.jrxml");
            cmdAction.setProperty("title", "Loan Invoice");
        }

        if (recordSet == null || checkForALotOfLabels(recordSet)) {
            String labelFileName = cmdAction.getPropertyAsString("file");

            if (StringUtils.isEmpty(labelFileName)) {
                labelFileName = askForLabelName();
            }

            if (StringUtils.isNotEmpty(labelFileName)) {
                Taskable originatingTask = (Taskable) cmdAction.getProperty(NavBoxAction.ORGINATING_TASK);
                //System.out.println("************** "+(new File("/home/rods/Specify/reportsCache_Linux/fish_label.jrxml").lastModified()));
                doLabels(labelFileName, cmdAction.getPropertyAsString("title"), recordSet, params,
                        originatingTask == null ? this : originatingTask,
                        (ImageIcon) cmdAction.getProperty("icon"));
            }
        }

    } else if (cmdAction.getData() instanceof JRDataSource) {
        String labelFileName = cmdAction.getPropertyAsString("file");

        if (StringUtils.isEmpty(labelFileName)) {
            labelFileName = askForLabelName();
        }

        if (StringUtils.isNotEmpty(labelFileName)) {
            Taskable originatingTask = (Taskable) cmdAction.getProperty(NavBoxAction.ORGINATING_TASK);
            doLabels(labelFileName, cmdAction.getPropertyAsString("title"), cmdAction.getData(), params,
                    originatingTask, (ImageIcon) cmdAction.getProperty("icon"));
        }

    } else {
        String tableIDStr = cmdAction.getPropertyAsString("tableid");
        if (StringUtils.isNotEmpty(tableIDStr) && StringUtils.isNumeric(tableIDStr)) {
            RecordSetIFace recordSet = RecordSetTask.askForRecordSet(Integer.parseInt(tableIDStr));
            if (recordSet != null) {
                doLabels(cmdAction.getPropertyAsString("file"), cmdAction.getPropertyAsString("title"),
                        recordSet, params, this, (ImageIcon) cmdAction.getProperty("icon"));
            } else {
                UIRegistry.displayLocalizedStatusBarText("RecordSetTask.NoRecordsets");
            }
        }

    }

}

From source file:info.magnolia.jcr.util.PropertiesImportExport.java

/**
 * Transforms the keys to the following inner notation: <code>/some/path/node.prop</code> or
 * <code>/some/path/node.@type</code>.
 *///w  w  w  .j  av  a2s.co m
private Properties keysToInnerFormat(Properties properties) {
    Properties cleaned = new OrderedProperties();

    for (Object o : properties.keySet()) {
        String orgKey = (String) o;
        // explicitly enforce certain syntax
        if (!orgKey.startsWith("/")) {
            throw new IllegalArgumentException("Missing trailing '/' for key: " + orgKey);
        }
        if (StringUtils.countMatches(orgKey, ".") > 1) {
            throw new IllegalArgumentException("Key must not contain more than one '.': " + orgKey);
        }
        if (orgKey.contains("@") && !orgKey.contains(".@")) {
            throw new IllegalArgumentException("Key containing '@' must be preceded by a '.': " + orgKey);
        }
        // if this is a node definition (no property)
        String newKey = orgKey;

        String propertyName = StringUtils.substringAfterLast(newKey, ".");
        String keySuffix = StringUtils.substringBeforeLast(newKey, ".");
        String path = StringUtils.removeStart(keySuffix, "/");

        // if this is a path (no property)
        if (StringUtils.isEmpty(propertyName)) {
            // no value --> is a node
            if (StringUtils.isEmpty(properties.getProperty(orgKey))) {
                // make this the type property if not defined otherwise
                if (!properties.containsKey(orgKey + ".@type")) {
                    cleaned.put(path + ".@type", NodeTypes.ContentNode.NAME);
                }
                continue;
            }
            throw new IllegalArgumentException(
                    "Key for a path (everything without a '.' is considered to be a path) must not contain a value ('='): "
                            + orgKey);
        }
        cleaned.put(path + "." + propertyName, properties.get(orgKey));
    }
    return cleaned;
}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnectorFactoryConnIdImpl.java

/**
 * Scan class path for connector bundles
 *
 * @return Set of all bundle URL/*from  w ww .j  a  va 2  s .  c  o  m*/
 */
private Set<URI> scanClassPathForBundles() {
    Set<URI> bundle = new HashSet<>();

    // scan class path for bundles
    Enumeration<URL> en = null;
    try {
        // Search all jars in classpath
        en = ConnectorFactoryConnIdImpl.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
    } catch (IOException ex) {
        LOGGER.debug("Error during reding content from class path");
    }

    // Find which one is ICF connector
    while (en.hasMoreElements()) {
        URL u = en.nextElement();

        Properties prop = new Properties();
        LOGGER.trace("Scan classloader resource: " + u.toString());
        try {
            // read content of META-INF/MANIFEST.MF
            InputStream is = u.openStream();
            // skip if unreadable
            if (is == null) {
                continue;
            }
            // Convert to properties
            prop.load(is);
        } catch (IOException ex) {
            LOGGER.trace("Unable load: " + u + " [" + ex.getMessage() + "]");
        }
        // tomcat
        // toString >>> jar:file:/<ABSOLUTE_PATH_TO_TOMCAT_WEBAPPS>/midpoint/WEB-INF/lib/connector-csv-2.1-SNAPSHOT.jar!/META-INF/MANIFEST.MF
        // getPath  >>>     file:/<ABSOLUTE_PATH_TO_TOMCAT_WEBAPPS>/WEB-INF/lib/connector-csv-2.1-SNAPSHOT.jar!/META-INF/MANIFEST.MF

        // boot
        // toString >>> jar:file:/<ABSOLUTE_PATH_TO_WAR_FOLDER>/midpoint.war!/WEB-INF/lib/connector-csv-2.1-SNAPSHOT.jar!/META-INF/MANIFEST.MF
        // getPath  >>>     file:/<ABSOLUTE_PATH_TO_WAR_FOLDER>/midpoint.war!/WEB-INF/lib/connector-csv-2.1-SNAPSHOT.jar!/META-INF/MANIFEST.MF

        if (null != prop.get("ConnectorBundle-Name")) {
            LOGGER.info("Discovered ICF bundle on CLASSPATH: " + prop.get("ConnectorBundle-Name") + " version: "
                    + prop.get("ConnectorBundle-Version"));

            // hack to split MANIFEST from name
            try {
                String upath = u.toString();
                if (upath.split("!/").length != 3) {
                    // we're running standard war in application server
                    upath = u.getPath();
                }

                URL tmp = new URL(toUrl(upath.substring(0, upath.lastIndexOf("!"))));
                if (isThisBundleCompatible(tmp)) {
                    try {
                        bundle.add(tmp.toURI());
                    } catch (Exception e) {
                        LOGGER.error(e.getMessage(), e);
                    }
                } else {
                    LOGGER.warn("Skip loading ICF bundle {} due error occured", tmp);
                }
            } catch (MalformedURLException e) {
                LOGGER.error("This never happend we hope. URL:" + u.getPath(), e);
                throw new SystemException(e);
            }
        }
    }
    return bundle;
}

From source file:com.glaf.jbpm.connection.DbcpConnectionProvider.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public void configure(Properties props) throws RuntimeException {
    String jdbcDriverClass = props.getProperty(Environment.DRIVER);
    String jdbcUrl = props.getProperty(Environment.URL);
    Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(props);

    log.info("DBCP using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl);
    log.info("Connection properties: " + PropertiesHelper.maskOut(connectionProps, "password"));

    autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
    log.info("autocommit mode: " + autocommit);

    if (jdbcDriverClass == null) {
        log.warn("No JDBC Driver class was specified by property " + Environment.DRIVER);
    } else {/*  www. j av a2 s . c  om*/
        try {
            Class.forName(jdbcDriverClass);
        } catch (ClassNotFoundException cnfe) {
            try {
                ClassUtils.classForName(jdbcDriverClass);
            } catch (Exception e) {
                String msg = "JDBC Driver class not found: " + jdbcDriverClass;
                log.error(msg, e);
                throw new RuntimeException(msg, e);
            }
        }
    }

    String dbUser = props.getProperty(Environment.USER);
    String dbPassword = props.getProperty(Environment.PASS);

    if (dbUser == null) {
        dbUser = "";
    }

    if (dbPassword == null) {
        dbPassword = "";
    }

    Properties properties = new Properties();

    for (Iterator<Object> ii = props.keySet().iterator(); ii.hasNext();) {
        String key = (String) ii.next();
        if (key.startsWith("hibernate.dbcp.")) {
            String newKey = key.substring(15);
            properties.put(newKey, props.get(key));
        }
    }

    // Create the actual pool of connections
    ObjectPool connectionPool = new GenericObjectPool(null);

    if (props.getProperty("hibernate.connection.maxIdle") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.maxIdle", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setMaxIdle(value);
        }
    }

    if (props.getProperty("hibernate.connection.minIdle") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.minIdle", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setMinIdle(value);
        }
    }

    if (props.getProperty("hibernate.connection.maxActive") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.maxActive", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setMaxActive(value);
        }
    }

    if (props.getProperty("hibernate.connection.maxWait") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.maxWait", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setMaxWait(value);
        }
    }

    // how often should the evictor run (if ever, default is -1 = off)
    if (props.getProperty("hibernate.connection.timeBetweenEvictionRunsMillis") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.timeBetweenEvictionRunsMillis", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setTimeBetweenEvictionRunsMillis(value);

            // in each eviction run, ecict at least a fourth of "maxIdle"
            // connections
            int maxIdle = ((GenericObjectPool) connectionPool).getMaxIdle();
            int numTestsPerEvictionRun = (int) Math.ceil(((double) maxIdle / 4));
            ((GenericObjectPool) connectionPool).setNumTestsPerEvictionRun(numTestsPerEvictionRun);
        }
    }
    // how long may a connection sit idle in the pool before it may be
    // evicted
    if (props.getProperty("hibernate.connection.minEvictableIdleTimeMillis") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.minEvictableIdleTimeMillis", props, 0);
        if (value > 0) {
            ((GenericObjectPool) connectionPool).setMinEvictableIdleTimeMillis(value);
        }
    }

    // Create a factory to be used by the pool to create the connections
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(jdbcUrl, dbUser, dbPassword);

    // Create a factory for caching the PreparedStatements
    KeyedObjectPoolFactory kpf = null;

    if (props.getProperty("hibernate.connection.maxStatements") != null) {
        int value = PropertiesHelper.getInt("hibernate.connection.maxStatements", props, 0);
        if (value > 0) {
            kpf = new StackKeyedObjectPoolFactory(null, value);
        }
    } else {
        kpf = new StackKeyedObjectPoolFactory(null, 200);
    }

    // Wrap the connections and statements with pooled variants
    try {
        String testSQL = null;
        if (props.getProperty("hibernate.connection.testSQL") != null) {
            testSQL = PropertiesHelper.getString("hibernate.connection.testSQL", props, null);
        }
        new PoolableConnectionFactory(connectionFactory, connectionPool, kpf, testSQL, false, false);
        if (testSQL != null) {
            ((GenericObjectPool) connectionPool).setTestOnBorrow(true);
        }
    } catch (Exception e) {
        throw new ConnectionPoolException("DBCP", jdbcDriverClass, jdbcUrl, e);
    }

    ds = new PoolingDataSource(connectionPool);

    Connection conn = null;
    try {
        conn = ds.getConnection();
        if (conn == null) {
            throw new RuntimeException("DBCP connection pool can't get jdbc connection");
        }
    } catch (SQLException ex) {
        throw new RuntimeException(ex);
    } finally {
        JdbcUtils.close(conn);
    }

    String i = props.getProperty(Environment.ISOLATION);
    if (i == null) {
        isolation = null;
    } else {
        isolation = new Integer(i);
        log.info("JDBC isolation level: " + Environment.isolationLevelToString(isolation.intValue()));
    }

}

From source file:database.DataLoader.java

/**
 *    ?   /* ww w . j a v a2s .c  om*/
 */
public String moveData() throws SQLException, ClassNotFoundException, Exception {
    String res = "";
    Properties props = new Properties();
    File fl = new File("/usr/local/vuz/logs/prop");
    if (!fl.exists()) {
        fl.createNewFile();
    }
    InputStream inputStream = new FileInputStream(fl);
    props.load(inputStream);
    inputStream.close();
    FileOutputStream fos = new FileOutputStream(fl);
    if (props.get("ready") == null) {
        props.setProperty("ready", "1");
        props.setProperty("state", "moveUsers");
        props.store(fos, "no comment");
        //moveUsers();
        props.setProperty("state", "moveOrderTypes");
        props.store(fos, "no comment");
        //moveOrderTypes();
        props.setProperty("state", "moveDirections");
        props.store(fos, "no comment");
        //moveDirections();
        props.setProperty("state", "moveOrders");
        props.store(fos, "no comment");
        //moveOrders();
        props.setProperty("state", "moveAdminMessages");
        props.store(fos, "no comment");
        //moveAdminMessages();
        props.setProperty("state", "moveAuthorToDirections");
        props.store(fos, "no comment");
        //moveAuthorToDirections();
        props.setProperty("state", "moveAuthorSalary");
        props.store(fos, "no comment");
        //moveAuthorSalary();
        props.setProperty("state", "moveOrdersToDirections");
        props.store(fos, "no comment");
        //moveOrdersToDirections();
        props.setProperty("state", "moveAuthorReject");
        props.store(fos, "no comment");
        //moveAuthorReject();
        props.setProperty("state", "moveAuthorViews");
        props.store(fos, "no comment");
        //moveAuthorViews();
        props.setProperty("state", "moveAuthorMessages");
        props.store(fos, "no comment");
        //moveAuthorMessages();
        props.setProperty("state", "addPaymentsToOrders");
        props.store(fos, "no comment");
        //addPaymentsToOrders();
        props.setProperty("state", "moveOrderFiles");
        props.store(fos, "no comment");
        //moveOrderFiles();
        props.setProperty("state", "moveOrderReadyFiles");
        props.store(fos, "no comment");
        //moveOrderReadyFiles();
        props.setProperty("state", "moveAdminMessageFiles");
        props.store(fos, "no comment");
        //moveAdminMessageFiles();
        props.setProperty("state", "moveAuthorMessageFiles");
        props.store(fos, "no comment");
        //moveAuthorMessageFiles();
        addAuthorRights();
        //res=updatePass();

    } else {
        res = "? , ??: " + props.getProperty("state");
    }
    fos.close();
    return res;
}

From source file:com.adito.agent.client.ProxyUtil.java

/**
 * Attempt to proxy settings from Firefox.
 * //from w w w  . ja va2 s  .  c  om
 * @return firefox proxy settings
 * @throws IOException if firefox settings could not be obtained for some
 *         reason
 */
public static BrowserProxySettings lookupFirefoxProxySettings() throws IOException {

    try {

        Vector proxies = new Vector();
        Vector bypassAddr = new Vector();

        File home = new File(Utils.getHomeDirectory());
        File firefoxAppData;

        if (System.getProperty("os.name") != null && System.getProperty("os.name").startsWith("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            firefoxAppData = new File(home, "Application Data\\Mozilla\\Firefox\\profiles.ini"); //$NON-NLS-1$
        } else {
            firefoxAppData = new File(home, ".mozilla/firefox/profiles.ini"); //$NON-NLS-1$
        }

        // Look for Path elements in the profiles.ini
        BufferedReader reader = null;
        Hashtable profiles = new Hashtable();
        String line;
        try {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(firefoxAppData)));
            String currentProfileName = ""; //$NON-NLS-1$

            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("[") && line.endsWith("]")) { //$NON-NLS-1$ //$NON-NLS-2$
                    currentProfileName = line.substring(1, line.length() - 1);
                    continue;
                }

                if (line.startsWith("Path=")) { //$NON-NLS-1$
                    profiles.put(currentProfileName, new File(firefoxAppData.getParent(), line.substring(5)));
                }
            }
        } finally {
            if (reader != null) {
                reader.close();
            }
        }

        // Iterate through all the profiles and load the proxy infos from
        // the prefs.js file

        File prefsJS;
        String profileName;
        for (Enumeration e = profiles.keys(); e.hasMoreElements();) {
            profileName = (String) e.nextElement();
            prefsJS = new File((File) profiles.get(profileName), "prefs.js"); //$NON-NLS-1$
            Properties props = new Properties();
            reader = null;
            try {
                if (!prefsJS.exists()) {
                    // needed to defend against un-initialised profiles.
                    // #ifdef DEBUG
                    log.info("The file " + prefsJS.getAbsolutePath() + " does not exist."); //$NON-NLS-1$
                    // #endif
                    // now remove it from the map.
                    profiles.remove(profileName);
                    continue;
                }
                reader = new BufferedReader(new InputStreamReader(new FileInputStream(prefsJS)));
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("user_pref(\"")) { //$NON-NLS-1$
                        int idx = line.indexOf("\"", 11); //$NON-NLS-1$
                        if (idx == -1)
                            continue;
                        String pref = line.substring(11, idx);

                        // Save this position
                        int pos = idx + 1;

                        // Look for another quote
                        idx = line.indexOf("\"", idx + 1); //$NON-NLS-1$

                        String value;
                        if (idx == -1) {
                            // No more quotes
                            idx = line.indexOf(" ", pos); //$NON-NLS-1$

                            if (idx == -1)
                                continue;

                            int idx2 = line.indexOf(")", pos); //$NON-NLS-1$

                            if (idx2 == -1)
                                continue;

                            value = line.substring(idx + 1, idx2);

                        } else {

                            // String value
                            int idx2 = line.indexOf("\"", idx + 1); //$NON-NLS-1$

                            if (idx2 == -1)
                                continue;

                            value = line.substring(idx + 1, idx2);
                        }

                        props.put(pref, value);

                    }
                }
            } finally {
                if (reader != null) {
                    reader.close();
                }
            }
            ProxyInfo p;
            /**
             * Extract some proxies from the properites, if the proxy is
             * enabled
             */
            if ("1".equals(props.get("network.proxy.type"))) { //$NON-NLS-1$ //$NON-NLS-2$
                boolean isProfileActive = checkProfileActive(prefsJS);
                if (props.containsKey("network.proxy.ftp")) { //$NON-NLS-1$
                    p = createProxyInfo(
                            "ftp=" + props.get("network.proxy.ftp") + ":" + props.get("network.proxy.ftp_port"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                            "Firefox Profile [" + profileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    p.setActiveProfile(isProfileActive);
                    proxies.addElement(p);
                }

                if (props.containsKey("network.proxy.http")) { //$NON-NLS-1$
                    p = createProxyInfo(
                            "http=" + props.get("network.proxy.http") + ":" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                                    + props.get("network.proxy.http_port"), //$NON-NLS-1$
                            "Firefox Profile [" + profileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                    p.setActiveProfile(isProfileActive);
                    proxies.addElement(p);
                }

                if (props.containsKey("network.proxy.ssl")) { //$NON-NLS-1$
                    p = createProxyInfo(
                            "ssl=" + props.get("network.proxy.ssl") + ":" + props.get("network.proxy.ssl_port"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                            "Firefox Profile [" + profileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                    p.setActiveProfile(isProfileActive);
                    proxies.addElement(p);
                }

                if (props.containsKey("network.proxy.socks")) { //$NON-NLS-1$
                    p = createProxyInfo("socks=" + props.get("network.proxy.socks") + ":" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            + props.get("network.proxy.socks_port"), "Firefox Profile [" + profileName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    p.setActiveProfile(isProfileActive);
                    proxies.addElement(p);
                }

                if (props.containsKey("network.proxy.no_proxies_on")) { //$NON-NLS-1$

                    StringTokenizer tokens = new StringTokenizer(
                            props.getProperty("network.proxy.no_proxies_on"), ","); //$NON-NLS-1$ //$NON-NLS-2$

                    while (tokens.hasMoreTokens()) {
                        bypassAddr.addElement(((String) tokens.nextToken()).trim());
                    }

                }
            }
        }

        // need to ensure that the returned values are sorted correctly...
        BrowserProxySettings bps = new BrowserProxySettings();
        bps.setBrowser("Mozilla Firefox"); //$NON-NLS-1$
        bps.setProxiesActiveFirst(proxies);
        bps.setBypassAddr(new String[bypassAddr.size()]);
        bypassAddr.copyInto(bps.getBypassAddr());
        return bps;

    } catch (Throwable t) {
        throw new IOException("Failed to get proxy information from Firefox profiles: " + t.getMessage()); //$NON-NLS-1$
    }
}