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

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

Introduction

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

Prototype

boolean IS_OS_MAC_OSX

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

Click Source Link

Document

Is true if this is Mac.

The field will return false if OS_NAME is null.

Usage

From source file:com.asakusafw.testdriver.inprocess.InProcessJobExecutorTest.java

/**
 * Test method for executing non-emulated command.
 *//*from   w ww . j av  a  2 s .  co  m*/
@Test
public void executeCommand_delegate() {
    Assume.assumeTrue("not unix-like", SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_LINUX);

    File touch = new File("/usr/bin/touch");
    Assume.assumeTrue("no 'touch' command", touch.isFile() && touch.canExecute());

    AtomicBoolean call = new AtomicBoolean();
    MockCommandEmulator.callback(args -> call.set(true));
    File target = new File(framework.getWork("working"), "target");
    Assume.assumeFalse(target.exists());

    // exec: touch .../target
    TestExecutionPlan.Command command = command("generic", touch.getPath(), target.getAbsolutePath());
    JobExecutor executor = new InProcessJobExecutor(context);
    try {
        executor.execute(command, Collections.emptyMap());
    } catch (IOException e) {
        throw new AssertionError(e);
    }
    assertThat(target.exists(), is(true));
    assertThat(call.get(), is(false));
}

From source file:configuration.Config.java

/**
 * This set the default configuration properties
 *///from  w  w w  . j  a v  a2  s. com
public void setDefaultProperties() {
    //--Ask to set Email and other helpfull
    //--Path
    set("Name", "Configuration file (config.dat)");
    set("currentPath", currentPath);
    //==
    //==Note:
    //==This databasePath represent the default project filename
    set("databasePath", currentPath + File.separator + "projects" + File.separator + "New_Untitled.db");
    set("propertiesPath", currentPath + File.separator + "data" + File.separator + "properties"); // Reflect armadillo properties path
    set("classPath",
            currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "programs"); //Running program class
    set("editorPath",
            currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "editors"); //editor class
    set("dataPath", currentPath + File.separator + "data");
    set("ExecutableDir", currentPath + File.separator + "Executable");
    set("tmpDir", currentPath + File.separator + "tmp");
    set("temporaryDir", currentPath + File.separator + "tmp" + File.separator + "temporary");
    set("resultsDir", currentPath + File.separator + "results");
    set("testDir", currentPath + File.separator + "test");
    set("iconsPath", currentPath + File.separator + "data" + File.separator + "icons");
    set("projectsDir", currentPath + File.separator + "projects"); // Projects Directory
    set("hgncDataPath", dataPath() + File.separator + "hgnc.txt"); //default hgnc database...
    set("hgncWebDownload",
            "http://www.genenames.org/cgi-bin/hgnc_downloads.cgi?title=HGNC+output+data&hgnc_dbtag=on&preset=all&status=Approved&status=Entry+Withdrawn&status_opt=2&level=pri&=on&where=&order_by=gd_app_sym_sort&limit=&format=text&submit=submit&.cgifields=&.cgifields=level&.cgifields=chr&.cgifields=status&.cgifields=hgnc_dbtag");
    set("log", currentPath + File.separator + "armadillo.log");

    //--Try to create the tempDir (temporary file directory) if doesn't exists
    Util.CreateDir(get("tmpDir"));
    Util.CreateDir(get("resultsDir"));
    Util.CreateDir(get("projectsDir"));
    try {
        if (Util.FileExists(dataPath("New_Untitled_default.db"))) {
            Util.copy(dataPath("New_Untitled_default.db"),
                    this.projectsDir() + File.separator + "New_Untitled.db");
        } else {
            log("Unable to find the default project file...");
        }
    } catch (Exception e) {
    }

    Util.CreateDir(get("temporaryDir"));

    //--Version and Other
    set("authorArmadillo",
            "Etienne Lord, Mickael Leclercq, Alix Boc,  Abdoulaye Banir Diallo, Vladimir Makarenkov");
    set("version", "2.0");
    set("applicationName", "Armadillo Workflow Platform");
    set("webpageArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/"); //--Armadillo default webpage
    set("webserverArmadillo", "http://trex.uqam.ca/armadillo/"); //--Armadillo webserver
    set("helpArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/wiki/index.php/Main_Page"); //--Armadillo default help page
    set("getting_startedArmadillo",
            dataPath() + File.separator + "Documents" + File.separator + "getting_started.html"); //--Getting started page shown at start up
    set("splashIconPath", currentPath + File.separator + "data" + File.separator + "splash1.png");
    set("smallIconPath", currentPath + File.separator + "data" + File.separator + "armadillo.png");
    set("imagePath", currentPath + File.separator + "data" + File.separator + "images");
    set("imageNcbiLoading", currentPath + File.separator + "data" + File.separator + "LoadingNcbi.jpg");
    set("imageEnsemblLoading", currentPath + File.separator + "data" + File.separator + "LoadingEnsembl.jpg");
    set("imageSequenceLoading", currentPath + File.separator + "data" + File.separator + "LoadingSequence.jpg");

    //--Editor version and name
    set("editorApplicationName", "Armadillo Editor");
    set("editorVersion", "0.1");
    set("editorAuthor", "Etienne Lord, Mickael Leclercq");
    set("workflow_w", 2000); //Initial workflow size
    set("workflow_h", 600);
    set("font_size_adjuster", 0); //--Increase of decrease workflow font size;
    set("FirstTime", 1);

    //--Special (Tree Editor, etc...)
    set("LoadPhyloWidget", false);
    //--By default, display the Start page
    set("DisplayStartPage", true);

    //--Programs
    currentPath = new File("").getAbsolutePath();

    //Databases used
    set("HGNCData", currentPath + File.separator + "data" + File.separator + "hgnc.txt");
    set("Tooltip", currentPath + File.separator + "data" + File.separator + "tooltips.csv");
    //set("iso",currentPath+"//data//iso.txt");
    set("EnsemblDb", currentPath + File.separator + "data" + File.separator + "EnsemblDB.tsv");
    //Others
    set("defaultSplashPath",
            currentPath + File.separator + "data" + File.separator + "splash" + File.separator);

    set("urlToModelTest", "http://www.hiv.lanl.gov/content/sequence/findmodel/findmodel.html");
    set("download_genbank", false);
    set("debugEditor", false);

    //--System environment specific options
    if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC) {
        set("MacOSX", true);
        set("font_size_adjuster", -1);
    } else if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) {
        set("Linux", true);
    } else if (SystemUtils.IS_OS_WINDOWS) {
        set("Windows", true);
    }
    Save();
}

