added possibility to send notifications from Catalogue
This commit is contained in:
parent
8a60b754ee
commit
72bb6c65ba
|
@ -25,9 +25,8 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
|||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
|
@ -56,6 +57,7 @@ import org.gcube.portal.social.networking.ws.utils.CassandraConnection;
|
|||
import org.gcube.portal.social.networking.ws.utils.DistributedCacheClient;
|
||||
import org.gcube.portal.social.networking.ws.utils.ErrorMessages;
|
||||
import org.gcube.portal.social.networking.ws.utils.SocialUtils;
|
||||
import org.gcube.portal.social.networking.ws.utils.TokensUtils;
|
||||
import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean;
|
||||
|
||||
import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEvent;
|
||||
|
@ -74,6 +76,7 @@ import org.gcube.vomanagement.usermanagement.GroupManager;
|
|||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.mortbay.log.Log;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -345,11 +348,29 @@ public class Notifications {
|
|||
public Response catalogue(
|
||||
@NotNull(message="input is missing")
|
||||
@Valid
|
||||
CatalogueEvent event) throws ValidationException{
|
||||
CatalogueEvent event) throws ValidationException, UserManagementSystemException, UserRetrievalFault{
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
UserManager um = UserManagerWSBuilder.getInstance().getUserManager();
|
||||
GCubeUser senderUser = null;
|
||||
SocialNetworkingUser user = null;
|
||||
// check if the token belongs to an application token. In this case use J.A.R.V.I.S (the username used to communicate with Liferay)
|
||||
String username = null;
|
||||
String fullName = "";
|
||||
if(!TokensUtils.isUserToken(caller)){
|
||||
GCubeUser jarvis = UserManagerWSBuilder.getInstance().getUserManager().getUserByEmail(LiferayJSONWsCredentials.getSingleton().getUser());
|
||||
SecurityTokenProvider.instance.set(LiferayJSONWsCredentials.getSingleton().getNotifierUserToken());
|
||||
username = jarvis.getUsername();
|
||||
fullName = "Catalogue" + "("+caller.getClient().getId()+")"; // the actual name of the IAM Client
|
||||
senderUser = um.getUserByUsername(username);
|
||||
user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), fullName, senderUser.getUserAvatarURL());
|
||||
}else{
|
||||
username = caller.getClient().getId();
|
||||
senderUser = um.getUserByUsername(username);
|
||||
user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
||||
}
|
||||
|
||||
String context = ScopeProvider.instance.get();
|
||||
String username = caller.getClient().getId();
|
||||
|
||||
logger.debug("catalogue notifications from user = " + username);
|
||||
ResponseBean responseBean = new ResponseBean();
|
||||
|
@ -358,9 +379,8 @@ public class Notifications {
|
|||
try {
|
||||
logger.debug("catalogue notifications type is " + event.getType());
|
||||
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
||||
UserManager um = UserManagerWSBuilder.getInstance().getUserManager();
|
||||
GCubeUser senderUser = um.getUserByUsername(username);
|
||||
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
||||
|
||||
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
||||
|
||||
String[] idsToNotify = event.getIdsToNotify();
|
||||
|
|
Loading…
Reference in New Issue