@Test public void testOpen() throws Exception { final AtomicBoolean t = new AtomicBoolean(); final NullSession session = new NullTransferSession(new Host(new TestProtocol())) { @Override @SuppressWarnings("unchecked") public <T> T _getFeature(final Class<T> type) { if(type.equals(Read.class)) { return (T) new Read() { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) { t.set(true); return IOUtils.toInputStream("content", Charset.defaultCharset()); } @Override public boolean offset(final Path file) { assertEquals(new Path("/f", EnumSet.of(Path.Type.file)), file); return false; } }; } return super._getFeature(type); } }; final AtomicBoolean e = new AtomicBoolean(); final Path file = new Path("/f", EnumSet.of(Path.Type.file)); file.attributes().setSize("content".getBytes().length); final AbstractEditor editor = new AbstractEditor(new Application("com.editor"), new StatelessSessionPool(new TestLoginConnectionService(), session, PathCache.empty(), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), file, new DisabledProgressListener()) { @Override public void close() { } @Override protected void edit(final ApplicationQuitCallback quit, final FileWatcherListener listener) { e.set(true); } @Override protected void watch(final Local local, final FileWatcherListener listener) { } }; editor.open(new DisabledApplicationQuitCallback(), new DisabledTransferErrorCallback(), new DisabledFileWatcherListener()).run(session); assertTrue(t.get()); assertNotNull(editor.getLocal()); assertTrue(e.get()); assertTrue(editor.getLocal().exists()); }
@Override public Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener) { final Worker<Transfer> worker = new EditOpenWorker(session.getHost(), this, error, new ApplicationQuitCallback() { @Override public void callback() { quit.callback(); close(); delete(); } }, this.listener, listener, notification) { @Override public void cleanup(final Transfer download) { try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e)); } } }; if(log.isDebugEnabled()) { log.debug(String.format("Download file for edit %s", local)); } return worker; }
AbstractEditor implements Editor { @Override public Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener) { final Worker<Transfer> worker = new EditOpenWorker(session.getHost(), this, error, new ApplicationQuitCallback() { @Override public void callback() { quit.callback(); close(); delete(); } }, this.listener, listener, notification) { @Override public void cleanup(final Transfer download) { try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e)); } } }; if(log.isDebugEnabled()) { log.debug(String.format("Download file for edit %s", local)); } return worker; } }
AbstractEditor implements Editor { @Override public Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener) { final Worker<Transfer> worker = new EditOpenWorker(session.getHost(), this, error, new ApplicationQuitCallback() { @Override public void callback() { quit.callback(); close(); delete(); } }, this.listener, listener, notification) { @Override public void cleanup(final Transfer download) { try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e)); } } }; if(log.isDebugEnabled()) { log.debug(String.format("Download file for edit %s", local)); } return worker; } AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ProgressListener listener);  AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ApplicationLauncher launcher,
                          final ApplicationFinder finder,
                          final ProgressListener listener); }
AbstractEditor implements Editor { @Override public Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener) { final Worker<Transfer> worker = new EditOpenWorker(session.getHost(), this, error, new ApplicationQuitCallback() { @Override public void callback() { quit.callback(); close(); delete(); } }, this.listener, listener, notification) { @Override public void cleanup(final Transfer download) { try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e)); } } }; if(log.isDebugEnabled()) { log.debug(String.format("Download file for edit %s", local)); } return worker; } AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ProgressListener listener);  AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ApplicationLauncher launcher,
                          final ApplicationFinder finder,
                          final ProgressListener listener); Path getRemote(); Local getLocal(); Application getApplication(); boolean isModified(); void setModified(boolean modified); @Override void delete(); @Override Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener); @Override Worker<Transfer> save(final TransferErrorCallback error); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
AbstractEditor implements Editor { @Override public Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener) { final Worker<Transfer> worker = new EditOpenWorker(session.getHost(), this, error, new ApplicationQuitCallback() { @Override public void callback() { quit.callback(); close(); delete(); } }, this.listener, listener, notification) { @Override public void cleanup(final Transfer download) { try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e)); } } }; if(log.isDebugEnabled()) { log.debug(String.format("Download file for edit %s", local)); } return worker; } AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ProgressListener listener);  AbstractEditor(final Application application,
                          final SessionPool session,
                          final Path file,
                          final ApplicationLauncher launcher,
                          final ApplicationFinder finder,
                          final ProgressListener listener); Path getRemote(); Local getLocal(); Application getApplication(); boolean isModified(); void setModified(boolean modified); @Override void delete(); @Override Worker<Transfer> open(final ApplicationQuitCallback quit, final TransferErrorCallback error, final FileWatcherListener listener); @Override Worker<Transfer> save(final TransferErrorCallback error); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }