From ca2814c7d332809847bbc20b1ac387958b32c749 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 25 Jan 2017 15:38:50 +0000 Subject: [PATCH] Improved exceptions handling< git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@141784 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 5 +++++ pom.xml | 2 +- .../databook/server/DBCassandraAstyanaxImpl.java | 10 +++++----- .../databook/shared/ex/FeedIDNotFoundException.java | 9 +++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index d8e0f69..5d9e105 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,9 @@ + + Added support for job completion notifications + Improved exceptions handling + upgrade astyanax dependency to 2.0.2 diff --git a/pom.xml b/pom.xml index 448d068..fd7f2d1 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.portal social-networking-library - 1.14.0-SNAPSHOT + 1.15.0-SNAPSHOT gCube Social Networking Library The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities. diff --git a/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java b/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java index a77b452..1892db9 100644 --- a/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java +++ b/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java @@ -442,7 +442,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { try { toCheck = readFeed(feedId); if (toCheck == null) - throw new FeedIDNotFoundException("Could not find Feed with id " + feedId); + throw new FeedIDNotFoundException("Could not find Feed with id " + feedId, feedId); } catch (Exception e) { e.printStackTrace(); return false; @@ -470,7 +470,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { ColumnList columns = result.getResult(); if (columns.size() == 0) { - throw new FeedIDNotFoundException("The requested feedid: " + feedid + " is not existing"); + throw new FeedIDNotFoundException("The requested feedid: " + feedid + " is not existing", feedid); } toReturn.setKey(feedid); @@ -1344,7 +1344,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { try { toComment = readFeed(feedId); if (toComment == null) - throw new FeedIDNotFoundException("Could not find Feed with id " + feedId + " to associate this comment"); + throw new FeedIDNotFoundException("Could not find Feed with id " + feedId + " to associate this comment", feedId); } catch (Exception e) { e.printStackTrace(); return false; @@ -1615,7 +1615,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { try { toLike = readFeed(feedId); if (toLike == null) - throw new FeedIDNotFoundException("Could not find Feed with id " + feedId + " to associate this like"); + throw new FeedIDNotFoundException("Could not find Feed with id " + feedId + " to associate this like", feedId); } catch (Exception e) { e.printStackTrace(); return false; @@ -2160,7 +2160,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { try { toCheck = readFeed(feedId); if (toCheck == null) - throw new FeedIDNotFoundException("Could not find Feed with id " + feedId); + throw new FeedIDNotFoundException("Could not find Feed with id " + feedId, feedId); } catch (Exception e) { e.printStackTrace(); return null; diff --git a/src/main/java/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java b/src/main/java/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java index 8ceaac7..d298574 100644 --- a/src/main/java/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java +++ b/src/main/java/org/gcube/portal/databook/shared/ex/FeedIDNotFoundException.java @@ -1,8 +1,13 @@ package org.gcube.portal.databook.shared.ex; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + @SuppressWarnings("serial") public class FeedIDNotFoundException extends Exception { - public FeedIDNotFoundException(String message) { - super(message); + private static final Logger _log = LoggerFactory.getLogger(FeedIDNotFoundException.class); + public FeedIDNotFoundException(String message, String postId) { + _log.info("The Post having id: " + postId + " is not present in the database: " + message); } } \ No newline at end of file