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:org.apache.maven.plugin.jdiff.JavadocBean.java

private String getJavadocPath() {
    final String javadocCommand = "javadoc" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");
    // For IBM's JDK 1.2
    final File javadocExe = (SystemUtils.IS_OS_AIX
            ? new File(SystemUtils.getJavaHome() + "/../sh", javadocCommand)
            : new File(SystemUtils.getJavaHome() + "/../bin", javadocCommand));

    //return javadocExe.getAbsolutePath();

    return "javadoc";
}

From source file:org.apache.rya.accumulo.mr.merge.util.AccumuloInstanceDriver.java

/**
 * Copies the HADOOP_HOME bin directory to the {@link MiniAccumuloCluster} temp directory.
 * {@link MiniAccumuloCluster} expects to find bin/winutils.exe in the MAC temp
 * directory instead of HADOOP_HOME for some reason.
 * @throws IOException/*from   w w w .j a  v a 2  s .  com*/
 */
private void copyHadoopHomeToTemp() throws IOException {
    if (IS_COPY_HADOOP_HOME_ENABLED && SystemUtils.IS_OS_WINDOWS) {
        final String hadoopHomeEnv = System.getenv("HADOOP_HOME");
        if (hadoopHomeEnv != null) {
            final File hadoopHomeDir = new File(hadoopHomeEnv);
            if (hadoopHomeDir.exists()) {
                final File binDir = Paths.get(hadoopHomeDir.getAbsolutePath(), "/bin").toFile();
                if (binDir.exists()) {
                    FileUtils.copyDirectoryToDirectory(binDir, tempDir);
                } else {
                    log.warn("The specified path for the Hadoop bin directory does not exist: "
                            + binDir.getAbsolutePath());
                }
            } else {
                log.warn("The specified path for HADOOP_HOME does not exist: "
                        + hadoopHomeDir.getAbsolutePath());
            }
        } else {
            log.warn("The HADOOP_HOME environment variable was not found.");
        }
    }
}

From source file:org.apache.spark.streaming.aliyun.mns.adapter.MNSAgentUtil.java

@SuppressWarnings("unchecked")
private static URLClassLoader getUrlClassLoader(Configuration conf, boolean runLocal) {
    if (urlClassLoader == null) {
        synchronized (MNSAgentUtil.class) {
            if (urlClassLoader == null) {
                try {
                    String[] internalDep = getMNSClasses(conf, runLocal);
                    ArrayList<URL> urls = new ArrayList<URL>();
                    if (internalDep != null) {
                        for (String dep : internalDep) {
                            urls.add(new URL("file://" + dep));
                        }/*w  ww .j  a v a 2s  . c o  m*/
                    }
                    String[] cp;
                    if (SystemUtils.IS_OS_WINDOWS) {
                        cp = System.getProperty("java.class.path").split(";");
                        for (String entity : cp) {
                            urls.add(new URL("file:" + entity));
                        }
                    } else {
                        cp = System.getProperty("java.class.path").split(":");
                        for (String entity : cp) {
                            urls.add(new URL("file://" + entity));
                        }
                    }
                    urlClassLoader = new URLClassLoader(urls.toArray(new URL[0]), null);
                } catch (Exception e) {
                    throw new RuntimeException("Can not initialize MNS " + "URLClassLoader, " + e.getMessage());
                }
            }
        }
    }
    return urlClassLoader;
}

From source file:org.apache.spark.streaming.aliyun.mns.adapter.ResourceLoader.java

private static List<URL> geClassLoaderURLs(Configuration conf, boolean runLocal) throws Exception {
    String dependPath = conf.get("fs.oss.sdk.dependency.path");
    String[] sdkDeps = null;//from w ww  .  j  a  v  a  2s .c  o  m
    if ((dependPath == null || dependPath.isEmpty()) && !runLocal) {
        throw new RuntimeException(
                "Job dose not run locally, set " + "\"fs.oss.sdk.dependency.path\" first please.");
    } else if (dependPath == null || dependPath.isEmpty()) {
        LOG.info("\"mapreduce.job.run-local\" set true.");
    } else {
        sdkDeps = dependPath.split(",");
    }

    ArrayList<URL> urls = new ArrayList<URL>();
    if (sdkDeps != null) {
        for (String dep : sdkDeps) {
            urls.add(new URL("file://" + dep));
        }
    }
    String[] cp;
    if (runLocal) {
        if (SystemUtils.IS_OS_WINDOWS) {
            cp = System.getProperty("java.class.path").split(";");

        } else {
            cp = System.getProperty("java.class.path").split(":");
        }
        for (String entity : cp) {
            urls.add(new URL("file:" + entity));
        }
    }

    return urls;
}

From source file:org.artifactory.info.InfoWriter.java

private static void splitLine(StringBuilder sb, String propertyName, String value) {
    String multiValueSeparator = SystemUtils.IS_OS_WINDOWS ? ";" : ":";
    String[] separateValues = value.split(multiValueSeparator);
    for (int i = 0; i < separateValues.length; i++) {
        String separateValue = separateValues[i];
        sb.append(String.format(listFormat, (i == 0) ? propertyName : "", separateValue));
    }//from  w w  w . j a  v  a 2s  .c o  m
}

