/** * Used to look up resources based on user provided url, using the Data Directory as base * directory. * * <p>Supports * * <ul> * <li>Actual URL to external resource using http or ftp protocol - will return null * <li>Resource URL - will support resources from resource store * <li>File URL - will support absolute file references * <li>File URL - will support relative file references - this is deprecated, use resource: * instead * <li>Fake URLs - sde://user:pass@server:port - will return null. * </ul> * * @param url the url * @return corresponding Resource */ public static Resource fromURL(URL url) { return ((GeoServerResourceLoader) GeoServerExtensions.bean("resourceLoader")).fromURL(url); }
/** * Used to look up resources based on user provided url (or path) using the Data Directory as * base directory. * * <p>This method is used to process a URL provided by a user: <i>Given a path, tries to * interpret it as a file into the data directory, or as an absolute location, and returns the * actual absolute location of the file.</i> * * <p>Over time this url method has grown in the telling to support: * * <ul> * <li>Actual URL to external resource using http or ftp protocol - will return null * <li>Resource URL - will support resources from resource store * <li>File URL - will support absolute file references * <li>File URL - will support relative file references - this is deprecated, use resource: * instead * <li>Fake URLs - sde://user:pass@server:port - will return null. * <li>path - user supplied file path (operating specific specific) * </ul> * * @param path File URL, or path, relative to data directory * @return Resource indicated by provided URL */ public static Resource fromURL(String path) { return ((GeoServerResourceLoader) GeoServerExtensions.bean("resourceLoader")).fromURL(path); }
@Override public void visit(Mark mark) { final Expression wellKnownName = mark.getWellKnownName(); if (wellKnownName instanceof Literal) { final String name = wellKnownName.evaluate(null, String.class); if (name.startsWith("resource:/")) { try { Resource r = resourceLoader.fromURL(name); if (r != null && r.getType() != Type.UNDEFINED) { resources.add(r); } } catch (IllegalArgumentException e) { GeoServerConfigPersister.LOGGER.log( Level.WARNING, "Error attemping to process SLD resource", e); } } } }
@Override public void visit(ExternalGraphic exgr) { if (exgr.getOnlineResource() == null) { return; } try { final String location = exgr.getURI(); Resource r = resourceLoader.fromURL(location); if (r != null && r.getType() != Type.UNDEFINED) { resources.add(r); } } catch (IllegalArgumentException e) { GeoServerConfigPersister.LOGGER.log( Level.WARNING, "Error attemping to process SLD resource", e); } }
URL url = super.locateResource(uri); if (url != null && url.getProtocol().equalsIgnoreCase("resource")) { Resource resource = resourceLoader.fromURL(url); File file; if (Resources.exists(resource)) {