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 6872f27..de99591 100644 --- a/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java +++ b/src/main/java/org/gcube/social_networking/socialutillibrary/Utils.java @@ -39,25 +39,25 @@ public class Utils { /** * Hashtag regex enhanced for ticket #4937 */ - @Deprecated + private static final String HASHTAG_REGEX = "^#\\w+([-_.]?\\w+)*|\\s#\\w+([-_.]?\\w+)*|(?<=[\\[({])#\\w+([-_.]?\\w+)"; /** * IPv4 regex */ - @Deprecated + public static final String IPV4_REGEX = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; /** * IPV6 regex needs to be put in square brackets, see below */ - @Deprecated + public static final String IPV6_REGEX = "\\b(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\\b"; /** * Pattern for URLS */ - @Deprecated + private static final Pattern URL_PATTERN = Pattern.compile( "\\b(((ht|f)tp(s?)\\:\\/\\/|~\\/|\\/)|www.)" + "(\\w+:\\w+@)?((([-\\w]+\\.)+(com|org|net|gov" + @@ -161,7 +161,7 @@ public class Utils { * @param postText * @return the list of hashtags present in the text */ - @Deprecated + public static List getHashTags(String postText) { List hashtags = new ArrayList<>(); Pattern MY_PATTERN = Pattern.compile(HASHTAG_REGEX);//Pattern.compile("^#\\w+|\\s#\\w+"); @@ -178,7 +178,7 @@ public class Utils { * @param feedText * @return the text with the clickable url in it */ - @Deprecated + public static String extractURL(String feedText) { // separate input by spaces ( URLs have no spaces ) feedText = feedText.replaceAll("(\r\n|\n)","
"); @@ -207,7 +207,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; @@ -230,7 +230,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(">", ">"); @@ -242,7 +242,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 ) @@ -276,7 +276,7 @@ public class Utils { * @param item a text token * @return the actual http link */ - @Deprecated + public static String getHttpToken(String originalItem) { // apply pattern String item = null; @@ -304,15 +304,19 @@ public class Utils { * @param taggedPeople * @return */ - @Deprecated + public static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList taggedPeople, HttpServletRequest request) { String pageToRedirectURL = ""; String httpGETAttrName = ""; String httpGETAttrValue =""; - + PortalContext pContext = PortalContext.getConfiguration(); + String gatewayURL = pContext.getGatewayURL(request); for (ItemBean tagged : taggedPeople) { if (! tagged.isItemGroup()) { - pageToRedirectURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + StringBuilder sb = new StringBuilder(gatewayURL) + .append(pContext.getSiteLandingPagePath(request)) + .append(GCubePortalConstants.USER_PROFILE_FRIENDLY_URL); + pageToRedirectURL = sb.toString(); httpGETAttrName = GCubeSocialNetworking.USER_PROFILE_OID; httpGETAttrValue = tagged.getName(); } else { @@ -322,7 +326,11 @@ public class Utils { //returns the VRE url e.g. /devVRE String vreURL = new LiferayGroupManager().getGroup(theTeam.getGroupId()).getFriendlyURL(); //append the members url - pageToRedirectURL= GCubePortalConstants.PREFIX_GROUP_URL + vreURL + GCubePortalConstants.GROUP_MEMBERS_FRIENDLY_URL; + StringBuilder sb = new StringBuilder(gatewayURL) + .append(GCubePortalConstants.PREFIX_GROUP_URL) + .append(vreURL) + .append(GCubePortalConstants.GROUP_MEMBERS_FRIENDLY_URL); + pageToRedirectURL= sb.toString(); httpGETAttrName = GCubeSocialNetworking.GROUP_MEMBERS_OID; httpGETAttrValue = tagged.getId(); } catch (Exception e) { @@ -344,7 +352,7 @@ public class Utils { * @param hashtags * @return */ - @Deprecated + public static String convertHashtagsAnchorHTML(String escapedFeedText, List hashtags) { for (String hashtag : hashtags) { String taggedHTML = "