private void assertIsFile(String filePath) throws FileSystemException { if (!isFile(filePath)) { throw new FileSystemException(filePath + " is a folder"); } }
private void assertExistence(String path) throws FileSystemException { if (!exists(path)) { throw new FileSystemException("no such file " + path); } }
private void assertIsFile(String filePath) throws FileSystemException { if (!isFile(filePath)) { throw new FileSystemException(filePath + " is a folder"); } }
private void assertExistence(String path) throws FileSystemException { if (!exists(path)) { throw new FileSystemException("no such file " + path); } }
/** * {@inheritDoc} */ public String[] list(String folderPath) throws FileSystemException { File f = new File(root, osPath(folderPath)); String[] entries = f.list(); if (entries == null) { String msg = folderPath + " does not denote a folder"; log.debug(msg); throw new FileSystemException(msg); } return entries; }
/** * {@inheritDoc} */ public String[] list(String folderPath) throws FileSystemException { File f = new File(root, osPath(folderPath)); String[] entries = f.list(); if (entries == null) { String msg = folderPath + " does not denote a folder"; log.debug(msg); throw new FileSystemException(msg); } return entries; }
/** * {@inheritDoc} */ public String[] list(String folderPath) throws FileSystemException { File f = new File(root, osPath(folderPath)); String[] entries = f.list(); if (entries == null) { String msg = folderPath + " does not denote a folder"; log.debug(msg); throw new FileSystemException(msg); } return entries; }
/** * {@inheritDoc} */ public OutputStream getOutputStream(String filePath) throws FileSystemException { File f = new File(root, osPath(filePath)); try { return new FileOutputStream(f); } catch (FileNotFoundException fnfe) { String msg = "failed to get output stream for " + f.getPath(); log.debug(msg); throw new FileSystemException(msg, fnfe); } }
/** * {@inheritDoc} */ public OutputStream getOutputStream(String filePath) throws FileSystemException { File f = new File(root, osPath(filePath)); try { return new FileOutputStream(f); } catch (FileNotFoundException fnfe) { String msg = "failed to get output stream for " + f.getPath(); log.debug(msg); throw new FileSystemException(msg, fnfe); } }
@Override public void deleteFile(String filePath) throws FileSystemException { try { final FileObject fo = resolveFileObject(filePath); if (!fo.isFile()) { throw new FileSystemException("File doesn't exist at " + filePath + "."); } fo.delete(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to delete file at " + filePath; log.debug(msg, e); throw new FileSystemException(msg, e); } }
@Override public boolean isFile(String path) throws FileSystemException { try { final FileObject fo = resolveFileObject(path); return fo.isFile(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to check if it is a file at " + path + "."; log.debug(msg, e); throw new FileSystemException(msg, e); } }
@Override public boolean exists(String path) throws FileSystemException { try { final FileObject fo = resolveFileObject(path); return fo.exists(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to check if file exists at " + path + "."; log.debug(msg, e); throw new FileSystemException(msg, e); } }
@Override public boolean isFolder(String path) throws FileSystemException { try { final FileObject fo = resolveFileObject(path); return fo.isFolder(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to check if it is a folder at " + path + "."; log.debug(msg, e); throw new FileSystemException(msg, e); } }
/** * {@inheritDoc} */ @Override public void close() throws FileSystemException { super.close(); if (shutdownOnClose) { try { ((DerbyConnectionHelper) conHelper).shutDown(driver); } catch (SQLException e) { throw new FileSystemException("failed to shutdown Derby", e); } } } }
/** * {@inheritDoc} */ @Override public void close() throws FileSystemException { super.close(); if (shutdownOnClose) { try { ((DerbyConnectionHelper) conHelper).shutDown(driver); } catch (SQLException e) { throw new FileSystemException("failed to shutdown Derby", e); } } } }
@Override public long lastModified(String path) throws FileSystemException { try (final FileObject fo = resolveFileObject(path)) { return fo.getContent().getLastModifiedTime(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to get the last modified time of the file at " + path + "."; log.debug(msg, e); throw new FileSystemException(msg, e); } }
@Override public long length(String filePath) throws FileSystemException { try (final FileObject fo = resolveFileObject(filePath)) { return fo.getContent().getSize(); } catch (org.apache.commons.vfs2.FileSystemException e) { final String msg = "Failed to get the length of the file at " + filePath + "."; log.debug(msg, e); throw new FileSystemException(msg, e); } }
/** * {@inheritDoc} */ public void createFolder(String folderPath) throws FileSystemException { if (!initialized) { throw new IllegalStateException("not initialized"); } FileSystemPathUtil.checkFormat(folderPath); if (!exists(folderPath)) { createDeepFolder(folderPath); } else { throw new FileSystemException("file system entry already exists: " + folderPath); } }
private void assertIsFolder(String folderPath) throws FileSystemException { assertExistence(folderPath); if (!getEntry(folderPath).isFolder()) { throw new FileSystemException("Folder " + folderPath + " does not exist"); } }
private void assertIsFolder(String folderPath) throws FileSystemException { assertExistence(folderPath); if (!getEntry(folderPath).isFolder()) { throw new FileSystemException("Folder " + folderPath + " does not exist"); } }