private static File createCacheDir() throws IOException { // todo - this is not acceptable - beam-home might have no write access for current user final File cacheDir = new File(SystemUtils.getApplicationHomeDir(), "temp"); if (!cacheDir.exists() && !cacheDir.mkdir()) { throw new IOException("Failed to create directory '" + cacheDir + "'."); } return cacheDir; }
public VersionChecker() { this(new File(SystemUtils.getApplicationHomeDir(), "VERSION.txt"), SystemUtils.getApplicationRemoteVersionUrl()); }
/** * Gets a log file pattern for the given filname prefix. The pattern returned includes an absolute path the BEAM's * system log directory <code><i>$BEAM_INSTALL_DIR$</i>/log</code> and a filename created from the given log * filename prefix. This pattern is used to create <code>java.util.logging.FileHandler</code> instances. * * @param logFilenamePrefix the log filename prefix * @return a log file pattern for the given filname prefix * @see #getLogFilePattern(File, String) * @deprecated no replacement */ @Deprecated public static String getLogFilePattern(String logFilenamePrefix) { return getLogFilePattern(new File(SystemUtils.getApplicationHomeDir(), "log"), logFilenamePrefix); }
/** * Gets the application's home directory as set by the system property "${ceres.context}.home". * If not set, the method determines the home directory by retrieving the URL of this * class using the method {@link #getApplicationHomeDir(java.net.URL)}. * * @return an assumption of an application's home directory, never <code>null</code> */ public static File getApplicationHomeDir() { final String homeKey = getApplicationHomePropertyName(); final String homeValue = System.getProperty(homeKey); if (homeValue != null) { return new File(homeValue); } // Use fallback final URL url = SystemUtils.class.getResource(getClassFileName(SystemUtils.class)); return getApplicationHomeDir(url); }
private File getLastDir() { if (getParameter().getValue() instanceof File) { File file = (File) getParameter().getValue(); final File parentDir = file.getParentFile(); if (parentDir != null && parentDir.isDirectory()) { return parentDir; } } return (File) getParameter().getProperties().getPropertyValue(ParamProperties.LAST_DIR_KEY, SystemUtils.getApplicationHomeDir()); }
@Test public void testGetApplicationHomeDir() { final File applicationHomeDir = SystemUtils.getApplicationHomeDir(); assertNotNull(applicationHomeDir); assertTrue(applicationHomeDir.exists()); assertTrue(new File(applicationHomeDir, "modules").exists()); assertTrue(!applicationHomeDir.getPath().contains("modules")); assertTrue(!applicationHomeDir.getPath().contains(".jar")); }
@Test public void testApplicationProperties() { assertNotNull(SystemUtils.getApplicationContextId()); assertFalse(SystemUtils.getApplicationContextId().isEmpty()); assertNotNull(SystemUtils.getApplicationName()); assertFalse(SystemUtils.getApplicationName().isEmpty()); assertNotNull(SystemUtils.getApplicationHomepageUrl()); assertFalse(SystemUtils.getApplicationHomepageUrl().isEmpty()); assertNotNull(SystemUtils.getApplicationHomeDir()); }