From b677ce347bf8a98280e36706e4da63b28c145cef Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 22 Jun 2021 11:53:50 +0200 Subject: [PATCH] removed HL dependency --- CHANGELOG.md | 47 +++++++++++++ FUNDING.md | 26 +++++++ distro/LICENSE | 1 - distro/README | 67 ------------------- distro/changelog.xml | 40 ----------- distro/descriptor.xml | 42 ------------ distro/profile.xml | 25 ------- pom.xml | 23 +++---- .../gcube/portal/socialmail/PeriodicTask.java | 45 ++++--------- 9 files changed, 97 insertions(+), 219 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 FUNDING.md delete mode 100644 distro/LICENSE delete mode 100644 distro/README delete mode 100644 distro/changelog.xml delete mode 100644 distro/descriptor.xml delete mode 100644 distro/profile.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..789169b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,47 @@ + +# Changelog for workspace + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v2.5.0-SNAPSHOT] - 2021-06-22 + +- Feature #21689 Social Mail Servlet to StorageHub migration + +- Removed HomeLibrary Dependency + +## [v2.4.0] - 2019-12-30 + +- Ported to git + +## [v2.3.0] - 2018-08-30 + +- Fix for Incident #12351 Email Parser stuck on AGINFRA Gateway + +- Support #12332 Notifications via emails not working for bfr.bund.de domain + +- Feature #12613, Replace use of "$" character with "_" when sending notification emails about posts and messages + +## [v2.1.1] - 2017-02-03 + +- Minor refactor for comment replies + +- Resilient to Email server failures + +## [v2.1.0] - 2016-08-31 + +- Added possibility to change poller time at runtime as well as to quit it by editing a property file in the server + +- Added support for oAuth2 + +## [v1.2.0] - 2015-10-14 + +- Added support for reply via email in Messages + +- Read LDAP service endpoint from infrastructure + +- Fix for bug #577 + +## [v1.0.0] - 2015-07-07 + +- First release diff --git a/FUNDING.md b/FUNDING.md new file mode 100644 index 0000000..6fa9eac --- /dev/null +++ b/FUNDING.md @@ -0,0 +1,26 @@ +# Acknowledgments + +The projects leading to this software have received funding from a series of European Union programmes including: + +- the Sixth Framework Programme for Research and Technological Development + - [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260). +- the Seventh Framework Programme for research, technological development and demonstration + - [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488); + - [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019); + - [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465); + - [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644); + - [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754). +- the H2020 research and innovation programme + - [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024); + - [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119); + - [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142); + - [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182); + - [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680); + - [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610); + - [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001); + - [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194); + - [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914); + - [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091); + - [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650); + - [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409); + - [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042); \ No newline at end of file diff --git a/distro/LICENSE b/distro/LICENSE deleted file mode 100644 index 2d9616a..0000000 --- a/distro/LICENSE +++ /dev/null @@ -1 +0,0 @@ -${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README deleted file mode 100644 index 35c99c0..0000000 --- a/distro/README +++ /dev/null @@ -1,67 +0,0 @@ -The gCube System - ${name} --------------------------------------------------- - -${description} - - -${gcube.description} - -${gcube.funding} - - -Version --------------------------------------------------- - -${version} (${buildDate}) - -Please see the file named "changelog.xml" in this directory for the release notes. - - -Authors --------------------------------------------------- - -* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). - - - -Maintainers ------------ - -* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). - - -Download information --------------------------------------------------- - -Source code is available from SVN: - ${scm.url} - -Binaries can be downloaded from the gCube website: - ${gcube.website} - - -Installation --------------------------------------------------- - -Installation documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot}/ - - -Documentation --------------------------------------------------- - -Documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot}/ - ${gcube.wikiRoot}/ - -Support --------------------------------------------------- - -Bugs and support requests can be reported in the gCube issue tracking tool: - ${gcube.issueTracking} - - -Licensing --------------------------------------------------- - -This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml deleted file mode 100644 index a58ab6e..0000000 --- a/distro/changelog.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - Fix for Incident #12351 Email Parser stuck on AGINFRA Gateway - Support #12332 Notifications via emails not working for bfr.bund.de domain, Feature #12613, Replace use of "$" character with "_" when sending notification emails about posts and messages - - - Minor refactor for comment replies - Resilient to Email server failures - - - Added possibility to change poller time at runtime as well as - to quit it by editing a property file in the server - Added support for Auth2 - - - Discussion is now reported in email's body - Upgraded deprecated methods of asl social - - - Removed the part the export users to LDAP - - - Added support for reply via email in Messages - - - Fix for #577 - Read LDAP service endpoint from infrastructure - - - First Release - - diff --git a/distro/descriptor.xml b/distro/descriptor.xml deleted file mode 100644 index c81acc0..0000000 --- a/distro/descriptor.xml +++ /dev/null @@ -1,42 +0,0 @@ - - servicearchive - - tar.gz - - / - - - ${distroDirectory} - / - true - - README - LICENSE - changelog.xml - profile.xml - - 755 - true - - - target/apidocs - /${artifactId}/doc/api - true - 755 - - - - - ${distroDirectory}/profile.xml - ./ - true - - - target/${build.finalName}.war - /${artifactId} - - - \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml deleted file mode 100644 index 4dda0b9..0000000 --- a/distro/profile.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Library - - ${description} - Portal - ${artifactId} - 1.0.0 - - - ${artifactId} - ${version} - - ${groupId} - ${artifactId} - ${version} - - - ${build.finalName}.war - - - - - diff --git a/pom.xml b/pom.xml index 0a052a2..400d941 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portal social-mail-servlet war - 2.4.0 + 2.5.0-SNAPSHOT scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git @@ -37,7 +37,7 @@ org.gcube.distribution maven-portal-bom - 3.6.0 + 3.6.2-SNAPSHOT pom import @@ -71,26 +71,25 @@ aslsocial provided + + org.gcube.common + storagehub-client-library + org.gcube.portal social-networking-library provided + + org.apache.commons + commons-lang3 + 3.5 + org.gcube.portal notifications-common-library provided - - org.gcube.common - home-library - provided - - - org.gcube.common - home-library-jcr - provided - com.google gwt-jsonmaker diff --git a/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java b/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java index d021695..cb25aac 100644 --- a/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java +++ b/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java @@ -2,11 +2,9 @@ package org.gcube.portal.socialmail; import static org.gcube.common.authorization.client.Constants.authorizationService; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; import java.security.GeneralSecurityException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Properties; @@ -26,7 +24,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage.RecipientType; import javax.servlet.http.HttpServletRequest; -import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringEscapeUtils; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.util.GenderType; @@ -37,16 +35,10 @@ import org.gcube.applicationsupportlayer.social.mailing.SocialMailingUtil; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.common.authorization.library.provider.UserInfo; -import org.gcube.common.homelibrary.home.HomeLibrary; -import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.common.homelibrary.home.workspace.Workspace; -import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException; -import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; -import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage; -import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessageManager; import org.gcube.common.portal.PortalContext; 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.databook.server.DatabookStore; import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.Feed; @@ -266,18 +258,17 @@ public class PeriodicTask implements Runnable { _log.debug("Found message reply, subject: " + subject + " body: " + messageText); String newMessageId = null; - Workspace workspace; List recipientIds = null; try { - workspace = getWorkspace(fakeSession); + setAuthorizationToken(fakeSession); + MessageManagerClient mmClient = AbstractPlugin.messages().build(); + org.gcube.common.storagehub.model.messages.Message theMessage = mmClient.get(messageId); - WorkspaceMessageManager messageManager = workspace.getWorkspaceMessageManager(); - WorkspaceMessage theMessage = messageManager.getReceivedMessage(messageId); - recipientIds = theMessage.getAddresses(); + recipientIds = Arrays.asList(theMessage.getAddresses()); //add the sender and remove the person who is replying from the recipients - String sender = theMessage.getSender().getPortalLogin(); + String sender = theMessage.getSender().getUserName(); String originalText = theMessage.getBody(); - Date originalSentTime = theMessage.getSendTime().getTime(); + Date originalSentTime = theMessage.getCreationTime().getTime(); recipientIds.add(sender); recipientIds.remove(fakeSession.getUsername()); @@ -289,9 +280,9 @@ public class PeriodicTask implements Runnable { messageText += getReplyHeaderMessage(sender, originalSentTime, originalText); _log.debug("Trying to send message with subject: " + subject + " to: " + recipientIds.toString()); - newMessageId = messageManager.sendMessageToPortalLogins(subject, messageText, new ArrayList(), recipientIds); + newMessageId = mmClient.sendMessage(recipientIds, subject, messageText, new ArrayList()); - } catch (WorkspaceFolderNotFoundException | InternalErrorException | HomeNotFoundException | ItemNotFoundException e) { + } catch (Exception e) { e.printStackTrace(); } @@ -617,16 +608,6 @@ public class PeriodicTask implements Runnable { return toReturn; } - /** - * - * @return the workspace instance - * @throws InternalErrorException - * @throws HomeNotFoundException - * @throws WorkspaceFolderNotFoundException - */ - private Workspace getWorkspace(ASLSession session) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException { - Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); - return workspace; - } + }