/** * Checks {@link Resource#getType()} and returns existing dir() if available, or null for {@link * Resource.Type#UNDEFINED} or {@link Resource.Type#RESOURCE}. * * <p>This approach is a reproduction of GeoServerDataDirectory findDataDir logic and will not * create a new directory. * * @see Resource#dir() * @param resource Resource indicated * @return File reference to existing directory, or null for an existing file (or if directory * does not exist) */ public static File directory(Resource resource) { return directory(resource, false); }
/** * Returns the root of the directory which contains spatial data files, if the directory does * exist, null is returned. * * <p>This directory is called 'data', and is located directly under {@link #root()} */ public File findDataRoot() throws IOException { Resource directory = get("data"); return Resources.directory(directory); }
/** * Returns the directory in which a resources configuration is persisted, if the directory does * not exist null is returned. * * @deprecated As of GeoServer 2.6, replaced by {@link #get(ResourceInfo, String...)} */ @Deprecated public File findResourceDir(ResourceInfo resource) throws IOException { Resource directory = get(resource); return Resources.directory(directory); }
/** * Returns the directory in which global styles are persisted, if the directory does not exist * null is returned. * * @deprecated As of GeoServer 2.6, replaced by {@link #get(StyleInfo, String...)} */ public File findStyleDir() throws IOException { Resource styles = get(STYLE_DIR); return Resources.directory(styles); }
/** * Returns the directory in which a stores configuration is persisted, if the directory does not * exists null is returned. * * @deprecated As of GeoServer 2.6, replaced by {@link #get(StoreInfo, String...)} */ @Deprecated public File findStoreDir(StoreInfo store) throws IOException { Resource directory = get(store); return Resources.directory(directory); }
/** * Returns the configuration file for the specified namespace, if the file does not exist null * is returned. * * @deprecated As of GeoServer 2.6, replaced by {@link #get(WorkspaceInfo, String...)} */ @Deprecated public File findNamespaceFile(WorkspaceInfo ws) throws IOException { Resource directory = get(ws); return Resources.directory(directory); }
/** * Returns the root of the directory which contains security configuration files, if the * directory does exist, null is returned. * * <p>This directory is called 'security', and is located directly under {@link #root()} * * @deprecated As of GeoServer 2.6, replaced by @link {@link #getSecurity()} */ @Deprecated public File findSecurityRoot() throws IOException { return Resources.directory(getSecurity()); }
/** * Returns the directory for the specified workspace, if the directory does not exist null is * returned. * * @deprecated As of GeoServer 2.6, replaced by @link {@link #get(WorkspaceInfo)} */ @Deprecated public File findWorkspaceDir(WorkspaceInfo ws) throws IOException { Resource directory = get(ws); return Resources.directory(directory); }
/** * Returns a directory under the {@link #securityRoot()} directory, if the directory does not * exist null will be returned. * * @deprecated As of GeoServer 2.6, replaced by @link {@link #getSecurity()} */ @Deprecated public File findSecurityDir(String... location) throws IOException { return Resources.directory(getSecurity(location)); }
/** * Returns the directory in which global layer groups are persisted, if the directory does not * exist null is returned. * * @deprecated As of GeoServer 2.6, replaced by {@link #get(LayerGroupInfo, String...)} */ public File findLayerGroupDir() throws IOException { Resource resource = getLayerGroups(); return Resources.directory(resource); }
/** * Styles directory (using StyleInfo). * * <p>Package visibility {@link GeoServerConfigPersister#dir(StyleInfo)}. * * @param create Create if needed * @param styleInfo * @throws IOException * @deprecated As of GeoServer 2.6, replaced by {@link #get(StyleInfo, String...)} */ File styleDir(boolean create, StyleInfo styleInfo) throws IOException { Resource styles = get(styleInfo); return Resources.directory(styles, create); }
/** * Access to styles directory for provided workspace (or global styles directory if workspace * not provided). * * <p>Package visibility for {@link GeoServerConfigPersister}. * * @param create Create directory if required * @param workspaceInfo Workspace used to access styles directory * @return styles directory * @throws IOException * @deprecated As of GeoServer 2.6, replaced by {@link #get(StyleInfo, String...)} */ File styleDir(boolean create, WorkspaceInfo workspaceInfo) throws IOException { Resource styles = get(workspaceInfo, STYLE_DIR); return Resources.directory(styles, create); }
/** * Access to security directory. * * @deprecated As of GeoServer 2.6, replaced by @link {@link #getSecurity()} */ @Deprecated private File securityRoot(boolean create) throws IOException { final Resource directory = getSecurity(); final File f; if (create) { f = directory.dir(); } else { f = Resources.directory(directory); } return f; }
/** * Role configuration root directory. * * @deprecated Use {@link #role()} */ public File getRoleRoot(boolean create) throws IOException { Resource directory = get("security/role"); if (create) { return directory.dir(); } else { return Resources.directory(directory); } }
/** * Returns a directory under the {@link #dataRoot()} directory, if the directory does not exist * null will be returned. */ public File findDataDir(String... location) throws IOException { Resource resource = get(Paths.path("data", Paths.path(location))); return Resources.directory(resource); }
/** * Returns a directory under the {@link #dataRoot()} directory. * * @param create Create directory if needed * @param location directory location * @return Directory (which may be newly created) or null if not found * @deprecated Unused */ private File dataDir(boolean create, String... location) throws IOException { Resource directory = get(Paths.path("data", Paths.path(location))); if (create) { return directory.dir(); } else { return Resources.directory(directory); } }
if (value != null) { Resource uploadsRoot = Resources.fromPath(value); return Resources.directory(uploadsRoot, !Resources.exists(uploadsRoot));
@Test public void testUploadRootExternalProps() throws Exception { // On a brand new data folder, the directory may not exists until the Importer has been // invoked the first time File dirFromProperties = Resources.directory(Resources.fromPath("props_uploads")); // Read the upload root folder and creates it if does not exists importer.getUploadRoot(); // Read the folder again... dirFromProperties = Resources.directory(Resources.fromPath("props_uploads")); // ... and ensure it is the same as defined on the .properties file assertEquals(dirFromProperties, importer.getUploadRoot()); // Let's now override the external folder through the Environment variable. This takes // precedence on .properties System.setProperty(Importer.UPLOAD_ROOT_KEY, "env_uploads"); // Let's check that the upload root is now different from the previous one... assertNotEquals(dirFromProperties, importer.getUploadRoot()); // ... but it is equal to the one defined through the Environment variable instead // Read the folder again... dirFromProperties = Resources.directory(Resources.fromPath("env_uploads")); // ... and ensure it is the same as defined on the .properties file assertEquals(dirFromProperties, importer.getUploadRoot()); }