public Resource get(String path) { return resourceLoader.get(path); }
/** * Performs a directory lookup, creating the file if it does not exist. * * @param parentFile The containing directory, possibly null. * @param location The components of the path that make up the location of the directory to find * or create. */ public File findOrCreateDirectory(File parentFile, String... location) throws IOException { Resource directory = get(Paths.convert(getBaseDirectory(), parentFile, location)); return directory.dir(); // will create directory as needed }
@Override protected URL validateRelativeURL(URL relativeUrl) { if (relativeUrl.getProtocol().equalsIgnoreCase("resource")) { String path = relativeUrl.getPath(); if (resourceLoader.get(path).getType() != Type.UNDEFINED) { return relativeUrl; } else { return null; } } else { return super.validateRelativeURL(relativeUrl); } }
/** * Performs a directory lookup, creating the file if it does not exist. * * @param parentFile The containing directory, may be null. * @param location The location of the directory to find or create. * @return The file handle. * @throws IOException If any i/o errors occur. */ public File findOrCreateDirectory(File parentFile, String location) throws IOException { Resource directory = get(Paths.convert(getBaseDirectory(), parentFile, location)); return directory.dir(); // will create directory as needed }
/** * Performs file lookup. * * @param location The name of the resource to lookup, can be absolute or relative. * @return The file handle representing the resource, or null if the resource could not be * found. * @throws IOException In the event of an I/O error. */ public File find(String location) throws IOException { Resource resource = get(Paths.convert(location)); return Resources.find(resource); }
/** * Creates a new file. * * <p>Calls through to {@link #createFile(File, String)} * * @param location Location of file to create, either absolute or relative. * @param parentFile The containing directory for the file. * @return The file handle of the created file. * @throws IOException In the event of an I/O error. */ public File createFile(File parentFile, String... location) throws IOException { Resource resource = get(Paths.convert(getBaseDirectory(), parentFile, location)); return Resources.createNewFile(resource); }
/** * Performs a directory lookup, creating the file if it does not exist. * * @param location The location of the directory to find or create. * @return The file handle. * @throws IOException If any i/o errors occur. */ public File findOrCreateDirectory(String location) throws IOException { Resource directory = get(Paths.convert(location)); return directory.dir(); // will create directory as needed }
/** * Creates a new directory specifying components of the location, and the containing directory. * * <p>Calls through to {@link #createDirectory(String)} * * @param parentFile The containing directory, possibly null. * @param location The components of the path that make up the location of the directory to * create * @return newly created directory */ public File createDirectory(File parentFile, String... location) throws IOException { Resource directory = get(Paths.convert(getBaseDirectory(), parentFile, location)); return Resources.createNewDirectory(directory); }
/** * Find the file that should provide the user information. * * @throws ConfigurationException if the user configuration file does not exist and cannot be * created * @throws IOException if an error occurs while opening the user configuration file */ private Resource getUserFile() throws ConfigurationException, IOException { GeoServerResourceLoader loader = geoServer.getCatalog().getResourceLoader(); return loader.get("security/users.properties"); }
/** * Creates a new directory specifying components of the location. * * <p>Calls through to {@link #createDirectory(String)} */ public File createDirectory(String... location) throws IOException { Resource directory = get(Paths.path(location)); return Resources.createNewDirectory(directory); }
/** * Performs a directory lookup, creating the file if it does not exist. * * @param location The components of the path that make up the location of the directory to find * or create. */ public File findOrCreateDirectory(String... location) throws IOException { Resource directory = get(Paths.path(location)); return directory.dir(); // will create directory as needed }
/** * Creates a new file. * * <p>Calls through to {@link #createFile(String)}. * * @param location The components of the location. * @return The file handle of the created file. * @throws IOException In the event of an I/O error. */ public File createFile(String... location) throws IOException { Resource resource = get(Paths.path(location)); return Resources.createNewFile(resource); }
/** * Creates a new file. * * <p>Calls through to {@link #createFile(File, String)} * * @param location Location of file to create, either absolute or relative. * @return The file handle of the created file. * @throws IOException In the event of an I/O error. */ public File createFile(String location) throws IOException { Resource resource = get(Paths.convert(location)); return Resources.createNewFile(resource); }
Resource dir(WorkspaceInfo ws) throws IOException { return resourceLoader.get(Paths.path("workspaces", ws.getName())); } }
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; } }
/** * Creates a new directory. * * <p>Relative paths are created relative to {@link #baseDirectory}. If {@link #baseDirectory} * is not set, an IOException is thrown. * * <p>If <code>location</code> already exists as a file, an IOException is thrown. * * @param location Location of directory to create, either absolute or relative. * @return The file handle of the created directory. */ public File createDirectory(String location) throws IOException { Resource directory = get(Paths.convert(location)); return Resources.createNewDirectory(directory); }
/** * Copies a resource located on the classpath to a specified path. * * <p>The <tt>resource</tt> is obtained from teh context class loader of the current thread. * When the <tt>to</tt> parameter is specified as a relative path it is considered to be * relative to {@link #getBaseDirectory()}. * * @param classpathResource The resource to copy. * @param location The destination to copy to. */ public void copyFromClassPath(String classpathResource, String location) throws IOException { Resource resource = get(Paths.convert(location)); copyFromClassPath(classpathResource, resource.file()); }
public void handleServiceRemove(ServiceInfo service) { XStreamServiceLoader loader = findServiceLoader(service); try { Resource dir = service.getWorkspace() != null ? dir(service.getWorkspace()) : resourceLoader.get(Paths.BASE); dir.get(loader.getFilename()).delete(); } catch (Throwable t) { throw new RuntimeException(t); } }
public final void save(T service, GeoServer gs, Resource directory) throws Exception { String filename = getFilename(); Resource resource = directory == null ? resourceLoader.get(filename) : directory.get(filename); // using resource output stream makes sure we write on a temp file and them move try (OutputStream out = resource.out()) { XStreamPersister xp = xpf.createXMLPersister(); initXStreamPersister(xp, gs); xp.save(service, out); } }
public final T load(GeoServer gs, Resource directory) throws Exception { // look for file matching classname Resource file; if (Resources.exists(file = directory.get(getFilename()))) { // xstream it in try (BufferedInputStream in = new BufferedInputStream(file.in())) { XStreamPersister xp = xpf.createXMLPersister(); initXStreamPersister(xp, gs); return initialize(xp.load(in, getServiceClass())); } } else { // create an 'empty' object ServiceInfo service = createServiceFromScratch(gs); return initialize((T) service); } }