diff --git a/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java b/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java index 4a55ba9..250da23 100644 --- a/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java +++ b/src/main/java/org/gcube/portal/databook/server/DBCassandraAstyanaxImpl.java @@ -2088,7 +2088,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { } //if there are no settings for this user create an entry and put all of them at true - if (result.all().isEmpty()) { + List results = result.all(); + if (results.isEmpty()) { _log.info("Userid " + userid + " settings not found, initiating its preferences..."); HashMap toCreate = new HashMap(); @@ -2108,7 +2109,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { } else { _log.trace("Notification preferences Found for " + userid); - for (Row row: result.all()){ + for (Row row: results){ String[] channels = row.getString(PREFERENCE).split(","); if (channels != null && channels.length == 1 && channels[0].toString().equals("") ) { //it is empty, preference is set to no notification at all toReturn.put(getNotificationType(row.getString(TYPE)), new NotificationChannelType[0]); @@ -2190,11 +2191,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { .build()); try { result = session.execute(stmtFind.bind(UUID.fromString(commentId))); - - if (result.all().isEmpty()) { + toReturn = readCommentFromRow(result.one()); + if (toReturn==null) { throw new CommentIDNotFoundException("The requested commentId: " + commentId + " is not existing"); } - toReturn = readCommentFromRow(result.one()); + } catch (Exception e){ e.printStackTrace(); } @@ -2284,9 +2285,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { try { result = session.execute(stmtFind.bind()); - - if (!result.all().isEmpty()){ - result.all().parallelStream().forEach( row->{ + List results = result.all(); + if (!results.isEmpty()){ + results.parallelStream().forEach( row->{ if(row.getString(USER_ID).equals(userid)){ try{ Comment c = readCommentById(row.getUuid(COMMENT_ID).toString()); @@ -3065,10 +3066,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { .build()); try { result = session.execute(stmtFind.bind(UUID.fromString(inviteid))); - if (result.one() == null) { + toReturn = readAInviteFromRow(result.one()); + if (toReturn == null) { throw new InviteStatusNotFoundException("The requested inviteid: " + inviteid + " is not existing"); } - toReturn = readAInviteFromRow(result.one()); + //toReturn = readAInviteFromRow(result.all().get(0)); } catch (Exception e){ e.printStackTrace(); @@ -3637,7 +3639,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore { .selectFrom(VRE_TIMELINE_POSTS).column(VRE_ID).all() .build()); try { - result = session.execute(stmtFind.getQuery()); + result = session.execute(stmtFind.bind()); } catch (Exception e){ e.printStackTrace();