@Test public void testSetTimestamp() throws Exception { final Path home = new FTPWorkdirService(session).find(); final long modified = System.currentTimeMillis(); final Path test = new Path(new FTPWorkdirService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new FTPTouchFeature(session).touch(test, new TransferStatus()); new FTPMFMTTimestampFeature(session).setTimestamp(test, modified); assertEquals(modified / 1000 * 1000, new FTPListService(session, null, TimeZone.getDefault()).list(home, new DisabledListProgressListener()).get(test).attributes().getModificationDate()); new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(status.getTimestamp(), TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } }
FTPMFMTTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(status.getTimestamp(), TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } }
FTPMFMTTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(status.getTimestamp(), TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } FTPMFMTTimestampFeature(final FTPSession session); }
FTPMFMTTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(status.getTimestamp(), TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } FTPMFMTTimestampFeature(final FTPSession session); @Override void setTimestamp(final Path file, final TransferStatus status); }
FTPMFMTTimestampFeature extends DefaultTimestampFeature implements Timestamp { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(status.getTimestamp(), TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } FTPMFMTTimestampFeature(final FTPSession session); @Override void setTimestamp(final Path file, final TransferStatus status);  }