Example usage for java.io File isAbsolute

List of usage examples for java.io File isAbsolute

Introduction

In this page you can find the example usage for java.io File isAbsolute.

Prototype

public boolean isAbsolute() 

Source Link

Document

Tests whether this abstract pathname is absolute.

Usage

From source file:org.geotools.gce.imagemosaic.catalog.SidecarFootprintProvider.java

private String getFullPath(String strValue) throws IOException {
    File file = new File(strValue);
    if (!file.isAbsolute()) {
        file = new File(mosaicFolder, strValue);
    }/*from   ww  w . j  a v  a 2 s .  co  m*/
    String path = file.getCanonicalPath();
    return path;
}

From source file:com.oprisnik.simpleconfig.XmlConfig.java

@Override
public String getNestedPath(String key) throws BadConfigException {
    File f = new File(getProperty(key));
    if (!f.isAbsolute()) {
        // relative path -> get correct path
        f = new File(mFile.getParentFile(), getProperty(key));
    }/*from w w  w  .  j  a  v a 2 s. c o m*/
    File parent = f.getParentFile();
    if (!parent.exists()) {
        parent.mkdirs();
    }
    return f.getAbsolutePath();
}

From source file:com.npower.dm.setup.task.ModelFetchTask.java

@Override
protected void process() throws SetupException {
    List<String> filenames = getFilenames();
    ManagementBeanFactory factory = null;
    try {/*from  ww w .j  a v  a  2  s  .  com*/
        factory = this.getManagementBeanFactory();
        ModelBean modelBean = factory.createModelBean();
        factory.beginTransaction();
        for (String filename : filenames) {
            File file = new File(filename);
            if (!file.isAbsolute()) {
                file = new File(this.getSetup().getWorkDir(), filename);
            }
            this.getSetup().getConsole().println("         Loading file [ " + file.getAbsolutePath() + " ]");
            List<ModelFetchItem> items = this.loadModelFetchItems(file.getAbsolutePath());
            for (ModelFetchItem modelFetchItem : items) {
                Manufacturer manufacturer = modelBean
                        .getManufacturerByExternalID(modelFetchItem.getManufacturerExternalID());
                if (manufacturer == null) {
                    continue;
                }
                Model model = modelBean.getModelByManufacturerModelID(manufacturer,
                        modelFetchItem.getExternalID());
                if (model == null) {
                    continue;
                }
                this.getSetup().getConsole().println("         Importing Model [ "
                        + manufacturer.getExternalId() + " " + model.getManufacturerModelId() + " ]");
                Map<String, String> specMap = modelFetchItem.getSpecifications();
                for (String specName : specMap.keySet()) {
                    String category = null;
                    String name = specName;
                    int index = specName.indexOf(".");
                    if (index >= 0) {
                        category = specName.substring(0, index);
                        name = specName.substring(index + 1, specName.length());
                    }
                    String value = specMap.get(specName);
                    ModelCharacter character = model.getCharacter(category, name);
                    if (character == null) {
                        character = modelBean.newModelCharacterInstance(model, category, name);
                    }
                    character.setValue(value);
                    modelBean.update(character);
                }
            }
        }
        factory.commit();
    } catch (Exception ex) {
        if (factory != null) {
            factory.rollback();
        }
        throw new SetupException("Error in import model specifications.", ex);
    } finally {
        if (factory != null) {
            factory.release();
        }
    }
}

From source file:de.shadowhunt.maven.plugins.packageinfo.PackageInfoPlugin.java

final File makeFileAbsolute(final File file) {
    if (file.isAbsolute()) {
        return file;
    }//  w  ww.ja  va2  s . c  om

    return new File(project.getBasedir(), file.getPath());
}

From source file:net.ymate.platform.extra.scaffold.TomcatServScaffold.java

/**
 * ??/*  ww  w .  jav  a 2  s  . co  m*/
 *
 * @throws Exception
 */
public void copyConfFiles() throws Exception {
    File _catalinaHomeDir = new File(this.__catalinaHome);
    if (!_catalinaHomeDir.isAbsolute() || !_catalinaHomeDir.exists() || !_catalinaHomeDir.isDirectory()) {
        throw new FileNotFoundException(this.__catalinaHome);
    }
    //
    for (String _fileName : __NEED_COPY_FILES) {
        FileUtils.copyFile(new File(_catalinaHomeDir, _fileName), new File(this.__catalinaBase, _fileName));
    }
}

From source file:org.giswater.dao.MainDao.java

