Example usage for org.apache.commons.lang SystemUtils USER_HOME

List of usage examples for org.apache.commons.lang SystemUtils USER_HOME

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils USER_HOME.

Prototype

String USER_HOME

To view the source code for org.apache.commons.lang SystemUtils USER_HOME.

Click Source Link

Document

The user.home System Property.

Usage

From source file:com.yahoo.flowetl.commons.runner.Main.java

/**
 * Gets some useful runtime info as a map of names -> info.
 */// www  .  ja v  a2 s.  c om
private static Map<String, Object> getRuntimeInfo() {
    Map<String, Object> sysInfo = new TreeMap<String, Object>();
    StringBuilder jvminfo = new StringBuilder();
    jvminfo.append("Vendor: ");
    jvminfo.append(SystemUtils.JAVA_VENDOR);
    jvminfo.append(", Version: ");
    jvminfo.append(SystemUtils.JAVA_VERSION + " - " + SystemUtils.JAVA_VM_INFO);
    jvminfo.append(", OS: ");
    jvminfo.append(SystemUtils.OS_NAME + " (" + SystemUtils.OS_VERSION + " : " + SystemUtils.OS_ARCH + ")");
    sysInfo.put(WordUtils.capitalizeFully("jvm"), jvminfo.toString());
    sysInfo.put(WordUtils.capitalizeFully("default charset encoding"), DEF_CHAR_SET.name());
    String netAdd = NetUtils.getLocalAddress();
    if (StringUtils.isEmpty(netAdd)) {
        netAdd = "????";
    }
    String localName = NetUtils.getLocalHostName();
    if (StringUtils.isEmpty(localName)) {
        localName = "????";
    }
    sysInfo.put(WordUtils.capitalizeFully("network"), localName + " at ip address " + netAdd);
    String cPath = SystemUtils.JAVA_CLASS_PATH;
    String linesep = StringEscapeUtils.escapeJava(SystemUtils.LINE_SEPARATOR);
    sysInfo.put(WordUtils.capitalizeFully("classpath"), cPath);
    sysInfo.put(WordUtils.capitalizeFully("jvm home"), SystemUtils.JAVA_HOME);
    sysInfo.put(WordUtils.capitalizeFully("jvm tmpdir"), SystemUtils.JAVA_IO_TMPDIR);
    sysInfo.put(WordUtils.capitalizeFully("jvm libpath"), SystemUtils.JAVA_LIBRARY_PATH);
    sysInfo.put(WordUtils.capitalizeFully("line separator"), linesep);
    sysInfo.put(WordUtils.capitalizeFully("path separator"),
            StringEscapeUtils.escapeJava(SystemUtils.PATH_SEPARATOR));
    sysInfo.put(WordUtils.capitalizeFully("user timezone"), SystemUtils.USER_TIMEZONE);
    sysInfo.put(WordUtils.capitalizeFully("user home"), SystemUtils.USER_HOME);
    sysInfo.put(WordUtils.capitalizeFully("user language"), SystemUtils.USER_LANGUAGE);
    sysInfo.put(WordUtils.capitalizeFully("user name"), SystemUtils.USER_NAME);
    return sysInfo;
}

From source file:de.awtools.config.PropertyHolder.java

/**
 * Ldt die Konfiguration aus dem Home-Verzeichnis des Anwenders.
 *///from  w  w  w. ja  v  a  2 s .  co m
private void loadHomepath() {
    if (log.isDebugEnabled()) {
        log.debug("Load homepath resource '" + getUserHomeFileName() + "'.");
    }

    try {
        File userHomePropertyFile = new File(SystemUtils.USER_HOME, getUserHomeFileName());
        if (!userHomePropertyFile.exists()) {
            userHomePropertyFile.createNewFile();
        }

        userHomeProperties = new PropertiesGlueConfig(userHomePropertyFile.toURI().toURL());
    } catch (MalformedURLException ex) {
        log.debug("MalformedURLException", ex);
        throw new IllegalStateException(ex);
    } catch (IOException ex) {
        log.debug("Cant create user_home property file!", ex);
        throw new IllegalStateException(ex);
    }
}

From source file:com.flagleader.builder.BuilderConfig.java

