@Override
    public void setPermission(final Path file, final TransferStatus status) throws BackgroundException {
        try {
            final Path bucket = containerService.getContainer(file);
            if(containerService.isContainer(file)) {
                final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(status.getAcl());
                status.setResponse(new GoogleStorageAttributesFinderFeature(session).toAttributes(
                        session.getClient().buckets().update(bucket.getName(),
                                new Bucket().setAcl(bucketAccessControls)).execute()
                ));
            }
            else {
                final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(status.getAcl());
                final Storage.Objects.Update request = session.getClient().objects().update(bucket.getName(), containerService.getKey(file),
                        new StorageObject().setAcl(objectAccessControls));
                if(bucket.attributes().getCustom().containsKey(GoogleStorageAttributesFinderFeature.KEY_REQUESTER_PAYS)) {
                    request.setUserProject(session.getHost().getCredentials().getUsername());
                }
                status.setResponse(new GoogleStorageAttributesFinderFeature(session).toAttributes(
                        request.execute()
                ));
            }
        }
        catch(IOException e) {
            final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file);
            if(file.isDirectory()) {
                if(failure instanceof NotfoundException) {
                    // No placeholder file may exist but we just have a common prefix
                    return;
                }
            }
            // 400 Bad Request response for buckets with uniform bucket-level access enabled
            throw failure;
        }
    }
@Test(expected = NotfoundException.class)
    public void testWriteNotFound() throws Exception {
        final Path container = new Path("cyberduck-test-eu", EnumSet.of(Path.Type.directory));
        final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        final GoogleStorageAccessControlListFeature f = new GoogleStorageAccessControlListFeature(session);
        final Acl acl = new Acl();
        acl.addAll(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ));
        f.setPermission(test, acl);
    }