@Test public void testSetTimestamp() throws Exception { final Path home = new SFTPHomeDirectoryService(session).find(); final Path test = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new SFTPTouchFeature(session).touch(test, new TransferStatus()); final long modified = System.currentTimeMillis(); new SFTPTimestampFeature(session).setTimestamp(test, modified); assertEquals(TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(modified)), new SFTPAttributesFinderFeature(session).find(test).getModificationDate()); assertEquals(TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(modified)), new DefaultAttributesFinderFeature(session).find(test).getModificationDate()); new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, status.getTimestamp() / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } }
SFTPTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, status.getTimestamp() / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } }
SFTPTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, status.getTimestamp() / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } SFTPTimestampFeature(final SFTPSession session); }
SFTPTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, status.getTimestamp() / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } SFTPTimestampFeature(final SFTPSession session); @Override void setTimestamp(final Path file, final TransferStatus status); }
SFTPTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, status.getTimestamp() / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } SFTPTimestampFeature(final SFTPSession session); @Override void setTimestamp(final Path file, final TransferStatus status);  }