/** * Determines if this file can be written to. * * @return {@code true} if this file is writeable, {@code false} if not. * @throws FileSystemException if an error occurs. */ @Override public boolean isWriteable() throws FileSystemException { return getFileSystem().hasCapability(Capability.WRITE_CONTENT); }
/** * Determines if this file can be written to. * * @return {@code true} if this file is writeable, {@code false} if not. * @throws FileSystemException if an error occurs. */ @Override public boolean isWriteable() throws FileSystemException { return getFileSystem().hasCapability(Capability.WRITE_CONTENT); }
/** * Determines if this file can be written to. * * @return {@code true} if this file is writeable, {@code false} if not. * @throws FileSystemException if an error occurs. */ @Override public boolean isWriteable() throws FileSystemException { return getFileSystem().hasCapability(Capability.WRITE_CONTENT); }
private SharedRandomContentInputStream(final Set<SharedRandomContentInputStream> createdStreams, final FileObject fo, final long fileStart, final long fileEnd, final InputStream is) throws FileSystemException { super(is); if (!fo.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ)) { throw new FileSystemException("vfs.util/missing-capability.error", Capability.RANDOM_ACCESS_READ); } this.fo = fo; this.fileStart = fileStart; this.fileEnd = fileEnd; this.createdStreams = createdStreams; synchronized (createdStreams) { createdStreams.add(this); } }
private SharedRandomContentInputStream(final Set<SharedRandomContentInputStream> createdStreams, final FileObject fo, final long fileStart, final long fileEnd, final InputStream is) throws FileSystemException { super(is); if (!fo.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ)) { throw new FileSystemException("vfs.util/missing-capability.error", Capability.RANDOM_ACCESS_READ); } this.fo = fo; this.fileStart = fileStart; this.fileEnd = fileEnd; this.createdStreams = createdStreams; synchronized(createdStreams) { createdStreams.add(this); } }
/** * Handles an out-of-date file. * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } }
/** * Handles an out-of-date file. * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } }
/** * Handles an out-of-date file. * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } }
public Part createCommunicationLink() throws IOException, MessagingException { if (mimeStream != null) { closeMimeStream(); } final FileObject parentLayer = getParentLayer(); if (!parentLayer.exists()) { return null; } if (parentLayer.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ)) { mimeStream = new SharedRandomContentInputStream(parentLayer); } else { mimeStream = getParentLayer().getContent().getInputStream(); } return new MimeMessage(null, mimeStream); } }
/** * Handles a single source file. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { if (!tryRename || !srcFile.canRenameTo(destFile)) { super.handleOutOfDateFile(srcFile, destFile); log("Deleting " + srcFile.getPublicURIString()); srcFile.delete(Selectors.SELECT_SELF); } else { log("Rename " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); srcFile.moveTo(destFile); if (!isPreserveLastModified() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { destFile.getContent().setLastModifiedTime(System.currentTimeMillis()); } } } }
/** * Handles a single source file. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { if (!tryRename || !srcFile.canRenameTo(destFile)) { super.handleOutOfDateFile(srcFile, destFile); log("Deleting " + srcFile.getPublicURIString()); srcFile.delete(Selectors.SELECT_SELF); } else { log("Rename " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); srcFile.moveTo(destFile); if (!isPreserveLastModified() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { destFile.getContent().setLastModifiedTime(System.currentTimeMillis()); } } } }
/** * Handles a single source file. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { if (!tryRename || !srcFile.canRenameTo(destFile)) { super.handleOutOfDateFile(srcFile, destFile); log("Deleting " + srcFile.getPublicURIString()); srcFile.delete(Selectors.SELECT_SELF); } else { log("Rename " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); srcFile.moveTo(destFile); if (!isPreserveLastModified() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { destFile.getContent().setLastModifiedTime(System.currentTimeMillis()); } } } }
/** * Tests that folders have no content. */ public void testFolderURL() throws Exception { final FileObject folder = getReadFolder().resolveFile("dir1"); if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test might not fail on e.g. HttpFileSystem as there are no direcotries. // A Directory do have a content on http. e.g a generated directory listing or the index.html page. return; } assertTrue(folder.exists()); // Try getting the content of a folder try { folder.getURL().openConnection().getInputStream(); fail(); } catch (final IOException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } } }
/** * Tests that folders have no content. */ public void testFolderURL() throws Exception { final FileObject folder = getReadFolder().resolveFile("dir1"); if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test might not fail on e.g. HttpFileSystem as there are no direcotries. // A Directory do have a content on http. e.g a generated directory listing or the index.html page. return; } assertTrue(folder.exists()); // Try getting the content of a folder try { folder.getURL().openConnection().getInputStream(); fail(); } catch (final IOException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } } }
/** * Tests that folders have no content. */ public void testFolderContent() throws Exception { if (getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test wont fail return; } // Try getting the content of a folder final FileObject folder = getReadFolderDir1(); try { folder.getContent().getInputStream(); fail(); } catch (final FileSystemException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } }
/** * Tests that folders have no content. */ public void testFolderContent() throws Exception { if (getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test wont fail return; } // Try getting the content of a folder final FileObject folder = getReadFolderDir1(); try { folder.getContent().getInputStream(); fail(); } catch (final FileSystemException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } }
/** * Tests setting the last modified time of a folder. * * @throws FileSystemException if error occurred */ public void testSetLastModifiedFolder() throws FileSystemException { final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)) { // Try a folder final FileObject folder = getReadFolder().resolveFile("dir1"); folder.getContent().setLastModifiedTime(yesterday); final long lastModTimeAccuracy = (long) folder.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = folder.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on Folder", yesterday, lastModifiedTime, lastModTimeAccuracy); } }
/** * Tests setting the last modified time of file. * * @throws FileSystemException if error occurred */ public void testSetLastModifiedFile() throws FileSystemException { final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { // Try a file final FileObject file = getReadFolder().resolveFile("file1.txt"); file.getContent().setLastModifiedTime(yesterday); final long lastModTimeAccuracy = (long) file.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = file.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on File", yesterday, lastModifiedTime, lastModTimeAccuracy); } } }
/** * Tests setting the last modified time of a folder. * * @throws FileSystemException if error occurred */ public void testSetLastModifiedFolder() throws FileSystemException { final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)) { // Try a folder final FileObject folder = getReadFolder().resolveFile("dir1"); folder.getContent().setLastModifiedTime(yesterday); final long lastModTimeAccuracy = (long) folder.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = folder.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on Folder", yesterday, lastModifiedTime, lastModTimeAccuracy); } }
/** * Tests setting the last modified time of file. * * @throws FileSystemException if error occurred */ public void testSetLastModifiedFile() throws FileSystemException { final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { // Try a file final FileObject file = getReadFolder().resolveFile("file1.txt"); file.getContent().setLastModifiedTime(yesterday); final long lastModTimeAccuracy = (long) file.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = file.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on File", yesterday, lastModifiedTime, lastModTimeAccuracy); } } }