protected static boolean isWindows() { return OS.isWindows(); }
/** * @param args the command line arguments */ public static void main(String args[]) { System.out.println("os.version = " + System.getProperty("os.version")); System.out.println("os.name = " + System.getProperty("os.name")); System.out.println("os.arch = " + System.getProperty("os.arch")); System.out.println("isUNIX() returned: " + isUNIX()); System.out.println("isWindows() returned: " + isWindows()); System.out.println("isWindowsForSure() returned: " + isWindowsForSure()); System.out.println("isSun() returned: " + isSun()); System.out.println("isLinux() returned: " + isLinux()); System.out.println("isDebianLinux() returned: " + isDebianLinux()); System.out.println("isFedoraLinux() returned: " + isFedoraLinux()); System.out.println("isGentooLinux() returned: " + isGentooLinux()); System.out.println("isKnoppixLinux() returned: " + isKnoppixLinux()); System.out.println("isMandrakeLinux() returned: " + isMandrakeLinux()); System.out.println("isMandrivaLinux() returned: " + isMandrivaLinux()); System.out.println("isRedHatLinux() returned: " + isRedHatLinux()); System.out.println("isSlackwareLinux() returned: " + isSlackwareLinux()); System.out.println("isSuSELinux() returned: " + isSuSELinux()); System.out.println("isUbuntuLinux() returned: " + isUbuntuLinux()); System.out.println("isSunX86() returned: " + isSunX86()); System.out.println("isSunSparc() returned: " + isSunSparc()); System.out.println("isDarwin() returned: " + isDarwin()); System.out.println("isSolaris10() returned: " + isSolaris10()); System.out.println("isAix() returned: " + isAix()); } }
public static final String getAdminScriptLocation(String installRoot) { final StringBuilder sb = new StringBuilder(); final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : ""; final String ASADMIN = "nadmin"; final String suffix = new StringBuilder("lib").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString(); sb.append(installRoot); final String fs = System.getProperty("file.separator"); if (!sb.toString().endsWith(fs)) sb.append(fs); sb.append(suffix); return ( sb.toString() ); }
/** * @param args the command line arguments */ public static void main(String args[]) { System.out.println("os.version = " + System.getProperty("os.version")); System.out.println("os.name = " + System.getProperty("os.name")); System.out.println("os.arch = " + System.getProperty("os.arch")); System.out.println("isUNIX() returned: " + isUNIX()); System.out.println("isWindows() returned: " + isWindows()); System.out.println("isWindowsForSure() returned: " + isWindowsForSure()); System.out.println("isSun() returned: " + isSun()); System.out.println("isLinux() returned: " + isLinux()); System.out.println("isDebianLinux() returned: " + isDebianLinux()); System.out.println("isFedoraLinux() returned: " + isFedoraLinux()); System.out.println("isGentooLinux() returned: " + isGentooLinux()); System.out.println("isKnoppixLinux() returned: " + isKnoppixLinux()); System.out.println("isMandrakeLinux() returned: " + isMandrakeLinux()); System.out.println("isMandrivaLinux() returned: " + isMandrivaLinux()); System.out.println("isRedHatLinux() returned: " + isRedHatLinux()); System.out.println("isSlackwareLinux() returned: " + isSlackwareLinux()); System.out.println("isSuSELinux() returned: " + isSuSELinux()); System.out.println("isUbuntuLinux() returned: " + isUbuntuLinux()); System.out.println("isSunX86() returned: " + isSunX86()); System.out.println("isSunSparc() returned: " + isSunSparc()); System.out.println("isDarwin() returned: " + isDarwin()); System.out.println("isSolaris10() returned: " + isSolaris10()); System.out.println("isAix() returned: " + isAix()); } }
public static final String getAdminScriptLocation(String installRoot) { final StringBuilder sb = new StringBuilder(); final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : ""; final String ASADMIN = "nadmin"; final String suffix = new StringBuilder("lib").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString(); sb.append(installRoot); final String fs = System.getProperty("file.separator"); if (!sb.toString().endsWith(fs)) sb.append(fs); sb.append(suffix); return ( sb.toString() ); }
public static final String getAsAdminScriptLocation(String installRoot) { final StringBuilder sb = new StringBuilder(); final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : ""; final String ASADMIN = "asadmin"; final String suffix = new StringBuilder("bin").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString(); sb.append(installRoot); final String fs = System.getProperty("file.separator"); if (!sb.toString().endsWith(fs)) sb.append(fs); sb.append(suffix); return ( sb.toString() ); }
public static boolean isWindowsForSure() { return isName("windows") && isWindows(); } ///////////////////////////////////////////////////////////////////////////
public static boolean isWindowsForSure() { return isName("windows") && isWindows(); } ///////////////////////////////////////////////////////////////////////////
public static boolean isWindowsForSure() { return isName("windows") && isWindows(); } ///////////////////////////////////////////////////////////////////////////
/** * Determines if the NSS support is available in this installation. The * check involves availability of the * <code> certutil </code> executable. * * @return true if certutil exists false otherwise */ public static boolean isNSSSupportAvailable() { File certUtilFile = null; if (OS.isWindows()) { certUtilFile = new File(CERTUTIL_CMD + ".exe"); } else { certUtilFile = new File(CERTUTIL_CMD); } if (certUtilFile.exists()) { return (true); } return (false); } }
/** * Given a string (typically a path), quote the string such that spaces * are protected from interpretation by a Unix or Windows command shell. * Note that this method does not handle quoting for all styles of special * characters. Just for the basic case of strings with spaces. * * @param s input string * @return a String which is quoted to protect spaces */ public static String quoteString(String s) { if (s == null) { throw new IllegalArgumentException("null string"); } if (!s.contains("\'")) { return("\'" + s + "\'"); } else if(!s.contains("\"")) { return("\"" + s + "\""); } else { // Contains a single quote and a double quote. Use backslash // On Unix. Double quotes on Windows. This method does not claim // to support this case well if at all if (OS.isWindows()) { return("\"" + s + "\""); } else { return(s.replaceAll("\040", "\134 ")); } } }
/** * Given a string (typically a path), quote the string such that spaces * are protected from interpretation by a Unix or Windows command shell. * Note that this method does not handle quoting for all styles of special * characters. Just for the basic case of strings with spaces. * * @param s input string * @return a String which is quoted to protect spaces */ public static String quoteString(String s) { if (s == null) { throw new IllegalArgumentException("null string"); } if (!s.contains("\'")) { return("\'" + s + "\'"); } else if(!s.contains("\"")) { return("\"" + s + "\""); } else { // Contains a single quote and a double quote. Use backslash // On Unix. Double quotes on Windows. This method does not claim // to support this case well if at all if (OS.isWindows()) { return("\"" + s + "\""); } else { return(s.replaceAll("\040", "\134 ")); } } }
/** * Given a string (typically a path), quote the string such that spaces * are protected from interpretation by a Unix or Windows command shell. * Note that this method does not handle quoting for all styles of special * characters. Just for the basic case of strings with spaces. * * @param s input string * @return a String which is quoted to protect spaces */ public static String quoteString(String s) { if (s == null) { throw new IllegalArgumentException("null string"); } if (!s.contains("\'")) { return("\'" + s + "\'"); } else if(!s.contains("\"")) { return("\"" + s + "\""); } else { // Contains a single quote and a double quote. Use backslash // On Unix. Double quotes on Windows. This method does not claim // to support this case well if at all if (OS.isWindows()) { return("\"" + s + "\""); } else { return(s.replaceAll("\040", "\134 ")); } } }
public static boolean safeIsRealDirectory(File f) { if (safeIsDirectory(f) == false) return false; // these 2 values while be different for symbolic links String canonical = safeGetCanonicalPath(f); String absolute = f.getAbsolutePath(); if (canonical.equals(absolute)) return true; /* Bug 4715043 -- WHOA -- Bug Obscura!! * In Windows, if you create the File object with, say, "d:/foo", then the * absolute path will be "d:\foo" and the canonical path will be "D:\foo" * and they won't match!!! **/ if (OS.isWindows() && canonical.equalsIgnoreCase(absolute)) return true; return false; }
public static boolean safeIsRealDirectory(File f) { if (safeIsDirectory(f) == false) return false; // these 2 values while be different for symbolic links String canonical = safeGetCanonicalPath(f); String absolute = f.getAbsolutePath(); if (canonical.equals(absolute)) return true; /* Bug 4715043 -- WHOA -- Bug Obscura!! * In Windows, if you create the File object with, say, "d:/foo", then the * absolute path will be "d:\foo" and the canonical path will be "D:\foo" * and they won't match!!! **/ if (OS.isWindows() && canonical.equalsIgnoreCase(absolute)) return true; return false; }
public static boolean safeIsRealDirectory(File f) { if (safeIsDirectory(f) == false) return false; // these 2 values while be different for symbolic links String canonical = safeGetCanonicalPath(f); String absolute = f.getAbsolutePath(); if (canonical.equals(absolute)) return true; /* Bug 4715043 -- WHOA -- Bug Obscura!! * In Windows, if you create the File object with, say, "d:/foo", then the * absolute path will be "d:\foo" and the canonical path will be "D:\foo" * and they won't match!!! **/ if (OS.isWindows() && canonical.equalsIgnoreCase(absolute)) return true; return false; }
if (OS.isWindows()) { validateString(propname, value, configValue, true); } else {
/** * Executes the supplied work object until the work is done or the max. * retry count is reached. * * @param work the RetriableWork implementation to be run * @return the number of retries performed; 0 indicates the work succeeded without having to retry */ private static int doWithRetry(RetriableWork work) { int retries = 0; /* *Try the work the first time. Ideally this will work. */ work.run(); /* *If the work failed and this is Windows - on which running gc may *unlock the locked file - then begin the retries. */ if (!work.workComplete() && OS.isWindows()) { _utillogger.log(FILE_OPERATION_LOG_LEVEL, "enterprise_util.perform_gc"); while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) { try { Thread.currentThread().sleep(FILE_OPERATION_SLEEP_DELAY_MS); } catch (InterruptedException ex) { } System.gc(); work.run(); } } return retries; }
/** * Executes the supplied work object until the work is done or the max. * retry count is reached. * * @param work the RetriableWork implementation to be run * @return the number of retries performed; 0 indicates the work succeeded without having to retry */ private static int doWithRetry(RetriableWork work) { int retries = 0; /* *Try the work the first time. Ideally this will work. */ work.run(); /* *If the work failed and this is Windows - on which running gc may *unlock the locked file - then begin the retries. */ if (!work.workComplete() && OS.isWindows()) { _utillogger.log(FILE_OPERATION_LOG_LEVEL, CULoggerInfo.performGC); while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) { try { Thread.sleep(FILE_OPERATION_SLEEP_DELAY_MS); } catch (InterruptedException ex) { } System.gc(); work.run(); } } return retries; }
/** * Executes the supplied work object until the work is done or the max. * retry count is reached. * * @param work the RetriableWork implementation to be run * @return the number of retries performed; 0 indicates the work succeeded without having to retry */ private static int doWithRetry(RetriableWork work) { int retries = 0; /* *Try the work the first time. Ideally this will work. */ work.run(); /* *If the work failed and this is Windows - on which running gc may *unlock the locked file - then begin the retries. */ if (!work.workComplete() && OS.isWindows()) { _utillogger.log(FILE_OPERATION_LOG_LEVEL, CULoggerInfo.performGC); while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) { try { Thread.sleep(FILE_OPERATION_SLEEP_DELAY_MS); } catch (InterruptedException ex) { } System.gc(); work.run(); } } return retries; }