|
|
|
@ -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,21 +2188,34 @@ 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>();
|
|
|
|
|
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.debug("size of user notification preferences" + toProcess.length);
|
|
|
|
|
if (toProcess == null) {
|
|
|
|
|
_log.debug("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
|
|
|
|
|
return createNewNotificationType(userid, notificationType);
|
|
|
|
|
}
|
|
|
|
|
else if (toProcess.length == 0){
|
|
|
|
|
_log.debug("size of user notification preferences " + 0);
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_log.debug("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
|
|
|
|
@ -2210,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 = "";
|
|
|
|
@ -2236,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
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -2253,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 += ",";
|
|
|
|
@ -2272,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;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -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.debug("Asking for Notification preferences of " + userid);
|
|
|
|
|
Map<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
|
|
|
|
|
|
|
|
|
|
ResultSet result = null;
|
|
|
|
@ -2301,11 +2314,13 @@ 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.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++) {
|
|
|
|
@ -2323,10 +2338,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|
|
|
|
return toCreate;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_log.trace("Notification preferences Found for " + userid);
|
|
|
|
|
_log.debug("Notification preferences Found for " + userid + " : " + results.size()) ;
|
|
|
|
|
for (Row row: results){
|
|
|
|
|
String[] channels = row.getString(PREFERENCE).split(",");
|
|
|
|
|
//_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.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];
|
|
|
|
@ -2335,10 +2352,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|
|
|
|
toAdd[i] = (getChannelType(channels[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//_log.debug("adding channels not null: " + getNotificationType(row.getString(TYPE)) + ", " + toAdd.toString());
|
|
|
|
|
toReturn.put(getNotificationType(row.getString(TYPE)), toAdd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_log.debug("Returning:"+toReturn.size());
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
@ -2413,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);
|
|
|
|
@ -2424,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();
|
|
|
|
@ -2586,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) {
|
|
|
|
|
|
|
|
|
@ -2687,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 {
|
|
|
|
@ -3139,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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -3620,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()),
|
|
|
|
@ -3933,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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3962,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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|