@Override public Resource get(String path) { return resources.get(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"); }
@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; }
@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; }
@Override public Resource get(String path) { List<String> pathNames = Paths.names(path); if (oldResourceStore != null && pathNames.size() > 0 && ArrayUtils.contains(dir.getConfig().getIgnoreDirs(), pathNames.get(0))) { return oldResourceStore.get(path); } return new JDBCResource(dir.createEntry(path)); }
protected Resource getConfigFile(String fileName, Class<?> scope, ResourceStore rl) throws IOException { Resource dir = rl.get(CONFIG_DIRECTORY); Resource file = dir.get(fileName); if (!Resources.exists(file)) { IOUtils.copy(scope.getResourceAsStream(fileName), file.out()); } return file; }
@Test public void testIgnoreDir() throws Exception { support.initialize(); JDBCResourceStoreProperties config = getConfig(true, false); ResourceStore dataDirStore = new DataDirectoryResourceStore(); ResourceStore store = new JDBCResourceStore(support.getDataSource(), config, dataDirStore); assertEquals(store.get("DirIgnore"), dataDirStore.get("DirIgnore")); assertEquals(store.get("DirIgnore/myfile"), dataDirStore.get("DirIgnore/myfile")); assertNotEquals(store.get("DirDontIgnore"), dataDirStore.get("DirDontIgnore")); }
private Resource resolveScript(String scriptProp, Resource configResource) { Resource scriptResource = resourceStore.get(scriptProp); if (scriptResource.getType().equals(Resource.Type.UNDEFINED)) { scriptResource = configResource.parent().get(scriptProp); checkArgument( scriptResource.getType().equals(Resource.Type.RESOURCE), "Script file %s does not exist", scriptResource.path()); } return scriptResource; }
@Before public void initialize() throws Exception { resourceBrowser = new PageResourceBrowser(); try (OutputStream os = resourceBrowser.store().get(PATH_RES).out()) { os.write(DATA.getBytes()); } try (OutputStream os = resourceBrowser.store().get(PATH_RES2).out()) { os.write(DATA.getBytes()); } tester.startPage(resourceBrowser); }
@Override public void saveConfiguration(GeoServerResourceLoader resourceLoader) throws IOException { for (Resource configFile : getFileLocations()) { Resource targetDir = Files.asResource( resourceLoader.findOrCreateDirectory( Paths.convert(rl.get("/").dir(), configFile.parent().dir()))); Resources.copy(configFile.file(), targetDir); } }