/** * Updates the attribute value for the given attribute domain and name. If the element is not writable or the * attribute could not be updated for any other reason, the method will return false. This method only returns true, * if the attribute has been updated successfully. * * @param domain the attribute domain. * @param key the attribute name * @param value the new attribute value. * @return true, if the update was successful, false otherwise. */ public boolean setAttribute( final String domain, final String key, final Object value ) { try { if ( LibRepositoryBoot.REPOSITORY_DOMAIN.equals( domain ) ) { if ( LibRepositoryBoot.VERSION_ATTRIBUTE.equals( key ) ) { if ( value instanceof Date ) { final Date date = (Date) value; backend.getContent().setLastModifiedTime( date.getTime() ); return true; } else if ( value instanceof Number ) { final Number time = (Number) value; backend.getContent().setLastModifiedTime( time.longValue() ); return true; } } } return false; } catch ( FileSystemException ex ) { throw new RuntimeException( ex ); } }
if ( setOriginalModificationDate ) { newFileObject.getContent().setLastModifiedTime( item.getContent().getLastModifiedTime() );
@Override public void setLastModifiedTime( final long l ) throws FileSystemException { fileContent.setLastModifiedTime( l ); }
/** * Sets the last-modified time of this file. * * @since 2.0 */ @Override protected boolean doSetLastModifiedTime(final long modtime) throws Exception { file.getContent().setLastModifiedTime(modtime); return true; }
/** * Sets the last-modified time of this file. * * @since 2.0 */ @Override protected boolean doSetLastModifiedTime(final long modtime) throws Exception { file.getContent().setLastModifiedTime(modtime); return true; }
/** * Sets the last-modified time of this file. * * @since 2.0 */ @Override protected boolean doSetLastModifiedTime(final long modtime) throws Exception { file.getContent().setLastModifiedTime(modtime); return true; }
/** * Sets the last-modified time of this file. * @since 2.0 */ @Override protected boolean doSetLastModifiedTime(final long modtime) throws Exception { file.getContent().setLastModifiedTime(modtime); return true; }
public static void main(final String[] args) throws Exception { if (args.length == 0) { System.err.println("Please pass the name of a file as parameter."); return; } final FileObject fo = VFS.getManager().resolveFile(args[0]); final long setTo = System.currentTimeMillis(); System.err.println("set to: " + setTo); fo.getContent().setLastModifiedTime(setTo); System.err.println("after set: " + fo.getContent().getLastModifiedTime()); }
/** * Does a 'touch' command. */ private void touch(final String[] cmd) throws Exception { if (cmd.length < 2) { throw new Exception("USAGE: touch <path>"); } final FileObject file = mgr.resolveFile(cwd, cmd[1]); if (!file.exists()) { file.createFile(); } file.getContent().setLastModifiedTime(System.currentTimeMillis()); }
@Test public void testSetLastModifiedTime() throws Exception { decorated.setLastModifiedTime( 100L ); verify( fileContent ).setLastModifiedTime( 100L ); }
/** * Set the last modified time of a fileObject, if the fileObject is writable. * @param fileObject the file object * @throws DataStoreException if the fileObject is writable but modifying the date fails */ private void updateLastModifiedTime(FileObject fileObject) throws DataStoreException { try { if (isTouchFilePreferred()) { getTouchFileObject(fileObject, true); } else { long time = System.currentTimeMillis() + ACCESS_TIME_RESOLUTION; fileObject.getContent().setLastModifiedTime(time); } } catch (FileSystemException e) { throw new DataStoreException("An IO Exception occurred while trying to set the last modified date: " + fileObject.getName().getFriendlyURI(), e); } }
/** * 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 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); } }
/** * 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 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 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); } }