added support to alert the users of a VRE when posting in to a VRE. Added new notification type

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@92660 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-03-04 23:39:43 +00:00
parent a9a9025017
commit f4100c709b
5 changed files with 18008 additions and 340 deletions

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,6 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>

View File

@ -926,13 +926,13 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
/**
* called when you add new notification types where the setting does not exist yet
* please note: by default we set only portal notifications
* please note: by default we set all notifications
*/
private List<NotificationChannelType> createNewNotificationType(String userid, NotificationType notificationType) {
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
String valueToInsert = "";
NotificationChannelType[] wpTypes = { NotificationChannelType.PORTAL };
NotificationChannelType[] wpTypes = NotificationChannelType.values();
for (int i = 0; i < wpTypes.length; i++) {
valueToInsert += wpTypes[i];
@ -1001,12 +1001,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
for (int i = 0; i < NotificationType.values().length; i++) {
//TODO: Potential bug in NotificationType for workspace are refactored
//create a map with all notification enabled except for workflow notifications (They start with WP_) it was the only quick way
if (NotificationType.values()[i].toString().startsWith("WP_") || NotificationType.values()[i].toString().startsWith("CALENDAR")) {
NotificationChannelType[] wpTypes = { NotificationChannelType.PORTAL };
toCreate.put(NotificationType.values()[i], wpTypes);
}
else
//create a map with all notification enabled except for workspace notifications (They start with WP_) it was the only quick way
// if (NotificationType.values()[i].toString().startsWith("WP_") || NotificationType.values()[i].toString().startsWith("CALENDAR")) {
// NotificationChannelType[] wpTypes = { NotificationChannelType.PORTAL };
// toCreate.put(NotificationType.values()[i], wpTypes);
// }
// else
toCreate.put(NotificationType.values()[i], NotificationChannelType.values());
}
setUserNotificationPreferences(userid, toCreate); //commit the map
@ -1472,6 +1472,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
else if (type.compareTo("MESSAGE") == 0) {
return NotificationType.MESSAGE;
}
else if (type.compareTo("POST_ALERT") == 0) {
return NotificationType.POST_ALERT;
}
else if (type.compareTo("REQUEST_CONNECTION") == 0) {
return NotificationType.REQUEST_CONNECTION;
}

View File

@ -29,7 +29,7 @@ public class DatabookCassandraTest {
@BeforeClass
public static void setup() throws Exception {
store = new DBCassandraAstyanaxImpl(false); //set to true if you want to drop the KeySpace and recreate it
store = new DBCassandraAstyanaxImpl(); //set to true if you want to drop the KeySpace and recreate it
}
@AfterClass
@ -38,50 +38,50 @@ public class DatabookCassandraTest {
System.out.println("End");
}
/**
* use exclusively to add a new CF to a keyspace
*/
@Test
public void addNotifPreferencesColumnFamily() {
// ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
// DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
// StringSerializer.get(), // Key Serializer
// StringSerializer.get()); // Column Serializer
//
// try {
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
// .put("default_validation_class", "UTF8Type")
// .put("key_validation_class", "UTF8Type")
// .put("comparator_type", "UTF8Type")
// .build());
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
}
@Test
public void testFriendships() {
assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
System.out.println("Pending Connections for massimiliano.assante:");
for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
System.out.println(userid);
}
System.out.println("Connections for massimiliano.assante:");
for (String userid: store.getFriends("massimiliano.assante")) {
System.out.println(userid);
}
}
//
// /**
// * use exclusively to add a new CF to a keyspace
// */
// @Test
// public void addNotifPreferencesColumnFamily() {
// // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
// // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
// // StringSerializer.get(), // Key Serializer
// // StringSerializer.get()); // Column Serializer
// //
// // try {
// // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
// // .put("default_validation_class", "UTF8Type")
// // .put("key_validation_class", "UTF8Type")
// // .put("comparator_type", "UTF8Type")
// // .build());
// // } catch (ConnectionException e) {
// // e.printStackTrace();
// // }
// }
//
// @Test
// public void testFriendships() {
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
// assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
// assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
// assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
//
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
// assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
//
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
// System.out.println("Pending Connections for massimiliano.assante:");
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// System.out.println("Connections for massimiliano.assante:");
// for (String userid: store.getFriends("massimiliano.assante")) {
// System.out.println(userid);
// }
//
// }
@Test
public void testLikedFeedsRetrieval() {
try {
@ -92,290 +92,290 @@ public class DatabookCassandraTest {
e.printStackTrace();
}
}
@Test
public void testSingleNotificationPreference() {
try {
for (NotificationChannelType channel : store.getUserNotificationChannels("massimiliano.assante", NotificationType.COMMENT)) {
System.out.println(channel);
}
} catch (NotificationChannelTypeNotFoundException e) {
e.printStackTrace();
} catch (NotificationTypeNotFoundException e) {
e.printStackTrace();
};
HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
for (int i = 0; i < NotificationType.values().length; i++) {
if (i == 0)
toCreate.put(NotificationType.values()[i], null);
else if (i ==3) {
NotificationChannelType[] nots = {NotificationChannelType.PORTAL};
toCreate.put(NotificationType.values()[i], nots);
}
else
toCreate.put(NotificationType.values()[i], NotificationChannelType.values());
}
store.setUserNotificationPreferences("antonio.gioia", toCreate);
try {
for (NotificationChannelType channel : store.getUserNotificationChannels("antonio.gioia", NotificationType.WP_FOLDER_RENAMED)) { //i == 3
System.out.println(channel);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testSingleNotification() {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.LIKE,
"leonardo.candela",
"MESSAGEID",
new Date(),
"uri",
"This is notification about a like",
false,
"leonardo.candela", "Leonardo Candela",
"thumburl");
assertTrue(store.saveNotification(not));
not = new Notification(
UUID.randomUUID().toString(),
NotificationType.MESSAGE,
"massimiliano.assante",
"MESSAGEID",
new Date(),
"uri",
"This is notification about a like",
false,
"antonio.gioia", "Antonio Gioia",
"thumburl");
assertTrue(store.saveNotification(not));
System.out.println("Writing one Notification " + not);
}
@Test
public void testNotifications() {
Notification not = null;
System.out.println("Writing 18 Notifications");
int count = 18;
for (int i = 0; i < count; i++) {
if (i % 2 != 0) {
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
"leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
} else {
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
"massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
}
assertTrue(store.saveNotification(not));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Notification rNot= null;
try {
//read
rNot = store.readNotification(not.getKey().toString());
assertNotNull(rNot);
System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
//set Read
assertTrue(store.setNotificationRead(rNot.getKey().toString()));
System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
"leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
assertTrue(store.saveNotification(not));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
rNot = store.readNotification(not.getKey().toString());
System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
// //set Read
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
//
Random randomGenerator = new Random();
System.out.println("leonardo.candela Notifications: ");
List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
assertNotNull(recentNots);
for (Notification notif :recentNots)
System.out.println(notif);
System.out.println("massimiliano.assante Notifications: ");
recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
assertNotNull(recentNots);
for (Notification notif :recentNots)
System.out.println(notif);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testFeeds() {
int count = 18;
Feed feed = null;
for (int i = 0; i < count; i++) {
if (i % 2 != 0) {
feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
} else {
feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
"www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
}
assertTrue(store.saveUserFeed(feed));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Feed rFeed = null;
try {
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
assertNotNull(rFeed);
String feedIdToDelete = UUID.randomUUID().toString();
feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
try {
Thread.sleep(250);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Test Delete Feed ");
assertTrue(store.deleteFeed(feedIdToDelete));
System.out.println("massimiliano.assante ALL FEEDS: ");
for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
System.out.println(recFeed);
Random randomGenerator = new Random();
System.out.println("leonardo.candela TIMELINE: ");
List<Feed> recentFeeds = store.getRecentFeedsByUser("leonardo.candela", randomGenerator.nextInt(50));
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
System.out.println("/gcube/devsec/devVRE TIMELINE: ");
recentFeeds = store.getRecentFeedsByVRE("/gcube/devsec/devVRE", randomGenerator.nextInt(50));
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
System.out.println("PORTAL TIMELINE: ");
recentFeeds = store.getAllPortalPrivacyLevelFeeds();
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
} catch (Exception e) {
e.printStackTrace();
}
}
// @Test
// public void testNotifications() {
// int count = 10;
// Notification notf = null;
// for (int i = 0; i < count; i++) {
// notf = new Notification(UUID.randomUUID().toString(), NotificationType.MESSAGE, "massimiliano.assante", new Date(), "http://urir.com", "Desc #"+i, "Gino Camillo", false);
// assertTrue(store.saveNotification(notf));
// }
// try {
// assertNotNull(store.getAllNotificationByUser("massimiliano.assante"));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
@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 testLikes() {
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 feed is Liked ", PrivacyLevel.PUBLIC,
"Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
try {
assertTrue(store.like(toUnlike));
for (int i = 0; i < count; i++)
assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
System.out.println("massimiliano.assante liked the following feeds: ");
for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
System.out.println(feedid);
}
for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
System.out.println(like);
}
System.out.println("trying unlike");
assertTrue(store.unlike(toUnlike.getKey(), toUnlike.getFeedid()));
} catch (Exception e) {
System.out.println("Exception feed id not found");
}
}
//
//
// @Test
// public void testSingleNotificationPreference() {
// try {
// for (NotificationChannelType channel : store.getUserNotificationChannels("massimiliano.assante", NotificationType.COMMENT)) {
// System.out.println(channel);
// }
// } catch (NotificationChannelTypeNotFoundException e) {
// e.printStackTrace();
// } catch (NotificationTypeNotFoundException e) {
// e.printStackTrace();
// };
// HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
// for (int i = 0; i < NotificationType.values().length; i++) {
// if (i == 0)
// toCreate.put(NotificationType.values()[i], null);
// else if (i ==3) {
// NotificationChannelType[] nots = {NotificationChannelType.PORTAL};
// toCreate.put(NotificationType.values()[i], nots);
// }
// else
// toCreate.put(NotificationType.values()[i], NotificationChannelType.values());
// }
// store.setUserNotificationPreferences("antonio.gioia", toCreate);
//
//
// try {
// for (NotificationChannelType channel : store.getUserNotificationChannels("antonio.gioia", NotificationType.WP_FOLDER_RENAMED)) { //i == 3
// System.out.println(channel);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// @Test
// public void testSingleNotification() {
// Notification not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.LIKE,
// "leonardo.candela",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "leonardo.candela", "Leonardo Candela",
// "thumburl");
// assertTrue(store.saveNotification(not));
//
// not = new Notification(
// UUID.randomUUID().toString(),
// NotificationType.MESSAGE,
// "massimiliano.assante",
// "MESSAGEID",
// new Date(),
// "uri",
// "This is notification about a like",
// false,
// "antonio.gioia", "Antonio Gioia",
// "thumburl");
// assertTrue(store.saveNotification(not));
// System.out.println("Writing one Notification " + not);
// }
//
// @Test
// public void testNotifications() {
// Notification not = null;
// System.out.println("Writing 18 Notifications");
// int count = 18;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
// "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
// } else {
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
// "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
// }
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Notification rNot= null;
// try {
//
// //read
// rNot = store.readNotification(not.getKey().toString());
// assertNotNull(rNot);
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
//
// //set Read
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
//
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
//
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
// "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
// assertTrue(store.saveNotification(not));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// rNot = store.readNotification(not.getKey().toString());
// System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
// // //set Read
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
// //
// Random randomGenerator = new Random();
//
// System.out.println("leonardo.candela Notifications: ");
// List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
//
//
// System.out.println("massimiliano.assante Notifications: ");
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
// assertNotNull(recentNots);
// for (Notification notif :recentNots)
// System.out.println(notif);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
// @Test
// public void testFeeds() {
// int count = 18;
// Feed feed = null;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// } else {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// }
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Feed rFeed = null;
// try {
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// assertNotNull(rFeed);
//
// String feedIdToDelete = UUID.randomUUID().toString();
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(250);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.out.println("Test Delete Feed ");
// assertTrue(store.deleteFeed(feedIdToDelete));
//
// System.out.println("massimiliano.assante ALL FEEDS: ");
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
// System.out.println(recFeed);
//
// Random randomGenerator = new Random();
//
// System.out.println("leonardo.candela TIMELINE: ");
// List<Feed> recentFeeds = store.getRecentFeedsByUser("leonardo.candela", randomGenerator.nextInt(50));
// assertNotNull(recentFeeds);
// for (Feed recFeed :recentFeeds)
// System.out.println(recFeed);
//
//
// System.out.println("/gcube/devsec/devVRE TIMELINE: ");
// recentFeeds = store.getRecentFeedsByVRE("/gcube/devsec/devVRE", randomGenerator.nextInt(50));
// assertNotNull(recentFeeds);
// for (Feed recFeed :recentFeeds)
// System.out.println(recFeed);
//
// System.out.println("PORTAL TIMELINE: ");
// recentFeeds = store.getAllPortalPrivacyLevelFeeds();
// assertNotNull(recentFeeds);
// for (Feed recFeed :recentFeeds)
// System.out.println(recFeed);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// // @Test
// // public void testNotifications() {
// // int count = 10;
// // Notification notf = null;
// // for (int i = 0; i < count; i++) {
// // notf = new Notification(UUID.randomUUID().toString(), NotificationType.MESSAGE, "massimiliano.assante", new Date(), "http://urir.com", "Desc #"+i, "Gino Camillo", false);
// // assertTrue(store.saveNotification(notf));
// // }
// // try {
// // assertNotNull(store.getAllNotificationByUser("massimiliano.assante"));
// // } catch (Exception e) {
// // e.printStackTrace();
// // }
// // }
//
// @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 testLikes() {
// 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 feed is Liked ", PrivacyLevel.PUBLIC,
// "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
//
// try {
// assertTrue(store.like(toUnlike));
// for (int i = 0; i < count; i++)
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
//
// System.out.println("massimiliano.assante liked the following feeds: ");
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
// System.out.println(feedid);
// }
//
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
// System.out.println(like);
// }
//
// System.out.println("trying unlike");
// assertTrue(store.unlike(toUnlike.getKey(), toUnlike.getFeedid()));
//
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
}

View File

@ -62,6 +62,10 @@ public enum NotificationType {
* use to notify a user he got a message
*/
MESSAGE,
/**
* use to notify every user of a VRE/Group that the post was made
*/
POST_ALERT,
/**
* use to notify a user that someone in his VRE created a new Event in the Calendar
*/