private void removeSharedResourcePermissions(
            String bucket, String location, ResourceDescriptor resource, Set<ResourceAccessType> permissionsToRemove) {
        ResourceDescriptor sharedWithMeResource = getShareResource(ResourceTypes.SHARED_WITH_ME, resource.getType(), bucket, location);
        String link = resource.getUrl();
        MutableObject<Boolean> wasReshared = new MutableObject<>();
        resourceService.computeResource(sharedWithMeResource, state -> {
            SharedResources sharedWithMe = ProxyUtil.convertToObject(state, SharedResources.class);
            if (sharedWithMe != null) {
                for (Iterator<SharedResource> iterator = sharedWithMe.getResources().iterator(); iterator.hasNext();) {
                    SharedResource sharedResource = iterator.next();
                    if (sharedResource.getUrl().equals(link)) {
                        wasReshared.setValue(sharedResource.getPermissions().contains(ResourceAccessType.SHARE));
                        sharedResource.getPermissions().removeAll(permissionsToRemove);
                        if (sharedResource.getPermissions().isEmpty()) {
                            iterator.remove();
                            break;
                        }
                    }
                }
            }

            return ProxyUtil.convertToString(sharedWithMe);
        });
        if (Boolean.TRUE.equals(wasReshared.getValue())) {
            invitationService.cleanUpResourceLink(bucket, location, resource);
        }
    }
Revoke share access for provided resources. Only resource owner can perform this operation

@param bucket              - user bucket
@param location            - storage location
@param permissionsToRevoke - collection of resources and permissions to revoke access
server/src/main/java/com/epam/aidial/core/server/service/ShareService.java