@Test public void testTouch() throws Exception { final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname())); assertNotNull(session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback())); assertTrue(session.isConnected()); assertNotNull(session.getClient()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path workdir = new LocalHomeFinderFeature(session).find(); final Path test = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new LocalTouchFeature(session).touch(test, new TransferStatus()); new LocalTouchFeature(session).touch(test, new TransferStatus()); assertTrue(new LocalFindFeature(session).find(test)); final AttributedList<Path> list = new LocalListService(session).list(workdir, new DisabledListProgressListener()); assertTrue(list.contains(test)); new LocalDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); }
LocalTouchFeature implements Touch { @Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); } }
LocalTouchFeature implements Touch { @Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); } LocalTouchFeature(final LocalSession session); }
LocalTouchFeature implements Touch { @Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); } LocalTouchFeature(final LocalSession session); @Override Path touch(final Path file, final TransferStatus status); @Override Touch withWriter(final Write writer); }
LocalTouchFeature implements Touch { @Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); } LocalTouchFeature(final LocalSession session); @Override Path touch(final Path file, final TransferStatus status); @Override Touch withWriter(final Write writer);  }