@Override public Resource get(String path) { return resources.get(path); }
@Override public ResourceNotificationDispatcher getResourceNotificationDispatcher() { return resources.getResourceNotificationDispatcher(); }
@Override public boolean move(String path, String target) { return resources.move(path, target); }
public ConfigStore(ResourceStore resourceLoader) { checkNotNull(resourceLoader, "resourceLoader"); this.resourceStore = resourceLoader; if (resourceLoader.get(CONFIG_DIR_NAME) == null) { throw new IllegalStateException("Unable to create config directory " + CONFIG_DIR_NAME); dispatcher = resourceLoader.getResourceNotificationDispatcher();
@Override public boolean remove(String path) { return resources.remove(path); }
/** * Used to look up resources based on user provided url (or path) using the Data Directory as * base directory. * * <p>Convenience method for Resources.fromURL(resources.get(Paths.BASE), url) * * <p>See {@link Resources#fromURL(Resource, String)} */ public Resource fromURL(String url) { return Resources.fromURL(resources.get(Paths.BASE), url); }
/** * Used to look up resources based on user provided path using the Data Directory as base * directory. * * <p>Convenience method for Resources.fromPath(resources.get(Paths.BASE), path) * * <p>See {@link Resources#fromPath(String, Resource)} */ public Resource fromPath(String path) { return Resources.fromPath(path, resources.get(Paths.BASE)); }
/** * Used to look up resources based on user provided url using the Data Directory as base * directory. * * <p>Convenience method for Resources.fromURL(resources.get(Paths.BASE), url) * * <p>See {@link Resources#fromURL(Resource, URL)} */ public Resource fromURL(URL url) { return Resources.fromURL(resources.get(Paths.BASE), url); }
@Override public Resource parent() { return ResourceStore.EMPTY.get(Paths.parent(path)); }
public Resource get(String resourcePath) { return ResourceStore.EMPTY.get(Paths.path(this.path, resourcePath)); }
/** * Spring Resource is made relative to Data Directory if path is relative. * * @param resource Spring resource * @param store the Resource Store * @return Spring resource relative to Data Directory * @throws IOException */ public static org.springframework.core.io.Resource relative( org.springframework.core.io.Resource resource, ResourceStore store) throws IOException { File f = resource.getFile(); if (f != null) { if (!f.isAbsolute()) { // make relative to data directory -- or create file from resource store Resource res = store.get(Paths.convert(f.getPath())); return new SpringResourceAdaptor(res); } else { return new SpringResourceAdaptor(Files.asResource(f)); } } else { return resource; } }
/** * Get the LoggingInfo used at startup before the regular configuration system is available. * * <p>You probably want {@link org.geoserver.config.GeoServer#getLogging} instead * * @return LoggingInfo loaded directly from logging.xml. Returns null if logging.xml does not * exist */ @Deprecated public static @Nullable LoggingInfo getLogging(ResourceStore store) throws IOException { // Exposing this is a hack to provide JDBCConfig with the information it needs to compute // the "change" between logging.xml and the versions stored in JDBC. KS // TODO find a better solution than re-initializing on JDBCCOnfig startup. Resource f = store.get("logging.xml"); if (f != null) { XStreamPersister xp = new XStreamPersisterFactory().createXMLPersister(); try (BufferedInputStream in = new BufferedInputStream(f.in())) { LoggingInfo loginfo = xp.load(in, LoggingInfo.class); return loginfo; } } else { return null; } }
private Resource whitelistResource() { return resourceStore.get("geogig/config/whitelist.xml"); }
public Resource getConfigRoot() { return resourceStore.get(CONFIG_DIR_NAME); }
@Override protected Resource load() { ResourceStore store = getResourceStore(); return store.get(path); }
@Override public void clearArtifacts(String executionId) throws IOException { Resource resource = store.get(executionId); resource.delete(); } }
private Resource resource(String id) { Resource resource = resourceStore.get(path(id)); return resource; }
@Override public Resource getArtifact(String executionId, ArtifactType type, String name) { Resource result = null; if (type == ArtifactType.Request) { result = store.get(Paths.path(executionId, "request.dat")); } else if (type == ArtifactType.Response) { result = store.get(Paths.path(executionId, "response.xml")); } else if (type == ArtifactType.Output) { result = store.get(Paths.path(executionId, "out", name)); } else { result = store.get(Paths.path(executionId, "tmp", name)); } return result; }
/** * Access resource requested, note this may be UNDEFINED * * @param request * @return Resource requested, may be UNDEFINED if not found. */ protected Resource resource(HttpServletRequest request) { String path = request.getPathInfo(); // Strip off "/resource" path = path.substring(9); // handle special characters try { path = URLDecoder.decode(path, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RestException( "Could not decode the resource URL to UTF-8 format", HttpStatus.INTERNAL_SERVER_ERROR); } return resources.get(path); }
@Override public List<Resource> listExecutionResourcess() { List<Resource> result = new ArrayList<>(); for (Resource r : store.get(Paths.BASE).list()) { if (r.getType() == Type.DIRECTORY) { result.add(r); } } return result; }