/** * 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; } } }
public List validateGETMAP(InputSource xml, ServletContext servContext) { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); Resource schema = loader.get("data/capabilities/sld/GetMap.xsd"); File schemaFile = schema.file(); // File schemaFile = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), // "/data/capabilities/sld/GetMap.xsd"); try { return validateGETMAP(xml, URLs.fileToUrl(schemaFile)); } catch (Exception e) { ArrayList al = new ArrayList(); al.add(new SAXException(e)); return al; } }
return URLs.fileToUrl(file); } else { return null;
/** * validates against the "normal" location of the schema (ie. * ".../capabilities/sld/StyleLayerDescriptor.xsd" uses the geoserver_home patch * * @param xml * @param req */ public List validateGETMAP(InputStream xml) { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); Resource schema = loader.get("data/capabilities/sld/GetMap.xsd"); File schemaFile = schema.file(); try { return validateGETMAP(xml, URLs.fileToUrl(schemaFile)); } catch (Exception e) { ArrayList al = new ArrayList(); al.add(new SAXException(e)); return al; } }
URL url = URLs.fileToUrl(proj_file); if (url != null) { return url;
URL url = URLs.fileToUrl(proj_file); if (url != null) { return url;
return URLs.fileToUrl(resource.file()); case DIRECTORY: case UNDEFINED:
public ResourceLocator getResourceLocator() { GeoServerResourceLocator locator = new GeoServerResourceLocator(); locator.setSourceUrl(URLs.fileToUrl(getStyles().dir())); return locator; }
/** * Returns the URL to the property file that contains Operation definitions from * $GEOSERVER_DATA_DIR/user_projections/{@value #FILENAME} * * @return The URL, or {@code null} if none. */ protected URL getDefinitionsURL() { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); if (loader != null) { // not available for SystemTestData Resource definition = loader.get("user_projections/" + FILENAME); if (definition.getType() == Type.RESOURCE) { File file = definition.file(); URL url = URLs.fileToUrl(file); if (url != null) { return url; } else { LOGGER.log(Level.SEVERE, "Had troubles converting file name to URL"); } } else { LOGGER.info( definition.path() + " was not found, using the default set of " + "coordinate operation overrides (normally empty)"); } } return GeoserverOverridingWKTFactory.class.getResource(FILENAME); } }
/** * Locate the specified grid file. * * <p>It will look in GEOSERVER_DATA_DIR/user_projections * * @param grid the grid name/location * @return the fully resolved URL of the grid or null, if the resource cannot be located. */ @Override public URL locateGrid(String grid) { if (grid == null) return null; GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); if (loader == null) { return null; // must be test case still loading } Resource gridfile = loader.get("user_projections/" + grid); if (gridfile.getType() == Type.RESOURCE) { return URLs.fileToUrl(gridfile.file()); } else { return null; } } }
Parser createSld11Parser( Object input, ResourceLocator resourceLocator, EntityResolver entityResolver) { if (resourceLocator == null && input instanceof File) { // setup for resolution of relative paths final java.net.URL surl = URLs.fileToUrl((File) input); DefaultResourceLocator defResourceLocator = new DefaultResourceLocator(); defResourceLocator.setSourceUrl(surl); resourceLocator = defResourceLocator; } final ResourceLocator locator = resourceLocator; SLDConfiguration sld; if (locator != null) { sld = new SLDConfiguration() { protected void configureContext( org.picocontainer.MutablePicoContainer container) { container.registerComponentInstance(ResourceLocator.class, locator); }; }; } else { sld = new SLDConfiguration(); } Parser parser = new Parser(sld); if (entityResolver != null) { parser.setEntityResolver(entityResolver); } return parser; }
private URL checkSource(Object input) { URL sourceURL = null; if (input instanceof URL) { sourceURL = (URL) input; } else if (input instanceof File) { sourceURL = URLs.fileToUrl((File) input); } return sourceURL; }
/** Keys for overriding default layer properties */ public static class StyleProperty<T> { T get(Map<StyleProperty, Object> map, T def) { return map != null && map.containsKey(this) ? (T) map.get(this) : def; } public static StyleProperty<String> FORMAT = new StyleProperty<String>(); public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>(); public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>(); }
expect(cs.getURL()).andReturn(URLs.fileToUrl(covFile).toString()).anyTimes(); expect(cs.getType()) .andAnswer(
static Properties createGranuleCatalogProperties(File datastoreProperties) throws IOException { Properties properties = CoverageUtilities.loadPropertiesFromURL(URLs.fileToUrl(datastoreProperties)); if (properties == null) { throw new IOException( "Unable to load properties from:" + datastoreProperties.getAbsolutePath()); } return properties; }
public MaskOverviewProvider(DatasetLayout layout, File inputFile, ImageReaderSpi suggestedSPI) throws IOException { this(layout, inputFile, new SpiHelper(URLs.fileToUrl(inputFile), suggestedSPI)); }
public DataStore getDataStore(File file) throws IOException { final URL url = URLs.fileToUrl(file); if (shpFactory.canProcess(url)) { Map<String, Serializable> params = new HashMap<String, Serializable>(originalParams); params.put(URLP.key, url); return shpFactory.createDataStore(params); } else { return null; } } }
@Override public ResourceInfo getInfo(String coverageName) { String name = checkUnspecifiedCoverage(coverageName); RasterManager manager = getRasterManager(name); String parentLocation = URLs.fileToUrl(parentDirectory).toString(); return new ImageMosaicFileResourceInfo(manager, parentLocation, this.locationAttributeName); }
String doc(String elName, String elValue) throws IOException { File sampleXsd = File.createTempFile("sample", "xsd", new File("target")); copy(TestSchema.class.getResourceAsStream("sample.xsd"), sampleXsd); return String.format( "<my:%s xmlns:my='http://localhost/xob/test' " + "schemaLocation='http://localhost/xob/test %s'>%s</my:%s>", elName, URLs.fileToUrl(sampleXsd), elValue, elName); }