/** * Locates and returns the property file, or returns null otherwise (e.g., the parent folder is * not there, or permission issues) * * @return * @throws ConfigurationException */ private File getPropertyFile() throws ConfigurationException { File securityDir = GeoserverDataDirectory.findCreateConfigDir("security"); if (securityDir != null) { return new File(securityDir, AUTHKEYS_FILE); } else { return null; } }
public GeorectifyConfiguration() { configFile = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), GDAL_CONFIG_FILE); timer = new Timer(true); timer.schedule(new ConfigurationPoller(), 1000); }
@Override public void run() { try { // first check that temp/wcs is really there in the data dir File temp = GeoserverDataDirectory.findConfigDir(GeoserverDataDirectory .getGeoserverDataDirectory(), "temp"); if (temp == null || !temp.exists()) return; File wcsTemp = new File(temp, "wcs"); if (!wcsTemp.exists()) return; // ok, now scan for existing files there and clean up those // that are too old long now = System.currentTimeMillis(); for(File f : wcsTemp.listFiles()) { if(now - f.lastModified() > (expirationDelay * 1000)) f.delete(); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Error occurred while trying to clean up " + "old coverages from temp storage", e); } }
public void setObject(Object object) { String location = (String) object; File dataDirectory = canonicalize(GeoserverDataDirectory.getGeoserverDataDirectory()); File file = canonicalize(new File(location)); if(isSubfile(dataDirectory, file)) { File curr = file; String path = null; // paranoid check to avoid infinite loops while(curr != null && !curr.equals(dataDirectory)){ if(path == null) { path = curr.getName(); } else { path = curr.getName() + "/" + path; } curr = curr.getParentFile(); } location = "file:" + path; } else if(!GeoserverDataDirectory.findDataFile(location).equals(file)) { // relative to the data directory, does not need fixing } else { location = "file://" + file.getAbsolutePath(); } delegate.setObject(location); }
/** * Loads validations plugins. * * @param dataDir The data directory. */ protected void loadPlugins(File dataDir) { Map plugIns = null; Map testSuites = null; try { File plugInDir = GeoserverDataDirectory.findConfigDir(dataDir, "plugIns"); File validationDir = GeoserverDataDirectory.findConfigDir(dataDir, "validation"); if (plugInDir != null && plugInDir.exists()) { plugIns = XMLReader.loadPlugIns(plugInDir); if (validationDir != null && validationDir.exists()) { testSuites = XMLReader.loadValidations(validationDir, plugIns); } } } catch (Exception e) { org.geotools.util.logging.Logging.getLogger("org.vfny.geoserver.global").log(Level.WARNING, "loading plugins", e); } if(testSuites == null) testSuites = new HashMap(); if(plugIns == null) plugIns = new HashMap(); load(testSuites, plugIns); }
File relFile = GeoserverDataDirectory.findDataFile(uriSpec); if(relFile == null || !relFile.exists()) { error(validatable, "FileExistsValidator.fileNotFoundError",
public void testLoad() throws Exception { tester.assertRenderedPage(StyleEditPage.class); tester.assertNoErrorMessage(); tester.assertComponent("form:name", TextField.class); tester.assertComponent("form:SLD:editorContainer:editor", TextArea.class); tester.assertModelValue("form:name", "Buildings"); File styleFile = GeoserverDataDirectory.findStyleFile( buildingsStyle.getFilename() ); DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document d1 = db.parse( new FileInputStream(styleFile) ); //GEOS-3257, actually drag into xml and compare with xmlunit to avoid // line ending problems String xml = tester.getComponentFromLastRenderedPage("form:SLD").getDefaultModelObjectAsString(); xml = xml.replaceAll("<","<").replaceAll(">",">").replaceAll(""", "\""); Document d2 = db.parse( new ByteArrayInputStream(xml .getBytes())); assertXMLEqual(d1, d2); }
File dataDirectory = GeoserverDataDirectory.getGeoserverDataDirectory(); roots.add(0, dataDirectory); File relativeToDataDir = GeoserverDataDirectory.findDataFile(selection.getPath()); if(relativeToDataDir != null) { selection = relativeToDataDir;
File file = GeoserverDataDirectory.findDataFile(globalWatermarkingURL); if (file.exists()) url = file.toURL();
/** * This function gets the stream of the request to copy it into a file. * @deprecated use {@link #handleBinUpload(String, File, Request)}. */ public static File handleBinUpload(String datasetName, String extension, Request request) throws IOException, ConfigurationException { final File dir = GeoserverDataDirectory.findCreateConfigDir("data"); return handleBinUpload( datasetName + "." + extension, dir, request ); }
public Ogr2OgrConfigurator(Ogr2OgrOutputFormat format, long pollInterval) { this.of = format; configFile = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), "ogr2ogr.xml"); timer = new Timer(true); timer.schedule(new ConfigurationPoller(), pollInterval); }
File data_dir = GeoserverDataDirectory.getGeoserverDataDirectory(); File style_dir; style_dir = GeoserverDataDirectory.findConfigDir(data_dir, "styles"); } catch (ConfigurationException cfe) { LOGGER.warning("no style dir found, creating new one");
/** * Unzip a zipped dataset. * * @param storeName the name of the store to handle. * @param zipFile the zipped archive * @return null if the zip file does not point to a valid zip file, the output directory otherwise. * * @deprecated use {@link #unzipFile(File, File)} * */ public static File unpackZippedDataset(String storeName, File zipFile) throws IOException, ConfigurationException { File outputDirectory = new File(GeoserverDataDirectory.findCreateConfigDir("data"), storeName); unzipFile(zipFile, outputDirectory); return outputDirectory; }
public DefaultControlFlowConfigurator() { configFile = new PropertyFileWatcher(new File( GeoserverDataDirectory.getGeoserverDataDirectory(), "controlflow.properties")); }
final File root = GeoserverDataDirectory.getGeoserverDataDirectory(); final File paletteDir = GeoserverDataDirectory.findConfigDir(root, "palettes"); final String[] names = new String[] { name + ".gif", name + ".png",
/** * Handles the upload of a dataset using the URL method. * * @param datasetName the name of the uploaded dataset. * @param extension the extension of the uploaded dataset. * @param request the incoming request. * @return a {@link File} that points to the final uploaded dataset. * * @throws IOException * @throws ConfigurationException * * @deprecated use {@link #handleURLUpload(String, File, Request)}. */ public static File handleURLUpload(String datasetName, String extension, Request request) throws IOException, ConfigurationException { //// // // Get the dir where to write and create a file there // //// File dir = GeoserverDataDirectory.findCreateConfigDir("data"); return handleURLUpload(datasetName + "." + extension, dir, request); }
/** * Default constructor */ public IpBlacklistFilter() { try { File file = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), "controlflow.properties"); configFile = new PropertyFileWatcher(file); blackListedAddresses = reloadConfiguration(); } catch (Exception e) { LOGGER.log(Level.FINER, e.getMessage(), e); throw new RuntimeException(e); } }
File getWpsOutputStorage() { File wpsStore = null; try { File temp = GeoserverDataDirectory.findCreateConfigDir("temp"); wpsStore = new File(temp, "wps"); if(!wpsStore.exists()) { mkdir(wpsStore); } } catch(Exception e) { throw new WcsException("Could not create the temporary storage directory for WPS"); } return wpsStore; }
@Override public boolean synchronize(DocumentFile event) throws Exception { if (event == null) { throw new NullArgumentException("Incoming object is null"); } try { final String fileName = File.separator + "styles" + File.separator + event.getPath().getName(); final File file = new File(GeoserverDataDirectory .getGeoserverDataDirectory().getCanonicalPath(), fileName); event.writeTo(file); return true; } catch (Exception e) { if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) LOGGER.severe(this.getClass() + " is unable to synchronize the incoming event: " + event); throw e; } }
public void clearCache(FeatureTypeInfo cfg){ try{ DeleteDbFiles.execute( GeoserverDataDirectory.findCreateConfigDir("geosearch").getCanonicalPath(), "h2cache_" + getDatabaseName(cfg), true ); } catch (Exception ioe) { LOGGER.severe("Couldn't clear out config dir due to: " + ioe); } }