public void save() {
    Properties localProperties = null;
    try {/*from w w  w  .  ja  v a2 s  . c  o  m*/
        localProperties = new Properties();
        if (this.c == null)
            this.c = new File(SystemUtils.USER_HOME + File.separator + ".visualrules", "builder.conf");
        if (!this.c.exists())
            this.c.createNewFile();
        localProperties.setProperty("autosave", new Boolean(this.h).toString());
        localProperties.setProperty("userName", this.k);
        localProperties.setProperty("licenseKey", this.l);
        localProperties.setProperty("demoKey", this.j);
        localProperties.setProperty("autosaveTime", new Long(this.i).toString());
        localProperties.setProperty("tomcatLogFile", this.n);
        localProperties.setProperty("projPath", this.q);
        localProperties.setProperty("updateUrl", this.r);
        localProperties.setProperty("emailServer", this.w);
        localProperties.setProperty("emailUser", this.x);
        localProperties.setProperty("emailPasswd", ConnectionFactory.encrypt(this.y));
        localProperties.setProperty("emailAuthor", this.z);
        localProperties.setProperty("emailAuthorName", this.A);
        localProperties.setProperty("emailTo", this.B);
        localProperties.setProperty("emailToName", this.C);
        localProperties.setProperty("firstLogin", new Boolean(this.s).toString());
        localProperties.setProperty("loadDefault", new Boolean(this.t).toString());
        localProperties.setProperty("autoCheckVersion", new Boolean(this.u).toString());
        localProperties.setProperty("autoCheckVersionTime", new Long(this.v).toString());
        localProperties.setProperty("compositeBuffer", this.m);
        localProperties.setProperty("fontname", this.g.getFontData()[0].getName());
        localProperties.setProperty("fontheight", String.valueOf(this.g.getFontData()[0].getHeight()));
        localProperties.setProperty("fontstyle", String.valueOf(this.g.getFontData()[0].getStyle()));
        localProperties.store(new FileOutputStream(this.c), "Business Rule Builder Config File");
    } catch (Exception localException) {
        localException.printStackTrace();
    }
}

From source file:de.pdark.dsmp.Config.java

public File getBaseDirectory() {
    String path = BASE_DIR;//from  w w w  .  j a v  a  2 s .com
    if (path == null)
        path = SystemUtils.USER_HOME;
    return new File(path);
}

From source file:org.apache.ctakes.jdl.common.FileUtilTest.java

@Theory
public void getCanonical(String fileName) throws IOException {
    assertThat(FileUtil.getCanonical(null, SystemUtils.USER_HOME), is(SystemUtils.USER_HOME));
    assertThat(FileUtil.getCanonical(null), is(SystemUtils.USER_DIR));
    assertThat(FileUtil.getCanonical(new File(fileName)), is(new File(fileName).getCanonicalPath()));
}

From source file:org.candlepin.client.cmds.Utils.java

private static void replaceSystemPropertyValues(Properties properties, String key) {
    properties.setProperty(key, String.format(properties.getProperty(key), SystemUtils.USER_HOME));
}

From source file:org.kuali.kra.infrastructure.TestUtilities.java

License:asdf

/**
 * Attempts to derive the database "platform" to use for unit tests by
 * inspected Ant build.properties files in typical locations.
 * @return the test platform if so defined in Ant build.properties file(s), or the DEFAULT_TEST_PLATFORM otherwise
 * @see #DEFAULT_TEST_PLATFORM//w w w.  j  a  v  a 2  s  . c  om
 * @throws IOException if anything goes awry
 */
public static String getTestPlatform() throws IOException {
    // check the user's build.properties in user's home
    File userBuildProperties = new File(SystemUtils.USER_HOME + "/" + BUILD_PROPERTIES);
    if (userBuildProperties.isFile()) {
        Properties properties = loadProperties(userBuildProperties);
        if (properties.containsKey(TEST_PLATFORM)) {
            return properties.getProperty(TEST_PLATFORM).toLowerCase();
        }
    }
    // check the "local" build.properties in the current directory
    File localBuildProperties = new File(BUILD_PROPERTIES);
    if (localBuildProperties.isFile()) {
        Properties properties = loadProperties(localBuildProperties);
        if (properties.containsKey(TEST_PLATFORM)) {
            return properties.getProperty(TEST_PLATFORM).toLowerCase();
        }
    }
    return DEFAULT_TEST_PLATFORM.toLowerCase();
}

From source file:phex.gui.dialogs.ExportDialog.java