From source file:dmh.kuebiko.view.NoteStackFrame.java

private void toggleUnsavedChangeIndicator(boolean unsavedChanges) {
    if (SystemUtils.IS_OS_MAC_OSX) {
        // Toggle the Mac OS X window-modified indicator.
        getRootPane().putClientProperty("Window.documentModified", unsavedChanges);
    } else {/*w ww .j a va 2s  . c  o  m*/
        if (unsavedChanges) {
            setTitle("* " + buildTitle());
        } else {
            setTitle(buildTitle());
        }
    }
}

From source file:com.houghtonassociates.bamboo.plugins.GerritRepositoryAdapter.java

public synchronized File prepareSSHKeyFile(String strRelativePath, String sshKey) {
    String filePath = getBaseBuildWorkingDirectory() + File.separator + strRelativePath;

    File f = new File(filePath);

    f.setReadable(true, true);//from w  ww  .ja  v a2s  . c o  m
    f.setWritable(true, true);
    f.setExecutable(false, false);

    try {
        FileUtils.writeStringToFile(f, sshKey);
    } catch (IOException e) {
        log.error(e.getMessage());
        return null;
    }

    try {
        if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX)
            Runtime.getRuntime().exec("chmod 700 " + filePath);
    } catch (IOException e) {
        log.warn(e.getMessage());
    }

    return f;
}

From source file:com.amazonaws.services.kinesis.producer.KinesisProducer.java

