Fixed bug returning sendNotification false when a Notification Preference was null for a given Notification Type

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@95317 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-05-05 14:26:18 +00:00
parent a96221d129
commit 750b9b0d4e
6 changed files with 3227 additions and 21 deletions

View File

@ -19,7 +19,7 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

File diff suppressed because it is too large Load Diff

View File

@ -26,4 +26,7 @@
<Change>Added support for notifications retrieval by range</Change>
<Change>Added support for unlike feature</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-6-1" date="2014-05-05">
<Change>Fixed bug returning sendNotification false when a Notification Preference was null for a given Notification Type</Change>
</Changeset>
</ReleaseNotes>

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.6.0-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
<name>gCube Social Networking Library</name>
<description>
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.

View File

@ -641,20 +641,20 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
ArrayList<Feed> feedsToReturn = new ArrayList<Feed>();
ArrayList<String> feedIDs = getVREFeedIds(vreid);
//if from is greater than feeds size return empty
if (from >= feedIDs.size()) {
_log.warn("The starting point of the range is greather than the total number of feeds for this timeline: " + from + " >= " + feedIDs.size());
return new RangeFeeds();
}
int rangeStart = feedIDs.size()-from;
int rangeEnd = rangeStart-quantity;
//check that you reached the end
if (rangeEnd<1)
rangeEnd = 0;
_log.debug("BEFORE starting Point=" + rangeStart + " rangeEnd= " + rangeEnd);
//need them in reverse order
int howMany = from;
@ -885,20 +885,20 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
ArrayList<Notification> toReturn = new ArrayList<Notification>();
ArrayList<String> notificationsIDs = getUserNotificationsIds(userid);
//if from is greater than feeds size return empty
if (from >= notificationsIDs.size()) {
_log.warn("The starting point of the range is greather than the total number of feeds for this timeline: " + from + " >= " + notificationsIDs.size());
return new ArrayList<Notification>();
}
int rangeStart = notificationsIDs.size()-from;
int rangeEnd = rangeStart-quantity;
//check that you reached the end
if (rangeEnd<1)
rangeEnd = 0;
_log.debug("BEFORE starting Point=" + rangeStart + " rangeEnd= " + rangeEnd);
//need them in reverse order
for (int i = rangeStart; i > rangeEnd; i--) {
@ -994,7 +994,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
if (toProcess == null) {
_log.warn("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
return createNewNotificationType(userid, notificationType);
} else
}
else if (toProcess.length == 0)
return toReturn;
else
for (int i = 0; i < toProcess.length; i++) {
toReturn.add(toProcess[i]);
}
@ -1009,7 +1012,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
String valueToInsert = "";
NotificationChannelType[] wpTypes = NotificationChannelType.values();
for (int i = 0; i < wpTypes.length; i++) {
valueToInsert += wpTypes[i];
if (i < wpTypes.length-1)
@ -1094,13 +1097,17 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
for (Row<String, String> row : result.getResult())
for (Column<String> column : row.getColumns()) {
String[] channels = column.getStringValue().split(",");
NotificationChannelType[] toAdd = new NotificationChannelType[channels.length];
for (int i = 0; i < channels.length; i++) {
if (channels[i].compareTo("") != 0)
toAdd[i] = (getChannelType(channels[i]));
if (channels != null && channels.length == 1 && channels[0].toString().equals("") ) { //it is empty, preference is set to no notification at all
toReturn.put(getNotificationType(column.getName()), new NotificationChannelType[0]);
} else {
NotificationChannelType[] toAdd = new NotificationChannelType[channels.length];
for (int i = 0; i < channels.length; i++) {
if (channels[i].compareTo("") != 0) {
toAdd[i] = (getChannelType(channels[i]));
}
}
toReturn.put(getNotificationType(column.getName()), toAdd);
}
toReturn.put(getNotificationType(column.getName()), toAdd);
}
}
return toReturn;
@ -1297,8 +1304,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
m.withRow(cf_Likes, likeid).delete();
//delete the column from UserLikes
m.withRow(cf_UserLikedFeeds, userid).deleteColumn(likeid);
try {
m.execute();

View File

@ -242,7 +242,7 @@ public interface DatabookStore {
*/
List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException;
/**
* set the notification preferences map (enableor disable the channels to be used for notifying the user)
* set the notification preferences map (enable or disable the channels to be used for notifying the user)
* @param userid user identifier
* @param notificationType the type of the notification
* @param enabledChannels a map of the channels to which reach the user per notification, empty array or null values to set the key notification type off