@Test(expected = InteroperabilityException.class) public void testSetUnixPermission() throws Exception { final FTPWorkdirService workdir = new FTPWorkdirService(session); final Path home = workdir.find(); final Path test = new Path(workdir.find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new FTPTouchFeature(session).touch(test, new TransferStatus()); new FTPUnixPermissionFeature(session).setUnixPermission(test, new Permission(666)); assertEquals("666", new FTPListService(session, null, TimeZone.getDefault()).list(home, new DisabledListProgressListener()).get(test).attributes().getPermission().getMode()); new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting permission for %s due to previous failure %s", file, failure.getMessage())); } throw failure; } try { if(!session.getClient().sendSiteCommand(String.format("CHMOD %s %s", permission.getMode(), file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw failure = new FTPExceptionMappingService().map("Cannot change permissions of {0}", e, file); } }
FTPUnixPermissionFeature extends DefaultUnixPermissionFeature implements UnixPermission { @Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting permission for %s due to previous failure %s", file, failure.getMessage())); } throw failure; } try { if(!session.getClient().sendSiteCommand(String.format("CHMOD %s %s", permission.getMode(), file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw failure = new FTPExceptionMappingService().map("Cannot change permissions of {0}", e, file); } } }
FTPUnixPermissionFeature extends DefaultUnixPermissionFeature implements UnixPermission { @Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting permission for %s due to previous failure %s", file, failure.getMessage())); } throw failure; } try { if(!session.getClient().sendSiteCommand(String.format("CHMOD %s %s", permission.getMode(), file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw failure = new FTPExceptionMappingService().map("Cannot change permissions of {0}", e, file); } } FTPUnixPermissionFeature(final FTPSession session); }
FTPUnixPermissionFeature extends DefaultUnixPermissionFeature implements UnixPermission { @Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting permission for %s due to previous failure %s", file, failure.getMessage())); } throw failure; } try { if(!session.getClient().sendSiteCommand(String.format("CHMOD %s %s", permission.getMode(), file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw failure = new FTPExceptionMappingService().map("Cannot change permissions of {0}", e, file); } } FTPUnixPermissionFeature(final FTPSession session); @Override void setUnixOwner(final Path file, final String owner); @Override void setUnixGroup(final Path file, final String group); @Override Permission getUnixPermission(final Path file); @Override void setUnixPermission(final Path file, final Permission permission); }
FTPUnixPermissionFeature extends DefaultUnixPermissionFeature implements UnixPermission { @Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting permission for %s due to previous failure %s", file, failure.getMessage())); } throw failure; } try { if(!session.getClient().sendSiteCommand(String.format("CHMOD %s %s", permission.getMode(), file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw failure = new FTPExceptionMappingService().map("Cannot change permissions of {0}", e, file); } } FTPUnixPermissionFeature(final FTPSession session); @Override void setUnixOwner(final Path file, final String owner); @Override void setUnixGroup(final Path file, final String group); @Override Permission getUnixPermission(final Path file); @Override void setUnixPermission(final Path file, final Permission permission);  }