From source file:org.artifactory.storage.db.binstore.itest.service.BinaryStoreImplFullPathFileProviderTest.java

@Override
protected String getBinaryStoreDirName() {
    if (SystemUtils.IS_OS_WINDOWS) {
        return SystemUtils.getJavaIoTmpDir().getAbsolutePath() + "\\fstest-" + hashCode();
    }/*  w w w.  j av  a  2 s  .com*/
    return "/tmp/fstest-" + hashCode();
}

From source file:org.cleartk.util.PlatformDetection.java

public PlatformDetection() {
    // resolve OS
    if (SystemUtils.IS_OS_WINDOWS) {
        this.os = OS_WINDOWS;
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        this.os = OS_OSX;
    } else if (SystemUtils.IS_OS_SOLARIS) {
        this.os = OS_SOLARIS;
    } else if (SystemUtils.IS_OS_LINUX) {
        this.os = OS_LINUX;
    } else {//w w w . j  a  v  a  2s.com
        throw new IllegalArgumentException("Unknown operating system " + SystemUtils.OS_NAME);
    }

    // resolve architecture
    Map<String, String> archMap = new HashMap<String, String>();
    archMap.put("x86", ARCH_X86_32);
    archMap.put("i386", ARCH_X86_32);
    archMap.put("i486", ARCH_X86_32);
    archMap.put("i586", ARCH_X86_32);
    archMap.put("i686", ARCH_X86_32);
    archMap.put("x86_64", ARCH_X86_64);
    archMap.put("amd64", ARCH_X86_64);
    archMap.put("powerpc", ARCH_PPC);
    this.arch = archMap.get(SystemUtils.OS_ARCH);
    if (this.arch == null) {
        throw new IllegalArgumentException("Unknown architecture " + SystemUtils.OS_ARCH);
    }
}

From source file:org.codehaus.mojo.keytool.GenkeyMojo.java

private static File getJDKCommandExe(String command) {
    String fullCommand = command + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");

    File exe;//w  ww  .  j a  v a2  s.  com

    // For IBM's JDK 1.2
    if (SystemUtils.IS_OS_AIX) {
        exe = new File(SystemUtils.getJavaHome() + "/../sh", fullCommand);
    } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ??
    {
        exe = new File(SystemUtils.getJavaHome() + "/bin", fullCommand);
    } else {
        exe = new File(SystemUtils.getJavaHome() + "/../bin", fullCommand);
    }

    return exe;
}

From source file:org.codehaus.mojo.keytool.KeyToolMojoSupport.java

/**
 * Constructs the operating system specific File path of the JDK command given the specified command name.
 * @param command the executable name //from   w ww.j a va 2  s .  co m
 * @return a File representing the path to the command.
 */
public static File getJDKCommandExe(String command) {
    String fullCommand = command + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");

    File exe;

    // For IBM's JDK 1.2
    if (SystemUtils.IS_OS_AIX) {
        exe = new File(SystemUtils.getJavaHome() + "/../sh", fullCommand);
    } else if (SystemUtils.IS_OS_MAC_OSX) // what about IS_OS_MAC_OS ??
    {
        exe = new File(SystemUtils.getJavaHome() + "/bin", fullCommand);
    } else {
        exe = new File(SystemUtils.getJavaHome() + "/../bin", fullCommand);
    }

    return exe;
}

From source file:org.codehaus.plexus.redback.struts2.interceptor.SecureActionInterceptor.java

private void executeReferrerSecurityCheck() {
    String referrer = ServletActionContext.getRequest().getHeader(HTTP_HEADER_REFERER);

    logger.debug("HTTP Referer header: {}", referrer);

    String[] tokens = StringUtils.splitPreserveAllTokens(referrer, "/", 3);

    if (tokens != null) {
        String path;/*from   ww  w  .ja  v a2  s.c  om*/
        if (tokens.length < 3) {
            path = referrer;
        } else {
            path = tokens[tokens.length - 1];
        }

        logger.debug("Calculated virtual path: {}", path);

        ServletContext servletContext = ServletActionContext.getServletContext();

        String realPath = servletContext.getRealPath(path);

        if (StringUtils.isNotEmpty(realPath)) {
            // on windows realPath can return full path c:\\bla\\bla\....
            // so transforming \\ to /
            if (SystemUtils.IS_OS_WINDOWS) {
                realPath = StringUtils.replace(realPath, "\\", "/");
            }
            if (!realPath.endsWith(path)) {
                String errorMsg = "Failed referrer security check: Request did not come from the same server. "
                        + "Detected HTTP Referer header is '" + referrer + "'.";
                logger.error(errorMsg);
                throw new RuntimeException(errorMsg);
            } else {
                logger.debug("HTTP Referer header path found in server.");
            }
        }
    } else {
        logger.warn("HTTP Referer header is null.");
    }
}