List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:com.kurento.test.selenium.BaseSeleniumTst.java
private void setup(Class<? extends WebDriver> driverClass) { if (driverClass.equals(FirefoxDriver.class)) { driver = new FirefoxDriver(); } else if (driverClass.equals(ChromeDriver.class)) { String chromedriver = null; if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) { chromedriver = "chromedriver"; } else if (SystemUtils.IS_OS_WINDOWS) { chromedriver = "chromedriver.exe"; }//from w w w . jav a 2s . c om System.setProperty("webdriver.chrome.driver", new File("target/webdriver/" + chromedriver).getAbsolutePath()); ChromeOptions options = new ChromeOptions(); driver = new ChromeDriver(options); } }
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 . j a va 2s . c o m return filepath; } return pathEscapedSpaces.toString(); }
From source file:info.magnolia.cms.taglibs.util.TextToImageTag.java
/** * Initialize settings//from ww w. j av a 2 s . c o m */ public void setUp() { // check that all the necessary attributes are set if (this.text == null) { this.text = "Test Test Test"; } if (this.textFontFace == null) { this.textFontFace = SystemUtils.IS_OS_WINDOWS ? "Arial" : "Helvetica"; } if (this.textFontSize == 0) { this.textFontSize = 12; } if (this.textFontColor == null) { this.textFontColor = "000000"; } if (this.textBackColor == null) { this.textBackColor = "ffffff"; } if (this.textSplit == null) { this.textSplit = TEXT_SPLIT_NONE; } else if (!((this.textSplit.equals(TEXT_SPLIT_WORDS)) || (this.textSplit.equals(TEXT_SPLIT_CHARACTERS)))) { this.textSplit = TEXT_SPLIT_NONE; } if (this.divCSS == null) { this.divCSS = "text-box"; } }
From source file:net.erdfelt.android.sdkfido.local.LocalAndroidPlatforms.java
public File getBin(String binname) throws FetchException { String paths[] = { "tools", "platform-tools" }; String binosname = binname;// w ww.ja va2 s .c o m if (SystemUtils.IS_OS_WINDOWS) { binosname += ".exe"; } for (String searchPath : paths) { File bindir = new File(this.homeDir, searchPath); if (!bindir.exists()) { continue; // skip, dir does not exist. } File bin = new File(bindir, binosname); if (bin.exists() && bin.isFile() && bin.canExecute()) { return bin; } } throw new FetchException("Android Binary Not Found: " + binname); }
From source file:de.sub.goobi.forms.AdministrationForm.java
/** * Correct image path./* w ww. j a v a 2 s .c o m*/ */ @SuppressWarnings("unchecked") public void ImagepfadKorrigieren() throws DAOException { Session session = Helper.getHibernateSession(); Criteria crit = session.createCriteria(Process.class); List<Process> auftraege = crit.list(); /* alle Prozesse durchlaufen */ for (Process p : auftraege) { if (serviceManager.getProcessService().getBlockedUsers(p) != null) { Helper.setFehlerMeldung("metadata locked: ", p.getTitle()); } else { if (myLogger.isDebugEnabled()) { myLogger.debug("Process: " + p.getTitle()); } Prefs myPrefs = serviceManager.getRulesetService().getPreferences(p.getRuleset()); Fileformat gdzfile; try { gdzfile = serviceManager.getProcessService().readMetadataFile(p); MetadataType mdt = UghHelper.getMetadataType(myPrefs, "pathimagefiles"); List<? extends Metadata> alleMetadaten = gdzfile.getDigitalDocument().getPhysicalDocStruct() .getAllMetadataByType(mdt); if (alleMetadaten != null && alleMetadaten.size() > 0) { Metadata md = alleMetadaten.get(0); myLogger.debug(md.getValue()); if (SystemUtils.IS_OS_WINDOWS) { md.setValue("file:/" + serviceManager.getProcessService().getImagesDirectory(p) + p.getTitle().trim() + DIRECTORY_SUFFIX); } else { md.setValue("file://" + serviceManager.getProcessService().getImagesDirectory(p) + p.getTitle().trim() + DIRECTORY_SUFFIX); } serviceManager.getProcessService().writeMetadataFile(gdzfile, p); Helper.setMeldung(null, "", "Image path set: " + p.getTitle() + ": ./" + p.getTitle() + DIRECTORY_SUFFIX); } else { Helper.setMeldung(null, "", "No Image path available: " + p.getTitle()); } } catch (ReadException e) { Helper.setFehlerMeldung("", "ReadException: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("ReadException: " + p.getTitle(), e); } catch (IOException e) { Helper.setFehlerMeldung("", "IOException: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("IOException: " + p.getTitle(), e); } catch (InterruptedException e) { Helper.setFehlerMeldung("", "InterruptedException: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("InterruptedException: " + p.getTitle(), e); } catch (PreferencesException e) { Helper.setFehlerMeldung("", "PreferencesException: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("PreferencesException: " + p.getTitle(), e); } catch (UghHelperException e) { Helper.setFehlerMeldung("", "UghHelperException: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("UghHelperException: " + p.getTitle(), e); } catch (Exception e) { Helper.setFehlerMeldung("", "Exception: " + p.getTitle() + " - " + e.getMessage()); myLogger.error("Exception: " + p.getTitle(), e); } } } Helper.setMeldung(null, "", "------------------------------------------------------------------"); Helper.setMeldung(null, "", "Image paths set"); }
From source file:com.asakusafw.runtime.util.hadoop.ConfigurationProviderTest.java
/** * search for confdir from PATH using symlink. * @throws IOException IOException/*w w w .j a va2 s. co m*/ */ @Test public void symlink() throws IOException { Assume.assumeThat(SystemUtils.IS_OS_WINDOWS, is(false)); File cmd = putExec("hadoop/bin/hadoop"); putConf("hadoop/etc/hadoop/core-site.xml"); File path = folder.newFolder("path"); try { Process proc = new ProcessBuilder("ln", "-s", cmd.getAbsolutePath(), new File(path, "hadoop").getAbsolutePath()).start(); try { int exitCode = proc.waitFor(); Assume.assumeThat(exitCode, is(0)); } finally { proc.destroy(); } } catch (Exception e) { System.out.println("Failed to create symlink"); e.printStackTrace(System.out); Assume.assumeNoException(e); } Map<String, String> envp = new HashMap<>(); envp.put("PATH", path.getAbsolutePath()); Configuration conf = new ConfigurationProvider(envp).newInstance(); assertThat(isLoaded(conf), is(true)); File file = ConfigurationProvider.findHadoopCommand(envp); assertThat(file, is(notNullValue())); assertThat(file.toString(), file.canExecute(), is(true)); assertThat(file.toString(), file.getParentFile().getName(), is("path")); }
From source file:gmgen.util.MiscUtilities.java
/** * Constructs an absolute path name from a directory and another path name. * This method is VFS-aware.//from w ww .ja v a2s . c o m * *@param parent The directory *@param path The path name *@return the absolute path name *@since GMGen 3.3 */ // TODO There is probably a maintained method that does that in one of the Apache Commons libraries. public static String constructPath(String parent, String path) { if (isAbsolutePath(path)) { return canonPath(path); } // have to handle this case specially on windows. // insert \ between, eg A: and myfile.txt. if (SystemUtils.IS_OS_WINDOWS) { if ((path.length() == 2) && (path.charAt(1) == ':')) { return path; } else if ((path.length() > 2) && (path.charAt(1) == ':') && (path.charAt(2) != '\\')) { return canonPath(path.substring(0, 2) + '\\' + path.substring(2)); } } String dd = ".." + File.separator; String d = "." + File.separator; String returnParent = (parent == null) ? Globals.getDefaultPath() : parent; String returnPath = path; //DJ: This sucks, this also needs to be fixed for (;;) { if (returnPath.equals(".")) { return returnParent; } else if (returnPath.equals("..")) { return getParentOfPath(returnParent); } else if (returnPath.startsWith(dd) || returnPath.startsWith("../")) { returnParent = getParentOfPath(returnParent); returnPath = returnPath.substring(3); } else if (returnPath.startsWith(d)) { returnPath = returnPath.substring(2); } else { break; } } if (SystemUtils.IS_OS_MAC && returnPath.startsWith("\\")) { returnParent = returnParent.substring(0, 2); } if (!returnPath.endsWith("\\") && !returnPath.endsWith("/")) { returnParent += File.separator; } return returnParent + returnPath; }
From source file:com.amazonaws.services.kinesis.producer.Daemon.java
private void createPipes() throws IOException { if (SystemUtils.IS_OS_WINDOWS) { createPipesWindows();//from ww w .j ava 2 s.c o m } else { createPipesUnix(); } inPipe.deleteOnExit(); outPipe.deleteOnExit(); }
From source file:de.sub.goobi.persistence.apache.FolderInformation.java
/** * Get folder for process.//from w ww . j a v a 2 s. c o m * * @param useFallBack * boolean * @return Map of paths */ public Map<String, String> getFolderForProcess(boolean useFallBack) { Map<String, String> answer = new HashMap<String, String>(); String processpath = getProcessDataDirectory().replace("\\", "/"); String tifpath = getImagesTifDirectory(useFallBack).replace("\\", "/"); String imagepath = getImagesDirectory().replace("\\", "/"); String origpath = getImagesOrigDirectory(useFallBack).replace("\\", "/"); String metaFile = getMetadataFilePath().replace("\\", "/"); String ocrBasisPath = getOcrDirectory().replace("\\", "/"); String ocrPlaintextPath = getTxtDirectory().replace("\\", "/"); String sourcepath = getSourceDirectory().replace("\\", "/"); String importpath = getImportDirectory().replace("\\", "/"); if (tifpath.endsWith(File.separator)) { tifpath = tifpath.substring(0, tifpath.length() - File.separator.length()).replace("\\", "/"); } if (imagepath.endsWith(File.separator)) { imagepath = imagepath.substring(0, imagepath.length() - File.separator.length()).replace("\\", "/"); } if (origpath.endsWith(File.separator)) { origpath = origpath.substring(0, origpath.length() - File.separator.length()).replace("\\", "/"); } if (processpath.endsWith(File.separator)) { processpath = processpath.substring(0, processpath.length() - File.separator.length()).replace("\\", "/"); } if (sourcepath.endsWith(File.separator)) { sourcepath = sourcepath.substring(0, sourcepath.length() - File.separator.length()).replace("\\", "/"); } if (ocrBasisPath.endsWith(File.separator)) { ocrBasisPath = ocrBasisPath.substring(0, ocrBasisPath.length() - File.separator.length()).replace("\\", "/"); } if (ocrPlaintextPath.endsWith(File.separator)) { ocrPlaintextPath = ocrPlaintextPath.substring(0, ocrPlaintextPath.length() - File.separator.length()) .replace("\\", "/"); } if (SystemUtils.IS_OS_WINDOWS) { answer.put("(tifurl)", "file:/" + tifpath); } else { answer.put("(tifurl)", "file://" + tifpath); } if (SystemUtils.IS_OS_WINDOWS) { answer.put("(origurl)", "file:/" + origpath); } else { answer.put("(origurl)", "file://" + origpath); } if (SystemUtils.IS_OS_WINDOWS) { answer.put("(imageurl)", "file:/" + imagepath); } else { answer.put("(imageurl)", "file://" + imagepath); } answer.put("(tifpath)", tifpath); answer.put("(origpath)", origpath); answer.put("(imagepath)", imagepath); answer.put("(processpath)", processpath); answer.put("(sourcepath)", sourcepath); answer.put("(importpath)", importpath); answer.put("(ocrbasispath)", ocrBasisPath); answer.put("(ocrplaintextpath)", ocrPlaintextPath); answer.put("(metaFile)", metaFile); return answer; }
From source file:de.interactive_instruments.ShapeChange.UI.DefaultDialog.java
public void actionPerformed(ActionEvent e) { if (startButton == e.getSource()) { mdl = mdlField.getText().trim(); startButton.setEnabled(false);/*www . jav a2s. co m*/ exitButton.setEnabled(false); try { options.setParameter("inputFile", mdl); if (mdl.toLowerCase().endsWith(".xmi") || mdl.toLowerCase().endsWith(".xml")) options.setParameter("inputModelType", "XMI10"); else if (mdl.toLowerCase().endsWith(".eap")) options.setParameter("inputModelType", "EA7"); else if (mdl.toLowerCase().endsWith(".mdb")) options.setParameter("inputModelType", "GSIP"); options.setParameter("outputDirectory", outField.getText()); options.setParameter("logFile", outField.getText() + "/log.xml"); options.setParameter("appSchemaName", asField.getText()); options.setParameter("reportLevel", reportGroup.getSelection().getActionCommand()); options.setParameter(Options.TargetXmlSchemaClass, "defaultEncodingRule", ruleGroup.getSelection().getActionCommand()); if (docCB.isSelected()) options.setParameter(Options.TargetXmlSchemaClass, "includeDocumentation", "true"); else options.setParameter(Options.TargetXmlSchemaClass, "includeDocumentation", "false"); if (!visCB.isSelected()) options.setParameter("publicOnly", "true"); else options.setParameter("publicOnly", "false"); converter.convert(); } catch (ShapeChangeAbortException ex) { Toolkit.getDefaultToolkit().beep(); } logfile = new File(options.parameter("logFile").replace(".xml", ".html")); if (logfile != null && logfile.canRead()) logButton.setEnabled(true); else { logfile = new File(options.parameter("logFile")); if (logfile != null && logfile.canRead()) logButton.setEnabled(true); } exitButton.setEnabled(true); } else if (e.getSource() == logButton) { try { if (Desktop.isDesktopSupported()) Desktop.getDesktop().open(logfile); else if (SystemUtils.IS_OS_WINDOWS) Runtime.getRuntime().exec("cmd /c start " + logfile.getPath()); else Runtime.getRuntime().exec("open " + logfile.getPath()); } catch (IOException e1) { e1.printStackTrace(); System.exit(1); } } else if (e.getSource() == exitButton) { System.exit(0); } else if (e.getSource() == mdlButton) { int returnVal = fc.showOpenDialog(DefaultDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); mdlField.setText(file.getAbsolutePath()); } } else if (e.getSource() == cfgButton) { int returnVal = fc.showOpenDialog(DefaultDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); cfgField.setText(file.getAbsolutePath()); } } else if (e.getSource() == outButton) { fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(DefaultDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); outField.setText(file.getAbsolutePath()); } } }