diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index ecd5910..cbff659 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -8,9 +8,6 @@
uses
-
- uses
-
uses
diff --git a/distro/changelog.xml b/distro/changelog.xml
index bbd4554..aef2a5c 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,7 +1,8 @@
+ component="org.gcube.portlets-user.news-feed.2-8-2" date="2019-19-22">
HTML markup is not only escaped as it was but also displayed as simple text
+ Cleaned up code to remove print stack traces
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
index dc17b11..f9c4d5d 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java
@@ -167,7 +167,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} catch (Exception e) {
- e.printStackTrace();
+ _log.warn("Could not read user Settings");
}
return new UserSettings();
}
@@ -249,13 +249,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return enhanceFeeds(toReturn, 2);
} catch (PrivacyLevelTypeNotFoundException e) {
_log.error("Privacy Level not Found " + e.getMessage());
- e.printStackTrace();
} catch (FeedTypeNotFoundException e) {
_log.error("Feed Type not Found " + e.getMessage());
- e.printStackTrace();
} catch (ColumnNameNotFoundException e) {
_log.error("Column name not Found " + e.getMessage());
- e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
@@ -445,13 +442,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} catch (PrivacyLevelTypeNotFoundException e) {
_log.error("Privacy Level not Found " + e.getMessage());
- e.printStackTrace();
} catch (FeedTypeNotFoundException e) {
_log.error("Feed Type not Found " + e.getMessage());
- e.printStackTrace();
} catch (ColumnNameNotFoundException e) {
_log.error("Column name not Found " + e.getMessage());
- e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
@@ -504,7 +498,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
}
catch (Exception e) {
- e.printStackTrace();
+ _log.warn("Could not get more posts ...", e);
return null;
}
@@ -526,7 +520,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try {
userFeeds = (ArrayList) store.getRecentFeedsByUser(userName, 15);
} catch (Exception e) {
- e.printStackTrace();
+ _log.error("Could not read recent posts for this user " + userName);
}
Collections.sort(userFeeds, Collections.reverseOrder());
return enhanceFeeds(userFeeds, 2);
@@ -541,7 +535,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try {
userFeeds = (ArrayList) store.getAllLikedFeedsByUser(userName, 25);
} catch (Exception e) {
- e.printStackTrace();
+ _log.error("Could not read liked posts for this user " + userName);
}
Collections.sort(userFeeds, Collections.reverseOrder());
return enhanceFeeds(userFeeds, 2);
@@ -561,8 +555,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try {
likeCommitResult = store.like(toLike);
} catch (FeedIDNotFoundException e) {
- _log.error("Feed not Found for this like " + e.getMessage());
- e.printStackTrace();
+ _log.error("Post not Found for this like " + e.getMessage());
return false;
}
//if the like was correctly delivered notify users involved
@@ -600,8 +593,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
}
} catch (FeedIDNotFoundException | PrivacyLevelTypeNotFoundException | FeedTypeNotFoundException | ColumnNameNotFoundException | LikeIDNotFoundException e) {
- _log.error("Either Feed or Like not Found " + e.getMessage());
- e.printStackTrace();
+ _log.error("Either Post or Like not Found " + e.getMessage());
return false;
}
return false;
@@ -643,7 +635,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
commentCommitResult = true;
} catch (FeedIDNotFoundException e) {
_log.error("Related post not found for this comment " + e.getMessage());
- e.printStackTrace();
return new OperationResult(false, "Related post not found for this comment", comment);
}
@@ -841,7 +832,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return new OperationResult(false, "Exception on the server, could not deliver the edited comment to storage", null);
}
} catch (Exception e) {
- e.printStackTrace();
return new OperationResult(false, "Exception on the server: " + e.getMessage(), null);
}
return new OperationResult(true, "OK", edited);
@@ -951,7 +941,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try {
thumbnailURL = new LiferayUserManager().getUserByUsername(screenName).getUserAvatarURL();
} catch (UserManagementSystemException | UserRetrievalFault e) {
- e.printStackTrace();
+ _log.warn("User " + screenName + " could not be found in this portal DB");
}
return thumbnailURL;
}
@@ -995,13 +985,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
_log.debug("Attempting to delete comment " + commentid);
return store.deleteComment(commentid, feedid);
} catch (Exception e) {
- e.printStackTrace();
+ _log.error("Failed to delete comment " + commentid);
return false;
}
}
@Override
public boolean deletePost(String postid) {
- _log.debug("Called delete feed " + postid);
+ _log.debug("Called delete post " + postid);
try {
Feed toDelete = store.readFeed(postid);
@@ -1009,7 +999,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
boolean hasComments = Integer.parseInt(toDelete.getCommentsNo()) > 0;
if(hasComments){
- _log.debug("Deleting feed's comments and their hashtags");
+ _log.debug("Deleting post comments and their hashtags");
List comments = store.getAllCommentByFeed(postid);
for (Comment comment : comments) {
deleteComment(comment.getKey(), postid);
@@ -1018,15 +1008,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
List hashtags = Utils.getHashTags(Utils.removeHTMLFromText(toDelete.getDescription()));
if (hashtags != null && !hashtags.isEmpty()) {
- _log.debug("The feed has hashtags, attempting to delete them ... " + hashtags.toString());
+ _log.debug("The post has hashtags, attempting to delete them ... " + hashtags.toString());
boolean deletedHashtag = store.deleteHashTags(postid, toDelete.getVreid(), hashtags);
_log.debug("deletedHashtag? " + deletedHashtag);
}
- _log.debug("Attempting to delete feed " + postid);
+ _log.debug("Attempting to delete post " + postid);
return store.deleteFeed(postid);
} catch (Exception e) {
- e.printStackTrace();
+ _log.debug("Failed to delete post " + postid);
return false;
}
}
@@ -1097,7 +1087,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
try {
isAdmin = isAdmin();
} catch (Exception e) {
- e.printStackTrace();
+ _log.error("Could not check isAdmin");
}
getThreadLocalRequest().getSession().setAttribute(SESSION_ADMIN_ATTR, isAdmin);
return isAdmin;