/** * Wrapper for {@link DataUtilities#fileToURL} that unescapes braces used to delimit CQL * templates. */ public static URL fileToUrlPreservingCqlTemplates(File file) { URL url = URLs.fileToUrl(file); if (!file.getPath().contains("${")) { // guard against situations in which braces are used but not for CQL templates return url; } else { try { return new URL(url.toExternalForm().replace("%7B", "{").replace("%7D", "}")); } catch (MalformedURLException e) { return null; } } }
/** * @deprecated Use {@link URLs#extendUrl(URL, String) */ public static URL extendURL(URL base, String extension) throws MalformedURLException { return URLs.extendUrl(base, extension); }
sourceURL = URLs.fileToUrl(sourceFile); } else if (source instanceof URL) { sourceURL = (URL) source; if (sourceURL.getProtocol().equals("file")) { sourceFile = URLs.urlToFile(sourceURL); sourceURL = new URL(tempSource); source = URLs.urlToFile(sourceURL); } catch (MalformedURLException e) { sourceURL = null; sourceURL = URLs.fileToUrl(tempFile); sourceFile = tempFile; return URLs.fileToUrl(sourceFile); Properties properties = new Properties(); String coverageNames = mosaics.get(0).getCoverageNames(); properties.put("Name", coverageNames != null ? coverageNames : directory.getName()); properties.put("LevelsNum", String.valueOf(mosaics.size())); StringBuilder sbDirNames = new StringBuilder(); StringBuilder sbLevels = new StringBuilder(); return URLs.fileToUrl(sourceFile);
final Properties overrideParams, final Hints hints) { final File sourceFile = URLs.urlToFile(sourceURL); final String extension = FilenameUtils.getExtension(sourceFile.getAbsolutePath()); final Properties params = new Properties(); params.put(Utils.Prop.PATH_TYPE, catalogConfigurationBean.getPathType()); params.put( Utils.Prop.LOCATION_ATTRIBUTE, catalogConfigurationBean.getLocationAttribute()); params.put(Utils.Prop.WRAP_STORE, catalogConfigurationBean.isWrapStore()); if (sourceURL != null) { File parentDirectory = URLs.urlToFile(sourceURL); if (parentDirectory.isFile()) parentDirectory = parentDirectory.getParentFile(); params.put(Utils.Prop.PARENT_LOCATION, URLs.fileToUrl(parentDirectory).toString()); } else params.put(Utils.Prop.PARENT_LOCATION, null);
boolean shapefile = true; try { final File sourceF = URLs.urlToFile(sourceURL); if (FilenameUtils.getName(sourceF.getAbsolutePath()) .equalsIgnoreCase("datastore.properties")) { final Properties properties = new Properties(); final FileInputStream stream = new FileInputStream(sourceF); try { properties.load(stream); } finally { IOUtils.closeQuietly(stream); final String SPIClass = properties.getProperty("SPI"); params, URLs.fileToUrl(sourceF.getParentFile()).toExternalForm()); File testFile = URLs.urlToFile(testPropertiesUrl); if (!testFile.exists()) { return false; final File parent = URLs.urlToFile(sourceURL).getParentFile(); && Utils.loadMosaicProperties(URLs.fileToUrl(propFile)) != null) { propsUrl = URLs.fileToUrl(propFile); break;
if (indexerTypeName != null && properties.getProperty(Prop.TYPENAME) == null) { properties.put(Prop.TYPENAME, indexerTypeName); URLs.fileToUrl( new File( parent, runConfiguration.getParameter(Prop.INDEX_NAME) + ".shp")); final Properties params = new Properties(); params.put(ShapefileDataStoreFactory.URLP.key, file); if (file.getProtocol().equalsIgnoreCase("file")) { params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);
source = (URL) o; } else if (o instanceof File) { source = URLs.fileToUrl((File) o); } else if (o instanceof String) { try { source = new URL((String) o); } catch (MalformedURLException e) { if (properties.containsKey("regex")) { property = properties.getProperty("regex");
ovrURL = new URL(inputFile.toString() + OVR_EXTENSION); hasDatasetLayout = layout != null; if (hasDatasetLayout && layout.getExternalOverviews() != null) { ovrURL = URLs.fileToUrl(layout.getExternalOverviews()); ovrStream = overviewStreamSpi.createInputStreamInstance( ovrURL, ImageIO.getUseCache(), ImageIO.getCacheDirectory()); if (ovrStream == null) { if (hasExternalMasks) { maskURL = URLs.fileToUrl(layout.getExternalMasks()); maskStream = maskStreamSpi.createInputStreamInstance( maskURL, ImageIO.getUseCache(), ImageIO.getCacheDirectory()); maskReaderSpi = getReaderSpiFromStream(suggestedSPI, maskStream); } catch (Exception e) { maskOvrURL = URLs.fileToUrl(layout.getExternalMaskOverviews());
source = (URL) o; } else if (o instanceof File) { source = URLs.fileToUrl((File) o); } else if (o instanceof String) { try { source = new URL((String) o); } catch (MalformedURLException e) { regex = properties.getProperty(REGEX); format = properties.getProperty(FORMAT); String fullPathParam = properties.getProperty(FULL_PATH); if (fullPathParam != null && fullPathParam.trim().length() > 0) { fullPath = Boolean.valueOf(fullPathParam);
GranuleCatalog catalog = null; final String SPIClass = properties.getProperty("SPI"); DataStoreFactorySpi spi = null; try { if (SPIClass == null) { if (properties.get(Utils.Prop.STORE_NAME) == null) { throw new IllegalArgumentException( "Required property SPI is missing from configuration"); properties.put("ParentLocation", URLs.fileToUrl(parent).toExternalForm()); if (wraps) { properties.put(Prop.WRAP_STORE, wraps);
URL url = null; try { url = new URL(imageURL); if (url.getProtocol() == null || url.getProtocol().equals("file")) { File file = loader.url(imageURL); if (file.exists()) { url = URLs.fileToUrl(file); Resource image = layouts.get(imageURL); if (image.getType() == Resource.Type.RESOURCE) { url = URLs.fileToUrl(image.file()); url = URLs.fileToUrl(image.file()); logo = ImageIO.read(url); if (url.getProtocol().equals("file")) { entry = new LogoCacheEntry(logo, new File(url.getFile()));
if (!sourceURL.toExternalForm().endsWith(".properties")) { propsURL = DataUtilities.changeUrlExt(sourceURL, "properties"); if (propsURL.getProtocol().equals("file")) { final File sourceFile = URLs.urlToFile(propsURL); if (!sourceFile.exists()) { if (LOGGER.isLoggable(Level.INFO)) { String bboxString = properties.getProperty(Prop.ENVELOPE2D, null); if (bboxString != null) { bboxString = bboxString.trim(); retValue.setAuxiliaryFilePath(properties.getProperty(Prop.AUXILIARY_FILE)); properties.getProperty(Prop.AUXILIARY_DATASTORE_FILE)); File mosaicParentFolder = URLs.urlToFile(sourceURL).getParentFile(); Indexer indexer = loadIndexer(mosaicParentFolder);
URL url = URLs.fileToUrl(indexFile); final Properties properties = CoverageUtilities.loadPropertiesFromURL(url); if (properties != null) { String canBeEmpty = properties.getProperty(Prop.CAN_BE_EMPTY, null); if (canBeEmpty != null) { if (Boolean.parseBoolean(canBeEmpty)) {
URL url = URLs.fileToUrl(fixedPath); entry.setValue((V) url.toExternalForm()); } else if (value instanceof URL && ((URL) value).getProtocol().equals("file")) { URL url = (URL) value; File fixedPath = loader.url(url.toString()); entry.setValue((V) URLs.fileToUrl(fixedPath)); } else if ((key != null) && (key.equals("directory") || key.equals("database"))
static InputStream input(URL url, Resource configDir) throws IOException { // check for a file url if ("file".equalsIgnoreCase(url.getProtocol())) { File f = URLs.urlToFile(url); // check if the file is relative if (!f.isAbsolute()) { // make it relative to the config directory for this password provider Resource res = configDir.get(f.getPath()); if (res.getType() != Type.RESOURCE) { // file must already exist. throw new FileNotFoundException(); } return res.in(); } else { return new FileInputStream(f); } } else { return url.openStream(); } }
protected static Properties initProperties(File configFile) { Properties properties = null; if (configFile != null && configFile.exists()) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "Retrieving footprints properties from " + "the specified config file: " + configFile.getAbsolutePath()); } properties = CoverageUtilities.loadPropertiesFromURL(URLs.fileToUrl(configFile)); } else { properties = new Properties(); } return properties; } }
CoverageUtilities.loadPropertiesFromURL(URLs.fileToUrl(configFile)); if (properties.containsKey("regex")) { value = properties.getProperty("regex");
static OutputStream output(URL url, Resource configDir) throws IOException { // check for file url if ("file".equalsIgnoreCase(url.getProtocol())) { File f = URLs.urlToFile(url); if (!f.isAbsolute()) { // make relative to config dir return configDir.get(f.getPath()).out(); } else { return new FileOutputStream(f); } } else { URLConnection cx = url.openConnection(); cx.setDoOutput(true); return cx.getOutputStream(); } }
throw new DataSourceException( "This plugin accepts File, URL or String. The string may describe a File or an URL"); if (sourceURL.getProtocol().equals("file")) { final File sourceFile = URLs.urlToFile(sourceURL); if (!sourceFile.exists()) { throw new DataSourceException( "The specified sourceURL doesn't refer to an existing file"); parentDirectory = URLs.urlToFile(sourceURL); if (!parentDirectory.isDirectory()) { parentDirectory = parentDirectory.getParentFile(); final File parent = URLs.urlToFile(sourceURL).getParentFile(); for (File propFile : properties) { if (Utils.checkFileReadable(propFile) && Utils.loadMosaicProperties(URLs.fileToUrl(propFile)) != null) { configuration = Utils.loadMosaicProperties(URLs.fileToUrl(propFile)); if (configuration != null) { beans.add(configuration); ImageMosaicConfigHandler.createCatalog( sourceURL, configuration, this.hints); File parent = URLs.urlToFile(sourceURL).getParentFile(); MultiLevelROIProvider rois = MultiLevelROIProviderMosaicFactory.createFootprintProvider(parent);