diff --git a/.classpath b/.classpath index e1c5019..8339954 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index 49c320f..91ccfb3 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-1.2.2-SNAPSHOT +lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-1.2.3-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/pom.xml b/pom.xml index 1e3fd03..efbe006 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user share-updates war - 1.2.2-SNAPSHOT + 1.2.3-SNAPSHOT gCube Share Updates Portlet diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index 823ec5e..c0b190e 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -150,7 +150,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel, String vreId, LinkPreview preview, String urlThumbnail, ArrayList mentionedUserFullNames,String fileName, String filePathOnServer, boolean notifyGroup) { - String escapedFeedText = escapeHtml(postText); + String escapedFeedText = escapeHtmlAndTransformUrl(postText); ArrayList mentionedUsers = null; if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { @@ -187,16 +187,17 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar if (escapedFeedText.compareTo(ShareUpdateForm.NO_TEXT_FILE_SHARE) == 0) { textToPost = convertFileNameAnchorHTML(url); } else { - textToPost = transformUrls(escapedFeedText); + textToPost = escapedFeedText; + System.out.println("textToPost=" + textToPost); } - + ScopeBean scope = new ScopeBean(session.getScope()); String vreId2Set = scope.is(Type.VRE) ? scope.toString() : ""; Feed toShare = new Feed(UUID.randomUUID().toString(), feedType, username, feedDate, vreId2Set, url, urlThumbnail, textToPost, pLevel, fullName, email, thumbnailURL, linkTitle, linkDesc, host); - _log.trace("Attempting to save Feed with text: " + escapedFeedText + " Level: " + pLevel); + _log.trace("Attempting to save Feed with text: " + textToPost + " Level: " + pLevel); boolean result = store.saveUserFeed(toShare); @@ -285,7 +286,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar return toReturn; } /** - * utilty method that convert a url ina text in a clickable url by the browser + * utility method that convert a url ina text in a clickable url by the browser * and if the user has just pasted a link, converts the link in: shared a link * @param feedText * @return the text with the clickable url in it @@ -295,7 +296,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar // separate input by spaces ( URLs have no spaces ) String [] parts = feedText.split("\\s"); // Attempt to convert each item into an URL. - for (int i = 0; i < parts.length; i++) { + for (int i = 0; i < parts.length; i++) { if (parts[i].startsWith("http")) { try { URL url = new URL(parts[i]); @@ -355,7 +356,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar _log.info("Returning test USER = " + session.getUsername()); HashMap fakeVreNames = new HashMap(); - //fakeVreNames.put("/gcube/devsec/devVRE","devVRE"); + fakeVreNames.put("/gcube/devsec/devVRE","devVRE"); //fakeVreNames.put("/gcube/devNext/NexNext","NexNext"); UserInfo user = new UserInfo(session.getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames); @@ -554,17 +555,19 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar * @param html the html string to escape * @return the escaped string */ - private String escapeHtml(String html) { + private String escapeHtmlAndTransformUrl(String html) { if (html == null) { return null; } String toReturn = html.replaceAll("&", "&").replaceAll("<", "<") .replaceAll(">", ">"); - // then replace all the line breaks by
, and all the double spaces by the html version   - toReturn = toReturn.replaceAll("(\r\n|\n)","
"); + // replace all the line breaks by
+ toReturn = toReturn.replaceAll("(\r\n|\n)","
"); + //transfrom the URL in a clickable URL + toReturn = transformUrls(toReturn); + // then replace all the double spaces by the html version   toReturn = toReturn.replaceAll("\\s\\s","  "); - return toReturn; } @@ -700,14 +703,14 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar try { title = getTitleFromHeader(pageUrl); ms = new MetaSeeker(connection, pageUrl); - + //try the metadata, otherwise ask the guesser description = (ms.getContent("description") != null && ! ms.getContent("description").isEmpty()) ? ms.getContent("description") : createDescriptionFromContent(link); ArrayList images = new ArrayList(); images = getImagesWithCleaner(pageUrl); toReturn = new LinkPreview(title, description, link, host, images); - + } catch(Exception e) { _log.error("[MANUAL-PARSE] Something wrong with the meta seeker returning ... "); return toReturn; @@ -787,7 +790,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar for (int i = 0; i < upTo; i++) { if (imgs[i].hasAttribute("src")) { String imageUrl = getImageUrlFromSrcAttribute(pageURL, imgs[i].getAttributeByName("src")); - images.add(imageUrl); + images.add(imageUrl); _log.trace("[FOUND image] " + imageUrl); } }