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

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

Introduction

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

Prototype

boolean IS_OS_WINDOWS

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

Click Source Link

Document

Is true if this is Windows.

The field will return false if OS_NAME is null.

Usage

From source file:net.urosk.mifss.core.workers.converters.BaseMediaConverter.java

public String getOsAwarePath(String path) throws MediaConverterException {

    if (SystemUtils.IS_OS_LINUX) {
        return path;
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return ("\"" + path + "\"");

    } else {//from   w w w  . j av  a2 s . c o  m
        throw new MediaConverterException("OS platform not supported ...");
    }
}

From source file:net.ymate.platform.commons.util.RuntimeUtils.java

/**
 * ???Windows
 * 
 * @return
 */
public static boolean isWindows() {
    return SystemUtils.IS_OS_WINDOWS;
}

From source file:net.ymate.platform.commons.util.SystemEnvUtils.java

/**
 * ?????/*from  w  ww  .ja  v a  2  s.com*/
 */
public static void initSystemEnvs() {
    Process p = null;
    try {
        if (SystemUtils.IS_OS_WINDOWS) {
            p = Runtime.getRuntime().exec("cmd /c set");
        } else if (SystemUtils.IS_OS_UNIX) {
            p = Runtime.getRuntime().exec("/bin/sh -c set");
        } else {
            _LOG.warn("Unknown os.name=" + SystemUtils.OS_NAME);
            SYSTEM_ENV_MAP.clear();
        }
        if (p != null) {
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                int i = line.indexOf("=");
                if (i > -1) {
                    String key = line.substring(0, i);
                    String value = line.substring(i + 1);
                    SYSTEM_ENV_MAP.put(key, value);
                }
            }
        }
    } catch (IOException e) {
        _LOG.warn(RuntimeUtils.unwrapThrow(e));
    }
}

From source file:net.ymate.platform.core.util.RuntimeUtils.java

/**
 * ?????//  w  ww . j  a  va 2  s  .  co m
 */
public static void initSystemEnvs() {
    Process p = null;
    BufferedReader br = null;
    try {
        if (SystemUtils.IS_OS_WINDOWS) {
            p = Runtime.getRuntime().exec("cmd /c set");
        } else if (SystemUtils.IS_OS_UNIX) {
            p = Runtime.getRuntime().exec("/bin/sh -c set");
        } else {
            _LOG.warn("Unknown os.name=" + SystemUtils.OS_NAME);
            SYSTEM_ENV_MAP.clear();
        }
        if (p != null) {
            br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                int i = line.indexOf('=');
                if (i > -1) {
                    String key = line.substring(0, i);
                    String value = line.substring(i + 1);
                    SYSTEM_ENV_MAP.put(key, value);
                }
            }
        }
    } catch (IOException e) {
        _LOG.warn(RuntimeUtils.unwrapThrow(e));
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException e) {
                _LOG.warn("", e);
            }
        }
        if (p != null) {
            p.destroy();
        }
    }
}

From source file:org.alfresco.extension.bulkfilesystemimport.impl.AbstractBulkFilesystemImporter.java

/**
 * //from  w w w .  j  av  a  2 s.co  m
 * @param rootLocation
 * @param absSourcePath
 * @return
 */
private final boolean isInContentStore(final String rootLocation, final String absSourcePath) {
    boolean result = false;
    // Case insensitive comparison on Windows
    if (SystemUtils.IS_OS_WINDOWS) {
        result = absSourcePath.toLowerCase().startsWith(validatePath(rootLocation).toLowerCase());
    } else {
        result = absSourcePath.startsWith(validatePath(rootLocation));
    }

    return (result);
}

From source file:org.alfresco.extension.bulkfilesystemimport.impl.AbstractBulkFilesystemImporter.java

private final String normaliseFilename(final String filename) {
    String result = null;/*  w  w w  .  j  a  v  a 2s.  c om*/

    if (filename != null) {
        result = filename.replaceAll("\\\\", "/"); // Normalise all path separators to Unix-style (note: quadruple escaping is indeed required!)
        result = result.replaceAll("/+", "/"); // De-dupe duplicate separators

        // Ensure case insensitive comparison on Windows
        if (SystemUtils.IS_OS_WINDOWS) {
            result = result.toLowerCase();
        }
    }

    return (result);
}

From source file:org.alfresco.os.mac.app.ScreenShotTest.java

@Test(groups = { "development" })
public void ldtp() {
    try {/* w w  w .j  a v  a  2  s.  c o m*/
        if (SystemUtils.IS_OS_MAC) {
            TextEdit notepad = new TextEdit();
            notepad.openApplication();
            notepad.close("error");
        } else if (SystemUtils.IS_OS_WINDOWS) {
            Notepad notepad = new Notepad();
            notepad.openApplication();
            notepad.close(new File("error"));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new TestException(e.getMessage(), e.getCause());
    }
}

From source file:org.alfresco.utilities.LdtpUtils.java

/**
 * This will kill a process based on windowsName - works on linux/mac OS
 * Fow windows application, just pass the exe name of the application as <windowName> e.g. "notepad.exe"
 * /*w ww. jav  a 2  s.  c o  m*/
 * @author <a href="mailto:paulbrodner@gmail.com">Paul Brodner</a>
 * @param windowName
 */
public static void killProcessByWindowName(String windowName) {

    if (SystemUtils.IS_OS_MAC) {
        executeOnUnix("kill `ps ax | grep \"" + windowName + "\" | awk '{print $1}'`");
    }

    if (SystemUtils.IS_OS_WINDOWS) {
        execute(new String[] { "taskkill", "/F", "/IM", windowName });
    }
}

From source file:org.alfresco.utilities.LdtpUtils.java

public static File getDocumentsFolder() {
    if (SystemUtils.IS_OS_MAC) {
        return new File(getHomeFolder(), "Documents");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return new File(getHomeFolder(), "My Documents");
    }//from w  w  w  . j a v  a2 s. c o m
    return null;
}

From source file:org.alfresco.utilities.LdtpUtils.java

/**
 * TODO add getTrashFolderLocation for Windows
 *//*from   w  ww  .ja  va  2 s . c o m*/
public static File getTrashFolderLocation() {
    if (SystemUtils.IS_OS_MAC) {
        return new File(getHomeFolder(), "Trash");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return new File(getHomeFolder(), "TBD");
    }
    return null;
}