Compare commits

..

7 Commits
main ... master

3 changed files with 110 additions and 64 deletions

View File

@ -4,6 +4,16 @@
All notable changes to this project will be documented in this file. 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). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.0-SNAPSHOT]
- updated to maven-portal-bom 4.0.0
## [v1.0.1] - 2024-04-16
- Null pointer exception bug fixed
- Removed unnecessary logs
## [v1.0.0] - 2023-11-15 ## [v1.0.0] - 2023-11-15
- First release - First release

View File

@ -5,13 +5,13 @@
<parent> <parent>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<version>1.1.0</version> <version>1.2.0</version>
<relativePath /> <relativePath />
</parent> </parent>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>social-library-stubs</artifactId> <artifactId>social-library-stubs</artifactId>
<version>1.0.0</version> <version>1.1.0-SNAPSHOT</version>
<name>gCube Social Library stubs</name> <name>gCube Social Library stubs</name>
<description> <description>
The gCube Social Networking Library stubs exploits the social networking facilities using the social-service-client to interface with the NoSQL data store for their storage. Specifically an Apache Cassandra data store. The gCube Social Networking Library stubs exploits the social networking facilities using the social-service-client to interface with the NoSQL data store for their storage. Specifically an Apache Cassandra data store.
@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.7.0</version> <version>4.0.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>org.gcube.social-networking</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId> <artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version> <version>[2.1.0-SNAPSHOT, 3.0.0)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

View File

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