private void initComponents() {
    closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.insertElementAt(Localizer.getString("ExportDialog_DefaultHTMLExport"), DEFAULT_HTML_INDEX);
    model.insertElementAt(Localizer.getString("ExportDialog_MagmaYAMLExport"), DEFAULT_MAGMA_YAML_INDEX);
    model.insertElementAt(Localizer.getString("ExportDialog_MetalinkXMLExport"), DEFAULT_METALINK_XML_INDEX);
    model.insertElementAt(Localizer.getString("ExportDialog_RSSXMLExport"), DEFAULT_RSS_XML_INDEX);

    standardExport = new JRadioButton(Localizer.getString("ExportDialog_StandardExportFormat"));
    standardExport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            replaceFileExtForStandardExport();
        }/* w w w . j  a va 2  s.c  om*/
    });

    customExport = new JRadioButton(Localizer.getString("ExportDialog_CustomExportFormat"));
    customExport.setToolTipText(Localizer.getString("ExportDialog_TTTCustomExportFormat"));
    ButtonGroup exportFormatGroup = new ButtonGroup();
    exportFormatGroup.add(standardExport);
    exportFormatGroup.add(customExport);
    standardExport.setSelected(true);

    standardExportFormatCB = new JComboBox(model);
    standardExportFormatCB.addActionListener(new ExportTypeListener());

    customExportFormatTF = new JTextField(40);
    customExportFormatTF.setToolTipText(Localizer.getString("ExportDialog_TTTCustomExportFormat"));
    customExportFormatTF.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            customExport.setSelected(true);
        }

        public void keyReleased(KeyEvent e) {
            customExport.setSelected(true);
        }

        public void keyTyped(KeyEvent e) {
            customExport.setSelected(true);
        }
    });

    browseCustomFormat = new JButton(Localizer.getString("ExportDialog_Browse"));
    browseCustomFormat.addActionListener(new BrowseCustomFileBtnListener());

    exportAllFiles = new JRadioButton(Localizer.getString("ExportDialog_ExportAllFiles"));
    // text will be set on initContent()
    exportSelectedFiles = new JRadioButton();
    ButtonGroup exportSourceGroup = new ButtonGroup();
    exportSourceGroup.add(exportAllFiles);
    exportSourceGroup.add(exportSelectedFiles);

    outputFileTF = new JTextField(40);
    File defOutFile = new File(SystemUtils.USER_HOME, "shared_files.html");
    outputFileTF.setText(defOutFile.getAbsolutePath());

    browseOutFile = new JButton(Localizer.getString("ExportDialog_Browse"));
    browseOutFile.addActionListener(new BrowseOutFileBtnListener());

    magnetInclXs = new JCheckBox(Localizer.getString("ExportDialog_MagnetIncludeXS"));
    magnetInclXs.setToolTipText(Localizer.getString("ExportDialog_TTTMagnetIncludeXS"));

    magnetInclFreebase = new JCheckBox(Localizer.getString("ExportDialog_MagnetIncludeFreebase"));
    magnetInclFreebase.setToolTipText(Localizer.getString("ExportDialog_TTTMagnetIncludeFreebase"));

    // delay setting initial index to ensure all components are available
    standardExportFormatCB.setSelectedIndex(0);

    okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());

    cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);
}

From source file:us.paulevans.basicxslt.Utils.java

/**
 * Retrieves the user preferences from disk.
 * @return Properties/* w  ww.  ja v a  2s  .  co  m*/
 * @throws Exception
 */
public synchronized static UserPreferences getUserPrefs() {

    FileInputStream in;
    File appPrefsDir, appPrefsFile;

    if (userPrefs == null) {
        userPrefs = new UserPreferences();
        in = null;
        try {
            appPrefsDir = new File(SystemUtils.USER_HOME + "/" + AppConstants.APP_PREFS_DIR);
            appPrefsDir.mkdir();
            appPrefsFile = new File(appPrefsDir, AppConstants.APP_PREFS_FILE);
            appPrefsFile.createNewFile();
            userPrefs.load(in = new FileInputStream(appPrefsFile));
        } catch (IOException aException) {
            logger.error(ExceptionUtils.getFullStackTrace(aException));
            Utils.showErrorDialog(null, aException);
        } finally {
            closeQuietly(in);
        }
    }
    return userPrefs;
}

From source file:us.paulevans.basicxslt.Utils.java

/**
 * Returns an output stream from the user prefs properties file.
 * @return OutputStream/*from   w w w.j  ava2s. co  m*/
 * @throws Exception
 */
public static OutputStream getUserPrefsOutputStream() throws IOException {

    File appPrefsDir;

    try {
        appPrefsDir = new File(SystemUtils.USER_HOME + "/" + AppConstants.APP_PREFS_DIR);
        appPrefsDir.mkdir();
        return new FileOutputStream(new File(appPrefsDir, AppConstants.APP_PREFS_FILE));
    } catch (IOException aException) {
        // log and re-throw...
        logger.error(ExceptionUtils.getFullStackTrace(aException));
        throw aException;
    }
}