private ShareResourceLimit getLimit(ProxyContext context, ResourceType resourceType) {
        List<String> userRoles = context.getUserRoles();
        Map<String, Role> roles = context.getConfig().getRoles();
        ShareResourceLimit limit = null;
        for (String userRole : userRoles) {
            ShareResourceLimit candidate = Optional.ofNullable(roles.get(userRole)).map(Role::getShare).map(limits -> limits.get(resourceType.name())).orElse(null);
            if (candidate != null) {
                if (limit == null) {
                    limit = new ShareResourceLimit(candidate.getMaxAcceptedUsers(), candidate.getInvitationTtl());
                } else {
                    limit.setInvitationTtl(Math.max(limit.getInvitationTtl(), candidate.getInvitationTtl()));
                    limit.setMaxAcceptedUsers(Math.max(limit.getMaxAcceptedUsers(), candidate.getMaxAcceptedUsers()));
                }
            }
        }
        if (limit != null) {
            return limit;
        }
        ShareResourceLimit defaultLimit = DEFAULT_LIMITS.get(resourceType);
        if (defaultLimit == null) {
            throw new IllegalArgumentException("Unsupported resource type: " + resourceType);
        }
        return defaultLimit;
    }
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