Social Post parsing switched to new solution
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@176761 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
835c7212f2
commit
42685d6cea
4
pom.xml
4
pom.xml
|
@ -76,11 +76,11 @@
|
|||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependency -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
|
@ -157,6 +157,7 @@ public class Utils {
|
|||
* @param postText
|
||||
* @return the list of hashtags present in the text
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getHashTags(String postText) {
|
||||
List<String> hashtags = new ArrayList<>();
|
||||
Pattern MY_PATTERN = Pattern.compile(HASHTAG_REGEX);//Pattern.compile("^#\\w+|\\s#\\w+");
|
||||
|
@ -201,6 +202,7 @@ public class Utils {
|
|||
* @param html the html string to escape
|
||||
* @return the escaped string
|
||||
*/
|
||||
@Deprecated
|
||||
public static String escapeHtmlAndTransformUrl(String html) {
|
||||
if (html == null) {
|
||||
return null;
|
||||
|
@ -223,6 +225,7 @@ public class Utils {
|
|||
* @param html the html string to escape
|
||||
* @return the escaped string
|
||||
*/
|
||||
@Deprecated
|
||||
public static String escapeHtml(String html) {
|
||||
return html.replaceAll("&", "&").replaceAll("<", "<")
|
||||
.replaceAll(">", ">");
|
||||
|
@ -234,6 +237,7 @@ public class Utils {
|
|||
* @param feedText
|
||||
* @return the text with the clickable url in it
|
||||
*/
|
||||
@Deprecated
|
||||
public static String transformUrls(String feedText) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// separate input by spaces ( URLs have no spaces )
|
||||
|
@ -294,6 +298,7 @@ public class Utils {
|
|||
* @param taggedPeople
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> taggedPeople, HttpServletRequest request) {
|
||||
String pageToRedirectURL = "";
|
||||
String httpGETAttrName = "";
|
||||
|
@ -333,6 +338,7 @@ public class Utils {
|
|||
* @param hashtags
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static String convertHashtagsAnchorHTML(String escapedFeedText, List<String> hashtags) {
|
||||
for (String hashtag : hashtags) {
|
||||
String taggedHTML = "<a class=\"link\" style=\"font-size:14px;\" href=\"?"+
|
||||
|
|
|
@ -6,8 +6,9 @@ import java.util.Map;
|
|||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
public class ReplaceableToken extends Token {
|
||||
|
||||
protected String tokenReplacement;
|
||||
|
||||
protected boolean replaced;
|
||||
protected String tokenReplacement;
|
||||
|
||||
public static String createHref(String baseURL, String attributeName, String attributeValue) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
@ -20,9 +21,9 @@ public class ReplaceableToken extends Token {
|
|||
|
||||
}
|
||||
|
||||
public static String createLink(String linkTarget, String linkValue, Map<String, String> additionalAttributes) {
|
||||
Map<String, String> attributes = new HashMap<>();
|
||||
if(additionalAttributes!=null) {
|
||||
public static String createLink(String linkTarget, String linkValue, Map<String,String> additionalAttributes) {
|
||||
Map<String,String> attributes = new HashMap<>();
|
||||
if(additionalAttributes != null) {
|
||||
attributes.putAll(additionalAttributes);
|
||||
}
|
||||
attributes.put("class", "link");
|
||||
|
@ -44,7 +45,6 @@ public class ReplaceableToken extends Token {
|
|||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
public ReplaceableToken(Token token) {
|
||||
super(token.getToken(), token.getDelimiter(), token.getStart(), token.getEnd());
|
||||
this.tokenReplacement = token.getToken();
|
||||
|
@ -54,14 +54,18 @@ public class ReplaceableToken extends Token {
|
|||
this(token);
|
||||
this.tokenReplacement = tokenReplacement;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDelimiter() {
|
||||
return delimiter.replaceAll("(\r\n|\n)","<br/>");
|
||||
return delimiter.replaceAll("(\r\n|\n)", "<br/>");
|
||||
}
|
||||
|
||||
public String getTokenReplacement() {
|
||||
if(!replaced) {
|
||||
tokenReplacement = tokenReplacement.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">",
|
||||
">");
|
||||
replaced = true;
|
||||
}
|
||||
return tokenReplacement;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
|||
|
||||
public class TagToken extends ReplaceableToken {
|
||||
|
||||
private boolean replaced;
|
||||
|
||||
public TagToken(Token token) {
|
||||
super(token);
|
||||
replaced = false;
|
||||
|
@ -17,7 +15,7 @@ public class TagToken extends ReplaceableToken {
|
|||
tokenReplacement = ReplaceableToken.createLink(linkTarget, token, null);
|
||||
replaced = true;
|
||||
}
|
||||
return super.getTokenReplacement();
|
||||
return tokenReplacement;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.util.Map;
|
|||
|
||||
public class URLToken extends ReplaceableToken {
|
||||
|
||||
private boolean replaced;
|
||||
|
||||
public URLToken(Token token, URL url) {
|
||||
super(token);
|
||||
this.tokenReplacement = "___URL____";
|
||||
|
@ -35,7 +33,7 @@ public class URLToken extends ReplaceableToken {
|
|||
tokenReplacement = ReplaceableToken.createLink(token, token, anchorAttibutes);
|
||||
replaced = true;
|
||||
}
|
||||
return super.getTokenReplacement();
|
||||
return tokenReplacement;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MessageParserTest {
|
|||
|
||||
@Test
|
||||
public void test() {
|
||||
String message = "Prova #Pippo Pollo http://google) :) ";
|
||||
String message = "Prova #Pippo Pollo http://google) <a href=\"/test\">Luca</a> :) ";
|
||||
|
||||
MessageParser messageParser = new MessageParser(message);
|
||||
logger.debug(messageParser.getParsedMessage());
|
||||
|
|
Loading…
Reference in New Issue