private void extractBinaries() {
    synchronized (EXTRACT_BIN_MUTEX) {
        final List<File> watchFiles = new ArrayList<>(2);
        String os = SystemUtils.OS_NAME;
        if (SystemUtils.IS_OS_WINDOWS) {
            os = "windows";
        } else if (SystemUtils.IS_OS_LINUX) {
            os = "linux";
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            os = "osx";
        } else {//  w w  w  . jav a2  s  . c  o  m
            throw new RuntimeException("Your operation system is not supported (" + os
                    + "), the KPL only supports Linux, OSX and Windows");
        }

        String root = "amazon-kinesis-producer-native-binaries";
        String tmpDir = config.getTempDirectory();
        if (tmpDir.trim().length() == 0) {
            tmpDir = System.getProperty("java.io.tmpdir");
        }
        tmpDir = Paths.get(tmpDir, root).toString();
        pathToTmpDir = tmpDir;

        String binPath = config.getNativeExecutable();
        if (binPath != null && !binPath.trim().isEmpty()) {
            pathToExecutable = binPath.trim();
            log.warn("Using non-default native binary at " + pathToExecutable);
            pathToLibDir = "";
        } else {
            log.info("Extracting binaries to " + tmpDir);
            try {
                File tmpDirFile = new File(tmpDir);
                if (!tmpDirFile.exists() && !tmpDirFile.mkdirs()) {
                    throw new IOException("Could not create tmp dir " + tmpDir);
                }

                String extension = os.equals("windows") ? ".exe" : "";
                String executableName = "kinesis_producer" + extension;
                byte[] bin = IOUtils.toByteArray(this.getClass().getClassLoader()
                        .getResourceAsStream(root + "/" + os + "/" + executableName));
                MessageDigest md = MessageDigest.getInstance("SHA1");
                String mdHex = DatatypeConverter.printHexBinary(md.digest(bin)).toLowerCase();

                pathToExecutable = Paths.get(pathToTmpDir, "kinesis_producer_" + mdHex + extension).toString();
                File extracted = new File(pathToExecutable);
                watchFiles.add(extracted);
                if (extracted.exists()) {
                    try (FileInputStream fis = new FileInputStream(extracted);
                            FileLock lock = fis.getChannel().lock(0, Long.MAX_VALUE, true)) {
                        boolean contentEqual = false;
                        if (extracted.length() == bin.length) {
                            byte[] existingBin = IOUtils.toByteArray(new FileInputStream(extracted));
                            contentEqual = Arrays.equals(bin, existingBin);
                        }
                        if (!contentEqual) {
                            throw new SecurityException("The contents of the binary "
                                    + extracted.getAbsolutePath() + " is not what it's expected to be.");
                        }
                    }
                } else {
                    try (FileOutputStream fos = new FileOutputStream(extracted);
                            FileLock lock = fos.getChannel().lock()) {
                        IOUtils.write(bin, fos);
                    }
                    extracted.setExecutable(true);
                }

                String certFileName = "b204d74a.0";
                File certFile = new File(pathToTmpDir, certFileName);
                if (!certFile.exists()) {
                    try (FileOutputStream fos = new FileOutputStream(certFile);
                            FileLock lock = fos.getChannel().lock()) {
                        byte[] certs = IOUtils.toByteArray(this.getClass().getClassLoader()
                                .getResourceAsStream("cacerts/" + certFileName));
                        IOUtils.write(certs, fos);
                    }
                }

                watchFiles.add(certFile);
                pathToLibDir = pathToTmpDir;
                FileAgeManager.instance().registerFiles(watchFiles);
            } catch (Exception e) {
                throw new RuntimeException("Could not copy native binaries to temp directory " + tmpDir, e);
            }

        }
    }
}

From source file:configuration.Util.java

/**
 * Get the OS executable for docker//  w w  w . ja v a 2s .  co  m
 */

public static String getOSCommandLine(workflow_properties properties) {
    if (config.getBoolean("MacOSX") || SystemUtils.IS_OS_MAC_OSX) {
        return properties.getExecutableMacOSX();
    } else if (config.getBoolean("Linux") || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) {
        return properties.getExecutableLinux();
    }
    return properties.getExecutable();
}

From source file:no.java.swing.SingleSelectionFileDialog.java

public Result showOpenDialog(Component target) {
    if (SystemUtils.IS_OS_MAC_OSX) {
        return showNativeDialog(target, true);
    }/*from www .  j  av  a2  s.c o m*/
    return showJFileChooser(target, true);
}

