111 lines
2.6 KiB
Java
111 lines
2.6 KiB
Java
package org.gcube.application.cms.notifications.social;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.gcube.portal.databook.shared.Post;
|
|
import org.gcube.social_networking.social_networking_client_library.MessageClient;
|
|
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
|
import org.gcube.social_networking.social_networking_client_library.UserClient;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.MessageInputBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
/**
|
|
* The Class SocialClients.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
*
|
|
* Mar 20, 2024
|
|
*/
|
|
@Slf4j
|
|
public class SocialClients {
|
|
|
|
private PostClient postClient;
|
|
private MessageClient messagesClient;
|
|
private UserClient userClient;
|
|
|
|
/**
|
|
* Instantiates a new social util.
|
|
*/
|
|
public SocialClients() {
|
|
try {
|
|
this.postClient = new PostClient();
|
|
} catch (Exception e) {
|
|
log.error("Error on instacing {}: ", PostClient.class.getSimpleName(), e);
|
|
}
|
|
|
|
try {
|
|
this.messagesClient = new MessageClient();
|
|
} catch (Exception e) {
|
|
log.error("Error on instacing {}: ", MessageClient.class.getSimpleName(), e);
|
|
}
|
|
|
|
try {
|
|
this.userClient = new UserClient();
|
|
} catch (Exception e) {
|
|
log.error("Error on instacing {}: ", UserClient.class.getSimpleName(), e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets the usernames by role.
|
|
*
|
|
* @param roleName the role name
|
|
* @return the usernames by role
|
|
* @throws Exception the exception
|
|
*/
|
|
public List<String> getUsernamesByRole(String roleName) throws Exception {
|
|
return new ArrayList<String>(userClient.getAllUsernamesByRole(roleName));
|
|
}
|
|
|
|
/**
|
|
* Gets the usernames by scope.
|
|
*
|
|
* @return the usernames by scope
|
|
* @throws Exception the exception
|
|
*/
|
|
public List<String> getUsernamesByScope() throws Exception {
|
|
return new ArrayList<String>(userClient.getAllUsernamesContext());
|
|
}
|
|
|
|
/**
|
|
* Write message.
|
|
*
|
|
* @param msg the msg
|
|
* @return the string
|
|
* @throws Exception the exception
|
|
*/
|
|
public String writeMessage(MessageInputBean msg) throws Exception {
|
|
return messagesClient.writeMessage(msg);
|
|
}
|
|
|
|
/**
|
|
* Write user post.
|
|
*
|
|
* @param toWrite the to write
|
|
* @return the post
|
|
*/
|
|
public Post writeUserPost(PostInputBean toWrite) {
|
|
return postClient.writeUserPost(toWrite);
|
|
}
|
|
|
|
public static org.slf4j.Logger getLog() {
|
|
return log;
|
|
}
|
|
|
|
public PostClient getPostClient() {
|
|
return postClient;
|
|
}
|
|
|
|
public MessageClient getMessagesClient() {
|
|
return messagesClient;
|
|
}
|
|
|
|
public UserClient getUserClient() {
|
|
return userClient;
|
|
}
|
|
|
|
}
|