List of usage examples for org.apache.commons.vfs2 FileObject exists
boolean exists() throws FileSystemException;
From source file:com.stratuscom.harvester.FileUtilityImpl.java
public FileObject getWorkingDirectory(String name) throws IOException { FileObject workDir = getProfileDirectory().resolveFile(Strings.WORK).resolveFile(name); if (!workDir.exists()) { workDir.createFolder();/*from w ww. j av a 2s . c o m*/ } return workDir; }
From source file:com.sonicle.webtop.vfs.sfs.StoreFileSystem.java
private void initRootFileObject() throws FileSystemException { configureOptions();// w w w.ja v a2 s . c om FileSystemManager fsm = VFS.getManager(); FileObject fo = fsm.resolveFile(uri.toString(), fso); if (autoCreateRoot && !fo.exists()) fo.createFolder(); if (fo.exists()) rootFo = fo; }
From source file:com.collective.celos.ci.mode.test.TestRunCelosServerModeEmbedded.java
public void copyRemoteDefaultsToLocal(String username, URI defaultsDirUri) throws URISyntaxException, FileSystemException { JScpWorker worker = new JScpWorker(username); if (defaultsDirUri != null) { FileObject remoteDefaultsDir = worker.getFileObjectByUri(defaultsDirUri); if (remoteDefaultsDir.exists()) { FileObject localDefaultsDir = worker.getFileObjectByUri(getCelosDefaultsDir()); localDefaultsDir.copyFrom(remoteDefaultsDir, Selectors.SELECT_CHILDREN); }//w w w .j a v a 2 s .c om } }
From source file:com.google.code.docbook4j.XslURIResolver.java
public Source resolve(String href, String base) throws TransformerException { log.debug("Resolving href={} for base={}", href, base); if (href == null || href.trim().length() == 0) return null; if (docbookXslBase == null && href.startsWith("res:") && href.endsWith("docbook.xsl")) { try {/* ww w. java 2 s . co m*/ docbookXslBase = FileObjectUtils.resolveFile(href).getParent().getURL().toExternalForm(); } catch (FileSystemException e) { docbookXslBase = null; } } String normalizedBase = null; if (base != null) { try { normalizedBase = FileObjectUtils.resolveFile(base).getParent().getURL().toExternalForm(); } catch (FileSystemException e) { normalizedBase = null; } } try { FileObject urlFileObject = FileObjectUtils.resolveFile(href, normalizedBase); if (!urlFileObject.exists()) throw new FileSystemException("File object not found: " + urlFileObject); return new StreamSource(urlFileObject.getContent().getInputStream(), urlFileObject.getURL().toExternalForm()); } catch (FileSystemException e) { // not exists for given base? try with docbook base... try { if (docbookXslBase != null) { FileObject urlFileObject = FileObjectUtils.resolveFile(href, docbookXslBase); return new StreamSource(urlFileObject.getContent().getInputStream(), urlFileObject.getURL().toExternalForm()); } } catch (FileSystemException e1) { // do nothing. } log.error("Error resolving href=" + href + " for base=" + base, e); } return null; }
From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java
public FileObject resolve(final String path) throws FileSystemException { FileObject res = fsManager.resolveFile(MEM_PREFIX + path); if (!res.exists()) { res = fsManager.resolveFile(RES_PREFIX + path); }/*from w ww. j av a 2 s .com*/ if (!res.exists()) { throw new FileSystemException("Unresolved path " + path); } return res; }
From source file:net.sourceforge.fullsync.fs.connection.CommonsVfsConnection.java
@Override public final Map<String, File> getChildren(final File dir) throws IOException { try {//from ww w. j a v a2 s .co m Map<String, File> children = new HashMap<>(); FileObject obj = base.resolveFile(dir.getPath()); if (obj.exists() && (obj.getType() == FileType.FOLDER)) { FileObject[] list = obj.getChildren(); for (FileObject element : list) { children.put(element.getName().getBaseName(), buildNode(dir, element)); } } return children; } catch (org.apache.commons.vfs2.FileSystemException fse) { throw new IOException(fse.getMessage(), fse); } }
From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java
public FileObject putInMemory(final InputStream is, final String path) throws IOException { final FileObject memObject = fsManager.resolveFile(MEM_PREFIX + path); if (memObject.exists()) { memObject.delete();//from www . j a v a2s. c o m } // create in-memory file memObject.createFile(); // read in-memory content final OutputStream os = memObject.getContent().getOutputStream(); IOUtils.copy(is, os); IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); return memObject; }
From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java
public void deleteFile(final String relativePath) { for (Accept accept : Accept.values()) { final String path = getAbsolutePath(relativePath, accept); LOG.info("Delete {}", path); try {//w ww .j av a 2 s . c o m final FileObject fileObject = fsManager.resolveFile(MEM_PREFIX + path); if (fileObject.exists()) { fileObject.delete(); } } catch (IOException ignore) { // ignore exception } } }
From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java
public InputStream readFile(final String relativePath, final Accept accept) { final String path = getAbsolutePath(relativePath, accept); LOG.info("Read {}", path); try {/*from w w w . java 2 s . com*/ FileObject fileObject = fsManager.resolveFile(MEM_PREFIX + path); if (!fileObject.exists()) { LOG.warn("In-memory path '{}' not found", path); try { fileObject = fsManager.resolveFile(RES_PREFIX + path); fileObject = putInMemory(fileObject.getContent().getInputStream(), path); } catch (FileSystemException fse) { LOG.warn("Resource path '{}' not found", path, fse); } } if (!fileObject.exists()) { throw new NotFoundException(); } // return new in-memory content return fileObject.getContent().getInputStream(); } catch (IOException e) { throw new NotFoundException(e); } }
From source file:de.innovationgate.wgpublisher.design.sync.DesignDeployment.java
public void resetUpdateInformation() throws InstantiationException, IllegalAccessException, IOException, WGDesignSyncException { _timestampOfCodeFile = getCodeFile().getContent().getLastModifiedTime(); _codeFileSize = getCodeFile().getContent().getSize(); FileObject metadataFile = getMetadataFile(); if (metadataFile.exists()) { _timestampOfMetadataFile = metadataFile.getContent().getLastModifiedTime(); }/*from w w w . ja v a 2 s. co m*/ }