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

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

Introduction

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

Prototype

boolean IS_OS_UNIX

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

Click Source Link

Document

Is true if this is a POSIX compilant system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.

The field will return false if OS_NAME is null.

Usage

From source file:eu.qualimaster.adaptation.platform.ToolBase.java

/**
 * Returns the configuration file, possibly considering OS-specific default file locations.
 * //from   ww  w .  j  ava 2 s.  c o m
 * @param fileName the file name
 * @return the related file object
 */
static File obtainConfigurationFile(String fileName) {
    File result = null;
    if (SystemUtils.IS_OS_UNIX) {
        File tmp = new File("/etc/qualiMaster", fileName);
        if (isReadable(tmp)) {
            result = tmp;
        } else {
            tmp = relocate(fileName);
            if (isReadable(tmp)) {
                result = tmp;
            }
        }
    }
    if (null == result) {
        // use local directory instead (interactive mode)
        result = new File(fileName);
    }
    return result;
}

From source file:com.consol.citrus.admin.launcher.ProcessLauncherTest.java

private ProcessBuilder getSleepProcessBuilder(int sleepInSeconds) throws InterruptedException {
    String command;//from   w w  w  .  j a  va 2 s .  com
    if (SystemUtils.IS_OS_UNIX) {
        command = String.format("ping -c %s 127.0.0.1", sleepInSeconds);
    } else {
        command = String.format("ping -n %s 127.0.0.1", sleepInSeconds);
    }
    return new ExecuteCommand(command, new File(System.getProperty("user.dir"))).getProcessBuilder();
}

From source file:com.consol.citrus.admin.process.ProcessLauncherTest.java

private ProcessBuilder getSleepProcessBuilder(int sleepInSeconds) throws InterruptedException {
    String command;/*from  ww  w.j  a  v  a 2  s .c  o  m*/
    if (SystemUtils.IS_OS_UNIX) {
        command = String.format("ping -c %s 127.0.0.1", sleepInSeconds);
    } else {
        command = String.format("ping -n %s 127.0.0.1", sleepInSeconds);
    }
    return new AbstractExecuteCommand(new File(System.getProperty("user.dir"))) {
        public String buildCommand() {
            return command;
        }
    }.getProcessBuilder();
}

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

private void enableExitKey() {
    InputMap rootInput = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap rootAction = getRootPane().getActionMap();

    if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_WINDOWS) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK), "exit");
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK), "exit");
    }/*from w  ww .  j a v  a2  s . co m*/

    if (SystemUtils.IS_OS_MAC) {
        rootInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.META_DOWN_MASK), "exit");
    }

    rootAction.put("exit", new KeyAction(actionMapper, "exit"));
}

From source file:com.evolveum.midpoint.repo.common.commandline.CommandLineScriptExecutor.java

public String getOsSpecificFilePath(String filepath) {
    StringBuilder pathEscapedSpaces = new StringBuilder();
    if (SystemUtils.IS_OS_UNIX) {
        pathEscapedSpaces.append("'").append(filepath).append("'");
    } else if (SystemUtils.IS_OS_WINDOWS) {
        filepath = filepath.replace("/", "\\");
        pathEscapedSpaces.append(QUOTATION_MARK).append(filepath).append(QUOTATION_MARK);
    } else {/*w w  w .  java  2 s .co m*/
        return filepath;
    }
    return pathEscapedSpaces.toString();
}

From source file:configuration.Config.java

/**
 * This set the default configuration properties
 *///from  ww w  .j a v a 2s. co m
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: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   www  . j  a v  a  2 s.  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:de.uni_hildesheim.sse.easy_producer.instantiator.model.buildlangModel.BuildlangExecution.java

/**
 * Processes the {@link LoadProperties}.
 * //from ww  w.j ava2  s. com
 * @param script the script to process the properties for
 * @param base the base path to make relative paths absolute
 * @throws VilLanguageException in case that something goes wrong
 */
private void processProperties(Script script, File base) throws VilLanguageException {
    Properties loaded = new Properties();
    for (int p = 0; p < script.getPropertiesCount(); p++) {
        LoadProperties prop = script.getProperties(p);
        String path = prop.getPath();
        try {
            path = StringReplacer.substitute(path, environment, getExpressionParser(), this);
        } catch (ExpressionException e) {
            throw new VilLanguageException(e);
        }
        File file = absolute(path, base);
        loadProperties(file, loaded, null);
        if (SystemUtils.IS_OS_MAC) {
            loadProperties(file, loaded, "macos");
        } else if (SystemUtils.IS_OS_UNIX) {
            loadProperties(file, loaded, "unix");
        } else if (SystemUtils.IS_OS_WINDOWS) {
            loadProperties(file, loaded, "win");
        }
    }
    for (int v = 0; v < script.getVariableDeclarationCount(); v++) {
        VariableDeclaration var = script.getVariableDeclaration(v);
        String value = loaded.getProperty(var.getName(), null);
        if (null != value) {
            if (var.isConstant() && null != var.getExpression()) {
                throw new VilLanguageException("constant '" + var.getName() + "' is already assigned a value",
                        VilLanguageException.ID_IS_CONSTANT);
            }
            Object actValue = evaluateExternalValue(var, value);
            environment.setValue(var, actValue);
            tracer.valueDefined(var, actValue);
        }
    }
}

From source file:com.buaa.cfs.utils.StringUtils.java

static void startupShutdownMessage(Class<?> clazz, String[] args, final LogAdapter LOG) {
    final String hostname = NetUtils.getHostname();
    final String classname = clazz.getSimpleName();
    LOG.info(toStartupShutdownString("STARTUP_MSG: ",
            new String[] { "Starting " + classname, "  host = " + hostname, "  args = " + Arrays.asList(args),
                    "  version = " + VersionInfo.getVersion(),
                    "  classpath = " + System.getProperty("java.class.path"),
                    "  build = " + VersionInfo.getUrl() + " -r " + VersionInfo.getRevision() + "; compiled by '"
                            + VersionInfo.getUser() + "' on " + VersionInfo.getDate(),
                    "  java = " + System.getProperty("java.version") }));

    if (SystemUtils.IS_OS_UNIX) {
        try {//  w ww.  ja va2s.  c o  m
            SignalLogger.INSTANCE.register(LOG);
        } catch (Throwable t) {
            LOG.warn("failed to register any UNIX signal loggers: ", t);
        }
    }
    ShutdownHookManager.get().addShutdownHook(new Runnable() {
        @Override
        public void run() {
            LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ",
                    new String[] { "Shutting down " + classname + " at " + hostname }));
        }
    }, SHUTDOWN_HOOK_PRIORITY);

}

From source file:configuration.Util.java

/**
 * Get the OS executable for docker/*from www. j  ava2s.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();
}