@Test public void testMakeDirectory() throws Exception { final Path test = new Path(new SFTPHomeDirectoryService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); new SFTPDirectoryFeature(session).mkdir(test, null, new TransferStatus()); assertTrue(new SFTPFindFeature(session).find(test)); new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); }
SFTPDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); } }
SFTPDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); } SFTPDirectoryFeature(final SFTPSession session); }
SFTPDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); } SFTPDirectoryFeature(final SFTPSession session); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override SFTPDirectoryFeature withWriter(final Write<Void> writer); }
SFTPDirectoryFeature implements Directory<Void> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final FileAttributes attrs; if(Permission.EMPTY != status.getPermission()) { attrs = new FileAttributes.Builder().withPermissions(Integer.parseInt(status.getPermission().getMode(), 8)).build(); } else { attrs = FileAttributes.EMPTY; } session.sftp().makeDir(folder.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new SFTPAttributesFinderFeature(session).find(folder)); } SFTPDirectoryFeature(final SFTPSession session); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override SFTPDirectoryFeature withWriter(final Write<Void> writer);  }