protected void appendRootUri(StringBuffer buffer, boolean addPassword) { buffer.append(getScheme()); buffer.append(":"); buffer.append(getOuterName().getURI()); buffer.append("!"); } }
/** * Does a reverse lookup to find the FileObject when we only have the * URL. */ private FileObject lookupFileObject(final String name) { final Iterator it = resources.iterator(); while (it.hasNext()) { final FileObject object = (FileObject) it.next(); if (name.equals(object.getName().getURI())) { return object; } } return null; }
protected URL createURL(final FileName name) throws MalformedURLException, FileSystemException, URIException { if (name instanceof URLFileName) { URLFileName urlName = (URLFileName) getName(); // TODO: charset return new URL(urlName.getURIEncoded(null)); } return new URL(getName().getURI()); }
protected URL createURL(final FileName name) throws MalformedURLException, FileSystemException, URIException { String url; if (name instanceof URLFileName) { URLFileName urlName = (URLFileName) getName(); // TODO: charset url = urlName.getURIEncoded(null); } else { url = getName().getURI(); } if (url.startsWith("mvn:///")) { url = "mvn:" + url.substring("mvn:///".length()); } return new URL(url); }
/** * Executes the task. */ public void execute() throws BuildException { try { final FileObject file = resolveFile(url); log("Details of " + file.getName().getURI()); showFile(file, INDENT); } catch (final Exception e) { throw new BuildException(e); } }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); FileObject dir = getCurrentDirectory(context); io.info(dir.getName().getURI()); FileObjects.close(dir); return Result.SUCCESS; } }
protected InputStream doGetInputStream() throws Exception { // check file InputStream is = getContainer().getContent().getInputStream(); return wrapInputStream(getName().getURI(), is); }
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo(); FileObject dir = getCurrentDirectory(context); io.info(dir.getName().getURI()); FileObjects.close(dir); return Result.SUCCESS; } }
/** * Get a list of direct descendents of the given resource. Note that attempts to get a list of * children does <emphasize>not</emphasize> result in an error. Instead an error message is * logged and an empty ArrayList returned. * * @return A <code>ArrayList</code> of VFSResources */ public List getChildren() { init(); ArrayList list = new ArrayList(); try { if ((resourceImpl != null) && resourceImpl.exists() && (resourceImpl.getType() == FileType.FOLDER)) { FileObject[] children = resourceImpl.getChildren(); for (int i = 0; i < children.length; i++) { FileObject child = children[i]; list.add(normalize(child.getName().getURI())); } } } catch (IOException e) { Message.debug(e); Message.verbose(e.getLocalizedMessage()); } return list; }
final String url = newURL.getName().getURI(); final StringBuffer filePart = new StringBuffer(); final String protocolPart = UriParser.extractScheme(url, filePart);
/** * Return a listing of the contents of a parent directory. Listing is a set of strings * representing VFS URIs. * * @param vfsURI * providing identifying a VFS provided resource * @throws IOException * on failure. * @see "Supported File Systems in the jakarta-commons-vfs documentation" */ public List list(String vfsURI) throws IOException { ArrayList list = new ArrayList(); Message.debug("list called for URI" + vfsURI); FileObject resourceImpl = getVFSManager().resolveFile(vfsURI); Message.debug("resourceImpl=" + resourceImpl.toString()); Message.debug("resourceImpl.exists()" + resourceImpl.exists()); Message.debug("resourceImpl.getType()" + resourceImpl.getType()); Message.debug("FileType.FOLDER" + FileType.FOLDER); if ((resourceImpl != null) && resourceImpl.exists() && (resourceImpl.getType() == FileType.FOLDER)) { FileObject[] children = resourceImpl.getChildren(); for (int i = 0; i < children.length; i++) { FileObject child = children[i]; Message.debug("child " + i + child.getName().getURI()); list.add(VfsResource.normalize(child.getName().getURI())); } } return list; }
/** * Locates a file object, by absolute URI. */ public FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions properties) throws FileSystemException { // Split the URI up into its parts final LayeredFileName name = (LayeredFileName) parseUri(baseFile!=null?baseFile.getName():null, uri); // Make the URI canonical // Resolve the outer file name final FileName fileName = name.getOuterName(); final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), properties); // Create the file system final FileObject rootFile = createFileSystem(name.getScheme(), file, properties); // Resolve the file return rootFile.resolveFile(name.getPath()); }
/** * Gets the parent of a given path. {@inheritDoc} * @param path Path * @return Parent of <code>path</code> */ @Override public String getParent(String path) { String result; try { result = getFileSystemManager().resolveFile(path).getParent().getName().getURI(); } catch (FileSystemException e) { throw new CargoException("Failed to get parent for path [" + path + "]", e); } return result; }
/** * Get the children of a directory. {@inheritDoc} * @param directory Directory to which to get the children. * @return Children of <code>directory</code>. */ @Override public String[] getChildren(String directory) { String[] results; try { FileObject[] files = getFileSystemManager().resolveFile(directory).getChildren(); results = new String[files.length]; for (int i = 0; i < files.length; i++) { results[i] = files[i].getName().getURI(); } } catch (FileSystemException e) { throw new CargoException("Failed to get childrens for [" + directory + "]", e); } return results; } }
io.info("Path: {}", file.getName().getPath()); io.info("Scheme: {}", file.getName().getScheme()); io.info("URI: {}", file.getName().getURI()); io.info("Root URI: {}", file.getName().getRootURI()); io.info("Parent: {}", file.getName().getParent());
io.info("Path: {}", file.getName().getPath()); io.info("Scheme: {}", file.getName().getScheme()); io.info("URI: {}", file.getName().getURI()); io.info("Root URI: {}", file.getName().getRootURI()); io.info("Parent: {}", file.getName().getParent());