Compare commits
16 Commits
|
@ -4,6 +4,10 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v2.0.1] - 2023-12-04
|
||||
|
||||
- Bug 27218 - Null pointer exception getting notifications preferences fixed
|
||||
|
||||
## [v2.0.0] - 2023-12-04
|
||||
|
||||
- Support for Cassandra 4.1.3 using DataStax java driver
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</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.
|
||||
|
|
|
@ -2190,19 +2190,32 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
|
||||
_log.info("Asking for Single Notification preference of " + userid + " Type: " + notificationType);
|
||||
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
|
||||
NotificationChannelType[] toProcess = getUserNotificationPreferences(userid).get(notificationType);
|
||||
_log.info("size of user notification preferences" + toProcess.length);
|
||||
if (toProcess == null) {
|
||||
_log.info("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
|
||||
return createNewNotificationType(userid, notificationType);
|
||||
}
|
||||
else if (toProcess.length == 0)
|
||||
return toReturn;
|
||||
else
|
||||
for (int i = 0; i < toProcess.length; i++) {
|
||||
toReturn.add(toProcess[i]);
|
||||
Map<NotificationType, NotificationChannelType[]> userNotPref = getUserNotificationPreferences(userid);
|
||||
if(userNotPref!=null){
|
||||
if(userNotPref.containsKey(notificationType)){
|
||||
NotificationChannelType[] toProcess = userNotPref.get(notificationType);
|
||||
//_log.info("size of user notification preferences" + toProcess.length);
|
||||
if (toProcess == null) {
|
||||
_log.info("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
|
||||
return createNewNotificationType(userid, notificationType);
|
||||
}
|
||||
else if (toProcess.length == 0){
|
||||
_log.info("size of user notification preferences " + 0);
|
||||
return toReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.info("size of user notification preferences " + toProcess.length);
|
||||
for (int i = 0; i < toProcess.length; i++) {
|
||||
toReturn.add(toProcess[i]);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
/**
|
||||
* called when you add new notification types where the setting does not exist yet
|
||||
|
@ -2284,7 +2297,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
*/
|
||||
@Override
|
||||
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
|
||||
_log.trace("Asking for Notification preferences of " + userid);
|
||||
_log.info("Asking for Notification preferences of " + userid);
|
||||
Map<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
|
||||
|
||||
ResultSet result = null;
|
||||
|
@ -2301,9 +2314,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//if there are no settings for this user create an entry and put all of them at true
|
||||
List<Row> results = result.all();
|
||||
List<Row> results = new ArrayList<>();
|
||||
if(result!=null) results = result.all();
|
||||
//_log.info("Result set empty? " + results.isEmpty());
|
||||
if (results.isEmpty()) {
|
||||
_log.info("Userid " + userid + " settings not found, initiating its preferences...");
|
||||
HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
|
||||
|
@ -2323,10 +2338,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
return toCreate;
|
||||
}
|
||||
else {
|
||||
_log.trace("Notification preferences Found for " + userid);
|
||||
_log.info("Notification preferences Found for " + userid + " : " + results.size()) ;
|
||||
for (Row row: results){
|
||||
String[] channels = row.getString(PREFERENCE).split(",");
|
||||
//_log.info("Row : " + row.getString(PREFERENCE));
|
||||
if (channels != null && channels.length == 1 && channels[0].toString().equals("") ) { //it is empty, preference is set to no notification at all
|
||||
//_log.info("adding CHANNELS NULL: " + getNotificationType(row.getString(TYPE)) + ", " + new NotificationChannelType[0]);
|
||||
toReturn.put(getNotificationType(row.getString(TYPE)), new NotificationChannelType[0]);
|
||||
} else {
|
||||
NotificationChannelType[] toAdd = new NotificationChannelType[channels.length];
|
||||
|
@ -2335,10 +2352,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
toAdd[i] = (getChannelType(channels[i]));
|
||||
}
|
||||
}
|
||||
//_log.info("adding channels not null: " + getNotificationType(row.getString(TYPE)) + ", " + toAdd.toString());
|
||||
toReturn.put(getNotificationType(row.getString(TYPE)), toAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
_log.info("Returning:"+toReturn.size());
|
||||
return toReturn;
|
||||
}
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue