diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 9920812..817a818 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,22 +1,28 @@ + + + + + uses - + uses - - uses - - + uses + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ac885..ec58e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - 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 diff --git a/pom.xml b/pom.xml index 10f841d..a094e33 100644 --- a/pom.xml +++ b/pom.xml @@ -25,19 +25,17 @@ UTF-8 UTF-8 - - scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git - scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git - https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws + scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git + scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git + https://code-repo.d4science.org/gCubeSystem//${project.artifactId} - - + org.gcube.distribution gcube-smartgears-bom - 2.0.0-SNAPSHOT + 2.1.0 pom import @@ -151,6 +149,12 @@ [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) compile + + org.gcube.common + storagehub-client-library + [1.2.2-SNAPSHOT, 2.0.0-SNAPSHOT) + compile + org.gcube.resources.discovery ic-client @@ -166,18 +170,6 @@ authorization-client provided - - org.gcube.common - home-library - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) - compile - - - org.gcube.common - home-library-jcr - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) - compile - junit junit diff --git a/src/main/java/org/gcube/portal/social/networking/ws/methods/v1/Messages.java b/src/main/java/org/gcube/portal/social/networking/ws/methods/v1/Messages.java index c1099d1..df57938 100644 --- a/src/main/java/org/gcube/portal/social/networking/ws/methods/v1/Messages.java +++ b/src/main/java/org/gcube/portal/social/networking/ws/methods/v1/Messages.java @@ -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); - Workspace workspace = HomeLibrary.getUserWorkspace(senderId); + MessageManagerClient client = AbstractPlugin.messages().build(); // send message - logger.debug("Sending message to " + recipientsListFiltered); - String messageId = workspace.getWorkspaceMessageManager() - .sendMessageToPortalLogins(subject, body, - new ArrayList(), recipientsListFiltered); + logger.info("Sending message (v1) to: " + recipientsListFiltered); + String checkedSubject = subject; + String checkedBody = body; + String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null); // send notification logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds); diff --git a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Messages.java b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Messages.java index 6883699..e6c69d3 100644 --- a/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Messages.java +++ b/src/main/java/org/gcube/portal/social/networking/ws/methods/v2/Messages.java @@ -1,12 +1,5 @@ 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; @@ -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.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; @@ -53,6 +46,13 @@ 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,15 +136,13 @@ public class Messages { // sender info GCubeUser senderUser = UserManagerWSBuilder.getInstance().getUserManager().getUserByUsername(senderId); - Workspace workspace = HomeLibrary.getUserWorkspace(senderId); - - logger.debug("Workspace is " + workspace.getRoot()); + MessageManagerClient client = AbstractPlugin.messages().build(); // send message - logger.debug("Sending message to " + recipientsListFiltered); - String messageId = workspace.getWorkspaceMessageManager() - .sendMessageToPortalLogins(subject, body, - new ArrayList(), recipientsListFiltered); + logger.debug("Sending message (v2) to: " + recipientsListFiltered); + String checkedSubject = subject; + String checkedBody = body; + String messageId = client.sendMessage(recipientsListFiltered, checkedSubject, checkedBody, null); // send notification logger.debug("Message sent to " + recipientsIds + ". Sending message notification to: " + recipientsIds); @@ -183,14 +181,14 @@ public class Messages { logger.info("Request for retrieving sent messages by " + username); - try{ - Workspace workspace = HomeLibrary.getUserWorkspace(username); - List sentMessages = workspace.getWorkspaceMessageManager().getSentMessages(); + try { + MessageManagerClient client = AbstractPlugin.messages().build(); + List sentMessages = client.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; @@ -215,9 +213,9 @@ public class Messages { Status status = Status.OK; logger.info("Request for retrieving received messages by " + username); - try{ - Workspace workspace = HomeLibrary.getUserWorkspace(username); - List getMessages = workspace.getWorkspaceMessageManager().getReceivedMessages(); + try { + MessageManagerClient client = AbstractPlugin.messages().build(); + List getMessages = client.getReceivedMessages(); Collections.reverse(getMessages); responseBean.setSuccess(true); responseBean.setResult(getMessages); diff --git a/src/main/java/org/gcube/portal/social/networking/ws/providers/CustomObjectMapper.java b/src/main/java/org/gcube/portal/social/networking/ws/providers/CustomObjectMapper.java index b5b3554..3a556df 100644 --- a/src/main/java/org/gcube/portal/social/networking/ws/providers/CustomObjectMapper.java +++ b/src/main/java/org/gcube/portal/social/networking/ws/providers/CustomObjectMapper.java @@ -26,7 +26,7 @@ public class CustomObjectMapper implements ContextResolver { logger.debug("new ObjectMapperResolver()"); mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); + mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); } @Override