porting to storagehub for messages
This commit is contained in:
parent
ad43c3782c
commit
1ca35916cd
33
pom.xml
33
pom.xml
|
@ -12,13 +12,12 @@
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library-ws</artifactId>
|
<artifactId>social-networking-library-ws</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.3.3-SNAPSHOT</version>
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
<name>social-networking-library-ws</name>
|
<name>social-networking-library-ws</name>
|
||||||
<description>Rest interface for the social networking library.</description>
|
<description>Rest interface for the social networking library.</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java-version>1.8</java-version>
|
<java-version>1.8</java-version>
|
||||||
<version.swagger>1.5.13</version.swagger>
|
<version.swagger>1.5.13</version.swagger>
|
||||||
<version.jersey>2.25.1</version.jersey>
|
|
||||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||||
<distroDirectory>distro</distroDirectory>
|
<distroDirectory>distro</distroDirectory>
|
||||||
|
@ -56,6 +55,11 @@
|
||||||
<version>[2.4.1-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
<version>[2.4.1-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
|
@ -166,18 +170,7 @@
|
||||||
<artifactId>authorization-client</artifactId>
|
<artifactId>authorization-client</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library</artifactId>
|
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library-jcr</artifactId>
|
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -221,32 +214,22 @@
|
||||||
<groupId>org.glassfish.jersey.containers</groupId>
|
<groupId>org.glassfish.jersey.containers</groupId>
|
||||||
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
|
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
|
||||||
<artifactId>jersey-container-servlet-core</artifactId>
|
<artifactId>jersey-container-servlet-core</artifactId>
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-json-processing</artifactId>
|
<artifactId>jersey-media-json-processing</artifactId>
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-multipart</artifactId>
|
<artifactId>jersey-media-multipart</artifactId>
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-sse</artifactId>
|
<artifactId>jersey-media-sse</artifactId>
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.ext</groupId>
|
<groupId>org.glassfish.jersey.ext</groupId>
|
||||||
<artifactId>jersey-bean-validation</artifactId>
|
<artifactId>jersey-bean-validation</artifactId>
|
||||||
<version>${version.jersey}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
|
@ -305,7 +288,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.1.1</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>compile</phase>
|
<phase>compile</phase>
|
||||||
|
@ -321,7 +303,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
|
|
@ -17,9 +17,9 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||||
import org.gcube.common.authorization.library.utils.Caller;
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
|
||||||
import org.gcube.portal.notifications.bean.GenericItemBean;
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||||
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
||||||
import org.gcube.portal.social.networking.caches.SocialNetworkingSiteFinder;
|
import org.gcube.portal.social.networking.caches.SocialNetworkingSiteFinder;
|
||||||
|
@ -115,13 +115,12 @@ public class Messages {
|
||||||
|
|
||||||
// sender info
|
// sender info
|
||||||
GCubeUser senderUser = uManager.getUserByUsername(senderId);
|
GCubeUser senderUser = uManager.getUserByUsername(senderId);
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(senderId);
|
|
||||||
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
|
|
||||||
// send message
|
// send message
|
||||||
logger.debug("Sending message to " + recipientsListFiltered);
|
logger.debug("Sending message to " + recipientsListFiltered);
|
||||||
String messageId = workspace.getWorkspaceMessageManager()
|
String messageId = client.sendMessage(recipientsListFiltered, subject, body, null);
|
||||||
.sendMessageToPortalLogins(subject, body,
|
|
||||||
new ArrayList<String>(), recipientsListFiltered);
|
|
||||||
|
|
||||||
// send notification
|
// send notification
|
||||||
logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds);
|
logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds);
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package org.gcube.portal.social.networking.ws.methods.v2;
|
package org.gcube.portal.social.networking.ws.methods.v2;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import io.swagger.annotations.Authorization;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,10 +25,10 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.authorization.library.utils.Caller;
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
|
||||||
|
import org.gcube.common.storagehub.model.messages.Message;
|
||||||
import org.gcube.portal.notifications.bean.GenericItemBean;
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||||
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
||||||
import org.gcube.portal.social.networking.caches.SocialNetworkingSiteFinder;
|
import org.gcube.portal.social.networking.caches.SocialNetworkingSiteFinder;
|
||||||
|
@ -53,6 +46,13 @@ import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.Authorization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Messages services REST interface
|
* Messages services REST interface
|
||||||
* @author Costantino Perciante at ISTI-CNR
|
* @author Costantino Perciante at ISTI-CNR
|
||||||
|
@ -136,15 +136,11 @@ public class Messages {
|
||||||
|
|
||||||
// sender info
|
// sender info
|
||||||
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(senderId);
|
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(senderId);
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(senderId);
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
|
|
||||||
logger.debug("Workspace is " + workspace.getRoot());
|
|
||||||
|
|
||||||
// send message
|
// send message
|
||||||
logger.debug("Sending message to " + recipientsListFiltered);
|
logger.debug("Sending message to " + recipientsListFiltered);
|
||||||
String messageId = workspace.getWorkspaceMessageManager()
|
String messageId = client.sendMessage(recipientsListFiltered, subject, body, null);
|
||||||
.sendMessageToPortalLogins(subject, body,
|
|
||||||
new ArrayList<String>(), recipientsListFiltered);
|
|
||||||
|
|
||||||
// send notification
|
// send notification
|
||||||
logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds);
|
logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds);
|
||||||
|
@ -184,8 +180,8 @@ public class Messages {
|
||||||
logger.info("Request for retrieving sent messages by " + username);
|
logger.info("Request for retrieving sent messages by " + username);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(username);
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
List<WorkspaceMessage> sentMessages = workspace.getWorkspaceMessageManager().getSentMessages();
|
List<Message> sentMessages = client.getSentMessages();
|
||||||
Collections.reverse(sentMessages);
|
Collections.reverse(sentMessages);
|
||||||
responseBean.setSuccess(true);
|
responseBean.setSuccess(true);
|
||||||
logger.debug("Result is " + sentMessages);
|
logger.debug("Result is " + sentMessages);
|
||||||
|
@ -216,8 +212,8 @@ public class Messages {
|
||||||
|
|
||||||
logger.info("Request for retrieving received messages by " + username);
|
logger.info("Request for retrieving received messages by " + username);
|
||||||
try{
|
try{
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(username);
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
List<WorkspaceMessage> getMessages = workspace.getWorkspaceMessageManager().getReceivedMessages();
|
List<Message> getMessages =client.getReceivedMessages();
|
||||||
Collections.reverse(getMessages);
|
Collections.reverse(getMessages);
|
||||||
responseBean.setSuccess(true);
|
responseBean.setSuccess(true);
|
||||||
responseBean.setResult(getMessages);
|
responseBean.setResult(getMessages);
|
||||||
|
|
Loading…
Reference in New Issue