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">
<dependency-type>uses</dependency-type>
</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">
<dependency-type>uses</dependency-type>
</dependent-module>

View File

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

30
pom.xml
View File

@ -25,17 +25,19 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem//${project.artifactId}</url>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws</url>
</scm>
<dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>2.1.0</version>
<version>2.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -149,12 +151,6 @@
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</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>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
@ -170,6 +166,18 @@
<artifactId>authorization-client</artifactId>
<scope>provided</scope>
</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>
<groupId>junit</groupId>
<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.common.authorization.library.provider.AuthorizationProvider;
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.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.MessageManagerClient;
import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.portal.social.networking.caches.SocialNetworkingSiteFinder;
@ -115,13 +115,13 @@ public class Messages {
// sender info
GCubeUser senderUser = uManager.getUserByUsername(senderId);
MessageManagerClient client = AbstractPlugin.messages().build();
Workspace workspace = HomeLibrary.getUserWorkspace(senderId);
// send message
logger.info("Sending message (v1) to: " + recipientsListFiltered);
String checkedSubject = subject;
String checkedBody = body;
String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null);
logger.debug("Sending message to " + recipientsListFiltered);
String messageId = workspace.getWorkspaceMessageManager()
.sendMessageToPortalLogins(subject, body,
new ArrayList<String>(), recipientsListFiltered);
// send notification
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;
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.Collections;
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.SecurityTokenProvider;
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.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.thread.MessageNotificationsThread;
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.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
* @author Costantino Perciante at ISTI-CNR
@ -136,13 +136,15 @@ public class Messages {
// sender info
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
logger.debug("Sending message (v2) to: " + recipientsListFiltered);
String checkedSubject = subject;
String checkedBody = body;
String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null);
logger.debug("Sending message to " + recipientsListFiltered);
String messageId = workspace.getWorkspaceMessageManager()
.sendMessageToPortalLogins(subject, body,
new ArrayList<String>(), recipientsListFiltered);
// send notification
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);
try {
MessageManagerClient client = AbstractPlugin.messages().build();
List<Message> sentMessages = client.getSentMessages();
try{
Workspace workspace = HomeLibrary.getUserWorkspace(username);
List<WorkspaceMessage> sentMessages = workspace.getWorkspaceMessageManager().getSentMessages();
Collections.reverse(sentMessages);
responseBean.setSuccess(true);
logger.debug("Result is " + sentMessages);
responseBean.setResult(sentMessages);
} catch(Exception e){
}catch(Exception e){
logger.error("Unable to retrieve sent messages", e);
responseBean.setMessage(e.getMessage());
status = Status.INTERNAL_SERVER_ERROR;
@ -213,9 +215,9 @@ public class Messages {
Status status = Status.OK;
logger.info("Request for retrieving received messages by " + username);
try {
MessageManagerClient client = AbstractPlugin.messages().build();
List<Message> getMessages = client.getReceivedMessages();
try{
Workspace workspace = HomeLibrary.getUserWorkspace(username);
List<WorkspaceMessage> getMessages = workspace.getWorkspaceMessageManager().getReceivedMessages();
Collections.reverse(getMessages);
responseBean.setSuccess(true);
responseBean.setResult(getMessages);

View File

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