diff --git a/pom.xml b/pom.xml
index e2556ca..5310ce3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.gcube.portal
social-networking-library
- 1.10.0-SNAPSHOT
+ 1.10.1-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 cdc4348..05fa4e0 100644
--- a/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java
+++ b/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java
@@ -9,7 +9,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
@@ -1335,6 +1334,39 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
boolean updateCommentNoResult = updateFeedCommentsCount(toComment, true);
return updateCommentNoResult;
}
+ /**
+ * {@inheritDoc}
+ */
+ public Comment readCommentById(String commentId) throws CommentIDNotFoundException {
+ Comment toReturn = new Comment();
+ OperationResult> result;
+ try {
+ result = conn.getKeyspace().prepareQuery(cf_Comments)
+ .getKey(commentId)
+ .execute();
+
+ ColumnList columns = result.getResult();
+ if (columns.size() == 0) {
+ throw new CommentIDNotFoundException("The requested commentId: " + commentId + " is not existing");
+ }
+
+ toReturn.setKey(commentId);
+ toReturn.setText(columns.getColumnByName("Text").getStringValue());
+ toReturn.setFullName(columns.getColumnByName("FullName").getStringValue());
+ toReturn.setEdit(columns.getColumnByName("IsEdited").getBooleanValue());
+ toReturn.setFeedid(columns.getColumnByName("Feedid").getStringValue());
+ toReturn.setUserid(columns.getColumnByName("Userid").getStringValue());
+ toReturn.setTime(getDateFromTimeInMillis(columns.getColumnByName("Timestamp").getStringValue()));
+ toReturn.setThumbnailURL(columns.getColumnByName("ThumbnailURL").getStringValue());
+ if (columns.getColumnByName("LastEditTime") != null)
+ toReturn.setLastEditTime(getDateFromTimeInMillis(columns.getColumnByName("LastEditTime").getStringValue()));
+
+ } catch (ConnectionException e) {
+ e.printStackTrace();
+ return null;
+ }
+ return toReturn;
+ }
/**
* {@inheritDoc}
*/
diff --git a/src/main/java/org/gcube/portal/databook/server/DatabookCassandraTest.java b/src/main/java/org/gcube/portal/databook/server/DatabookCassandraTest.java
index b92a180..4400483 100644
--- a/src/main/java/org/gcube/portal/databook/server/DatabookCassandraTest.java
+++ b/src/main/java/org/gcube/portal/databook/server/DatabookCassandraTest.java
@@ -8,9 +8,11 @@ import java.util.List;
import java.util.UUID;
import org.gcube.portal.databook.shared.Attachment;
+import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.PrivacyLevel;
+import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -58,41 +60,41 @@ public class DatabookCassandraTest {
// System.err.println("retrieved " + feeds.size() + " and " + numComment + " in " + (end - init) + "ms");
// }
- @Test
- public void testAttachments() {
- Attachment a1 = new Attachment(UUID.randomUUID().toString(), "www1", "gattino1", "description1", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg", "image/jpg");
- Attachment a2 = new Attachment(UUID.randomUUID().toString(), "www2", "name2", "description2", "http://www.gcomegatto.it/wp-content/uploads/2015/01/09gatto.jpg","image/jpg");
- Attachment a3 = new Attachment(UUID.randomUUID().toString(), "www3", "name3", "description3", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg","image/jpg");
- List toPass = new ArrayList();
- toPass.add(a1);
- toPass.add(a2);
- toPass.add(a3);
-
- String feedId = UUID.randomUUID().toString();
- Feed feed = new Feed(feedId, FeedType.TWEET, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
- "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
- "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
- "This post has attachments (gattini) ", PrivacyLevel.SINGLE_VRE,
- "Massimiliano Assante",
- "massimiliano.assante@isti.cnr.it",
- "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
- "Gattino",
- "linkDesc",
- "image/jpeg", false);
- feed.setMultiFileUpload(true);
- assertTrue(store.saveUserFeed(feed, toPass));
- System.out.println("Wrote post? ");
- System.out.println("Feed has the following attachments: ");
- try {
- for (Attachment at : store.getAttachmentsByFeedId(feedId)) {
- System.out.println(at);
- }
- } catch (FeedIDNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
+// @Test
+// public void testAttachments() {
+// Attachment a1 = new Attachment(UUID.randomUUID().toString(), "www1", "gattino1", "description1", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg", "image/jpg");
+// Attachment a2 = new Attachment(UUID.randomUUID().toString(), "www2", "name2", "description2", "http://www.gcomegatto.it/wp-content/uploads/2015/01/09gatto.jpg","image/jpg");
+// Attachment a3 = new Attachment(UUID.randomUUID().toString(), "www3", "name3", "description3", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg","image/jpg");
+// List toPass = new ArrayList();
+// toPass.add(a1);
+// toPass.add(a2);
+// toPass.add(a3);
+//
+// String feedId = UUID.randomUUID().toString();
+// Feed feed = new Feed(feedId, FeedType.TWEET, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
+// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
+// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
+// "This post has attachments (gattini) ", PrivacyLevel.SINGLE_VRE,
+// "Massimiliano Assante",
+// "massimiliano.assante@isti.cnr.it",
+// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
+// "Gattino",
+// "linkDesc",
+// "image/jpeg", false);
+// feed.setMultiFileUpload(true);
+// assertTrue(store.saveUserFeed(feed, toPass));
+// System.out.println("Wrote post? ");
+// System.out.println("Feed has the following attachments: ");
+// try {
+// for (Attachment at : store.getAttachmentsByFeedId(feedId)) {
+// System.out.println(at);
+// }
+// } catch (FeedIDNotFoundException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
// @Test
// public void testHashTag() {
@@ -494,36 +496,41 @@ public class DatabookCassandraTest {
//
//
//
- // @Test
- // public void testComments() {
- // int count = 10;
- // Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
- // "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
- // "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
- // assertTrue(store.saveUserFeed(feed));
- //
- // Comment toDelete = null;
- // for (int i = 0; i < count; i++) {
- // try {
- // toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
- // new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
- // assertTrue(store.addComment(toDelete));
- //
- // } catch (FeedIDNotFoundException e) {
- // System.out.println("Exception feed id not found");
- // }
- // }
- // System.out.println("GetAllCOmmentsByFeed ");
- // for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
- // System.out.println(cm.getText());
- // };
- //
- // try {
- // assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
- // } catch (Exception e) {
- // System.out.println("Exception feed id not found");
- // }
- // }
+// @Test
+// public void testComments() {
+// int count = 10;
+// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
+// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
+// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
+// assertTrue(store.saveUserFeed(feed));
+//
+// Comment toDelete = null;
+// for (int i = 0; i < count; i++) {
+// try {
+// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
+// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
+// assertTrue(store.addComment(toDelete));
+//
+// } catch (FeedIDNotFoundException e) {
+// System.out.println("Exception feed id not found");
+// }
+// }
+// System.out.println("GetAllCOmmentsByFeed ");
+// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
+// try {
+// System.out.println(store.readCommentById(cm.getKey()));
+// } catch (CommentIDNotFoundException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// };
+//
+// try {
+// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
+// } catch (Exception e) {
+// System.out.println("Exception feed id not found");
+// }
+// }
}
diff --git a/src/main/java/org/gcube/portal/databook/server/DatabookStore.java b/src/main/java/org/gcube/portal/databook/server/DatabookStore.java
index c0c6e38..6a2bcb7 100644
--- a/src/main/java/org/gcube/portal/databook/server/DatabookStore.java
+++ b/src/main/java/org/gcube/portal/databook/server/DatabookStore.java
@@ -286,7 +286,13 @@ public interface DatabookStore {
* @throws NotificationChannelTypeNotFoundException self explaining
*/
Map getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException;
-
+
+ /**
+ * @param commentId comment unique identifier
+ * @return the comment belonging to the commentId
+ * @throws CommentIDNotFoundException
+ */
+ Comment readCommentById(String commentId) throws CommentIDNotFoundException;
/**
* add a comment to a feed
* @param comment the Comment instance to add