public static boolean setBinFolder() {

    boolean result = false;
    String dbAdminPath = PropertiesDao.getPropertiesFile().get("FILE_DBADMIN", "");
    if (!dbAdminPath.equals("")) {
        File file = new File(dbAdminPath);
        binFolder = file.getParent();//w w  w . j  a  v a2s.c  o  m
        if (!file.exists()) {
            // If path is relative, make it absolute and check it again
            if (!file.isAbsolute()) {
                Utils.getLogger().info("dbAdminFile path not exists: " + dbAdminPath);
                String absolutePath = giswaterUsersFolder + dbAdminPath;
                file = new File(absolutePath);
                binFolder = file.getParent() + File.separator;
                result = file.exists();
            } else {
                result = false;
            }
        } else {
            binFolder = file.getParent() + File.separator;
            result = true;
        }
    }

    return result;

}

From source file:edu.harvard.med.screensaver.ui.arch.util.servlet.ImageProviderServlet.java

public boolean canFindImage(URL url) {
    String baseUrl = _appInfo.getApplicationProperties().getProperty("screensaver.images.base_url");
    String relativePath = url.toString().substring(baseUrl.length());
    File file = new File(_imagesFileSystemPath, relativePath);
    if (!file.isAbsolute()) {
        // if path is relative, bypass this check, since those paths are used during testing
        return true;
    }/*w w w. ja  va  2 s .  c o  m*/
    if (!file.exists()) {
        log.info("can't find the image at the url: " + url + ", mapped to the file: " + file);
        return false;
    }
    return true;
}

From source file:net.ymate.platform.extra.scaffold.TomcatServScaffold.java

/**
 * //  ww w.j av  a 2  s  . c o  m
 *
 * @throws Exception
 */
public void makeTomcatDirs() throws Exception {
    File _catalinaBaseDir = new File(this.__catalinaBase);
    if (!_catalinaBaseDir.isAbsolute()) {
        throw new IllegalArgumentException(this.__catalinaBase);
    } else if (!_catalinaBaseDir.exists()) {
        if (_catalinaBaseDir.mkdir()) {
            for (String _dirName : __NEED_MK_DIRS) {
                new File(_catalinaBaseDir, _dirName).mkdir();
            }
        } else {
            throw new IOException(this.__catalinaBase);
        }
    }
}

From source file:kenh.xscript.elements.Include.java

@Processing
public void processFile(@Attribute(ATTRIBUTE_FILE) String file,
        @Attribute(ATTRIBUTE_LOAD_PUBLIC) boolean loadPublics,
        @Attribute(ATTRIBUTE_LOAD_METHOD) boolean loadMethods, @Attribute(ATTRIBUTE_METHODS) String methodNames)
        throws UnsupportedScriptException {
    File f = null;
    try {//from w w w  .ja va 2s  .c om
        f = new File(file);
        if (!f.isAbsolute() && this.getEnvironment().containsVariable(Constant.VARIABLE_HOME)) {
            Object obj = this.getEnvironment().getVariable(Constant.VARIABLE_HOME);
            if (obj instanceof String)
                f = new File((String) obj, file);
        }
        f = f.getCanonicalFile();

    } catch (Exception e) {
        throw new UnsupportedScriptException(this, e);
    }

    Element element = ScriptUtils.getInstance(f, this.getEnvironment());
    if (element == null)
        throw new UnsupportedScriptException(this, "Unabled to load script. [" + f.getPath() + "]");

    handleScript(element, loadPublics, loadMethods, methodNames);
}

From source file:it.geosolutions.geoserver.jms.impl.utils.JMSPropertyPlaceholderConfigurer.java

@Override
public void afterPropertiesSet() throws Exception {
    File properties = new File(
            config.getConfiguration(EmbeddedBrokerConfiguration.EMBEDDED_BROKER_PROPERTIES_KEY).toString());
    if (!properties.isAbsolute() && !properties.isFile()) {
        // try to resolve as absolute
        properties = new File(JMSConfiguration.getConfigPathDir(), properties.getPath());
        if (!properties.isFile()) {
            // copy the defaults
            IOUtils.copy(defaults.getFile(), properties);
        }/*  w  ww.ja  va 2 s .com*/
    }
    final Resource res = new FileSystemResource(properties);
    super.setLocation(res);

    // make sure the activemq.base is set to a valuable default 
    final Properties props = new Properties();
    props.setProperty("activemq.base", (String) config.getConfiguration("CLUSTER_CONFIG_DIR"));
    props.setProperty("instanceName", (String) config.getConfiguration("instanceName"));
    setProperties(props);
}