private void validateShareResourcesRequest(ShareResourcesRequest request) {
        Set<SharedResource> sharedResources = request.getResources();
        if (sharedResources.isEmpty()) {
            throw new IllegalArgumentException("No resources provided");
        }
        Set<String> owners = new HashSet<>();
        for (SharedResource resource : sharedResources) {
            if (resource.getPermissions() == null) {
                resource.setPermissions(ResourceAccessType.READ_ONLY);
            } else if (resource.getPermissions().size() == 1 && resource.getPermissions().contains(ResourceAccessType.SHARE)) {
                throw new IllegalArgumentException("You're not allowed to share a resource with the permission SHARE only."
                        + " This permission is allowed along with READ and/or WRITE");
            }
            ResourceDescriptor descriptor = resourceFromUrl(resource.getUrl(), encryptionService);
            owners.add(descriptor.getBucketName());
        }
        if (owners.size() > 1) {
            throw new IllegalArgumentException("You're not allowed to share resources of different owners in a single request");
        }
    }
Initialize share request by creating invitation object

@param request  - request body
@return invitation link
server/src/main/java/com/epam/aidial/core/server/service/ShareService.java