@Override public File getFile() throws IOException { return Resources.find(resource); }
@Override public URI getURI() throws IOException { return Resources.find(resource).toURI(); }
@Override public long contentLength() throws IOException { return Resources.find(resource).length(); }
@Override public URL getURL() throws IOException { return Resources.find(resource).toURI().toURL(); }
/** * Test if the file or directory behind the resource is hidden. For file system based resources, * the platform-dependent hidden property is used. For other resource implementations, filenames * starting with a "." are considered hidden, irrespective of the platform. * * @see File#isHidden() * @param resource Resource indicated * @return true If resource is hidden */ public static boolean isHidden(Resource resource) { if (resource instanceof SerializableResourceWrapper) { resource = ((SerializableResourceWrapper) resource).delegate; } if (resource instanceof FileSystemResourceStore.FileSystemResource || resource instanceof Files.ResourceAdaptor) { // this is a file based resource, just check the file return find(resource).isHidden(); } else { // not a file system based resource, no point in caching // we only support linux style hidden file. return resource.name().startsWith("."); } }
/** * Returns a file under the {@link #root()} directory, if the file does not exist null is * returned. */ public File findFile(String... location) throws IOException { Resource resource = get(Paths.path(location)); return Resources.find(resource); }
/** * 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); }
/** @deprecated use {@link Resources#fromURL(Resource, String)} */ @Deprecated public static File url(File baseDirectory, String url) { Resource res = Resources.fromURL(asResource(baseDirectory), url); if (res == null) { return null; } File file = Resources.find(res); if (file == null) { return new File(baseDirectory, res.path()); } return file; }
/** * Performs a resource lookup. * * <pre> * Example: * File f = resourceLoader.find( "data", "shapefiles", "foo.shp" ); * </pre> * * @param location The components of the path of the resource to lookup. * @return The file handle representing the resource, or null if the resource could not be * found. * @throws IOException Any I/O errors that occur. */ public File find(String... location) throws IOException { Resource resource = get(Paths.path(location)); return Resources.find(resource); }
/** * Performs a resource lookup, optionally specifying the containing directory. * * @param parentFile The containing directory, optionally null. * @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(File parentFile, String location) throws IOException { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest( "Looking up resource " + location + " with parent " + (parentFile != null ? parentFile.getPath() : "null")); } Resource resource = get(Paths.convert(getBaseDirectory(), parentFile, location)); return Resources.find(resource); }
/** * Performs a resource lookup, optionally specifying a containing directory. * * <pre> * Example: * File f = resourceLoader.find( "data", "shapefiles", "foo.shp" ); * </pre> * * @param parentFile The parent directory, may be null. * @param location The components of the path of the resource to lookup. * @return The file handle representing the resource, or null if the resource could not be * found. * @throws IOException Any I/O errors that occur. */ public File find(File parentFile, String... location) throws IOException { Resource resource = get(Paths.convert(getBaseDirectory(), parentFile, location)); return Resources.find(resource); }
void updateParameters( Map connectionParameters, DataAccessFactory factory, Resource uploadedFile) { File f = Resources.find(uploadedFile); for (DataAccessFactory.Param p : factory.getParametersInfo()) {
for (Resource res : doFileUpload(method, workspaceName, storeName, filename, format, request)) { uploadedFiles.add(Resources.find(res));