removed noisy logs

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2024-04-22 10:49:02 +02:00
parent 8509015a18
commit 572c7b8199
3 changed files with 42 additions and 41 deletions

View File

@ -4,9 +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
## [v2.0.1-SNAPSHOT] - 2024-04-22
- Bug 27218 - Null pointer exception getting notifications preferences fixed
- Feature 27286 - Removed noisy logs
## [v2.0.0] - 2023-12-04

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>2.0.1</version>
<version>2.0.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

@ -748,7 +748,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
Boolean result = session.execute(writeBatch).wasApplied();
if (result){
_log.info("Wrote user post with id " + post.getKey());
_log.debug("Wrote user post with id " + post.getKey());
}
@ -796,7 +796,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
Boolean result = session.execute(writeBatch).wasApplied();
if (result){
_log.info("Wrote user post with id " + post.getKey());
_log.debug("Wrote user post with id " + post.getKey());
}
@ -831,7 +831,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
post.setMultiFileUpload(true);
boolean savePostResult = saveUserPost(post);
if (savePostResult) {
_log.info("Post has been saved");
_log.debug("Post has been saved");
String postkey = post.getKey();
for (Attachment attachment : attachments) {
boolean attachSaveResult = saveAttachmentEntry(postkey, attachment);
@ -888,7 +888,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
boolean result = session.execute(writeBatch).wasApplied();
if (result)
_log.info("Wrote app post with id " + post.getKey());
_log.debug("Wrote app post with id " + post.getKey());
return result;
}
@ -936,7 +936,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
boolean result = session.execute(writeBatch).wasApplied();
if (result)
_log.info("Wrote app post with id " + post.getKey());
_log.debug("Wrote app post with id " + post.getKey());
return result;
}
@ -1169,7 +1169,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("Delete Post OK");
_log.debug("Delete Post OK");
return true;
}
/**
@ -1189,7 +1189,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("Delete Post OK");
_log.debug("Delete Post OK");
return true;
}
/**
@ -2188,24 +2188,24 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
_log.info("Asking for Single Notification preference of " + userid + " Type: " + notificationType);
_log.debug("Asking for Single Notification preference of " + userid + " Type: " + notificationType);
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
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);
//_log.debug("size of user notification preferences" + toProcess.length);
if (toProcess == null) {
_log.info("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
_log.debug("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);
_log.debug("size of user notification preferences " + 0);
return toReturn;
}
else
{
_log.info("size of user notification preferences " + toProcess.length);
_log.debug("size of user notification preferences " + toProcess.length);
for (int i = 0; i < toProcess.length; i++) {
toReturn.add(toProcess[i]);
}
@ -2223,7 +2223,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
private List<NotificationChannelType> createNewNotificationType(String userid, NotificationType notificationType) {
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
_log.info("Create new notification type");
_log.debug("Create new notification type");
CqlSession session = conn.getKeyspaceSession();
String valueToInsert = "";
@ -2249,11 +2249,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
if (res) {
_log.info("Set New Notification Setting for " + userid + " OK");
_log.info("toreturn:" + toReturn.toString());
_log.debug("Set New Notification Setting for " + userid + " OK");
_log.debug("toreturn:" + toReturn.toString());
return toReturn;
}
_log.info("empty list");
_log.debug("empty list");
return new ArrayList<NotificationChannelType>(); //no notification if sth fails
}
/**
@ -2266,10 +2266,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
for (NotificationType nType : enabledChannels.keySet()) {
String valueToInsert = "";
_log.info("Type: " + nType.toString());
_log.debug("Type: " + nType.toString());
int channelsNo = (enabledChannels.get(nType) != null) ? enabledChannels.get(nType).length : 0;
for (int i = 0; i < channelsNo; i++) {
_log.info(enabledChannels.get(nType)[i].toString());
_log.debug(enabledChannels.get(nType)[i].toString());
valueToInsert += NotificationChannelType.valueOf(enabledChannels.get(nType)[i].toString());
if (i < channelsNo-1)
valueToInsert += ",";
@ -2285,9 +2285,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
BatchStatement writeBatch = getBatch().addAll(boundStatements);
boolean overAllresult = session.execute(writeBatch).wasApplied();
if (overAllresult)
_log.info("Set Notification Map for " + userid + " OK");
_log.debug("Set Notification Map for " + userid + " OK");
else
_log.info("Set Notification Map for " + userid + " FAILED");
_log.debug("Set Notification Map for " + userid + " FAILED");
return overAllresult;
}
/**
@ -2297,7 +2297,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
_log.info("Asking for Notification preferences of " + userid);
_log.debug("Asking for Notification preferences of " + userid);
Map<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
ResultSet result = null;
@ -2318,9 +2318,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
//if there are no settings for this user create an entry and put all of them at true
List<Row> results = new ArrayList<>();
if(result!=null) results = result.all();
//_log.info("Result set empty? " + results.isEmpty());
//_log.debug("Result set empty? " + results.isEmpty());
if (results.isEmpty()) {
_log.info("Userid " + userid + " settings not found, initiating its preferences...");
_log.debug("Userid " + userid + " settings not found, initiating its preferences...");
HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
for (int i = 0; i < NotificationType.values().length; i++) {
@ -2338,12 +2338,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return toCreate;
}
else {
_log.info("Notification preferences Found for " + userid + " : " + results.size()) ;
_log.debug("Notification preferences Found for " + userid + " : " + results.size()) ;
for (Row row: results){
String[] channels = row.getString(PREFERENCE).split(",");
//_log.info("Row : " + row.getString(PREFERENCE));
//_log.debug("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]);
//_log.debug("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];
@ -2352,12 +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());
//_log.debug("adding channels not null: " + getNotificationType(row.getString(TYPE)) + ", " + toAdd.toString());
toReturn.put(getNotificationType(row.getString(TYPE)), toAdd);
}
}
}
_log.info("Returning:"+toReturn.size());
_log.debug("Returning:"+toReturn.size());
return toReturn;
}
/*
@ -2432,7 +2432,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
e.printStackTrace();
return false;
}
_log.info("Writing comment : {}", comment.toString());
_log.debug("Writing comment : {}", comment.toString());
CqlSession session = conn.getKeyspaceSession();
List<BoundStatement> boundStatements = insertIntoComments(session, comment);
@ -2443,10 +2443,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
try {
ResultSet res = session.execute(writeBatch);
for (ExecutionInfo ex: res.getExecutionInfos()){
_log.info("Writing comment result errors: {}", ex.getErrors());
_log.info("Writing comment result payload: {}", ex.getIncomingPayload());
_log.debug("Writing comment result errors: {}", ex.getErrors());
_log.debug("Writing comment result payload: {}", ex.getIncomingPayload());
}
_log.info("Writing comment result executed?: {}", res.wasApplied());
_log.debug("Writing comment result executed?: {}", res.wasApplied());
} catch (Exception e) {
e.printStackTrace();
@ -2605,7 +2605,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
try {
boolean res = session.execute(writeBatch).wasApplied();
_log.info("Comments update OK to: " + comment2Edit.getText());
_log.debug("Comments update OK to: " + comment2Edit.getText());
return res;
} catch (Exception e) {
@ -2706,7 +2706,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
if (isPostLiked(like.getUserid(), feedId)) {
_log.info("User " + like.getUserid() + " already liked Feed " + feedId);
_log.debug("User " + like.getUserid() + " already liked Feed " + feedId);
return true;
}
else {
@ -3158,7 +3158,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
if(feeds.isEmpty()){
_log.info("There are no feeds containing hashtag " + row.getString(HASHTAG) + " in vre " + vreid);
_log.debug("There are no feeds containing hashtag " + row.getString(HASHTAG) + " in vre " + vreid);
continue;
}
@ -3639,8 +3639,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
BatchStatement writeBatch = getBatch().addAll(boundStatements);
//boundStatements.forEach(stmt->writeBatch.add(stmt));
ResultSet res = session.execute(writeBatch);
_log.info(res.getExecutionInfos().toString());
_log.info(""+res.wasApplied());
_log.debug(res.getExecutionInfos().toString());
_log.debug(""+res.wasApplied());
/*
session.execute(createNewaAttachEntry(session).bind(
UUID.fromString(toSave.getId()),
@ -3952,7 +3952,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("CommentsNo update OK to: " + newCount);
_log.debug("CommentsNo update OK to: " + newCount);
return true;
}
@ -3981,7 +3981,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("LikesNo update OK to: " + newCount);
_log.debug("LikesNo update OK to: " + newCount);
return true;
}