@Test(expected = NotfoundException.class) public void testWriteNotFound() throws Exception { final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final S3AccessControlListFeature f = new S3AccessControlListFeature(session); final Acl acl = new Acl(); acl.addAll(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ)); f.setPermission(test, acl); }
@Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { final Path container = containerService.getContainer(file); if(null == acl.getOwner()) { acl.setOwner(file.attributes().getAcl().getOwner()); } if(null == acl.getOwner()) { final Acl permission = this.getPermission(container); acl.setOwner(permission.getOwner()); } if(containerService.isContainer(file)) { session.getClient().putBucketAcl(container.getName(), this.convert(acl)); } else { if(file.isFile() || file.isPlaceholder()) { session.getClient().putObjectAcl(container.getName(), containerService.getKey(file), this.convert(acl)); } } } catch(ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } }
S3AccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { final Path container = containerService.getContainer(file); if(null == acl.getOwner()) { acl.setOwner(file.attributes().getAcl().getOwner()); } if(null == acl.getOwner()) { final Acl permission = this.getPermission(container); acl.setOwner(permission.getOwner()); } if(containerService.isContainer(file)) { session.getClient().putBucketAcl(container.getName(), this.convert(acl)); } else { if(file.isFile() || file.isPlaceholder()) { session.getClient().putObjectAcl(container.getName(), containerService.getKey(file), this.convert(acl)); } } } catch(ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } }
S3AccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { final Path container = containerService.getContainer(file); if(null == acl.getOwner()) { acl.setOwner(file.attributes().getAcl().getOwner()); } if(null == acl.getOwner()) { final Acl permission = this.getPermission(container); acl.setOwner(permission.getOwner()); } if(containerService.isContainer(file)) { session.getClient().putBucketAcl(container.getName(), this.convert(acl)); } else { if(file.isFile() || file.isPlaceholder()) { session.getClient().putObjectAcl(container.getName(), containerService.getKey(file), this.convert(acl)); } } } catch(ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } S3AccessControlListFeature(final S3Session session); }
S3AccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { final Path container = containerService.getContainer(file); if(null == acl.getOwner()) { acl.setOwner(file.attributes().getAcl().getOwner()); } if(null == acl.getOwner()) { final Acl permission = this.getPermission(container); acl.setOwner(permission.getOwner()); } if(containerService.isContainer(file)) { session.getClient().putBucketAcl(container.getName(), this.convert(acl)); } else { if(file.isFile() || file.isPlaceholder()) { session.getClient().putObjectAcl(container.getName(), containerService.getKey(file), this.convert(acl)); } } } catch(ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } S3AccessControlListFeature(final S3Session session); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files); @Override List<Acl.User> getAvailableAclUsers(); }
S3AccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { final Path container = containerService.getContainer(file); if(null == acl.getOwner()) { acl.setOwner(file.attributes().getAcl().getOwner()); } if(null == acl.getOwner()) { final Acl permission = this.getPermission(container); acl.setOwner(permission.getOwner()); } if(containerService.isContainer(file)) { session.getClient().putBucketAcl(container.getName(), this.convert(acl)); } else { if(file.isFile() || file.isPlaceholder()) { session.getClient().putObjectAcl(container.getName(), containerService.getKey(file), this.convert(acl)); } } } catch(ServiceException e) { final BackgroundException failure = new S3ExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } S3AccessControlListFeature(final S3Session session); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files); @Override List<Acl.User> getAvailableAclUsers();  }