Compare commits

..

1 Commits

26 changed files with 3071 additions and 5037 deletions

View File

@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="social-library">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/test/java"/>
</wb-module>
</project-modules>

View File

@ -4,14 +4,12 @@
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] - 2024-04-22
## [v2.0.0] - 2023-10-24
- Feature #25901, add Cassandra 4.1.3 java client
- Bug 27218 - Null pointer exception getting notifications preferences fixed
- Feature 27286 - Removed noisy logs
## [v1.18.0] - 2022-09-20
## [v2.0.0] - 2023-12-04
- Support for Cassandra 4.1.3 using DataStax java driver
- Feature #23891, The (wrongly named) Feed class has been changed to Post, all the methods have been changed accordingly and the old one set as deprecated
## [v1.17.0] - 2022-05-13

View File

@ -24,14 +24,10 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/social-util-library/r
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
## Maintainers
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
## License
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
@ -43,4 +39,4 @@ open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

64
pom.xml
View File

@ -1,21 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.2.0</version>
<version>1.1.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>2.0.1</version>
<version>2.0.0-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.
The social networking facilities exploit a NoSQL data store for their storage. Specifically an Apache Cassandra data store.
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
The social networking facilities exploit a NoSQL data store for their storage. Specifically an Apache Cassandra data store.
</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</connection>
@ -31,51 +31,36 @@
<cassandra.driver.oss.version>4.13.0</cassandra.driver.oss.version>
<logback.version>1.2.3</logback.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>1.0.4</version>
<scope>provided</scope>
<version>[1.0.5-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
<version>[2.4.2-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<scope>provided</scope>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@ -86,23 +71,21 @@
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -140,6 +123,31 @@
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.gcube.portal.databook.server.Tester</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
*
*/
public class CassandraClusterConnection {
@ -41,7 +41,7 @@ public class CassandraClusterConnection {
* @param dropSchema set true if you want do drop the current and set up new one
* the connection to cassandra cluster
*/
protected CassandraClusterConnection(boolean dropSchema) throws Exception {
protected CassandraClusterConnection(boolean dropSchema) {
if (hosts == null || datacenterName == null || keyspaceName == null) {
RunningCluster cluster = RunningCluster.getInstance(null);
@ -62,7 +62,7 @@ public class CassandraClusterConnection {
* @param dropSchema set true if you want to drop the current and set up new one
* the connection to cassandra cluster
*/
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) throws Exception {
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) {
if (hosts == null || datacenterName == null || keyspaceName == null) {
RunningCluster cluster = RunningCluster.getInstance(infrastructureName);
//host = cluster.getHost();
@ -145,7 +145,7 @@ public class CassandraClusterConnection {
CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withKeyspace(KEYSPACE_NAME)
.withLocalDatacenter(datacenterName)
.withLocalDatacenter("1")
.build();
_log.info("[OK] Connected to Keyspace {} ", KEYSPACE_NAME);
return cqlSession;
@ -180,7 +180,7 @@ public class CassandraClusterConnection {
private static void createKeyspace(String keyspaceName, int replicationFactor) {
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withLocalDatacenter(datacenterName)
.withLocalDatacenter("1")
.build()) {
cqlSession.execute(SchemaBuilder.createKeyspace(keyspaceName)
.ifNotExists()
@ -196,7 +196,7 @@ public class CassandraClusterConnection {
ResultSet toreturn;
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withLocalDatacenter(datacenterName)
.withLocalDatacenter("1")
.build()) {
toreturn = cqlSession.execute(SchemaBuilder.dropKeyspace(keyspaceName).ifExists().build());
_log.info("Keyspace {} dropped.", keyspaceName);
@ -207,7 +207,7 @@ public class CassandraClusterConnection {
private void createTables(){
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withLocalDatacenter(datacenterName)
.withLocalDatacenter("1")
.withKeyspace(keyspaceName)
.build()) {
@ -500,4 +500,4 @@ public class CassandraClusterConnection {
_log.info("+ Table '{}' has been created (if needed).", "Posts");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,12 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class DatabookCassandraTest {
private static DBCassandraAstyanaxImpl store;
private static DBCassandraDatastaxImpl store;
@BeforeClass
public static void setup() throws Exception {
store = new DBCassandraAstyanaxImpl(); //set to true if you want to drop the KeySpace and recreate it
store = new DBCassandraDatastaxImpl(); //set to true if you want to drop the KeySpace and recreate it
}
@AfterClass

View File

@ -7,7 +7,6 @@ import javax.mail.internet.AddressException;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Invite;
import org.gcube.portal.databook.shared.InviteOperationResult;
import org.gcube.portal.databook.shared.InviteStatus;
@ -16,19 +15,9 @@ import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.Post;
import org.gcube.portal.databook.shared.RangeFeeds;
import org.gcube.portal.databook.shared.RangePosts;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.*;
/**
* @author Massimiliano Assante ISTI-CNR
@ -36,51 +25,11 @@ import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
*/
public interface DatabookStore {
/**
* userid from requests a friendship to userid to
* @return true if everything went fine
*/
boolean requestFriendship(String from, String to);
/**
* userid from approves a friendship to userid to
* @return true if everything went fine
*/
boolean approveFriendship(String from, String to);
/**
* userid from denies a friendship to userid to
* @return true if everything went fine
*/
boolean denyFriendship(String from, String to);
/**
* @param userid the user id you want to know friends
* @return a List of userid representing the friends for the given userid
*/
List<String> getFriends(String userid);
/**
* @param userid the user id you want to know the pending friend requests
* @return a List of userid representing the friends for the given userid
*/
List<String> getPendingFriendRequests(String userid);
/**
* @deprecated use saveUserPost
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveUserFeed(Feed feed);
/**
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveUserPost(Post feed);
/**
* Save a Feed instance in the store having more than one attachment
* Use this if you need to attach more than one file to the post
*
* @deprecated use saveUserPost
* @param attachments a list of attachments starting from the second
* @return true if everything went fine
*/
boolean saveUserFeed(Feed feed, List<Attachment> attachments);
/**
* Save a Post instance in the store having more than one attachment
* Use this if you need to attach more than one file to the post
@ -89,54 +38,24 @@ public interface DatabookStore {
* @return true if everything went fine
*/
boolean saveUserPost(Post post, List<Attachment> attachments);
/**
* Delete a Feed from the store
* @deprecated use saveUserPost
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deleteFeed(String feedid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
/**
* delete a Feed from the store
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
* Save a post in the VRES TimeLine in the store
* @deprecated use savePostToVRETimeline
* @param feedKey feedKey
* @param vreid vre identifier
* @throws FeedIDNotFoundException
*/
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
boolean deletePost(String postid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* save a post in the VRES TimeLine in the store
* @param postKey the post id
* @param vreid vre identifier
* @throws FeedIDNotFoundException
*/
boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException;
/**
* @deprecated use saveAppPost
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed);
boolean savePostToVRETimeline(String postKey, String vreid) throws PostIDNotFoundException;
/**
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveAppPost(Post feed);
/**
* @deprecated use saveAppPost
* Save a Post instance in the store
* Use this if your app needs to attach more than one file to the post
*
* @param attachments a list of attachments starting from the second
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed, List<Attachment> attachments);
/**
* Save a Post instance in the store
* Use this if your app needs to attach more than one file to the post
@ -145,64 +64,28 @@ public interface DatabookStore {
* @return true if everything went fine
*/
boolean saveAppPost(Post feed, List<Attachment> attachments);
/**
* @deprecated use readPost
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
Feed readFeed(String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws ColumnNameNotFoundException
*/
Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getAllPostsByUser instead
Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, PostTypeNotFoundException, PostIDNotFoundException;
/**
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getAllPostsByApp instead
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getRecentCommentedPostsByUserAndDate instead
* @param userid the user identifier like andrea.rossi
* @param timeInMillis the initial time in millis to be considered
* @return a list of feeds commented by userid starting from timeInMillis
* @throws Exception
*/
List<Feed> getRecentCommentedFeedsByUserAndDate(String userid, long timeInMillis) throws Exception;
/**
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* @param userid the user identifier like andrea.rossi
* @param timeInMillis the initial time in millis to be considered
* @return a list of feeds commented by userid starting from timeInMillis
@ -210,97 +93,41 @@ public interface DatabookStore {
*/
List<Post> getRecentCommentedPostsByUserAndDate(String userid, long timeInMillis) throws Exception;
/**
* @deprecated use getAllPortalPrivacyLevelPosts instead
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
/**
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
List<Post> getAllPortalPrivacyLevelPosts() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, PostTypeNotFoundException;
/**
* return the most recent feeds for this user up to quantity param
* @deprecated
* @param userid user identifier
* @param quantity the number of most recent feeds for this user
* @return a <class>List</class> of most recent feeds for this user
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* return the most recent feeds for this user up to quantity param
* @param userid user identifier
* @param quantity the number of most recent feeds for this user
* @return a <class>List</class> of most recent feeds for this user
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @deprecated use getAllPostsByVRE
* @param vreid vre identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @param vreid vre identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getRecentPostsByVRE
* return the most recent feeds for this vre up to quantity param
* @param vreid VRES identifier
* @param quantity the number of most recent feeds for this vre
* @return a <class>List</class> of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @param vreid vre identifier
* return all the feeds belonging to the userid
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* return the most recent posts for this vre up to quantity param
* @param vreid VRES identifier
* @param quantity the number of most recent posts for this vre
* @return a <class>List</class> of most recent posts for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getRecentPostsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
List<Post> getRecentPostsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* return the most recent posts for this vre up to quantity param and the last index of the feeds in the timeline
* lastReturnedFeedTimelineIndex is usuful to know from where to start the range the second time you ask
* because there are deletions
*
* @deprecated use getRecentPostsByVREAndRange
* @param vreid VRES identifier
* @param from the range start (most recent feeds for this vre) has to be greater than 0
* @param quantity the number of most recent feeds for this vre starting from "from" param
* @return a <class>lastReturnedFeedTimelineIndex</class> containing of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
@ -309,19 +136,11 @@ public interface DatabookStore {
* @param from the range start (most recent feeds for this vre) has to be greater than 0
* @param quantity the number of most recent feeds for this vre starting from "from" param
* @return a <class>RangePosts</class> containing of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getRecentPostsByUserAndDate
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
* @return the number of feeds in the range from: today to: timeInMillis
*/
List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
@ -435,13 +254,7 @@ public interface DatabookStore {
* add a comment to a feed
* @param comment the Comment instance to add
*/
boolean addComment(Comment comment) throws FeedIDNotFoundException;
/**
* @deprecated use getAllCommentByPost
* @param feedid feed identifier
* return all the comments belonging to the feedid
*/
List<Comment> getAllCommentByFeed(String feedid);
boolean addComment(Comment comment);
/**
* @param postid the post identifier
* return all the comments belonging to the postid
@ -458,20 +271,19 @@ public interface DatabookStore {
* @param comment the comment to edit
* @return true if success, false otherwise
*/
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException;
/**
* deletes a comment
* @param commentid the comment identifier to delete
* @param feedid the feedid to which the comment is associated
* @return true if success, false otherwise
*/
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException;
/**
* add a like to a feed
* @param like instance
* @throws FeedIDNotFoundException
*/
boolean like(Like like) throws FeedIDNotFoundException;
boolean like(Like like);
/**
* unlike a feed
* @param userid user identifier
@ -479,62 +291,29 @@ public interface DatabookStore {
* @param feedid the feedid to which the comment is associated
* @return true if success, false otherwise
*/
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
/**
* @deprecated use getAllLikedPostIdsByUser
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedFeedIdsByUser(String userid);
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException;
/**
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedPostIdsByUser(String userid);
/**
* @deprecated use getAllLikedPostsByUser
* @param userid user identifier
* @param limit set 0 to get everything, an int to get the most recent -limit- liked feeds
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* return all the feeds a user has liked
*/
List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* return all the feeds a user has liked
*/
List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getRecentLikedPostsByUserAndDate
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
* @return the likes made to feeds in the range from: today to: timeInMillis
*/
List<Feed> getRecentLikedFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
* @return the likes made to feeds in the range from: today to: timeInMillis
*/
List<Post> getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* @deprecated use getAllLikesByPost
* @param postid postid identifier
* return all the likes belonging to the postid
*/
List<Like> getAllLikesByFeed(String postid);
/**
* @param postid postid identifier
* return all the likes belonging to the postid
@ -546,9 +325,8 @@ public interface DatabookStore {
* @param postid the postid to which the hashtag is associated
* @param vreid VRE identifier
* @return true if success, false otherwise
* @throws FeedIDNotFoundException
*/
boolean saveHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
boolean saveHashTags(String postid, String vreid, List<String> hashtags);
/**
*
* @param hashtags the hashtag including the '#'
@ -564,9 +342,8 @@ public interface DatabookStore {
* @param postid the postid to which the hashtag is associated
* @param vreid VRE identifier
* @return true if success, false otherwise
* @throws FeedIDNotFoundException
*/
boolean deleteHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
boolean deleteHashTags(String postid, String vreid, List<String> hashtags) ;
/**
*
* @param hashtags the hashtag including the '#'
@ -589,30 +366,15 @@ public interface DatabookStore {
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
*/
Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp);
/**
* @deprecated use getVREPostsByHashtag
* @param vreid VRE identifier
* @param hashtag the hashtag to look for including the '#', it is case sensitive
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* @return all the feeds having the hashtag passed as parameter
*/
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
*
* @param vreid VRE identifier
* @param hashtag the hashtag to look for including the '#', it is case sensitive
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* @return all the feeds having the hashtag passed as parameter
* @throws PrivacyLevelTypeNotFoundException
* @return all the feeds having the hashtag passed as parameter
*/
List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
/**
* Save the invite for a given email into a given vre
@ -652,12 +414,7 @@ public interface DatabookStore {
* @param feedId
* @return the list of attachments of the feed feedId, starting from the second one (first attachment is included in Feed instance already)
*/
List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException;
/**
* save an attachment
*/
boolean saveAttachmentEntry(String feedId, Attachment toSave);
List<Attachment> getAttachmentsByFeedId(String feedId);
/**
* Retrieve all the ids of the vre

View File

@ -27,8 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
@ -42,14 +42,14 @@ public class RunningCluster implements Serializable {
/**
* properties to read
*/
private static final String HOST_PROPERTY = "host";
private static final String HOST_PROPERTY = "host";
private static final String HOST_PORT_PROPERTY = "port";
private static final String DATACENTER_NAME_PROPERTY = "datacenter";
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
/**
* other constants
*/
private final static String RUNTIME_RESOURCE_NAME = "SocialDB";
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
private final static String PLATFORM_NAME = "Cassandra";
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
@ -72,19 +72,18 @@ public class RunningCluster implements Serializable {
* @param infrastructureName could be null
* @return an instance of the RunningCluster
*/
public static synchronized RunningCluster getInstance(String infrastructureName){
public static synchronized RunningCluster getInstance(String infrastructureName) {
if (singleton == null) {
singleton = new RunningCluster(infrastructureName);
}
return singleton;
}
}
/**
* private constructor
*/
private RunningCluster(String infrastructureName){
private RunningCluster(String infrastructureName) {
//Query the IS (for the future)
try{
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
/*List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
if (resources.size() > 1) {
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name "
@ -98,25 +97,25 @@ public class RunningCluster implements Serializable {
for (ServiceEndpoint res : resources) {
AccessPoint found = res.profile().accessPoints().iterator().next();
host = found.address();
datacenterName = found.description();
clusterName = found.description();
keyspaceName = found.name();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
/*host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
datacenterName = "1";
keyspaceName = "dev_mig_consistent";*/
keyspaceName = "dev_mig_new_schema_test";
}
/**
*
*
* @return the
* @throws Exception
*/
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) {
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
String scope = "/";
if(infrastructureName != null && !infrastructureName.isEmpty())
@ -134,7 +133,7 @@ public class RunningCluster implements Serializable {
List<ServiceEndpoint> toReturn = client.submit(query);
ScopeProvider.instance.set(currScope);
return toReturn;
}
}
private String readInfrastructureName() {
@ -142,9 +141,9 @@ public class RunningCluster implements Serializable {
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
sb.append(File.separator)
.append(PortalContext.CONFIGURATION_FOLDER)
.append(File.separator)
.append(PortalContext.INFRA_PROPERTY_FILENAME);
.append(PortalContext.CONFIGURATION_FOLDER)
.append(File.separator)
.append(PortalContext.INFRA_PROPERTY_FILENAME);
String propertyfile = sb.toString();
File propsFile = new File(propertyfile);
FileInputStream fis = new FileInputStream(propsFile);
@ -154,12 +153,12 @@ public class RunningCluster implements Serializable {
catch(IOException e) {
_log.error("infrastructure.properties file not found under $CATALINA_HOME/conf/ dir, setting default infrastructure Name " + "gcube");
return "gcube";
}
}
}
/**
*
*
*/
private void loadDefaultConfiguration() {
Properties props = new Properties();
@ -198,7 +197,7 @@ public class RunningCluster implements Serializable {
+ ", keyspaceName=" + keyspaceName + "]";
}
/**
*
*
* @return $CATALINA_HOME
*/
private static String getCatalinaHome() {
@ -210,7 +209,7 @@ public class RunningCluster implements Serializable {
public String getDatacenterName() {
return datacenterName;
}
}
public List<InetSocketAddress> getHosts() {
List<InetSocketAddress> hosts = new ArrayList<>();
@ -221,4 +220,4 @@ public class RunningCluster implements Serializable {
}
return hosts;
}
}
}

View File

@ -1,13 +1,5 @@
package org.gcube.portal.databook.server;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
public class Schema {
//Tables
public static final String NOTIFICATIONS = "Notifications";
@ -73,4 +65,4 @@ public class Schema {
public static final String COMMENTS_NO = "commentsno"; //big int
public static final String LINK_TITLE = "linktitle"; //text
}
}

View File

@ -7,30 +7,22 @@ import org.slf4j.LoggerFactory;
import java.util.List;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
public class Tester {
private static DBCassandraAstyanaxImpl store;
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
private static DBCassandraDatastaxImpl store;
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
public Tester() {
store = new DBCassandraAstyanaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it
}
public Tester() {
store = new DBCassandraDatastaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it
}
public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
Tester test = new Tester();
//test.getComment();
test.testFunc();
System.exit(0);
public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
Tester test = new Tester();
//test.getComment();
test.testFunc();
System.exit(0);
}
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
}
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26";
Post read = store.readPost(postIdToUpdate);
@ -39,15 +31,15 @@ public class Tester {
readC.forEach(c -> System.out.println(c.getText()));
}
public void getComment(){
String uuid = "820969b2-4632-4197-9fd6-5aafab781faa";
String uuid = "820969b2-4632-4197-9fd6-5aafab781faa";
Comment c;
try {
c = store.readCommentById(uuid);
System.out.println(c);
} catch (CommentIDNotFoundException e) {
// TODO Auto-generated catch block
System.err.println(e.toString());
Comment c;
try {
c = store.readCommentById(uuid);
System.out.println(c);
} catch (CommentIDNotFoundException e) {
// TODO Auto-generated catch block
System.err.println(e.toString());
}
}
}
}
}

View File

@ -1,9 +1,13 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Objects;
import com.datastax.oss.driver.api.core.cql.Row;
import org.jsonmaker.gwt.client.Jsonizer;
import static org.gcube.portal.databook.server.Schema.*;
@SuppressWarnings("serial")
public class Attachment implements Serializable {
@ -37,8 +41,18 @@ public class Attachment implements Serializable {
this.description = description;
this.thumbnailURL = thumbnailURL;
this.mimeType = mimeType;
}
}
public Attachment(Row record) {
super();
this.id = Objects.requireNonNull(record.getUuid(ATTACH_ID)).toString();
this.uri = record.getString(URI);
this.name = record.getString(NAME);
this.description = record.getString(DESCRIPTION);
this.thumbnailURL = record.getString(URI_THUMBNAIL);
this.mimeType = record.getString(MIME_TYPE);
}
public String getId() {
return id;
}

View File

@ -1,7 +1,13 @@
package org.gcube.portal.databook.shared;
import com.datastax.oss.driver.api.core.cql.Row;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.gcube.portal.databook.server.Schema.*;
import static org.gcube.portal.databook.server.Schema.THUMBNAIL_URL;
/**
*
@ -15,7 +21,7 @@ public class Comment implements Serializable, Comparable<Comment> {
private String key;
private String userid;
private Date time;
private String feedid;
private String postid;
private String text;
private String fullName;
private String thumbnailURL;
@ -33,18 +39,18 @@ public class Comment implements Serializable, Comparable<Comment> {
* @param key
* @param userid
* @param time
* @param feedid
* @param postid
* @param text
* @param fullName
* @param thumbnailURL
*/
public Comment(String key, String userid, Date time, String feedid,
public Comment(String key, String userid, Date time, String postid,
String text, String fullName, String thumbnailURL) {
super();
this.key = key;
this.userid = userid;
this.time = time;
this.feedid = feedid;
this.postid = postid;
this.text = text;
this.fullName = fullName;
this.thumbnailURL = thumbnailURL;
@ -58,27 +64,39 @@ public class Comment implements Serializable, Comparable<Comment> {
* @param key
* @param userid
* @param time
* @param feedid
* @param postid
* @param text
* @param fullName
* @param thumbnailURL
* @param isEdit
* @param editDate
*/
public Comment(String key, String userid, Date time, String feedid,
public Comment(String key, String userid, Date time, String postid,
String text, String fullName, String thumbnailURL, boolean isEdit, Date editDate) {
super();
this.key = key;
this.userid = userid;
this.time = time;
this.feedid = feedid;
this.postid = postid;
this.text = text;
this.fullName = fullName;
this.thumbnailURL = thumbnailURL;
this.isEdit = isEdit;
this.lastEditTime = editDate;
}
public Comment(Row record) {
super();
this.key = Objects.requireNonNull(record.getUuid(COMMENT_ID)).toString();
this.userid = record.getString(USER_ID);
this.time = Date.from(Objects.requireNonNull(record.getInstant(TIMESTAMP)));
this.postid = Objects.requireNonNull(record.getUuid(POST_ID)).toString();
this.fullName = record.getString(FULL_NAME);
this.thumbnailURL = record.getString(THUMBNAIL_URL);
this.text = record.getString(COMMENT);
this.isEdit = !record.isNull(IS_EDIT) && record.getBoolean(IS_EDIT);
this.lastEditTime = record.isNull(LAST_EDIT_TIME)? null : Date.from(Objects.requireNonNull(record.getInstant(LAST_EDIT_TIME)));
}
/**
*
* @return the text
@ -121,12 +139,12 @@ public class Comment implements Serializable, Comparable<Comment> {
this.time = time;
}
public String getFeedid() {
return feedid;
public String getpostid() {
return postid;
}
public void setFeedid(String feedid) {
this.feedid = feedid;
public void setpostid(String postid) {
this.postid = postid;
}
public String getFullName() {
@ -168,7 +186,7 @@ public class Comment implements Serializable, Comparable<Comment> {
@Override
public String toString() {
return "Comment [key=" + key + ", userid=" + userid + ", time=" + time
+ ", feedid=" + feedid + ", text=" + text + ", fullName="
+ ", postid=" + postid + ", text=" + text + ", fullName="
+ fullName + ", thumbnailURL=" + thumbnailURL + ", isEdit="
+ isEdit + ", lastEditTime=" + lastEditTime + "]";
}

View File

@ -10,7 +10,7 @@ import java.util.ArrayList;
*/
@SuppressWarnings("serial")
public class EnhancedFeed implements Serializable{
private Feed feed;
private Post post;
private boolean liked;
private boolean isUsers;
private ArrayList<Comment> comments;
@ -20,26 +20,26 @@ public class EnhancedFeed implements Serializable{
public EnhancedFeed() {
super();
}
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers) {
public EnhancedFeed(Post post, boolean liked, boolean isUsers) {
super();
this.feed = feed;
this.post = post;
this.liked = liked;
this.isUsers = isUsers;
}
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers, ArrayList<Comment> comments) {
public EnhancedFeed(Post post, boolean liked, boolean isUsers, ArrayList<Comment> comments) {
super();
this.isUsers = isUsers;
this.feed = feed;
this.post = post;
this.liked = liked;
this.comments = comments;
}
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers,
public EnhancedFeed(Post post, boolean liked, boolean isUsers,
ArrayList<Comment> comments, ArrayList<Attachment> attachments) {
super();
this.feed = feed;
this.post = post;
this.liked = liked;
this.isUsers = isUsers;
this.comments = comments;
@ -51,11 +51,11 @@ public class EnhancedFeed implements Serializable{
public void setComments(ArrayList<Comment> comments) {
this.comments = comments;
}
public Feed getFeed() {
return feed;
public Post getPost() {
return post;
}
public void setFeed(Feed feed) {
this.feed = feed;
public void setPost(Post post) {
this.post = post;
}
public boolean isLiked() {
return liked;
@ -77,7 +77,7 @@ public class EnhancedFeed implements Serializable{
}
@Override
public String toString() {
return "EnhancedFeed [feed=" + feed + ", liked=" + liked + ", isUsers="
return "EnhancedFeed [post=" + post + ", liked=" + liked + ", isUsers="
+ isUsers + ", comments=" + comments + ", attachments="
+ attachments + "]";
}

View File

@ -1,322 +0,0 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @deprecated use <class>org.gcube.portal.databook.shared.Post</class> instead
*/
@SuppressWarnings("serial")
public class Feed implements Serializable, Comparable<Feed> {
private String key;
private FeedType type;
private String entityId;
private Date time;
private String vreid;
private String uri;
private String uriThumbnail;
private String description;
private PrivacyLevel privacy;
private String fullName;
private String email;
private String thumbnailURL;
private String commentsNo;
private String likesNo;
private String linkTitle;
private String linkDescription;
private String linkHost;
boolean applicationFeed;
/**
* this boolean indicates that the attachments to the post are > 1
*/
boolean multiFileUpload;
/**
* default constructor
*/
public Feed() {
super();
}
/**
* To use ONLY for USER Feeds
*
*
* @param key a UUID
* @param type an instance of <class>FeedType</class>
* @param entityId the user or the app unique indentifier
* @param time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
* @param description optional description
* @param privacy the privacy level of <class>PrivacyLevel</class>
* @param fullName
* @param email
* @param thumbnailURL this is the user thumbnail url
* @param linkTitle optional to be used when posting links
* @param linkDescription optional to be used when posting links
* @param linkHost option to be used when posting linkgs
*/
public Feed(String key, FeedType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost) {
this.key = key;
this.type = type;
this.entityId = entityId;
this.time = time;
this.vreid = vreid;
this.uri = uri;
this.uriThumbnail = uriThumbnail;
this.description = description;
this.privacy = privacy;
this.fullName = fullName;
this.email = email;
this.thumbnailURL = thumbnailURL;
this.commentsNo = "0";
this.likesNo = "0";
this.linkDescription = linkDescription;
this.linkTitle = linkTitle;
this.linkHost = linkHost;
this.applicationFeed = false;
}
/**
* To use for USER and ApplicationProfile Feeds
*
* @param key a UUID
* @param type an instance of <class>FeedType</class>
* @param entityId the user or the app unique indentifier
* @param time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
* @param description optional description
* @param privacy the privacy level of <class>PrivacyLevel</class>
* @param fullName
* @param email
* @param thumbnailURL this is the user thumbnail url
* @param linkTitle optional to be used when posting links
* @param linkDescription optional to be used when posting links
* @param applicationFeed tell if this is an application feed or a user feed
*/
public Feed(String key, FeedType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) {
this(key, type, entityId, time, vreid, uri, uriThumbnail, description, privacy, fullName, email, thumbnailURL, linkTitle, linkDescription, linkHost);
this.applicationFeed = applicationFeed;
}
/**
* for serialization purposes
* @param key a UUID
* @param type an instance of <class>FeedType</class>
* @param entityId the user or the app unique indentifier
* @param time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
* @param description optional description
* @param privacy the privacy level of <class>PrivacyLevel</class>
* @param fullName
* @param email
* @param thumbnailURL this is the user thumbnail url
* @param linkTitle optional to be used when posting links
* @param linkDescription optional to be used when posting links
*/
public Feed(String key, FeedType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String commentsNo,
String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) {
super();
this.key = key;
this.type = type;
this.entityId = entityId;
this.time = time;
this.vreid = vreid;
this.uri = uri;
this.uriThumbnail = uriThumbnail;
this.description = description;
this.privacy = privacy;
this.fullName = fullName;
this.email = email;
this.thumbnailURL = thumbnailURL;
this.commentsNo = commentsNo;
this.likesNo = likesNo;
this.linkDescription = linkDescription;
this.linkTitle = linkTitle;
this.linkHost = linkHost;
this.applicationFeed = applicationFeed;
this.multiFileUpload = multiFileUpload;
}
/**
*
* @return the key
*/
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public FeedType getType() {
return type;
}
public void setType(FeedType type) {
this.type = type;
}
/**
*
* @return the User or the App id
*/
public String getEntityId() {
return entityId;
}
/**
* set the User or the App id
* @param entityId the UserId or the AppId id
*/
public void setEntityId(String entityId) {
this.entityId = entityId;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getVreid() {
return vreid;
}
public void setVreid(String vreid) {
this.vreid = vreid;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public PrivacyLevel getPrivacy() {
return privacy;
}
public void setPrivacy(PrivacyLevel privacy) {
this.privacy = privacy;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getThumbnailURL() {
return thumbnailURL;
}
public void setThumbnailURL(String thumbnailURL) {
this.thumbnailURL = thumbnailURL;
}
public String getCommentsNo() {
return commentsNo;
}
public void setCommentsNo(String commentsNo) {
this.commentsNo = commentsNo;
}
public String getLikesNo() {
return likesNo;
}
public void setLikesNo(String likesNo) {
this.likesNo = likesNo;
}
public String getUriThumbnail() {
return uriThumbnail;
}
public void setUriThumbnail(String uriThumbnail) {
this.uriThumbnail = uriThumbnail;
}
public String getLinkTitle() {
return linkTitle;
}
public void setLinkTitle(String linkTitle) {
this.linkTitle = linkTitle;
}
public String getLinkDescription() {
return linkDescription;
}
public void setLinkDescription(String linkDescription) {
this.linkDescription = linkDescription;
}
public int compareTo(Feed toCompare) {
if (this.time.after(toCompare.getTime()))
return 1;
if (this.time.before(toCompare.getTime()))
return -1;
return 0;
}
public String getLinkHost() {
return linkHost;
}
public void setLinkHost(String linkHost) {
this.linkHost = linkHost;
}
public boolean isApplicationFeed() {
return applicationFeed;
}
public void setApplicationFeed(boolean applicationFeed) {
this.applicationFeed = applicationFeed;
}
public boolean isMultiFileUpload() {
return multiFileUpload;
}
public void setMultiFileUpload(boolean multiFileUpload) {
this.multiFileUpload = multiFileUpload;
}
@Override
public String toString() {
return "Feed [key=" + key + ", type=" + type + ", entityId=" + entityId
+ ", time=" + time + ", vreid=" + vreid + ", uri=" + uri
+ ", uriThumbnail=" + uriThumbnail + ", description="
+ description + ", privacy=" + privacy + ", fullName="
+ fullName + ", email=" + email + ", thumbnailURL="
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
+ linkDescription + ", linkHost=" + linkHost
+ ", applicationFeed=" + applicationFeed
+ ", multiFileUpload=" + multiFileUpload + "]";
}
}

View File

@ -1,19 +0,0 @@
package org.gcube.portal.databook.shared;
/**
* @author Massimiliano Assante ISTI-CNR
* @deprecated use PostType
* @version 1.2 October 2012
*/
public enum FeedType {
JOIN, SHARE, PUBLISH, TWEET, CONNECTED,
/**
* Special case used when accounting
*/
ACCOUNTING,
/**
* Special case used when a Feed is removed
*/
DISABLED;
}

View File

@ -1,7 +1,14 @@
package org.gcube.portal.databook.shared;
import com.datastax.oss.driver.api.core.cql.Row;
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.gcube.portal.databook.server.Schema.*;
/**
*
* @author Massimiliano Assante, ISTI-CNR
@ -18,8 +25,23 @@ public class Invite implements Serializable {
private InviteStatus status;
private Date time;
private String senderFullName;
public static InviteStatus getInviteStatusType(String type) throws InviteStatusNotFoundException {
switch (type) {
case "PENDING":
return InviteStatus.PENDING;
case "ACCEPTED":
return InviteStatus.ACCEPTED;
case "REJECTED":
return InviteStatus.REJECTED;
case "RETRACTED":
return InviteStatus.RETRACTED;
default:
throw new InviteStatusNotFoundException("The Invite Status was not recognized should be one of " + InviteStatus.values() + " asked for: " + type);
}
}
public Invite() {
super();
}
@ -41,6 +63,17 @@ public class Invite implements Serializable {
this.senderFullName = senderFullName;
}
public Invite(Row record) throws InviteStatusNotFoundException {
super();
this.key = Objects.requireNonNull(record.getUuid(INVITE_ID)).toString();
this.senderUserId = record.getString(SENDER_USER_ID);
this.vreid = record.getString(VRE_ID);
this.invitedEmail = record.getString(EMAIL);
this.controlCode = record.getString(CONTROL_CODE);
this.status = getInviteStatusType(Objects.requireNonNull(record.getString(STATUS)));
this.time = Date.from(Objects.requireNonNull(record.getInstant(TIMESTAMP)));
this.senderFullName = record.getString(SENDER_FULL_NAME);
}

View File

@ -1,7 +1,15 @@
package org.gcube.portal.databook.shared;
import com.datastax.oss.driver.api.core.cql.Row;
import org.gcube.portal.databook.shared.ex.PostTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.gcube.portal.databook.server.Schema.*;
/**
*
* @author Massimiliano Assante, ISTI-CNR
@ -14,7 +22,7 @@ public class Like implements Serializable {
private String key;
private String userid;
private Date time;
private String feedid;
private String postid;
private String fullName;
private String thumbnailURL;
@ -22,17 +30,28 @@ public class Like implements Serializable {
super();
}
public Like(String key, String userid, Date time, String feedid,
public Like(String key, String userid, Date time, String postid,
String fullName, String thumbnailURL) {
super();
this.key = key;
this.userid = userid;
this.time = time;
this.feedid = feedid;
this.postid = postid;
this.fullName = fullName;
this.thumbnailURL = thumbnailURL;
}
public Like(Row record) {
super();
this.key = Objects.requireNonNull(record.getUuid(LIKE_ID)).toString();
this.userid = record.getString(USER_ID);
this.time = Date.from(Objects.requireNonNull(record.getInstant(TIMESTAMP)));
this.postid = Objects.requireNonNull(record.getUuid(POST_ID)).toString();
this.fullName = record.getString(FULL_NAME);
this.thumbnailURL = record.getString(THUMBNAIL_URL);
}
public String getKey() {
return key;
}
@ -57,12 +76,12 @@ public class Like implements Serializable {
this.time = time;
}
public String getFeedid() {
return feedid;
public String getpostid() {
return postid;
}
public void setFeedid(String feedid) {
this.feedid = feedid;
public void setpostid(String postid) {
this.postid = postid;
}
public String getFullName() {

View File

@ -1,7 +1,15 @@
package org.gcube.portal.databook.shared;
import com.datastax.oss.driver.api.core.cql.Row;
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.gcube.portal.databook.server.Schema.*;
/**
*
@ -22,9 +30,156 @@ public class Notification implements Serializable {
private String senderid;
private String senderFullName;
private String senderThumbnail;
private String commentKey;
public static NotificationChannelType getChannelType(String channelName) throws NotificationChannelTypeNotFoundException {
if (channelName.compareTo("PORTAL") == 0)
return NotificationChannelType.PORTAL;
else if (channelName.compareTo("EMAIL") == 0)
return NotificationChannelType.EMAIL;
else if (channelName.compareTo("TWITTER") == 0)
return NotificationChannelType.TWITTER;
else
throw new NotificationChannelTypeNotFoundException("The Notification Channel Type was not recognized should be one of " + NotificationChannelType.values() + " asked for: " + channelName);
}
/**
* simply return an enum representing the feed type
* @param type .
* @return correct enum representing the feed type
* @throws NotificationTypeNotFoundException .
*/
public static NotificationType getNotificationType(String type) throws NotificationTypeNotFoundException {
if (type.compareTo("WP_FOLDER_SHARE") == 0) {
return NotificationType.WP_FOLDER_SHARE;
}
else if (type.compareTo("WP_FOLDER_UNSHARE") == 0) {
return NotificationType.WP_FOLDER_UNSHARE;
}
else if (type.compareTo("WP_ADMIN_UPGRADE") == 0) {
return NotificationType.WP_ADMIN_UPGRADE;
}
else if (type.compareTo("WP_ADMIN_DOWNGRADE") == 0) {
return NotificationType.WP_ADMIN_DOWNGRADE;
}
else if (type.compareTo("WP_FOLDER_RENAMED") == 0) {
return NotificationType.WP_FOLDER_RENAMED;
}
else if (type.compareTo("WP_FOLDER_ADDEDUSER") == 0) {
return NotificationType.WP_FOLDER_ADDEDUSER;
}
else if (type.compareTo("WP_FOLDER_REMOVEDUSER") == 0) {
return NotificationType.WP_FOLDER_REMOVEDUSER;
}
else if (type.compareTo("WP_ITEM_DELETE") == 0) {
return NotificationType.WP_ITEM_DELETE;
}
else if (type.compareTo("WP_ITEM_UPDATED") == 0) {
return NotificationType.WP_ITEM_UPDATED;
}
else if (type.compareTo("WP_ITEM_NEW") == 0) {
return NotificationType.WP_ITEM_NEW;
}
else if (type.compareTo("WP_ITEM_RENAMED") == 0) {
return NotificationType.WP_ITEM_RENAMED;
}
else if (type.compareTo("OWN_COMMENT") == 0) {
return NotificationType.OWN_COMMENT;
}
else if (type.compareTo("COMMENT") == 0) {
return NotificationType.COMMENT;
}
else if (type.compareTo("MENTION") == 0) {
return NotificationType.MENTION;
}
else if (type.compareTo("LIKE") == 0) {
return NotificationType.LIKE;
}
else if (type.compareTo("CALENDAR_ADDED_EVENT") == 0) {
return NotificationType.CALENDAR_ADDED_EVENT;
}
else if (type.compareTo("CALENDAR_UPDATED_EVENT") == 0) {
return NotificationType.CALENDAR_UPDATED_EVENT;
}
else if (type.compareTo("CALENDAR_DELETED_EVENT") == 0) {
return NotificationType.CALENDAR_DELETED_EVENT;
}
else if (type.compareTo("CALENDAR_ADDED_EVENT") == 0) {
return NotificationType.CALENDAR_ADDED_EVENT;
}
else if (type.compareTo("CALENDAR_UPDATED_EVENT") == 0) {
return NotificationType.CALENDAR_UPDATED_EVENT;
}
else if (type.compareTo("CALENDAR_DELETED_EVENT") == 0) {
return NotificationType.CALENDAR_DELETED_EVENT;
}
else if (type.compareTo("MESSAGE") == 0) {
return NotificationType.MESSAGE;
}
else if (type.compareTo("POST_ALERT") == 0) {
return NotificationType.POST_ALERT;
}
else if (type.compareTo("REQUEST_CONNECTION") == 0) {
return NotificationType.REQUEST_CONNECTION;
}
else if (type.compareTo("JOB_COMPLETED_NOK") == 0) {
return NotificationType.JOB_COMPLETED_NOK;
}
else if (type.compareTo("JOB_COMPLETED_OK") == 0) {
return NotificationType.JOB_COMPLETED_OK;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_EDIT") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_EDIT;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_VIEW") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_VIEW;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_STEP_FORWARD_PEER") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_STEP_FORWARD_PEER;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_STEP_REQUEST_TASK") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER;
}
else if (type.compareTo("DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT") == 0) {
return NotificationType.DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT;
}
else if (type.compareTo("TDM_TAB_RESOURCE_SHARE") == 0) {
return NotificationType.TDM_TAB_RESOURCE_SHARE;
}
else if (type.compareTo("TDM_RULE_SHARE") == 0) {
return NotificationType.TDM_RULE_SHARE;
}
else if (type.compareTo("TDM_TEMPLATE_SHARE") == 0) {
return NotificationType.TDM_TEMPLATE_SHARE;
}
else if (type.compareTo("CAT_ITEM_SUBMITTED") == 0) {
return NotificationType.CAT_ITEM_SUBMITTED;
}
else if (type.compareTo("CAT_ITEM_REJECTED") == 0) {
return NotificationType.CAT_ITEM_REJECTED;
}
else if (type.compareTo("CAT_ITEM_PUBLISHED") == 0) {
return NotificationType.CAT_ITEM_PUBLISHED;
}
else if (type.compareTo("CAT_ITEM_UPDATED") == 0) {
return NotificationType.CAT_ITEM_UPDATED;
}
else if (type.compareTo("CAT_ITEM_DELETE") == 0) {
return NotificationType.CAT_ITEM_DELETE;
}
else if (type.compareTo("GENERIC") == 0) {
return NotificationType.GENERIC;
}
else
throw new NotificationTypeNotFoundException("The Notification Type was not recognized should be one of " + NotificationType.values() + " asked for: " + type);
}
/**
* default constructor
*/
@ -32,8 +187,6 @@ public class Notification implements Serializable {
super();
}
/**
*
* @param key
@ -65,41 +218,21 @@ public class Notification implements Serializable {
this.senderFullName = senderFullName;
this.senderThumbnail = senderThumbnail;
}
/**
*
* @param key
* @param type
* @param userid
* @param subjectid the subject id of this notification, if is a like on a feed then is the feedid, it is a message then is the messageid and so on
* @param time
* @param uri
* @param description
* @param read
* @param senderid
* @param senderFullName
* @param senderThumbnail
* @param commentKey when a mail notification must be sent, stop the embedded discussion at this comment
*/
public Notification(String key, NotificationType type, String userid,
String subjectid, Date time, String uri, String description,
boolean read, String senderid, String senderFullName,
String senderThumbnail, String commentKey) {
super();
this.key = key;
this.type = type;
this.userid = userid;
this.subjectid = subjectid;
this.time = time;
this.uri = uri;
this.description = description;
this.read = read;
this.senderid = senderid;
this.senderFullName = senderFullName;
this.senderThumbnail = senderThumbnail;
this.commentKey = commentKey;
}
public Notification(Row record) throws NotificationTypeNotFoundException {
super();
this.key = Objects.requireNonNull(record.getUuid(NOT_ID)).toString();
this.type = getNotificationType(Objects.requireNonNull(record.getString(TYPE)));
this.userid = record.getString(USER_ID);
this.subjectid = record.getString(SUBJECT_ID);
this.time = Date.from(Objects.requireNonNull(record.getInstant(TIMESTAMP)));
this.uri = record.getString(URI);
this.description = record.getString(DESCRIPTION);
this.read = record.getBoolean(IS_READ);
this.senderid = record.getString(SENDER_ID);
this.senderFullName = record.getString(SENDER_FULL_NAME);
this.senderThumbnail = record.getString(SENDER_THUMBNAIL_URL);
}
/**
*
* @return .
@ -171,16 +304,6 @@ public class Notification implements Serializable {
this.subjectid = subjectid;
}
public String getCommentKey() {
return commentKey;
}
public void setCommentKey(String commentKey) {
this.commentKey = commentKey;
}
@Override
public String toString() {
return "Notification [key=" + key + ", type=" + type + ", userid="
@ -188,6 +311,6 @@ public class Notification implements Serializable {
+ ", uri=" + uri + ", description=" + description + ", read="
+ read + ", senderid=" + senderid + ", senderFullName="
+ senderFullName + ", senderThumbnail=" + senderThumbnail
+ ", commentKey=" + commentKey + "]";
+ "]";
}
}

View File

@ -1,7 +1,15 @@
package org.gcube.portal.databook.shared;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.type.DataTypes;
import org.gcube.portal.databook.shared.ex.PostTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
import org.gcube.portal.databook.server.Schema.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import static org.gcube.portal.databook.server.Schema.*;
/**
*
@ -28,7 +36,7 @@ public class Post implements Serializable, Comparable<Post> {
private String linkTitle;
private String linkDescription;
private String linkHost;
boolean applicationFeed;
boolean applicationPost;
/**
* this boolean indicates that the attachments to the post are > 1
*/
@ -40,7 +48,7 @@ public class Post implements Serializable, Comparable<Post> {
super();
}
/**
* To use ONLY for USER Feeds
* To use ONLY for USER Posts
*
*
* @param key a UUID
@ -79,13 +87,13 @@ public class Post implements Serializable, Comparable<Post> {
this.linkDescription = linkDescription;
this.linkTitle = linkTitle;
this.linkHost = linkHost;
this.applicationFeed = false;
this.applicationPost = false;
}
/**
* To use for USER and ApplicationProfile Feeds
* To use for USER and ApplicationProfile Posts
*
* @param key a UUID
* @param type an instance of <class>FeedType</class>
* @param type an instance of <class>PostType</class>
* @param entityId the user or the app unique indentifier
* @param time when
* @param vreid a unique vre id
@ -98,13 +106,13 @@ public class Post implements Serializable, Comparable<Post> {
* @param thumbnailURL this is the user thumbnail url
* @param linkTitle optional to be used when posting links
* @param linkDescription optional to be used when posting links
* @param applicationFeed tell if this is an application feed or a user feed
* @param applicationPost tell if this is an application Post or a user Post
*/
public Post(String key, PostType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) {
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationPost) {
this(key, type, entityId, time, vreid, uri, uriThumbnail, description, privacy, fullName, email, thumbnailURL, linkTitle, linkDescription, linkHost);
this.applicationFeed = applicationFeed;
this.applicationPost= applicationPost;
}
@ -128,7 +136,7 @@ public class Post implements Serializable, Comparable<Post> {
public Post(String key, PostType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String commentsNo,
String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) {
String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationPost, boolean multiFileUpload) {
super();
this.key = key;
this.type = type;
@ -147,10 +155,34 @@ public class Post implements Serializable, Comparable<Post> {
this.linkDescription = linkDescription;
this.linkTitle = linkTitle;
this.linkHost = linkHost;
this.applicationFeed = applicationFeed;
this.applicationPost = applicationPost;
this.multiFileUpload = multiFileUpload;
}
/**
public Post(Row record) throws PostTypeNotFoundException, PrivacyLevelTypeNotFoundException {
super();
this.key = Objects.requireNonNull(record.getUuid(POST_ID)).toString();
this.type = this.getPostType(Objects.requireNonNull(record.getString(TYPE)));
this.entityId = record.getString(ENTITY_ID);
this.time = Date.from(Objects.requireNonNull(record.getInstant(TIMESTAMP)));
this.vreid = record.getString(VRE_ID);
this.uri = record.getString(URI);
this.uriThumbnail = record.getString(URI_THUMBNAIL);
this.description = record.getString(DESCRIPTION);
this.privacy = this.getPrivacyLevel(Objects.requireNonNull(record.getString(PRIVACY)));
this.fullName = record.getString(FULL_NAME);
this.email = record.getString(EMAIL);
this.thumbnailURL = record.getString(THUMBNAIL_URL);
this.commentsNo = String.valueOf(record.getLong(COMMENTS_NO));
this.likesNo = String.valueOf(record.getLong(LIKES_NO));
this.linkDescription = record.getString(LINK_DESCRIPTION);
this.linkTitle = record.getString(LINK_TITLE);
this.linkHost = record.getString(LINK_HOST);
this.applicationPost = record.getBoolean(IS_APPLICATION_POST);
this.multiFileUpload = record.getBoolean(MULTI_FILE_UPLOAD);
}
/**
*
* @return post id
*/
@ -293,11 +325,11 @@ public class Post implements Serializable, Comparable<Post> {
this.linkHost = linkHost;
}
public boolean isApplicationFeed() {
return applicationFeed;
public boolean isApplicationPost() {
return applicationPost;
}
public void setApplicationFeed(boolean applicationFeed) {
this.applicationFeed = applicationFeed;
public void setApplicationPost(boolean applicationPost) {
this.applicationPost = applicationPost;
}
public boolean isMultiFileUpload() {
return multiFileUpload;
@ -315,8 +347,47 @@ public class Post implements Serializable, Comparable<Post> {
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
+ linkDescription + ", linkHost=" + linkHost
+ ", applicationFeed=" + applicationFeed
+ ", applicationPost=" + applicationPost
+ ", multiFileUpload=" + multiFileUpload + "]";
}
public static PostType getPostType(String type) throws PostTypeNotFoundException {
if (type.compareTo("TWEET") == 0) {
return PostType.TWEET;
}
else if (type.compareTo("JOIN") == 0) {
return PostType.JOIN;
}
else if (type.compareTo("PUBLISH") == 0) {
return PostType.PUBLISH;
}
else if (type.compareTo("SHARE") == 0) {
return PostType.SHARE;
}
else if (type.compareTo("ACCOUNTING") == 0) {
return PostType.ACCOUNTING;
}
else if (type.compareTo("DISABLED") == 0) {
return PostType.DISABLED;
}
else
throw new PostTypeNotFoundException("The Post Type was not recognized should be one of " + PostType.values() + " asked for: " + type);
}
public static PrivacyLevel getPrivacyLevel(String privacyLevel) throws PrivacyLevelTypeNotFoundException {
if (privacyLevel.compareTo("CONNECTION") == 0)
return PrivacyLevel.CONNECTION;
else if (privacyLevel.compareTo("PRIVATE") == 0)
return PrivacyLevel.PRIVATE;
else if (privacyLevel.compareTo("PUBLIC") == 0)
return PrivacyLevel.PUBLIC;
else if (privacyLevel.compareTo("VRES") == 0)
return PrivacyLevel.VRES;
else if (privacyLevel.compareTo("SINGLE_VRE") == 0)
return PrivacyLevel.SINGLE_VRE;
else if (privacyLevel.compareTo("PORTAL") == 0)
return PrivacyLevel.PORTAL;
else
throw new PrivacyLevelTypeNotFoundException("The Privacy Level was not recognized should be one of " + PrivacyLevel.values() + " asked for: " + privacyLevel);
}
}

View File

@ -1,56 +0,0 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.List;
@SuppressWarnings("serial")
public class PostWithAttachment implements Serializable {
private Post post;
private List<Attachment> attachments;
public PostWithAttachment(Post post, List<Attachment> attachments){
super();
this.post = post;
this.attachments = attachments;
}
public void setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
}
public void setPost(Post post) {
this.post = post;
}
public List<Attachment> getAttachments() {
return attachments;
}
public Post getPost() {
return post;
}
public String toString() {
String postInfo = "Post [key=" + post.getKey() + ", type=" + post.getType() + ", entityId=" + post.getEntityId()
+ ", time=" + post.getTime() + ", vreid=" + post.getVreid() + ", uri=" + post.getUri()
+ ", uriThumbnail=" + post.getUriThumbnail() + ", description="
+ post.getDescription() + ", privacy=" + post.getPrivacy() + ", fullName="
+ post.getFullName() + ", email=" + post.getEmail() + ", thumbnailURL="
+ post.getThumbnailURL() + ", commentsNo=" + post.getCommentsNo() + ", likesNo="
+ post.getLikesNo() + ", linkTitle=" + post.getLinkTitle() + ", linkDescription="
+ post.getLinkDescription() + ", linkHost=" + post.getLinkHost()
+ ", applicationFeed=" + post.isApplicationFeed()
+ ", multiFileUpload=" + post.isMultiFileUpload() + "]";
String attachmentInfo = "[Attachments: ";
for (Attachment attachment: attachments){
attachmentInfo += "[Attachment [key=" + attachment.getId() + ", uri=" + attachment.getUri() + ", name=" + attachment.getName() + ", description="
+ attachment.getDescription() + ", thumbnailURL=" + attachment.getThumbnailURL()
+ ", mimeType=" + attachment.getMimeType() + "]],";
}
attachmentInfo = attachmentInfo.substring(0, attachmentInfo.length()-1);
attachmentInfo += "]";
;
return "[" + postInfo + ", " + attachmentInfo + "]" ;
}
}

View File

@ -1,40 +0,0 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @deprecated use RangePosts
*/
@SuppressWarnings("serial")
public class RangeFeeds implements Serializable {
private int lastReturnedFeedTimelineIndex;
private ArrayList<Feed> feeds;
public RangeFeeds() {
super();
}
public RangeFeeds(int lastReturnedFeedTimelineIndex, ArrayList<Feed> feeds) {
super();
this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex;
this.feeds = feeds;
}
public int getLastReturnedFeedTimelineIndex() {
return lastReturnedFeedTimelineIndex;
}
public void setLastReturnedFeedTimelineIndex(int lastReturnedFeedTimelineIndex) {
this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex;
}
public ArrayList<Feed> getFeeds() {
return feeds;
}
public void setFeeds(ArrayList<Feed> feeds) {
this.feeds = feeds;
}
}

View File

@ -1,8 +0,0 @@
package org.gcube.portal.databook.shared.ex;
@SuppressWarnings("serial")
public class FeedTypeNotFoundException extends Exception {
public FeedTypeNotFoundException(String message) {
super(message);
}
}

View File

@ -2,8 +2,8 @@ package org.gcube.portal.databook.shared.ex;
@SuppressWarnings("serial")
public class FeedIDNotFoundException extends Exception {
public FeedIDNotFoundException(String message, String postId) {
public class PostIDNotFoundException extends Exception {
public PostIDNotFoundException(String message, String postId) {
super("The Post having id: " + postId + " is not present in the database: " + message);
}
}

View File

@ -0,0 +1,8 @@
package org.gcube.portal.databook.shared.ex;
@SuppressWarnings("serial")
public class PostTypeNotFoundException extends Exception {
public PostTypeNotFoundException(String message) {
super(message);
}
}