added null checks
This commit is contained in:
parent
66387bb586
commit
551c3ec923
|
@ -276,12 +276,15 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
List<Post> posts = getRecentPostsByUserAndDate(userid, timeInMillis);
|
||||
if(posts!=null){
|
||||
_log.info("Length of posts is " + posts.size());
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
_log.info(post.toString());
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
@ -318,9 +321,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByUser(userid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
@ -337,9 +342,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByApp(appid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
@ -359,9 +367,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
long timeInMillis) throws Exception {
|
||||
List<Post> posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
@ -381,9 +391,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||
List<Post> posts = getAllPortalPrivacyLevelPosts();
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if (posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
|
@ -398,9 +410,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getRecentPostsByUser(userid, quantity);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
|
@ -415,9 +429,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByVRE(vreid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
@ -435,11 +451,13 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
_log.info("\n\n in getRecentFeedsByVRE");
|
||||
List<Post> posts = getRecentPostsByVRE(vreid, quantity);
|
||||
_log.info("length of vre posts = " + posts.size());
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
_log.info("length of vre posts = " + posts.size());
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
_log.info("length of vre feeds = " + feeds.size());
|
||||
return feeds;
|
||||
}
|
||||
|
@ -455,6 +473,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
RangePosts rangePosts = getRecentPostsByVREAndRange(vreid, from, quantity);
|
||||
List<Post> posts = rangePosts.getPosts();
|
||||
if(posts!=null){
|
||||
ArrayList<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
|
@ -462,6 +481,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
RangeFeeds rangeFeeds = new RangeFeeds(rangePosts.getLastReturnedPostTimelineIndex(), feeds);
|
||||
return rangeFeeds;
|
||||
}
|
||||
else{
|
||||
return new RangeFeeds();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -559,12 +583,14 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
*/
|
||||
@Override
|
||||
public boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels) {
|
||||
if(enabledChannels!=null){
|
||||
for(NotificationType notificationType: enabledChannels.keySet()){
|
||||
_log.info("Type: " + notificationType.toString());
|
||||
for(NotificationChannelType channelType: enabledChannels.get(notificationType)){
|
||||
_log.info(channelType.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return libClient.setUserNotificationPreferencesLib(userid, enabledChannels);
|
||||
}
|
||||
/**
|
||||
|
@ -674,6 +700,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
ArrayList<Feed> toReturn = new ArrayList<>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
if(likedPostIDs!=null){
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
|
@ -690,6 +717,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
|
@ -700,6 +730,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
ArrayList<Post> toReturn = new ArrayList<Post>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
if(likedPostIDs!=null){
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
|
@ -716,6 +747,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
@ -890,9 +923,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
List<Post>posts = getVREPostsByHashtag(vreid,hashtag);
|
||||
List<Feed>feeds = new ArrayList<>();
|
||||
if(posts!=null){
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
}
|
||||
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue