Search in sources :

Example 1 with RuntimeExec

use of org.alfresco.util.exec.RuntimeExec in project alfresco-repository by Alfresco.

the class JmxDumpUtil method updateOSNameAttributeForLinux.

/**
 * Adds a Linux version
 *
 * @param osName os.name attribute
 * @return String
 */
public static String updateOSNameAttributeForLinux(String osName) {
    RuntimeExec exec = new RuntimeExec();
    Map<String, String[]> commandMap = new HashMap<String, String[]>(3, 1.0f);
    commandMap.put("Linux", new String[] { "lsb_release", "-d" });
    exec.setCommandsAndArguments(commandMap);
    ExecutionResult ret = exec.execute();
    if (ret.getSuccess()) {
        osName += " (" + ret.getStdOut().replace("\n", "") + ")";
    } else {
        commandMap.put("Linux", new String[] { "uname", "-a" });
        exec.setCommandsAndArguments(commandMap);
        ret = exec.execute();
        if (ret.getSuccess()) {
            osName += " (" + ret.getStdOut().replace("\n", "") + ")";
        } else {
            osName += " (Unknown)";
        }
    }
    return osName;
}
Also used : HashMap(java.util.HashMap) RuntimeExec(org.alfresco.util.exec.RuntimeExec) ExecutionResult(org.alfresco.util.exec.RuntimeExec.ExecutionResult)

Example 2 with RuntimeExec

use of org.alfresco.util.exec.RuntimeExec in project alfresco-repository by Alfresco.

the class RuntimeExecutableContentTransformerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    RuntimeExecutableContentTransformerWorker worker = new RuntimeExecutableContentTransformerWorker();
    // the command to execute
    RuntimeExec transformCommand = new RuntimeExec();
    Map<String, String> commandMap = new HashMap<String, String>(5);
    commandMap.put("Mac OS X", "mv -f ${source} ${target}");
    commandMap.put("Linux", "mv -f ${source} ${target}");
    commandMap.put(".*", "cmd /c copy /Y \"${source}\" \"${target}\"");
    transformCommand.setCommandMap(commandMap);
    transformCommand.setErrorCodes("1, 2");
    worker.setTransformCommand(transformCommand);
    worker.setMimetypeService(serviceRegistry.getMimetypeService());
    // set the explicit transformations
    List<ExplictTransformationDetails> explicitTranformations = new ArrayList<ExplictTransformationDetails>(1);
    explicitTranformations.add(new ExplictTransformationDetails(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_XML));
    worker.setExplicitTransformations(explicitTranformations);
    // initialise so that it doesn't score 0
    worker.afterPropertiesSet();
    TransformerDebug transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    TransformerConfig transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");
    ProxyContentTransformer transformer = new ProxyContentTransformer();
    transformer.setMimetypeService(serviceRegistry.getMimetypeService());
    transformer.setTransformerDebug(transformerDebug);
    transformer.setTransformerConfig(transformerConfig);
    transformer.setWorker(worker);
    this.transformer = transformer;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RuntimeExec(org.alfresco.util.exec.RuntimeExec)

Aggregations

HashMap (java.util.HashMap)2 RuntimeExec (org.alfresco.util.exec.RuntimeExec)2 ArrayList (java.util.ArrayList)1 ExecutionResult (org.alfresco.util.exec.RuntimeExec.ExecutionResult)1