Cleaned up code to remove print stack traces

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@182085 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-10-23 08:37:05 +00:00
parent b6efac1e66
commit bdd43a9806
3 changed files with 16 additions and 28 deletions

View File

@ -8,9 +8,6 @@
<dependent-module archiveName="gcube-widgets-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="social-util-library-1.6.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-util-library/social-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pickitem-widget-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<dependency-type>uses</dependency-type>
</dependent-module>

View File

@ -1,7 +1,8 @@
<ReleaseNotes>
<Changeset
component="org.gcube.portlets-user.news-feed.2-8-2" date="2019-08-02">
component="org.gcube.portlets-user.news-feed.2-8-2" date="2019-19-22">
<Change>HTML markup is not only escaped as it was but also displayed as simple text</Change>
<Change>Cleaned up code to remove print stack traces</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-user.news-feed.2-8-1" date="2019-07-17">

View File

@ -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<Feed>) 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<Feed>) 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<Comment> comments = store.getAllCommentByFeed(postid);
for (Comment comment : comments) {
deleteComment(comment.getKey(), postid);
@ -1018,15 +1008,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
List<String> 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;