From 2692ae036e0a6a4039abc7bcdf33d59f723c98ce Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 15 Jan 2021 10:08:33 +0100 Subject: [PATCH 1/3] Fixed authorship --- .classpath | 1 - .settings/org.eclipse.jdt.core.prefs | 6 ++- README.md | 42 ++++++++++++++++--- .../socialutillibrary/Utils.java | 5 +++ .../socialtoken/HashTagToken.java | 1 + .../socialtoken/ReplaceableToken.java | 3 ++ .../socialtoken/SanitizedHashTag.java | 4 ++ .../socialtoken/SanitizedURL.java | 4 ++ .../socialtoken/SocialMessageParser.java | 3 ++ .../socialtoken/URLToken.java | 3 ++ .../tokenization/GCubeStringTokenizer.java | 3 ++ .../socialnetworking/tokenization/Token.java | 3 ++ 12 files changed, 70 insertions(+), 8 deletions(-) diff --git a/.classpath b/.classpath index 3af1ad0..9081dbe 100644 --- a/.classpath +++ b/.classpath @@ -22,7 +22,6 @@ - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index a5c7673..cac0df4 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/README.md b/README.md index 8d5bca1..90e7716 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gCube System - Social Util Library +# gCube Social Util Library ## Structure of the project @@ -19,13 +19,31 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/social-util-library/r ## Authors +* **Luca Frosini** ([ORCID](https://orcid.org/0000-0003-3183-2291)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) * **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) * **Costantino Perciante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) + ## Maintainers +* **Luca Frosini** ([ORCID](https://orcid.org/0000-0003-3183-2291)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) * **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) +## How to Cite this Software + +Tell people how to cite this software. +* Cite an associated paper? +* Use a specific BibTeX entry for the software? + + @software{, + title = {gCube Social Util Library}, + author = {{Frosini, Luca, Assante, Massimiliano, Perciante, Costantino}}, + organization = {ISTI - CNR}, + address = {Pisa, Italy}, + year = 2021, + url = {http://www.gcube-system.org/} + } + ## License This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details. @@ -40,9 +58,23 @@ by favouring the realisation of reuse oriented policies. 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 (grant no. 004260); + - DILIGENT (grant no. 004260). - the Seventh Framework Programme for research, technological development and demonstration - - D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644); + - D4Science (grant no. 212488); + - D4Science-II (grant no.239019); + - ENVRI (grant no. 283465); + - iMarine(grant no. 283644); + - EUBrazilOpenBio (grant no. 288754). - the H2020 research and innovation programme - - BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001); - \ No newline at end of file + - SoBigData (grant no. 654024); + - PARTHENOS (grant no. 654119); + - EGIEngage (grant no. 654142); + - ENVRIplus (grant no. 654182); + - BlueBRIDGE (grant no. 675680); + - PerformFish (grant no. 727610); + - AGINFRAplus (grant no. 731001); + - DESIRA (grant no. 818194); + - ARIADNEplus (grant no. 823914); + - RISIS2 (grant no. 824091); + + \ No newline at end of file diff --git a/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java b/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java index 622f0e7..0893a43 100644 --- a/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java +++ b/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java @@ -31,6 +31,11 @@ import org.htmlparser.beans.StringBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * @author Costantino Perciante (ISTI - CNR) + * @author Massimiliano Assante (ISTI - CNR) + * @author Luca Frosini (ISTI - CNR) + */ public class Utils { /** diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/HashTagToken.java b/src/main/java/org/gcube/socialnetworking/socialtoken/HashTagToken.java index 4b60a44..73caff1 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/HashTagToken.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/HashTagToken.java @@ -5,6 +5,7 @@ import org.gcube.socialnetworking.tokenization.Token; /** * @author Luca Frosini (ISTI - CNR) + * @author Massimiliano Assante (ISTI - CNR) */ public class HashTagToken extends ReplaceableToken { diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/ReplaceableToken.java b/src/main/java/org/gcube/socialnetworking/socialtoken/ReplaceableToken.java index 5ced686..cae0c81 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/ReplaceableToken.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/ReplaceableToken.java @@ -6,6 +6,9 @@ import java.util.Map; import org.apache.commons.codec.binary.Base64; import org.gcube.socialnetworking.tokenization.Token; +/** + * @author Luca Frosini (ISTI - CNR) + */ public class ReplaceableToken extends Token { protected boolean replaced; diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedHashTag.java b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedHashTag.java index 6b4e13e..eb4a546 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedHashTag.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedHashTag.java @@ -4,6 +4,10 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * @author Luca Frosini (ISTI - CNR) + * @author Massimiliano Assante (ISTI - CNR) + */ public class SanitizedHashTag { private static final String RECOGNIZE_HASHTAG_REGEX = "^.{0,3}#[\\w.-]{1,}[\\W]{0,3}"; diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java index 8a4bc62..94245bb 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java @@ -4,6 +4,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Objects; +/** + * @author Luca Frosini (ISTI - CNR) + * @author Massimiliano Assante (ISTI - CNR) + */ public class SanitizedURL { private static String CHARACTERS_TO_REMOVE = "[\\.\\,\\;\\(\\)\\:\\\"\\'\\“\\”\\‘\\’\\«\\»]"; diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/SocialMessageParser.java b/src/main/java/org/gcube/socialnetworking/socialtoken/SocialMessageParser.java index 0de4085..a089cc1 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/SocialMessageParser.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/SocialMessageParser.java @@ -15,6 +15,9 @@ import org.gcube.vomanagement.usermanagement.model.GCubeTeam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * @author Luca Frosini (ISTI - CNR) + */ public class SocialMessageParser { private static final Logger logger = LoggerFactory.getLogger(SocialMessageParser.class); diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/URLToken.java b/src/main/java/org/gcube/socialnetworking/socialtoken/URLToken.java index fccde43..efcbfb2 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/URLToken.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/URLToken.java @@ -7,6 +7,9 @@ import java.util.Map; import org.gcube.socialnetworking.tokenization.Token; +/** + * @author Luca Frosini (ISTI - CNR) + */ public class URLToken extends ReplaceableToken { protected SanitizedURL sanitizedURL; diff --git a/src/main/java/org/gcube/socialnetworking/tokenization/GCubeStringTokenizer.java b/src/main/java/org/gcube/socialnetworking/tokenization/GCubeStringTokenizer.java index 10230ac..98fae07 100644 --- a/src/main/java/org/gcube/socialnetworking/tokenization/GCubeStringTokenizer.java +++ b/src/main/java/org/gcube/socialnetworking/tokenization/GCubeStringTokenizer.java @@ -5,6 +5,9 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * @author Luca Frosini (ISTI - CNR) + */ public class GCubeStringTokenizer { /** diff --git a/src/main/java/org/gcube/socialnetworking/tokenization/Token.java b/src/main/java/org/gcube/socialnetworking/tokenization/Token.java index 1ba22cf..2de79fe 100644 --- a/src/main/java/org/gcube/socialnetworking/tokenization/Token.java +++ b/src/main/java/org/gcube/socialnetworking/tokenization/Token.java @@ -1,5 +1,8 @@ package org.gcube.socialnetworking.tokenization; +/** + * @author Luca Frosini (ISTI - CNR) + */ public class Token{ protected final String token; From 81c7b28c6299beda814874d161b8634fb4137566 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 15 Jan 2021 10:47:39 +0100 Subject: [PATCH 2/3] Fixed bug #18356 --- .../socialtoken/SanitizedURL.java | 20 +++++++++++-------- .../socialutillibrary/MessageParserTest.java | 19 +++++++++++++++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java index 94245bb..2926e62 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java @@ -21,8 +21,6 @@ public class SanitizedURL { throw new MalformedURLException(); } - - prefix = urlString.substring(0,1); if(prefix.matches(CHARACTERS_TO_REMOVE)) { prefix = urlString.substring(0, 1); @@ -35,16 +33,22 @@ public class SanitizedURL { urlString = "http://" + urlString; } - postfix = urlString.substring(urlString.length()-1); - if(postfix.matches(CHARACTERS_TO_REMOVE)) { - urlString = urlString.substring(0, urlString.length()-1); - }else { - postfix = ""; - } + postfix = ""; + urlString = stripPostfix(urlString); url = new URL(urlString); } + private String stripPostfix(String urlString) { + String testPostFix = urlString.substring(urlString.length()-1); + if(testPostFix.matches(CHARACTERS_TO_REMOVE)) { + postfix = urlString.substring(urlString.length()-1) + postfix; + urlString = urlString.substring(0, urlString.length()-1); + urlString = stripPostfix(urlString); + } + return urlString; + } + public String getPrefix() { return prefix; } diff --git a/src/test/java/org/gcube/social_networking/socialutillibrary/MessageParserTest.java b/src/test/java/org/gcube/social_networking/socialutillibrary/MessageParserTest.java index cd2bca2..8bd5521 100644 --- a/src/test/java/org/gcube/social_networking/socialutillibrary/MessageParserTest.java +++ b/src/test/java/org/gcube/social_networking/socialutillibrary/MessageParserTest.java @@ -56,6 +56,22 @@ public class MessageParserTest { public static final String TEST_LUCA_8 = "Hello this link \"https://virtuoso.parthenos.d4science.org/sparql?default-graph-uri=&query=SELECT+%3Ftype+%28COUNT%28%3Ftype%29+as+%3FtypeCount%29++%0D%0A%09%09%09%09%09WHERE+%7B%5B%5D+a+%3Ftype%7D%0D%0A%09%09%09%09%09GROUP+BY+%3Ftype&format=text%2Fhtml&timeout=0&debug=on\" is a SPARQL query "; + public static final String TEST_BUG_18356 = "Dear B-C colleagues,\n" + + "\n" + + "Just a kind reminder that we look forward to welcoming all of you during the Project’s upcoming Blue-Cloud “Service Exploitation & Sustainability Plan (SE&SP) and Roadmap to 2030” Workshop next Thursday, January 21st (9.30am to 1.30pm). Everyone's welcome for an interactive and productive discussion.\n" + + "\n" + + "Please find here a link to the workshop Agenda (https://data.d4science.net/tfXA), including connection details.\n" + + "\n" + + "As discussed, the workshop will provide an opportunity to share the high-level results of the initial phase of stakeholder consultations towards the B-C Roadmap and to work within the Partnership to discuss and align some of the underlying, strategic concepts and ideas that will set the direction for the B-C SE&SP and B-C Roadmap to 2030.\n" + + "\n" + + "To inform the discussions to be held during the workshop, we have produced a report bringing together all the feedback, messages and recommendations gathered during the initial phase of stakeholder consultations (available here - https://data.d4science.net/JEm7). It is a long document, but we have included a one-page Executive Summary with high-level, key messages & recommendations, in case useful.\n" + + "\n" + + "We look forward to a productive discussion with you next Thursday!\n" + + "\n" + + "Kind regards,\n" + + "Julia"; + + @Test public void test13() { SocialMessageParser messageParser = new SocialMessageParser(TEST_13); @@ -105,7 +121,8 @@ public class MessageParserTest { logger.debug(messageParser.getParsedMessage()); messageParser = new SocialMessageParser(TEST_LUCA_7); logger.debug("{}", messageParser.getParsedMessage()); - + messageParser = new SocialMessageParser(TEST_BUG_18356); + logger.debug("{}", messageParser.getParsedMessage()); } @Test(expected=MalformedURLException.class) From 3735db9dedee28918d5e4751ec2adeef3234224e Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 15 Jan 2021 10:50:29 +0100 Subject: [PATCH 3/3] Added comment --- .../gcube/socialnetworking/socialtoken/SanitizedURL.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java index 2926e62..b9a35b6 100644 --- a/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java +++ b/src/main/java/org/gcube/socialnetworking/socialtoken/SanitizedURL.java @@ -44,6 +44,12 @@ public class SanitizedURL { if(testPostFix.matches(CHARACTERS_TO_REMOVE)) { postfix = urlString.substring(urlString.length()-1) + postfix; urlString = urlString.substring(0, urlString.length()-1); + + /* + * The urlString could terminate with more than one character to be escaped + * So we need to further analyse the sanitised URL + * e.g. 'https://data.d4science.net/tfXA),' terminates with '),' + */ urlString = stripPostfix(urlString); } return urlString;