File storeDir = catalog.getResourceLoader().findOrCreateDirectory(prefix);
public File getImportRoot() { try { return catalog.getResourceLoader().findOrCreateDirectory("imports"); } catch (IOException e) { throw new RuntimeException(e); } }
public File getUploadRoot() { try { return catalog.getResourceLoader().findOrCreateDirectory("uploads"); } catch(IOException e) { throw new RuntimeException(e); } }
public File getImportRoot() { try { return catalog.getResourceLoader().findOrCreateDirectory("imports"); } catch (IOException e) { throw new RuntimeException(e); } }
public File getArchiveFile(ImportContext context) throws IOException { //String archiveName = "import-" + task.getContext().getId() + "-" + task.getId() + "-" + task.getData().getName() + ".zip"; String archiveName = "import-" + context.getId() + ".zip"; File dir = getCatalog().getResourceLoader().findOrCreateDirectory("uploads","archives"); return new File(dir, archiveName); }
baseDir = resourceLoader.findOrCreateDirectory(baseDirectory); } catch (IOException e) { throw propagate(e);
private File getFile(final String tileLayerId, final boolean create) throws IOException { final String fileName = FilePathGenerator.filteredLayerName(tileLayerId) + ".xml"; final File base = resourceLoader.findOrCreateDirectory(baseDirectory); File file = resourceLoader.find(base, fileName); if (null == file && create) { return resourceLoader.createFile(base, fileName); } return file; }
public File getArchiveFile(ImportContext context) throws IOException { // String archiveName = "import-" + task.getContext().getId() + "-" + task.getId() + "-" + // task.getData().getName() + ".zip"; String archiveName = "import-" + context.getId() + ".zip"; File dir = getCatalog().getResourceLoader().findOrCreateDirectory(getUploadRoot(), "archives"); return new File(dir, archiveName); }
/** * Create GeoServerInternalCatalogStore * * @param geoserver * @throws IOException */ public GeoServerInternalCatalogStore(GeoServer geoserver) throws IOException { super( geoserver.getCatalog()); GeoServerResourceLoader loader = geoserver.getCatalog().getResourceLoader(); File dir = loader.findOrCreateDirectory("csw"); for (Name name : descriptorByType.keySet()) { String typeName = name.getLocalPart(); File f = new File(dir, typeName + ".properties"); PropertyFileWatcher watcher = new PropertyFileWatcher(f); watchers.put(typeName, watcher); if (!f.exists()) { IOUtils.copy(getClass().getResourceAsStream(typeName + ".default.properties"),f); } addMapping (typeName, CatalogStoreMapping.parse(new HashMap<String, String>((Map) watcher.getProperties()))); } }
return Resources.directory(uploadsRoot, !Resources.exists(uploadsRoot)); return catalog.getResourceLoader().findOrCreateDirectory("uploads"); } catch (IOException e) { throw new RuntimeException(e);
/** * Does the file upload based on the specified method. * * @param method The method, one of 'file.' (inline), 'url.' (via url), or 'external.' (already on server) * @param storeName The name of the store being added * @param format The store format. */ protected File doFileUpload(String method, String workspaceName, String storeName, String format) { File directory = null; // Prepare the directory only in case this is not an external upload if (isInlineUpload(method)){ try { directory = catalog.getResourceLoader() .findOrCreateDirectory("data", workspaceName, storeName); // directory = File.createTempFile(storeName + "_", "", data); // directory.delete(); // directory.mkdir(); } catch (IOException e) { throw new RestletException( e.getMessage(), Status.SERVER_ERROR_INTERNAL, e ); } } return handleFileUpload(storeName, format, directory); }
/** * Writes out an {@code esri.properties} file to {@code <data_dir>/user_projections/} with the * single entry: {@code 4326=<esri version of 4326 WKT>} * * @throws IOException */ private void setupESRIPropertyFile() throws IOException { String esri_properties = "4326=" + get4326_ESRI_WKTContent(); InputStream input = new ByteArrayInputStream(esri_properties.getBytes()); File directory = getResourceLoader().findOrCreateDirectory("user_projections"); File file = new File(directory, "esri.properties"); if (file.exists()) { file.delete(); } org.geoserver.util.IOUtils.copy(input, file); }
private File doFileUpload() { try { getResponse().setStatus(Status.SUCCESS_ACCEPTED); File directory = catalog.getResourceLoader().findOrCreateDirectory(getDirectoryPath(getRequest())); if (LOGGER.isLoggable(Level.INFO)) { MediaType mediaType = getRequest().getEntity().getMediaType(); LOGGER.info("PUT file: mimetype=" + mediaType + ", path=" + directory.getAbsolutePath()); } return RESTUtils.handleBinUpload(getAttribute("template") + "." + MEDIATYPE_FTL_EXTENSION, directory, false, getRequest()); } catch (IOException e) { throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e); } }
File styles = resources.findOrCreateDirectory("styles"); URL base = URLs.fileToUrl(styles); url = new URL(base, onlineResource);
@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); } }
@Override public void saveConfiguration(GeoServerResourceLoader resourceLoader) throws IOException { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); for (Resource controlflow : getFileLocations()) { Resource targetDir = Files.asResource( resourceLoader.findOrCreateDirectory( Paths.convert( loader.getBaseDirectory(), controlflow.parent().dir()))); Resources.copy(controlflow.file(), targetDir); } }