class GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission {

    @Override
    public void setPermission(final Path file, final Acl acl) throws BackgroundException {
        try {
            if(containerService.isContainer(file)) {
                final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl);
                session.getClient().buckets().update(containerService.getContainer(file).getName(),
                    new Bucket().setAcl(bucketAccessControls)).execute();
            }
            else {
                final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl);
                session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file),
                    new StorageObject().setAcl(objectAccessControls)).execute();
            }
        }
        catch(IOException e) {
            final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file);
            if(file.isPlaceholder()) {
                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;
        }
    }

    public  GoogleStorageAccessControlListFeature(final GoogleStorageSession session);

}