restored version with HL Dependency for messaging

This commit is contained in:
Massimiliano Assante 2021-04-19 12:23:09 +02:00
parent 83ebb52e89
commit ad43c3782c
6 changed files with 54 additions and 43 deletions

View File

@ -12,6 +12,9 @@
<dependent-module archiveName="portal-manager-2.4.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/portal-manager/portal-manager"> <dependent-module archiveName="portal-manager-2.4.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/portal-manager/portal-manager">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="social-networking-library-1.16.3-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-networking-library/social-networking-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="aslsocial-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/aslsocial/aslsocial"> <dependent-module archiveName="aslsocial-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/aslsocial/aslsocial">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>

View File

@ -4,8 +4,6 @@
- removed jackson dependency - removed jackson dependency
- removed home library dependency
## [v2.3.0] - 2019-10-02 ## [v2.3.0] - 2019-10-02
- added support for mentions with @ in user's post as well as application posts - added support for mentions with @ in user's post as well as application posts

28
pom.xml
View File

@ -25,17 +25,19 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
<scm> <scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection> <connection>scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection> <developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem//${project.artifactId}</url> <url>https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws</url>
</scm> </scm>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId> <artifactId>gcube-smartgears-bom</artifactId>
<version>2.1.0</version> <version>2.0.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -149,12 +151,6 @@
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.0.0-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.2.2-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.resources.discovery</groupId> <groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId> <artifactId>ic-client</artifactId>
@ -170,6 +166,18 @@
<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>

View File

@ -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,13 @@ public class Messages {
// sender info // sender info
GCubeUser senderUser = uManager.getUserByUsername(senderId); GCubeUser senderUser = uManager.getUserByUsername(senderId);
MessageManagerClient client = AbstractPlugin.messages().build(); Workspace workspace = HomeLibrary.getUserWorkspace(senderId);
// send message // send message
logger.info("Sending message (v1) to: " + recipientsListFiltered); logger.debug("Sending message to " + recipientsListFiltered);
String checkedSubject = subject; String messageId = workspace.getWorkspaceMessageManager()
String checkedBody = body; .sendMessageToPortalLogins(subject, body,
String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null); 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);

View File

@ -1,5 +1,12 @@
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;
@ -25,10 +32,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;
@ -46,13 +53,6 @@ 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,13 +136,15 @@ public class Messages {
// sender info // sender info
GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(senderId); GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(senderId);
MessageManagerClient client = AbstractPlugin.messages().build(); Workspace workspace = HomeLibrary.getUserWorkspace(senderId);
logger.debug("Workspace is " + workspace.getRoot());
// send message // send message
logger.debug("Sending message (v2) to: " + recipientsListFiltered); logger.debug("Sending message to " + recipientsListFiltered);
String checkedSubject = subject; String messageId = workspace.getWorkspaceMessageManager()
String checkedBody = body; .sendMessageToPortalLogins(subject, body,
String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null); 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);
@ -181,14 +183,14 @@ public class Messages {
logger.info("Request for retrieving sent messages by " + username); logger.info("Request for retrieving sent messages by " + username);
try { try{
MessageManagerClient client = AbstractPlugin.messages().build(); Workspace workspace = HomeLibrary.getUserWorkspace(username);
List<Message> sentMessages = client.getSentMessages(); List<WorkspaceMessage> sentMessages = workspace.getWorkspaceMessageManager().getSentMessages();
Collections.reverse(sentMessages); Collections.reverse(sentMessages);
responseBean.setSuccess(true); responseBean.setSuccess(true);
logger.debug("Result is " + sentMessages); logger.debug("Result is " + sentMessages);
responseBean.setResult(sentMessages); responseBean.setResult(sentMessages);
} catch(Exception e){ }catch(Exception e){
logger.error("Unable to retrieve sent messages", e); logger.error("Unable to retrieve sent messages", e);
responseBean.setMessage(e.getMessage()); responseBean.setMessage(e.getMessage());
status = Status.INTERNAL_SERVER_ERROR; status = Status.INTERNAL_SERVER_ERROR;
@ -213,9 +215,9 @@ public class Messages {
Status status = Status.OK; Status status = Status.OK;
logger.info("Request for retrieving received messages by " + username); logger.info("Request for retrieving received messages by " + username);
try { try{
MessageManagerClient client = AbstractPlugin.messages().build(); Workspace workspace = HomeLibrary.getUserWorkspace(username);
List<Message> getMessages = client.getReceivedMessages(); List<WorkspaceMessage> getMessages = workspace.getWorkspaceMessageManager().getReceivedMessages();
Collections.reverse(getMessages); Collections.reverse(getMessages);
responseBean.setSuccess(true); responseBean.setSuccess(true);
responseBean.setResult(getMessages); responseBean.setResult(getMessages);

View File

@ -26,7 +26,7 @@ public class CustomObjectMapper implements ContextResolver<ObjectMapper> {
logger.debug("new ObjectMapperResolver()"); logger.debug("new ObjectMapperResolver()");
mapper = new ObjectMapper(); mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
} }
@Override @Override