Fixed null pointer exception while retrieving some old comments that don't have the "IsEdited" property.
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@122753 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
21e57efddb
commit
a5ea860381
|
@ -1354,7 +1354,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
toReturn.setKey(commentId);
|
||||
toReturn.setText(columns.getColumnByName("Text").getStringValue());
|
||||
toReturn.setFullName(columns.getColumnByName("FullName").getStringValue());
|
||||
toReturn.setEdit(columns.getColumnByName("IsEdited").getBooleanValue());
|
||||
if(columns.getColumnByName("IsEdited") != null)
|
||||
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()));
|
||||
|
@ -1363,7 +1364,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
toReturn.setLastEditTime(getDateFromTimeInMillis(columns.getColumnByName("LastEditTime").getStringValue()));
|
||||
|
||||
} catch (ConnectionException e) {
|
||||
e.printStackTrace();
|
||||
_log.debug(e.toString());
|
||||
return null;
|
||||
}
|
||||
return toReturn;
|
||||
|
@ -2353,7 +2354,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
}
|
||||
|
||||
_log.debug("VRE ids are " + ids);
|
||||
|
||||
|
||||
return ids;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,22 +32,37 @@ public class DatabookCassandraTest {
|
|||
public static void close(){
|
||||
store.closeConnection();
|
||||
System.out.println("End");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// public void vreIds(){
|
||||
//
|
||||
// public void getComment(){
|
||||
//
|
||||
// String uuid = "820969b2-4632-4197-9fd6-5aafab781faa";
|
||||
//
|
||||
// Comment c;
|
||||
// try {
|
||||
// List<String> ids = store.getAllVREIds();
|
||||
// System.out.println(ids);
|
||||
// } catch (ConnectionException e) {
|
||||
// c = store.readCommentById(uuid);
|
||||
// System.err.println(c);
|
||||
// } catch (CommentIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// System.err.println(e.toString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void vreIds(){
|
||||
//
|
||||
// try {
|
||||
// List<String> ids = store.getAllVREIds();
|
||||
// System.out.println(ids);
|
||||
// } catch (ConnectionException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testFeedNumberPerUser() {
|
||||
// String userid = "massimiliano.assante";
|
||||
|
@ -76,41 +91,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<Attachment> toPass = new ArrayList<Attachment>();
|
||||
// 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<Attachment> toPass = new ArrayList<Attachment>();
|
||||
// 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() {
|
||||
|
@ -148,31 +163,31 @@ public class DatabookCassandraTest {
|
|||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
|
||||
// */
|
||||
// @Test
|
||||
// public void addAttachmentStaticColumnFamilies() {
|
||||
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
|
||||
//
|
||||
// try {
|
||||
// String colNameToIndex = "feedId";
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
|
||||
// .put("column_metadata", ImmutableMap.<String, Object>builder()
|
||||
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
|
||||
// .put("validation_class", "UTF8Type")
|
||||
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
|
||||
// .put("index_type", "KEYS")
|
||||
// .build())
|
||||
// .build())
|
||||
// .build());
|
||||
//
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addStaticColumnFamily END");
|
||||
// }
|
||||
// /**
|
||||
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
|
||||
// */
|
||||
// @Test
|
||||
// public void addAttachmentStaticColumnFamilies() {
|
||||
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
|
||||
//
|
||||
// try {
|
||||
// String colNameToIndex = "feedId";
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
|
||||
// .put("column_metadata", ImmutableMap.<String, Object>builder()
|
||||
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
|
||||
// .put("validation_class", "UTF8Type")
|
||||
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
|
||||
// .put("index_type", "KEYS")
|
||||
// .build())
|
||||
// .build())
|
||||
// .build());
|
||||
//
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addStaticColumnFamily END");
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
|
@ -512,41 +527,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())) {
|
||||
// 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");
|
||||
// }
|
||||
// }
|
||||
// @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");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue