List of usage examples for java.io File isAbsolute
public boolean isAbsolute()
From source file:com.npower.cp.xmlinventory.OTAInventoryImpl.java
/** * Return base directory of XML inventory. * @return//from ww w . ja v a 2 s.c o m * @throws OTAException */ private String getResourceBaseDir() throws OTAException { String resourcePath = this.properties.getProperty(OTAInventoryImpl.CP_TEMPLATE_RESOURCE_DIR); if (StringUtils.isNotEmpty(resourcePath)) { File resourceDir = new File(resourcePath); if (!resourceDir.isAbsolute()) { resourceDir = new File(System.getProperty("otas.dm.home"), resourcePath); } resourcePath = resourceDir.getAbsolutePath(); } if (StringUtils.isEmpty(resourcePath)) { throw new OTAException( "CP Template Path must be specified in property: " + OTAInventoryImpl.CP_TEMPLATE_RESOURCE_DIR); } return resourcePath; }
From source file:com.googlecode.psiprobe.Tomcat55ContainerAdaptor.java
public File getAppBase() { File base = new File(host.getAppBase()); if (!base.isAbsolute()) { base = new File(System.getProperty("catalina.base"), host.getAppBase()); }//from w ww . j a v a 2 s.c om return base; }
From source file:org.commonjava.sshwrap.config.DefaultSSHConfiguration.java
private File toFile(final String path) { if (path.startsWith("~/")) { return new File(userHome(), path.substring(2)); }/* w w w . j a v a 2 s. com*/ final File ret = new File(path); if (ret.isAbsolute()) { return ret; } return new File(userHome(), path); }
From source file:org.apache.axis2.deployment.RepositoryListener.java
private void loadOtherDirectories() { for (Map.Entry<String, Map<String, Deployer>> entry : deploymentEngine.getDeployers().entrySet()) { String directory = entry.getKey(); Map<String, Deployer> extensionMap = entry.getValue(); for (String extension : extensionMap.keySet()) { File dirToSearch = new File(directory); if (!dirToSearch.isAbsolute()) { dirToSearch = new File(deploymentEngine.getRepositoryDir(), directory); }/*from w w w . j a va 2s . c o m*/ findFileForGivenDirectory(dirToSearch, extension, directory); } } }
From source file:com.eviware.loadui.groovy.GroovyBehaviorProvider.java
public GroovyBehaviorProvider(ComponentRegistry registry, ScheduledExecutorService scheduler, File scriptDir, ClassLoaderRegistry clr) {//from w w w . java 2 s . co m if (!scriptDir.isAbsolute()) { scriptDir = LoadUI.relativeFile(scriptDir.getPath()); } this.scriptDir = scriptDir; this.registry = registry; this.clr = clr; File groovyRoot = new File(System.getProperty("groovy.root")); if (!groovyRoot.isDirectory()) if (!groovyRoot.mkdirs()) throw new RuntimeException( "Unable to create required directories: " + groovyRoot.getAbsolutePath()); File grapeConfig = new File(groovyRoot, "grapeConfig.xml"); if (!grapeConfig.exists()) { try { Files.copy(new InputSupplier<InputStream>() { @Override public InputStream getInput() throws IOException { return getClass().getResourceAsStream("/grapeConfig.xml"); } }, grapeConfig); } catch (IOException e) { e.printStackTrace(); } } // registry.registerDescriptor( emptyDescriptor, this ); registry.registerType(TYPE, this); future = scheduler.scheduleWithFixedDelay(new DirWatcher(), 0, UPDATE_FREQUENCY, TimeUnit.SECONDS); }
From source file:org.apache.hyracks.maven.license.GenerateFileMojo.java
private String resolveLicenseContent(LicenseSpec license, boolean bestEffort) throws IOException { if (license.getContent() == null) { getLog().debug("Resolving content for " + license.getUrl() + " (" + license.getContentFile() + ")"); File cFile = new File(license.getContentFile()); if (!cFile.isAbsolute()) { cFile = new File(licenseDirectory, license.getContentFile()); }// ww w . j av a 2s .co m if (!cFile.exists()) { if (!bestEffort) { getLog().warn("MISSING: license content file (" + cFile + ") for url: " + license.getUrl()); license.setContent("MISSING: " + license.getContentFile() + " (" + license.getUrl() + ")"); } } else { getLog().info("Reading license content from file: " + cFile); StringWriter sw = new StringWriter(); LicenseUtil.readAndTrim(sw, cFile); license.setContent(sw.toString()); } } return license.getContent(); }
From source file:org.eclipse.jubula.autagent.commands.AbstractStartJavaAut.java
/** * // ww w . j a va 2s .co m * @param parameters The parameters for starting the AUT. * @return the absolute path to the AUT jar file or null. */ protected String createAbsoluteJarPath(Map parameters) { File workingDir = getWorkingDir(parameters); String jarPath = (String) parameters.get(AutConfigConstants.JAR_FILE); if (jarPath != null && jarPath.length() > 0) { if (workingDir != null) { File jarFile = new File(jarPath); if (!jarFile.isAbsolute()) { jarPath = workingDir + FILE_SEPARATOR + jarPath; } } } return jarPath; }
From source file:org.apache.jk.common.ChannelUn.java
public void init() throws IOException { if (file == null) { log.debug("No file, disabling unix channel"); return;//from w ww . j a v a 2s . co m //throw new IOException( "No file for the unix socket channel"); } if (wEnv != null && wEnv.getLocalId() != 0) { localId = wEnv.getLocalId(); } if (localId != 0) { file = file + localId; } File socketFile = new File(file); if (!socketFile.isAbsolute()) { String home = wEnv.getJkHome(); if (home == null) { log.debug("No jkhome"); } else { File homef = new File(home); socketFile = new File(homef, file); log.debug("Making the file absolute " + socketFile); } } if (!socketFile.exists()) { try { FileOutputStream fos = new FileOutputStream(socketFile); fos.write(1); fos.close(); } catch (Throwable t) { log.error("Attempting to create the file failed, disabling channel" + socketFile); return; } } // The socket file cannot be removed ... if (!socketFile.delete()) { log.error("Can't remove socket file " + socketFile); return; } super.initNative("channel.un:" + file); if (apr == null || !apr.isLoaded()) { log.debug("Apr is not available, disabling unix channel "); apr = null; return; } // Set properties and call init. setNativeAttribute("file", file); // unixListenSocket=apr.unSocketListen( file, 10 ); setNativeAttribute("listen", "10"); // setNativeAttribute( "debug", "10" ); // Initialize the thread pool and execution chain if (next == null && wEnv != null) { if (nextName != null) setNext(wEnv.getHandler(nextName)); if (next == null) next = wEnv.getHandler("dispatch"); if (next == null) next = wEnv.getHandler("request"); } tp = new ThreadPool(); super.initJkComponent(); log.info("JK: listening on unix socket: " + file); // Run a thread that will accept connections. tp.start(); AprAcceptor acceptAjp = new AprAcceptor(this); tp.runIt(acceptAjp); }
From source file:de.jflex.plugin.maven.JFlexMojo.java
private void parseLexFile(File lexFile) throws MojoFailureException, MojoExecutionException { assert lexFile.isAbsolute() : lexFile; getLog().debug("Generating Java code from " + lexFile.getName()); ClassInfo classInfo;/*from w w w . j av a2 s . c o m*/ try { classInfo = LexSimpleAnalyzer.guessPackageAndClass(lexFile); } catch (FileNotFoundException e) { throw new MojoFailureException(e.getMessage(), e); } catch (IOException e) { classInfo = new ClassInfo(); classInfo.className = LexSimpleAnalyzer.DEFAULT_NAME; classInfo.packageName = null; // NOPMD } checkParameters(lexFile); /* set destination directory */ File generatedFile = new File(outputDirectory, classInfo.getOutputFilename()); /* Generate only if needs to */ if (lexFile.lastModified() - generatedFile.lastModified() <= this.staleMillis) { getLog().info(" " + generatedFile.getName() + " is up to date."); getLog().debug("StaleMillis = " + staleMillis + "ms"); return; } /* * set options. Very strange that JFlex expects this in a static way. */ Options.setDefaults(); Options.setDir(generatedFile.getParentFile()); Options.dump = dump; Options.verbose = verbose; Options.unused_warning = unusedWarning; Options.dot = dot; Options.legacy_dot = legacyDot; Options.emitInputStreamCtor = inputStreamCtor; if (skeleton != null) { Options.setSkeleton(skeleton); } Options.jlex = jlex; Options.no_minimize = !minimize; // NOPMD Options.no_backup = !backup; // NOPMD if ("pack".equals(generationMethod)) { /* no-op - there is only one generation method */ } else { throw new MojoExecutionException("Illegal generation method: " + generationMethod); } try { Main.generate(lexFile); getLog().info(" generated " + generatedFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:ezbake.common.properties.EzProperties.java
/** * Get a property as a path, if this doesn't exist throw an IOException * * @param propertyName is the name of the property we are looking for (the key) * @param defaultValue the value to return if the key doesn't exist * * @return the proper path or null if we can't find the directory *///from www. j a va 2s . co m public String getPath(String propertyName, String defaultValue) { String path = getProperty(propertyName); if (path == null) { return defaultValue; } if (!OpenShiftUtil.inOpenShiftContainer()) { return path; } File file = new File(path); if (file.isAbsolute()) { return path; } /* * OpenShift cartridges like JBoss don't play nice with relative paths to match thrift runner we assume that we * are using relative paths. */ return OpenShiftUtil.getRepoDir() + File.separator + path; }