class ResourceSetService {

    Promise<Void, ResourceException> revokeAllPolicies(final Context context, String realm,
                                                       String resourceOwnerId) {
        ResourceSetWithPolicyQuery query = new ResourceSetWithPolicyQuery();
        query.setResourceSetQuery(QueryFilter.<String>alwaysTrue());
        return getResourceSets(context, realm, query, resourceOwnerId, false)
                .thenAsync(new AsyncFunction<Collection<ResourceSetDescription>, Void, ResourceException>() {
                    @Override
                    public Promise<Void, ResourceException> apply(Collection<ResourceSetDescription> resourceSets) {
                        List<Promise<Void, ResourceException>> promises
                                = new ArrayList<Promise<Void, ResourceException>>();
                        PromiseImpl<Void, ResourceException> kicker = PromiseImpl.create();
                        promises.add(kicker);
                        for (ResourceSetDescription resourceSet : resourceSets) {
                            promises.add(policyService.deletePolicy(context, resourceSet.getId())
                                    .thenCatchAsync(IGNORE_NOTFOUNDEXCEPTION));
                        }
                        Promise<List<Void>, ResourceException> when = Promises.when(promises);
                        kicker.handleResult(null);
                        return when.thenAsync(new AsyncFunction<List<Void>, Void, ResourceException>() {
                            @Override
                            public Promise<Void, ResourceException> apply(List<Void> voids) {
                                return newResultPromise(null);
                            }
                        });
                    }
                });
    }

    @Inject public  ResourceSetService(ResourceSetStoreFactory resourceSetStoreFactory, UmaPolicyService policyService,
            CoreWrapper coreWrapper, UmaProviderSettingsFactory umaProviderSettingsFactory);

}