From source file:no.java.swing.SingleSelectionFileDialog.java

public Result showSaveDialog(Component target) {
    if (SystemUtils.IS_OS_MAC_OSX) {
        return showNativeDialog(target, false);
    }/*from  www  . ja v  a2s  .  co m*/
    return showJFileChooser(target, false);
}

From source file:org.apache.maven.plugin.jar.JarSignMojo.java

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

    File exe;/*from w  ww  .jav  a2  s .c  o m*/

    // 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) {
        exe = new File(SystemUtils.getJavaHome() + "/bin", fullCommand);
    } else {
        exe = new File(SystemUtils.getJavaHome() + "/../bin", fullCommand);
    }

    return exe;
}

From source file:org.apache.maven.plugin.javadoc.AbstractJavadocMojo.java

/**
 * Get the path of the Javadoc tool executable depending the user entry or try to find it depending the OS
 * or the <code>java.home</code> system property or the <code>JAVA_HOME</code> environment variable.
 *
 * @return the path of the Javadoc tool//  w w  w  .j  a  va 2  s.c  o  m
 * @throws IOException if not found
 */
private String getJavadocExecutable() throws IOException {
    Toolchain tc = getToolchain();

    if (tc != null) {
        getLog().info("Toolchain in javadoc-plugin: " + tc);
        if (javadocExecutable != null) {
            getLog().warn(
                    "Toolchains are ignored, 'javadocExecutable' parameter is set to " + javadocExecutable);
        } else {
            javadocExecutable = tc.findTool("javadoc");
        }
    }

    String javadocCommand = "javadoc" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");

    File javadocExe;

    // ----------------------------------------------------------------------
    // The javadoc executable is defined by the user
    // ----------------------------------------------------------------------
    if (StringUtils.isNotEmpty(javadocExecutable)) {
        javadocExe = new File(javadocExecutable);

        if (javadocExe.isDirectory()) {
            javadocExe = new File(javadocExe, javadocCommand);
        }

        if (SystemUtils.IS_OS_WINDOWS && javadocExe.getName().indexOf('.') < 0) {
            javadocExe = new File(javadocExe.getPath() + ".exe");
        }

        if (!javadocExe.isFile()) {
            throw new IOException("The javadoc executable '" + javadocExe
                    + "' doesn't exist or is not a file. Verify the <javadocExecutable/> parameter.");
        }

        return javadocExe.getAbsolutePath();
    }

    // ----------------------------------------------------------------------
    // Try to find javadocExe from System.getProperty( "java.home" )
    // By default, System.getProperty( "java.home" ) = JRE_HOME and JRE_HOME
    // should be in the JDK_HOME
    // ----------------------------------------------------------------------
    // For IBM's JDK 1.2
    if (SystemUtils.IS_OS_AIX) {
        javadocExe = new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "sh",
                javadocCommand);
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        javadocExe = new File(SystemUtils.getJavaHome() + File.separator + "bin", javadocCommand);
    } else {
        javadocExe = new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "bin",
                javadocCommand);
    }

    // ----------------------------------------------------------------------
    // Try to find javadocExe from JAVA_HOME environment variable
    // ----------------------------------------------------------------------
    if (!javadocExe.exists() || !javadocExe.isFile()) {
        Properties env = CommandLineUtils.getSystemEnvVars();
        String javaHome = env.getProperty("JAVA_HOME");
        if (StringUtils.isEmpty(javaHome)) {
            throw new IOException("The environment variable JAVA_HOME is not correctly set.");
        }
        if ((!new File(javaHome).getCanonicalFile().exists())
                || (new File(javaHome).getCanonicalFile().isFile())) {
            throw new IOException("The environment variable JAVA_HOME=" + javaHome
                    + " doesn't exist or is not a valid directory.");
        }

        javadocExe = new File(javaHome + File.separator + "bin", javadocCommand);
    }

    if (!javadocExe.getCanonicalFile().exists() || !javadocExe.getCanonicalFile().isFile()) {
        throw new IOException("The javadoc executable '" + javadocExe
                + "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable.");
    }

    return javadocExe.getAbsolutePath();
}