Compare commits
1 Commits
master
...
Feature/25
Author | SHA1 | Date |
---|---|---|
Ahmed Salah Tawfik Ibrahim | 79aba2e2fd |
|
@ -4,6 +4,9 @@
|
||||||
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).
|
||||||
|
|
||||||
|
## [v2.0.0] - 2023-10-24
|
||||||
|
- Feature #25901, add Cassandra 4.1.3 java client
|
||||||
|
|
||||||
## [v1.18.0] - 2022-09-20
|
## [v1.18.0] - 2022-09-20
|
||||||
|
|
||||||
- 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
|
- 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
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Class-Path:
|
Main-Class: org.gcube.portal.databook.server.Tester
|
||||||
|
|
||||||
|
|
85
pom.xml
85
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
<version>1.18.0</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<name>gCube Social Networking Library</name>
|
<name>gCube Social Networking Library</name>
|
||||||
<description>
|
<description>
|
||||||
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
|
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
|
||||||
|
@ -28,57 +28,39 @@
|
||||||
<gwtVersion>2.8.1</gwtVersion>
|
<gwtVersion>2.8.1</gwtVersion>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<cassandra.driver.oss.version>4.13.0</cassandra.driver.oss.version>
|
||||||
|
<logback.version>1.2.3</logback.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.distribution</groupId>
|
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
|
||||||
<version>3.6.4</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.datastax.oss</groupId>
|
||||||
|
<artifactId>java-driver-query-builder</artifactId>
|
||||||
|
<version>${cassandra.driver.oss.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.datastax.oss</groupId>
|
||||||
|
<artifactId>java-driver-mapper-runtime</artifactId>
|
||||||
|
<version>${cassandra.driver.oss.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google</groupId>
|
<groupId>com.google</groupId>
|
||||||
<artifactId>gwt-jsonmaker</artifactId>
|
<artifactId>gwt-jsonmaker</artifactId>
|
||||||
</dependency>
|
<version>1.2.1</version>
|
||||||
<dependency>
|
|
||||||
<groupId>com.netflix.astyanax</groupId>
|
|
||||||
<artifactId>astyanax-core</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.netflix.astyanax</groupId>
|
|
||||||
<artifactId>astyanax-thrift</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.netflix.astyanax</groupId>
|
|
||||||
<artifactId>astyanax-cassandra</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
|
<version>[1.0.5-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
<scope>provided</scope>
|
<version>[2.4.2-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
<scope>provided</scope>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -89,15 +71,21 @@
|
||||||
<groupId>com.google.gwt</groupId>
|
<groupId>com.google.gwt</groupId>
|
||||||
<artifactId>gwt-user</artifactId>
|
<artifactId>gwt-user</artifactId>
|
||||||
<version>${gwtVersion}</version>
|
<version>${gwtVersion}</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>1.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.6.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
@ -135,6 +123,31 @@
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,25 @@
|
||||||
package org.gcube.portal.databook.server;
|
package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Map;
|
import java.time.Duration;
|
||||||
import java.util.UUID;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
|
||||||
|
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
|
||||||
|
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
|
||||||
|
import com.datastax.oss.driver.api.core.cql.ResultSet;
|
||||||
|
import com.datastax.oss.driver.api.core.metadata.Metadata;
|
||||||
|
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
|
||||||
|
import com.datastax.oss.driver.api.core.type.DataTypes;
|
||||||
|
import com.datastax.oss.driver.api.querybuilder.SchemaBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.netflix.astyanax.AstyanaxContext;
|
|
||||||
import com.netflix.astyanax.Cluster;
|
|
||||||
import com.netflix.astyanax.Keyspace;
|
|
||||||
import com.netflix.astyanax.connectionpool.NodeDiscoveryType;
|
|
||||||
import com.netflix.astyanax.connectionpool.OperationResult;
|
|
||||||
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
|
||||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
|
|
||||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolType;
|
|
||||||
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
|
|
||||||
import com.netflix.astyanax.ddl.ColumnDefinition;
|
|
||||||
import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
|
|
||||||
import com.netflix.astyanax.ddl.KeyspaceDefinition;
|
|
||||||
import com.netflix.astyanax.ddl.SchemaChangeResult;
|
|
||||||
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
|
|
||||||
import com.netflix.astyanax.thrift.ThriftFamilyFactory;
|
|
||||||
import com.netflix.astyanax.thrift.ddl.ThriftColumnDefinitionImpl;
|
|
||||||
import com.netflix.astyanax.thrift.ddl.ThriftColumnFamilyDefinitionImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Massimiliano Assante ISTI-CNR
|
* @author Massimiliano Assante ISTI-CNR
|
||||||
* @author Costantino Perciante ISTI-CNR
|
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CassandraClusterConnection {
|
public class CassandraClusterConnection {
|
||||||
|
@ -39,304 +31,473 @@ public class CassandraClusterConnection {
|
||||||
/**
|
/**
|
||||||
* keyspace location
|
* keyspace location
|
||||||
*/
|
*/
|
||||||
private static String clusterName;
|
private static List<InetSocketAddress> hosts;
|
||||||
private static String host;
|
private static String datacenterName;
|
||||||
private static String keyspaceName;
|
private static String keyspaceName;
|
||||||
|
private CqlSession myKeyspaceSession;
|
||||||
|
|
||||||
private Keyspace myKeyspace;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param dropSchema set true if you want do drop the current and set up new one
|
* @param dropSchema set true if you want do drop the current and set up new one
|
||||||
* the connection to cassandra cluster
|
* the connection to cassandra cluster
|
||||||
*/
|
*/
|
||||||
protected CassandraClusterConnection(boolean dropSchema) {
|
protected CassandraClusterConnection(boolean dropSchema) {
|
||||||
if (clusterName == null || host == null || keyspaceName == null) {
|
if (hosts == null || datacenterName == null || keyspaceName == null) {
|
||||||
RunningCluster cluster = RunningCluster.getInstance(null);
|
RunningCluster cluster = RunningCluster.getInstance(null);
|
||||||
clusterName = cluster.getClusterName();
|
|
||||||
host = cluster.getHost();
|
|
||||||
keyspaceName = cluster.getKeyspaceName();
|
|
||||||
}
|
|
||||||
|
|
||||||
AstyanaxContext<Cluster> clusterContext = new AstyanaxContext.Builder()
|
//host = cluster.getHost();
|
||||||
.forCluster(clusterName)
|
hosts = cluster.getHosts();
|
||||||
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl())
|
datacenterName = cluster.getDatacenterName();
|
||||||
.withConnectionPoolConfiguration(
|
keyspaceName = cluster.getKeyspaceName();
|
||||||
new ConnectionPoolConfigurationImpl(
|
}
|
||||||
clusterName).setMaxConnsPerHost(100)
|
|
||||||
.setSeeds(host))
|
|
||||||
.withConnectionPoolMonitor(
|
|
||||||
new CountingConnectionPoolMonitor())
|
|
||||||
.buildCluster(ThriftFamilyFactory.getInstance());
|
|
||||||
|
|
||||||
_log.info(keyspaceName + " KeySpace SetUp ...");
|
_log.info(keyspaceName + " KeySpace SetUp ...");
|
||||||
SetUpKeySpaces(clusterContext, dropSchema);
|
SetUpKeySpaces(dropSchema);
|
||||||
|
myKeyspaceSession = connect(keyspaceName);
|
||||||
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
|
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
|
||||||
|
|
||||||
// then close connection pool for cluster
|
|
||||||
_log.info("Closing cluster connection pool no longer needed (keyspace one will be used)");
|
|
||||||
clusterContext.shutdown();
|
|
||||||
_log.info("Closed cluster connection pool no longer needed (keyspace one will be used)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the connection pool
|
*
|
||||||
*/
|
* @param dropSchema set true if you want to drop the current and set up new one
|
||||||
public void closeConnection(){
|
|
||||||
|
|
||||||
if(myKeyspace != null){
|
|
||||||
try{
|
|
||||||
_log.info("Closing pool connection");
|
|
||||||
myKeyspace.getConnectionPool().shutdown();
|
|
||||||
_log.info("Pool closed!");
|
|
||||||
}catch(Exception e){
|
|
||||||
_log.error("Unable to close connection pool", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param dropSchema set true if you want do drop the current and set up new one
|
|
||||||
* the connection to cassandra cluster
|
* the connection to cassandra cluster
|
||||||
*/
|
*/
|
||||||
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) {
|
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) {
|
||||||
if (clusterName == null || host == null || keyspaceName == null) {
|
if (hosts == null || datacenterName == null || keyspaceName == null) {
|
||||||
RunningCluster cluster = RunningCluster.getInstance(infrastructureName);
|
RunningCluster cluster = RunningCluster.getInstance(infrastructureName);
|
||||||
clusterName = cluster.getClusterName();
|
//host = cluster.getHost();
|
||||||
host = cluster.getHost();
|
hosts = cluster.getHosts();
|
||||||
|
datacenterName = cluster.getDatacenterName();
|
||||||
keyspaceName = cluster.getKeyspaceName();
|
keyspaceName = cluster.getKeyspaceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
AstyanaxContext<Cluster> clusterContext = new AstyanaxContext.Builder()
|
|
||||||
.forCluster(clusterName)
|
|
||||||
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl())
|
|
||||||
.withConnectionPoolConfiguration(
|
|
||||||
new ConnectionPoolConfigurationImpl(
|
|
||||||
clusterName).setMaxConnsPerHost(100)
|
|
||||||
.setSeeds(host))
|
|
||||||
.withConnectionPoolMonitor(
|
|
||||||
new CountingConnectionPoolMonitor())
|
|
||||||
.buildCluster(ThriftFamilyFactory.getInstance());
|
|
||||||
|
|
||||||
_log.info(keyspaceName + " KeySpace SetUp ...");
|
_log.info(keyspaceName + " KeySpace SetUp ...");
|
||||||
SetUpKeySpaces(clusterContext, dropSchema);
|
SetUpKeySpaces(dropSchema);
|
||||||
|
myKeyspaceSession = connect(keyspaceName);
|
||||||
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
|
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
|
||||||
|
}
|
||||||
// then close connection pool for cluster
|
|
||||||
_log.info("Closing cluster connection pool no longer needed (keyspace one will be used)");
|
public CqlSession getKeyspaceSession(){
|
||||||
clusterContext.shutdown();
|
if (myKeyspaceSession.isClosed()){
|
||||||
_log.info("Closed cluster connection pool no longer needed (keyspace one will be used)");
|
myKeyspaceSession = connect(keyspaceName);
|
||||||
|
}
|
||||||
|
return myKeyspaceSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the reference to the current keyspace
|
* @param dropSchema set true if you want to drop the current and set up new one
|
||||||
* @return keyspace reference
|
* the connection to cassandra cluster
|
||||||
*/
|
*/
|
||||||
public Keyspace getKeyspace() {
|
public void SetUpKeySpaces(boolean dropSchema) {
|
||||||
|
boolean createNew = false;
|
||||||
// The Keyspace instance can be shared among different requests
|
boolean found = false;
|
||||||
if(myKeyspace == null){
|
CqlSession session = connect();
|
||||||
synchronized(this){
|
Metadata metaData = session.getMetadata();
|
||||||
if(myKeyspace == null){ // double checked lock
|
for (KeyspaceMetadata meta : metaData.getKeyspaces().values()) {
|
||||||
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
|
if (meta.getName().toString().equals(keyspaceName)){
|
||||||
.forCluster(clusterName)
|
found = true;
|
||||||
.forKeyspace(keyspaceName)
|
break;
|
||||||
.withAstyanaxConfiguration(
|
|
||||||
new AstyanaxConfigurationImpl()
|
|
||||||
.setDiscoveryType(NodeDiscoveryType.NONE) // use only the host given as seeds (do not discover)
|
|
||||||
.setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN) // how to handle connections of the the connection pool
|
|
||||||
)
|
|
||||||
.withConnectionPoolConfiguration(
|
|
||||||
new ConnectionPoolConfigurationImpl("MyConnectionPool")
|
|
||||||
.setMaxConnsPerHost(3) // for each seed(host)
|
|
||||||
.setSocketTimeout(2000) //-> default: 11 seconds
|
|
||||||
//.setConnectTimeout(1000) -> default: 2 seconds
|
|
||||||
.setSeeds(host)
|
|
||||||
)
|
|
||||||
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
|
|
||||||
.buildKeyspace(ThriftFamilyFactory.getInstance());
|
|
||||||
|
|
||||||
|
|
||||||
context.start();
|
|
||||||
|
|
||||||
// save keyspace reference
|
|
||||||
myKeyspace = context.getEntity();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return myKeyspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param clusterContext
|
|
||||||
* @param dropSchema
|
|
||||||
* @throws ConnectionException
|
|
||||||
*/
|
|
||||||
public void SetUpKeySpaces(AstyanaxContext<Cluster> clusterContext, boolean dropSchema) {
|
|
||||||
boolean createNew = false;
|
|
||||||
clusterContext.start();
|
|
||||||
try {
|
try {
|
||||||
Cluster cluster = clusterContext.getEntity();
|
if (dropSchema && found) {
|
||||||
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
|
|
||||||
|
|
||||||
if (dropSchema && keyspaceDef != null) {
|
|
||||||
_log.info("Dropping Keyspace: " + keyspaceName + " ...");
|
_log.info("Dropping Keyspace: " + keyspaceName + " ...");
|
||||||
try {
|
try {
|
||||||
OperationResult<SchemaChangeResult> returned = cluster.dropKeyspace(keyspaceName);
|
ResultSet returned = dropKeyspace();
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
_log.info("Dropped " + returned.getResult().toString());
|
if (returned.wasApplied())
|
||||||
} catch (ConnectionException e) {
|
_log.info("Dropped " + keyspaceName);
|
||||||
|
else
|
||||||
|
_log.info("Couldn't drop " + keyspaceName);
|
||||||
|
} catch (Exception e) {
|
||||||
_log.error("Dropping Keyspace operation Failed ... " + keyspaceName + " does NOT exists");
|
_log.error("Dropping Keyspace operation Failed ... " + keyspaceName + " does NOT exists");
|
||||||
return;
|
return;
|
||||||
} catch (InterruptedException e) {
|
}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
createNew = true;
|
createNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (!found || createNew) {
|
||||||
|
|
||||||
keyspaceDef = cluster.makeKeyspaceDefinition();
|
|
||||||
keyspaceDef = cluster.describeKeyspace(keyspaceName);
|
|
||||||
|
|
||||||
if (keyspaceDef == null || keyspaceDef.getName() == null || createNew) {
|
|
||||||
_log.info("Keyspace does not exist, triggering schema creation ... ");
|
_log.info("Keyspace does not exist, triggering schema creation ... ");
|
||||||
createSchema(cluster);
|
int replicationFactor = 2;
|
||||||
_log.info("Cluster " + clusterName + " on " + host + " Initialized OK!");
|
createKeyspace(keyspaceName, replicationFactor);
|
||||||
|
closeSession(session);
|
||||||
|
createTables();
|
||||||
_log.info("Using Keyspace " + keyspaceName);
|
_log.info("Using Keyspace " + keyspaceName);
|
||||||
}
|
}
|
||||||
} catch (ConnectionException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
********************** CASSANDRA KEYSPACE CREATION ***********************
|
********************** CASSANDRA KEYSPACE CREATION ***********************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
private static CqlSession connect() {
|
||||||
* create the databook schema
|
CqlSession cqlSession = configBuilder(CqlSession.builder())
|
||||||
* @return
|
.addContactPoints(hosts)
|
||||||
* @throws ConnectionException
|
.withLocalDatacenter(datacenterName)
|
||||||
*/
|
.build();
|
||||||
private void createSchema(Cluster cluster) throws ConnectionException {
|
_log.info("[OK] Connected to Cassandra Cluster");
|
||||||
|
return cqlSession;
|
||||||
Map<String, String> stratOptions = new HashMap<String, String>();
|
}
|
||||||
stratOptions.put("replication_factor", "1");
|
private static CqlSession connect(String KEYSPACE_NAME) {
|
||||||
|
CqlSession cqlSession = configBuilder(CqlSession.builder())
|
||||||
KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();
|
.addContactPoints(hosts)
|
||||||
|
.withKeyspace(KEYSPACE_NAME)
|
||||||
//get static column families with secondary indexes
|
.withLocalDatacenter("1")
|
||||||
/**
|
.build();
|
||||||
* define Notifications CF with Type as secondary index
|
_log.info("[OK] Connected to Keyspace {} ", KEYSPACE_NAME);
|
||||||
*/
|
return cqlSession;
|
||||||
ColumnFamilyDefinition cfDefNotifications = getStaticCFDef(DBCassandraAstyanaxImpl.NOTIFICATIONS, "Type");
|
|
||||||
/**
|
|
||||||
* define Feeds CF with Privacy as secondary index
|
|
||||||
*/
|
|
||||||
ColumnFamilyDefinition cfDefFeeds = getStaticCFDef(DBCassandraAstyanaxImpl.FEEDS, "Privacy");
|
|
||||||
/**
|
|
||||||
* define Comments CF with FeedId as secondary index
|
|
||||||
*/
|
|
||||||
ColumnFamilyDefinition cfDefComments = getStaticCFDef(DBCassandraAstyanaxImpl.COMMENTS, "Feedid");
|
|
||||||
/**
|
|
||||||
* define Likes CF with FeedId as secondary index
|
|
||||||
*/
|
|
||||||
ColumnFamilyDefinition cfDefLikes = getStaticCFDef(DBCassandraAstyanaxImpl.LIKES, "Feedid");
|
|
||||||
/**
|
|
||||||
* define Invites CF with SenderUserId as secondary index
|
|
||||||
*/
|
|
||||||
ColumnFamilyDefinition cfDefInvites = getStaticCFDef(DBCassandraAstyanaxImpl.INVITES, "SenderUserId");
|
|
||||||
/**
|
|
||||||
* define Attachments CF with FeedId as secondary index
|
|
||||||
*/
|
|
||||||
ColumnFamilyDefinition cfDefAttachments = getStaticCFDef(DBCassandraAstyanaxImpl.ATTACHMENTS, "feedId");
|
|
||||||
|
|
||||||
|
|
||||||
//get dynamic column families, act as auxiliary indexes
|
|
||||||
ColumnFamilyDefinition cfDefConn = getDynamicCFDef(DBCassandraAstyanaxImpl.CONNECTIONS);
|
|
||||||
ColumnFamilyDefinition cfDefPendingConn = getDynamicCFDef(DBCassandraAstyanaxImpl.PENDING_CONNECTIONS_CF_NAME);
|
|
||||||
ColumnFamilyDefinition cfDefVRETimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.VRE_TIMELINE_FEEDS);
|
|
||||||
ColumnFamilyDefinition cfDefAPPTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.APP_TIMELINE_FEEDS);
|
|
||||||
ColumnFamilyDefinition cfDefUserTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_TIMELINE_FEEDS);
|
|
||||||
ColumnFamilyDefinition cfDefUserLikedFeeds = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_LIKED_FEEDS);
|
|
||||||
ColumnFamilyDefinition cfDefUserNotifications = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_NOTIFICATIONS);
|
|
||||||
ColumnFamilyDefinition cfDefUserNotificationsUnread = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_UNREAD);
|
|
||||||
ColumnFamilyDefinition cfDefUserNotificationsPreferences = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES);
|
|
||||||
ColumnFamilyDefinition cfDefEmailInvitesTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.EMAIL_INVITES);
|
|
||||||
ColumnFamilyDefinition cfDefVREInvitesTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.VRE_INVITES);
|
|
||||||
ColumnFamilyDefinition cfDefHashtagsCounter = getDynamicCFDef(DBCassandraAstyanaxImpl.HASHTAGS_COUNTER);
|
|
||||||
ColumnFamilyDefinition cfDefHashtagTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.HASHTAGGED_FEEDS);
|
|
||||||
ColumnFamilyDefinition cfDefHashtagCommentsTimeline = getDynamicCFDef(DBCassandraAstyanaxImpl.HASHTAGGED_COMMENTS);
|
|
||||||
|
|
||||||
|
|
||||||
ksDef.setName(keyspaceName)
|
|
||||||
.setStrategyOptions(stratOptions)
|
|
||||||
.setStrategyClass("SimpleStrategy")
|
|
||||||
.addColumnFamily(cfDefNotifications)
|
|
||||||
.addColumnFamily(cfDefFeeds)
|
|
||||||
.addColumnFamily(cfDefComments)
|
|
||||||
.addColumnFamily(cfDefLikes)
|
|
||||||
.addColumnFamily(cfDefInvites)
|
|
||||||
.addColumnFamily(cfDefAttachments)
|
|
||||||
.addColumnFamily(cfDefConn)
|
|
||||||
.addColumnFamily(cfDefPendingConn)
|
|
||||||
.addColumnFamily(cfDefVRETimeline)
|
|
||||||
.addColumnFamily(cfDefAPPTimeline)
|
|
||||||
.addColumnFamily(cfDefUserTimeline)
|
|
||||||
.addColumnFamily(cfDefUserNotifications)
|
|
||||||
.addColumnFamily(cfDefUserNotificationsUnread)
|
|
||||||
.addColumnFamily(cfDefUserNotificationsPreferences)
|
|
||||||
.addColumnFamily(cfDefUserLikedFeeds)
|
|
||||||
.addColumnFamily(cfDefEmailInvitesTimeline)
|
|
||||||
.addColumnFamily(cfDefVREInvitesTimeline)
|
|
||||||
.addColumnFamily(cfDefHashtagsCounter)
|
|
||||||
.addColumnFamily(cfDefHashtagTimeline)
|
|
||||||
.addColumnFamily(cfDefHashtagCommentsTimeline);
|
|
||||||
|
|
||||||
cluster.addKeyspace(ksDef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static void closeSession(CqlSession session) {
|
||||||
* create a dynamic column family to be added in a keyspace
|
if (session != null) session.close();
|
||||||
*
|
_log.info("[OK]Session is now closed");
|
||||||
* @param cfName the CF name
|
|
||||||
* @return the instance to be added to the keyspace
|
|
||||||
*/
|
|
||||||
private ColumnFamilyDefinition getDynamicCFDef(String cfName) {
|
|
||||||
ColumnFamilyDefinition columnFamilyDefinition = new ThriftColumnFamilyDefinitionImpl();
|
|
||||||
columnFamilyDefinition.setName(cfName);
|
|
||||||
columnFamilyDefinition.setKeyValidationClass("UTF8Type");
|
|
||||||
columnFamilyDefinition.setComparatorType("UTF8Type");
|
|
||||||
return columnFamilyDefinition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void closeConnection(){
|
||||||
* create a static column family to be added in a keyspace with possibility to add a secondary index for a given column
|
if(!myKeyspaceSession.isClosed()){
|
||||||
*
|
try{
|
||||||
* @param cfName the CF name
|
_log.info("Closing connection");
|
||||||
* @param secondaryIndexedField the column name of the column to index
|
closeSession(myKeyspaceSession);
|
||||||
* @return the instance to be added to the keyspace
|
_log.info("Connection closed!");
|
||||||
*/
|
}catch(Exception e){
|
||||||
private ColumnFamilyDefinition getStaticCFDef(String cfName, String secondaryIndexedField) {
|
_log.error("Unable to close connection", e);
|
||||||
ColumnFamilyDefinition columnFamilyDefinition = new ThriftColumnFamilyDefinitionImpl();
|
}
|
||||||
columnFamilyDefinition.setName(cfName);
|
}
|
||||||
|
|
||||||
columnFamilyDefinition.setKeyValidationClass("UTF8Type");
|
|
||||||
columnFamilyDefinition.setComparatorType("UTF8Type");
|
|
||||||
|
|
||||||
|
|
||||||
//Add secondary index for userid
|
|
||||||
ColumnDefinition typeCDef = new ThriftColumnDefinitionImpl();
|
|
||||||
typeCDef.setName(secondaryIndexedField)
|
|
||||||
.setValidationClass("UTF8Type");
|
|
||||||
typeCDef.setIndex(secondaryIndexedField+"_"+UUID.randomUUID().toString().substring(0,5), "KEYS");
|
|
||||||
|
|
||||||
columnFamilyDefinition.addColumnDefinition(typeCDef);
|
|
||||||
return columnFamilyDefinition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CqlSessionBuilder configBuilder(CqlSessionBuilder cqlSessionBuilder){
|
||||||
|
return cqlSessionBuilder
|
||||||
|
.withConfigLoader(DriverConfigLoader.programmaticBuilder()
|
||||||
|
// Resolves the timeout query 'SELECT * FROM system_schema.tables' timed out after PT2S
|
||||||
|
.withDuration(DefaultDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT, Duration.ofMillis(240000))
|
||||||
|
.withDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, Duration.ofMillis(240000))
|
||||||
|
.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(240000))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
private static void createKeyspace(String keyspaceName, int replicationFactor) {
|
||||||
|
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
|
||||||
|
.addContactPoints(hosts)
|
||||||
|
.withLocalDatacenter("1")
|
||||||
|
.build()) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createKeyspace(keyspaceName)
|
||||||
|
.ifNotExists()
|
||||||
|
.withSimpleStrategy(replicationFactor)
|
||||||
|
.withDurableWrites(true)
|
||||||
|
.build());
|
||||||
|
_log.info("+ Keyspace '{}' created.", keyspaceName);
|
||||||
|
closeSession(cqlSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResultSet dropKeyspace(){
|
||||||
|
ResultSet toreturn;
|
||||||
|
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
|
||||||
|
.addContactPoints(hosts)
|
||||||
|
.withLocalDatacenter("1")
|
||||||
|
.build()) {
|
||||||
|
toreturn = cqlSession.execute(SchemaBuilder.dropKeyspace(keyspaceName).ifExists().build());
|
||||||
|
_log.info("Keyspace {} dropped.", keyspaceName);
|
||||||
|
closeSession(cqlSession);
|
||||||
|
}
|
||||||
|
return toreturn;
|
||||||
|
}
|
||||||
|
private void createTables(){
|
||||||
|
try (CqlSession cqlSession = configBuilder(CqlSession.builder())
|
||||||
|
.addContactPoints(hosts)
|
||||||
|
.withLocalDatacenter("1")
|
||||||
|
.withKeyspace(keyspaceName)
|
||||||
|
.build()) {
|
||||||
|
|
||||||
|
createTableUSERNotificationsPreferences(cqlSession);
|
||||||
|
createTableUSERNotifications(cqlSession);
|
||||||
|
createTableVRETimeline(cqlSession);
|
||||||
|
createTableAppTimeline(cqlSession);
|
||||||
|
createTableUSERTimeline(cqlSession);
|
||||||
|
createTableHashtaggedPosts(cqlSession);
|
||||||
|
createTableHashtaggedComments(cqlSession);
|
||||||
|
createTableHashtagsCounter(cqlSession);
|
||||||
|
createTableUSERNotificationsUnread(cqlSession);
|
||||||
|
createTableUSERLikes(cqlSession);
|
||||||
|
createTableVREInvites(cqlSession);
|
||||||
|
createTableEMAILInvites(cqlSession);
|
||||||
|
createTableAttachments(cqlSession);
|
||||||
|
createTableInvites(cqlSession);
|
||||||
|
createTableLikes(cqlSession);
|
||||||
|
createTableComments(cqlSession);
|
||||||
|
createTableNotifications(cqlSession);
|
||||||
|
createTablePosts(cqlSession);
|
||||||
|
|
||||||
|
closeSession(cqlSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void createTableUSERNotificationsPreferences(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("UserNotificationsPreferences")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("userid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("type", DataTypes.TEXT)
|
||||||
|
.withColumn("preference", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "USERNotificationsPreferences");
|
||||||
|
}
|
||||||
|
private void createTableUSERNotifications(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("UserNotifications")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("userid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("notid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "USERNotifications");
|
||||||
|
}
|
||||||
|
private void createTableVRETimeline(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("VRETimeline")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("vreid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "VRETimeline");
|
||||||
|
}
|
||||||
|
private void createTableAppTimeline(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("AppTimeline")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("appid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "AppTimeline");
|
||||||
|
}
|
||||||
|
private void createTableUSERTimeline(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("UserTimeline")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("userid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "USERTimeline");
|
||||||
|
}
|
||||||
|
private void createTableHashtaggedPosts(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("HashtaggedPosts")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("hashtag", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("postid", DataTypes.UUID)
|
||||||
|
.withColumn("vreid", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "HashtaggedPosts");
|
||||||
|
}
|
||||||
|
private void createTableHashtaggedComments(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("HashtaggedComments")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("hashtag", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("commentid", DataTypes.UUID)
|
||||||
|
.withColumn("vreid", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "HashtaggedComments");
|
||||||
|
}
|
||||||
|
private void createTableHashtagsCounter(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("HashtagsCounter")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("vreid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("hashtag", DataTypes.TEXT)
|
||||||
|
.withColumn("count", DataTypes.BIGINT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "HashtagsCounter");
|
||||||
|
}
|
||||||
|
private void createTableUSERNotificationsUnread(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("UserUnreadNotifications")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("userid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("notid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "USERNotificationsUnread");
|
||||||
|
}
|
||||||
|
private void createTableUSERLikes(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("UserLikes")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("userid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("likeid", DataTypes.UUID)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "USERLikes");
|
||||||
|
}
|
||||||
|
private void createTableVREInvites(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("VREInvites")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("vreid", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("inviteid", DataTypes.UUID)
|
||||||
|
.withColumn("status", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "VREInvites");
|
||||||
|
}
|
||||||
|
private void createTableEMAILInvites(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("EmailInvites")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("email", DataTypes.TEXT)
|
||||||
|
.withPartitionKey("vreid", DataTypes.TEXT)
|
||||||
|
.withColumn("inviteid", DataTypes.UUID)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "EMAILInvites");
|
||||||
|
}
|
||||||
|
private void createTableAttachments(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Attachments")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("attachid", DataTypes.UUID)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withColumn("uri", DataTypes.TEXT)
|
||||||
|
.withColumn("name", DataTypes.TEXT)
|
||||||
|
.withColumn("description", DataTypes.TEXT)
|
||||||
|
.withColumn("urithumbnail", DataTypes.TEXT)
|
||||||
|
.withColumn("mimetype", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("post_attach")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Attachments")
|
||||||
|
.andColumn("postid")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Attachments");
|
||||||
|
}
|
||||||
|
private void createTableInvites(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Invites")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("inviteid", DataTypes.UUID)
|
||||||
|
.withColumn("senderuserid", DataTypes.TEXT)
|
||||||
|
.withColumn("vreid", DataTypes.TEXT)
|
||||||
|
.withColumn("email", DataTypes.TEXT)
|
||||||
|
.withColumn("controlcode", DataTypes.TEXT)
|
||||||
|
.withColumn("status", DataTypes.TEXT)
|
||||||
|
.withColumn("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("senderfullname", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("sender")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Invites")
|
||||||
|
.andColumn("senderuserid")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Invites");
|
||||||
|
}
|
||||||
|
private void createTableLikes(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Likes")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("likeid", DataTypes.UUID)
|
||||||
|
.withColumn("userid", DataTypes.TEXT)
|
||||||
|
.withColumn("fullname", DataTypes.TEXT)
|
||||||
|
.withColumn("thumbnailurl", DataTypes.TEXT)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withColumn("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("post_likes")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Likes")
|
||||||
|
.andColumn("postid")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Likes");
|
||||||
|
}
|
||||||
|
private void createTableComments(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Comments")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("commentid", DataTypes.UUID)
|
||||||
|
.withColumn("userid", DataTypes.TEXT)
|
||||||
|
.withColumn("fullname", DataTypes.TEXT)
|
||||||
|
.withColumn("thumbnailurl", DataTypes.TEXT)
|
||||||
|
.withColumn("comment", DataTypes.TEXT)
|
||||||
|
.withColumn("postid", DataTypes.UUID)
|
||||||
|
.withColumn("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("isedit", DataTypes.BOOLEAN)
|
||||||
|
.withColumn("lastedittime", DataTypes.TIMESTAMP)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("post_comments")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Comments")
|
||||||
|
.andColumn("postid")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Comments");
|
||||||
|
}
|
||||||
|
private void createTableNotifications(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Notifications")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("notid", DataTypes.UUID)
|
||||||
|
.withColumn("type", DataTypes.TEXT)
|
||||||
|
.withColumn("userid", DataTypes.TEXT)
|
||||||
|
.withColumn("subjectid", DataTypes.TEXT)
|
||||||
|
.withColumn("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("description", DataTypes.TEXT)
|
||||||
|
.withColumn("uri", DataTypes.TEXT)
|
||||||
|
.withColumn("senderid", DataTypes.TEXT)
|
||||||
|
.withColumn("senderfullname", DataTypes.TEXT)
|
||||||
|
.withColumn("senderthumbnailurl", DataTypes.TEXT)
|
||||||
|
.withColumn("isread", DataTypes.BOOLEAN)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("not_type")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Notifications")
|
||||||
|
.andColumn("type")
|
||||||
|
.build());
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Notifications");
|
||||||
|
}
|
||||||
|
private void createTablePosts(CqlSession cqlSession) {
|
||||||
|
cqlSession.execute(SchemaBuilder.createTable("Posts")
|
||||||
|
.ifNotExists()
|
||||||
|
.withPartitionKey("postid", DataTypes.UUID)
|
||||||
|
.withColumn("linkhost", DataTypes.TEXT)
|
||||||
|
.withColumn("description", DataTypes.TEXT)
|
||||||
|
.withColumn("email", DataTypes.TEXT)
|
||||||
|
.withColumn("likesno", DataTypes.BIGINT)
|
||||||
|
.withColumn("thumbnailurl", DataTypes.TEXT)
|
||||||
|
.withColumn("linkdescription", DataTypes.TEXT)
|
||||||
|
.withColumn("timestamp", DataTypes.TIMESTAMP)
|
||||||
|
.withColumn("uri", DataTypes.TEXT)
|
||||||
|
.withColumn("isapplicationpost", DataTypes.BOOLEAN)
|
||||||
|
.withColumn("entityid", DataTypes.TEXT)
|
||||||
|
.withColumn("privacy", DataTypes.TEXT)
|
||||||
|
.withColumn("type", DataTypes.TEXT)
|
||||||
|
.withColumn("urithumbnail", DataTypes.TEXT)
|
||||||
|
.withColumn("vreid", DataTypes.TEXT)
|
||||||
|
.withColumn("multifileupload", DataTypes.BOOLEAN)
|
||||||
|
.withColumn("fullname", DataTypes.TEXT)
|
||||||
|
.withColumn("commentsno", DataTypes.BIGINT)
|
||||||
|
.withColumn("linktitle", DataTypes.TEXT)
|
||||||
|
.withCompactStorage()
|
||||||
|
.build());
|
||||||
|
cqlSession.execute(SchemaBuilder.createIndex("posts_privacy")
|
||||||
|
.ifNotExists()
|
||||||
|
.onTable("Posts")
|
||||||
|
.andColumn("privacy")
|
||||||
|
.build());
|
||||||
|
|
||||||
|
_log.info("+ Table '{}' has been created (if needed).", "Posts");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -5,17 +5,12 @@ import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
|
||||||
import com.netflix.astyanax.model.ColumnFamily;
|
|
||||||
import com.netflix.astyanax.serializers.StringSerializer;
|
|
||||||
|
|
||||||
public class DatabookCassandraTest {
|
public class DatabookCassandraTest {
|
||||||
private static DBCassandraAstyanaxImpl store;
|
private static DBCassandraDatastaxImpl store;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setup() throws Exception {
|
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
|
@AfterClass
|
||||||
|
|
|
@ -7,7 +7,6 @@ import javax.mail.internet.AddressException;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.Attachment;
|
import org.gcube.portal.databook.shared.Attachment;
|
||||||
import org.gcube.portal.databook.shared.Comment;
|
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.Invite;
|
||||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||||
import org.gcube.portal.databook.shared.InviteStatus;
|
import org.gcube.portal.databook.shared.InviteStatus;
|
||||||
|
@ -16,21 +15,9 @@ import org.gcube.portal.databook.shared.Notification;
|
||||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||||
import org.gcube.portal.databook.shared.NotificationType;
|
import org.gcube.portal.databook.shared.NotificationType;
|
||||||
import org.gcube.portal.databook.shared.Post;
|
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.RangePosts;
|
||||||
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
import org.gcube.portal.databook.shared.ex.*;
|
||||||
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 com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Massimiliano Assante ISTI-CNR
|
* @author Massimiliano Assante ISTI-CNR
|
||||||
|
@ -38,51 +25,11 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
||||||
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
|
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
|
||||||
*/
|
*/
|
||||||
public interface 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
|
* save a Post instance in the store
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
*/
|
*/
|
||||||
boolean saveUserPost(Post feed);
|
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
|
* 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
|
* Use this if you need to attach more than one file to the post
|
||||||
|
@ -91,54 +38,24 @@ public interface DatabookStore {
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
*/
|
*/
|
||||||
boolean saveUserPost(Post post, List<Attachment> attachments);
|
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
|
* delete a Feed from the store
|
||||||
* @throws FeedIDNotFoundException
|
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
*/
|
*/
|
||||||
boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
|
boolean deletePost(String postid) throws PrivacyLevelTypeNotFoundException, 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;
|
|
||||||
/**
|
/**
|
||||||
* save a post in the VRES TimeLine in the store
|
* save a post in the VRES TimeLine in the store
|
||||||
* @param postKey the post id
|
* @param postKey the post id
|
||||||
* @param vreid vre identifier
|
* @param vreid vre identifier
|
||||||
* @throws FeedIDNotFoundException
|
|
||||||
*/
|
*/
|
||||||
boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException;
|
boolean savePostToVRETimeline(String postKey, String vreid) throws PostIDNotFoundException;
|
||||||
/**
|
|
||||||
* @deprecated use saveAppPost
|
|
||||||
* save a Post instance in the store
|
|
||||||
* @return true if everything went fine
|
|
||||||
*/
|
|
||||||
boolean saveAppFeed(Feed feed);
|
|
||||||
/**
|
/**
|
||||||
* save a Post instance in the store
|
* save a Post instance in the store
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
*/
|
*/
|
||||||
boolean saveAppPost(Post feed);
|
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
|
* Save a Post instance in the store
|
||||||
* Use this if your app needs to attach more than one file to the post
|
* Use this if your app needs to attach more than one file to the post
|
||||||
|
@ -147,64 +64,28 @@ public interface DatabookStore {
|
||||||
* @return true if everything went fine
|
* @return true if everything went fine
|
||||||
*/
|
*/
|
||||||
boolean saveAppPost(Post feed, List<Attachment> attachments);
|
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
|
* read a feed from a given id
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws FeedTypeNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
* @throws ColumnNameNotFoundException
|
|
||||||
*/
|
*/
|
||||||
Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, PostTypeNotFoundException, PostIDNotFoundException;
|
||||||
/**
|
/**
|
||||||
* @deprecated use getAllPostsByUser instead
|
|
||||||
* @param userid user identifier
|
* @param userid user identifier
|
||||||
* return all the feeds belonging to the userid
|
* return all the feeds belonging to the userid
|
||||||
* @throws FeedTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
* @throws ColumnNameNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
*/
|
*/
|
||||||
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, 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
|
|
||||||
* @param appid application identifier
|
* @param appid application identifier
|
||||||
* return all the feeds belonging to the appid
|
* return all the feeds belonging to the appid
|
||||||
* @throws FeedTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
* @throws ColumnNameNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
*/
|
*/
|
||||||
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, 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;
|
|
||||||
/**
|
|
||||||
* @param userid the user identifier like andrea.rossi
|
* @param userid the user identifier like andrea.rossi
|
||||||
* @param timeInMillis the initial time in millis to be considered
|
* @param timeInMillis the initial time in millis to be considered
|
||||||
* @return a list of feeds commented by userid starting from timeInMillis
|
* @return a list of feeds commented by userid starting from timeInMillis
|
||||||
|
@ -212,97 +93,41 @@ public interface DatabookStore {
|
||||||
*/
|
*/
|
||||||
List<Post> getRecentCommentedPostsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
List<Post> getRecentCommentedPostsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
||||||
/**
|
/**
|
||||||
* @deprecated use getAllPortalPrivacyLevelPosts instead
|
|
||||||
* return all the feeds whose Level is PORTAL
|
* return all the feeds whose Level is PORTAL
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws ColumnNameNotFoundException
|
* @throws ColumnNameNotFoundException
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
*/
|
*/
|
||||||
List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
|
List<Post> getAllPortalPrivacyLevelPosts() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, PostTypeNotFoundException;
|
||||||
/**
|
|
||||||
* return all the feeds whose Level is PORTAL
|
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
* @throws ColumnNameNotFoundException
|
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
*/
|
|
||||||
List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* return the most recent feeds for this user up to quantity param
|
||||||
* @param userid user identifier
|
* @param userid user identifier
|
||||||
* @param quantity the number of most recent feeds for this user
|
* @param quantity the number of most recent feeds for this user
|
||||||
* @return a <class>List</class> 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
|
* @throws ColumnNameNotFoundException
|
||||||
*/
|
*/
|
||||||
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException;
|
||||||
/**
|
|
||||||
* @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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use getRecentPostsByVRE
|
* @param vreid vre identifier
|
||||||
* return the most recent feeds for this vre up to quantity param
|
* return all the feeds belonging to the userid
|
||||||
* @param vreid VRES identifier
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @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
|
|
||||||
* @throws ColumnNameNotFoundException
|
* @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
|
* return the most recent posts for this vre up to quantity param
|
||||||
* @param vreid VRES identifier
|
* @param vreid VRES identifier
|
||||||
* @param quantity the number of most recent posts for this vre
|
* @param quantity the number of most recent posts for this vre
|
||||||
* @return a <class>List</class> 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
|
* @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
|
* 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
|
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
|
||||||
|
@ -311,19 +136,11 @@ public interface DatabookStore {
|
||||||
* @param from the range start (most recent feeds for this vre) has to be greater than 0
|
* @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
|
* @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
|
* @return a <class>RangePosts</class> containing of most recent feeds for this vre
|
||||||
* @throws FeedTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
* @throws ColumnNameNotFoundException
|
* @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 userid user identifier
|
||||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||||
|
@ -437,13 +254,7 @@ public interface DatabookStore {
|
||||||
* add a comment to a feed
|
* add a comment to a feed
|
||||||
* @param comment the Comment instance to add
|
* @param comment the Comment instance to add
|
||||||
*/
|
*/
|
||||||
boolean addComment(Comment comment) throws FeedIDNotFoundException;
|
boolean addComment(Comment comment);
|
||||||
/**
|
|
||||||
* @deprecated use getAllCommentByPost
|
|
||||||
* @param feedid feed identifier
|
|
||||||
* return all the comments belonging to the feedid
|
|
||||||
*/
|
|
||||||
List<Comment> getAllCommentByFeed(String feedid);
|
|
||||||
/**
|
/**
|
||||||
* @param postid the post identifier
|
* @param postid the post identifier
|
||||||
* return all the comments belonging to the postid
|
* return all the comments belonging to the postid
|
||||||
|
@ -460,20 +271,19 @@ public interface DatabookStore {
|
||||||
* @param comment the comment to edit
|
* @param comment the comment to edit
|
||||||
* @return true if success, false otherwise
|
* @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
|
* deletes a comment
|
||||||
* @param commentid the comment identifier to delete
|
* @param commentid the comment identifier to delete
|
||||||
* @param feedid the feedid to which the comment is associated
|
* @param feedid the feedid to which the comment is associated
|
||||||
* @return true if success, false otherwise
|
* @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
|
* add a like to a feed
|
||||||
* @param like instance
|
* @param like instance
|
||||||
* @throws FeedIDNotFoundException
|
|
||||||
*/
|
*/
|
||||||
boolean like(Like like) throws FeedIDNotFoundException;
|
boolean like(Like like);
|
||||||
/**
|
/**
|
||||||
* unlike a feed
|
* unlike a feed
|
||||||
* @param userid user identifier
|
* @param userid user identifier
|
||||||
|
@ -481,62 +291,29 @@ public interface DatabookStore {
|
||||||
* @param feedid the feedid to which the comment is associated
|
* @param feedid the feedid to which the comment is associated
|
||||||
* @return true if success, false otherwise
|
* @return true if success, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
|
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException;
|
||||||
/**
|
|
||||||
* @deprecated use getAllLikedPostIdsByUser
|
|
||||||
* @param userid user identifier
|
|
||||||
* return all the feedids a user has liked
|
|
||||||
*/
|
|
||||||
List<String> getAllLikedFeedIdsByUser(String userid);
|
|
||||||
/**
|
/**
|
||||||
* @param userid user identifier
|
* @param userid user identifier
|
||||||
* return all the feedids a user has liked
|
* return all the feedids a user has liked
|
||||||
*/
|
*/
|
||||||
List<String> getAllLikedPostIdsByUser(String userid);
|
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 userid user identifier
|
||||||
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
|
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
|
||||||
* @throws ColumnNameNotFoundException .
|
* @throws ColumnNameNotFoundException .
|
||||||
* @throws FeedIDNotFoundException .
|
|
||||||
* @throws FeedTypeNotFoundException .
|
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws FeedIDNotFoundException .
|
|
||||||
* return all the feeds a user has liked
|
* 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 userid user identifier
|
||||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
* @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
|
* @return the likes made to feeds in the range from: today to: timeInMillis
|
||||||
*/
|
*/
|
||||||
List<Post> getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
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
|
* @param postid postid identifier
|
||||||
* return all the likes belonging to the postid
|
* return all the likes belonging to the postid
|
||||||
|
@ -548,9 +325,8 @@ public interface DatabookStore {
|
||||||
* @param postid the postid to which the hashtag is associated
|
* @param postid the postid to which the hashtag is associated
|
||||||
* @param vreid VRE identifier
|
* @param vreid VRE identifier
|
||||||
* @return true if success, false otherwise
|
* @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 '#'
|
* @param hashtags the hashtag including the '#'
|
||||||
|
@ -566,9 +342,8 @@ public interface DatabookStore {
|
||||||
* @param postid the postid to which the hashtag is associated
|
* @param postid the postid to which the hashtag is associated
|
||||||
* @param vreid VRE identifier
|
* @param vreid VRE identifier
|
||||||
* @return true if success, false otherwise
|
* @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 '#'
|
* @param hashtags the hashtag including the '#'
|
||||||
|
@ -591,30 +366,15 @@ public interface DatabookStore {
|
||||||
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
||||||
*/
|
*/
|
||||||
Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp);
|
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 vreid VRE identifier
|
||||||
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
||||||
* @throws ColumnNameNotFoundException .
|
* @throws ColumnNameNotFoundException .
|
||||||
* @throws FeedIDNotFoundException .
|
* @throws PrivacyLevelTypeNotFoundException
|
||||||
* @throws FeedTypeNotFoundException .
|
* @return all the feeds having the hashtag passed as parameter
|
||||||
* @throws PrivacyLevelTypeNotFoundException
|
|
||||||
* @throws FeedIDNotFoundException .
|
|
||||||
* @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
|
* Save the invite for a given email into a given vre
|
||||||
|
@ -654,14 +414,13 @@ public interface DatabookStore {
|
||||||
* @param feedId
|
* @param feedId
|
||||||
* @return the list of attachments of the feed feedId, starting from the second one (first attachment is included in Feed instance already)
|
* @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;
|
List<Attachment> getAttachmentsByFeedId(String feedId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all the ids of the vre
|
* Retrieve all the ids of the vre
|
||||||
* @return the set of ids of the vre available or empty list in case of errors.
|
* @return the set of ids of the vre available or empty list in case of errors.
|
||||||
* @throws ConnectionException
|
|
||||||
*/
|
*/
|
||||||
public List<String> getAllVREIds() throws ConnectionException;
|
public List<String> getAllVREIds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* close the connection to the underlying database
|
* close the connection to the underlying database
|
||||||
|
|
|
@ -7,9 +7,14 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
|
import com.datastax.oss.driver.api.core.metadata.Metadata;
|
||||||
|
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
|
||||||
import org.gcube.common.portal.GCubePortalConstants;
|
import org.gcube.common.portal.GCubePortalConstants;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
|
@ -22,8 +27,9 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* @author Massimiliano Assante ISTI-CNR
|
* @author Massimiliano Assante ISTI-CNR
|
||||||
|
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
|
||||||
*
|
*
|
||||||
* @version 0.1 Dec 2012
|
* @version 2.0.0 October 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@ -38,7 +44,7 @@ public class RunningCluster implements Serializable {
|
||||||
*/
|
*/
|
||||||
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 HOST_PORT_PROPERTY = "port";
|
||||||
private static final String CLUSTER_NAME_PROPERTY = "cluster";
|
private static final String DATACENTER_NAME_PROPERTY = "datacenter";
|
||||||
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
|
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
|
||||||
/**
|
/**
|
||||||
* other constants
|
* other constants
|
||||||
|
@ -56,11 +62,11 @@ public class RunningCluster implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Cluster Name
|
* Cluster Name
|
||||||
*/
|
*/
|
||||||
private String clusterName;
|
private String datacenterName;
|
||||||
/**
|
/**
|
||||||
* Keyspace Name
|
* Keyspace Name
|
||||||
*/
|
*/
|
||||||
private String keyspaceName;
|
private String keyspaceName; //to be modified
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param infrastructureName could be null
|
* @param infrastructureName could be null
|
||||||
|
@ -76,8 +82,8 @@ public class RunningCluster implements Serializable {
|
||||||
* private constructor
|
* private constructor
|
||||||
*/
|
*/
|
||||||
private RunningCluster(String infrastructureName) {
|
private RunningCluster(String infrastructureName) {
|
||||||
try {
|
//Query the IS (for the future)
|
||||||
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
/*List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
||||||
if (resources.size() > 1) {
|
if (resources.size() > 1) {
|
||||||
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
|
_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 "
|
throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name "
|
||||||
|
@ -97,8 +103,13 @@ public class RunningCluster implements Serializable {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
|
||||||
|
datacenterName = "1";
|
||||||
|
keyspaceName = "dev_mig_new_schema_test";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the
|
* @return the
|
||||||
|
@ -125,6 +136,7 @@ public class RunningCluster implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readInfrastructureName() {
|
private String readInfrastructureName() {
|
||||||
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder(getCatalinaHome());
|
StringBuilder sb = new StringBuilder(getCatalinaHome());
|
||||||
|
@ -153,7 +165,7 @@ public class RunningCluster implements Serializable {
|
||||||
try {
|
try {
|
||||||
props.load(CassandraClusterConnection.class.getResourceAsStream(DEFAULT_CONFIGURATION));
|
props.load(CassandraClusterConnection.class.getResourceAsStream(DEFAULT_CONFIGURATION));
|
||||||
host = props.getProperty(HOST_PROPERTY) + ":" + props.getProperty(HOST_PORT_PROPERTY);
|
host = props.getProperty(HOST_PROPERTY) + ":" + props.getProperty(HOST_PORT_PROPERTY);
|
||||||
clusterName = props.getProperty(CLUSTER_NAME_PROPERTY);
|
datacenterName = props.getProperty(DATACENTER_NAME_PROPERTY);
|
||||||
keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY);
|
keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -169,25 +181,19 @@ public class RunningCluster implements Serializable {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClusterName() {
|
|
||||||
return clusterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterName(String clusterName) {
|
|
||||||
this.clusterName = clusterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyspaceName() {
|
public String getKeyspaceName() {
|
||||||
return keyspaceName;
|
return keyspaceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setKeyspaceName(String keyspaceName) {
|
public void setKeyspaceName(String keyspaceName) {
|
||||||
this.keyspaceName = keyspaceName;
|
this.keyspaceName = keyspaceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RunningCluster [host=" + host + ", clusterName=" + clusterName
|
return "RunningCluster [host=" + host + ", datacenterName=" + datacenterName
|
||||||
+ ", keyspaceName=" + keyspaceName + "]";
|
+ ", keyspaceName=" + keyspaceName + "]";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -197,4 +203,21 @@ public class RunningCluster implements Serializable {
|
||||||
private static String getCatalinaHome() {
|
private static String getCatalinaHome() {
|
||||||
return (System.getenv("CATALINA_HOME").endsWith("/") ? System.getenv("CATALINA_HOME") : System.getenv("CATALINA_HOME")+"/");
|
return (System.getenv("CATALINA_HOME").endsWith("/") ? System.getenv("CATALINA_HOME") : System.getenv("CATALINA_HOME")+"/");
|
||||||
}
|
}
|
||||||
|
public void setDatacenterName(String datacenterName){
|
||||||
|
this.datacenterName = datacenterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatacenterName() {
|
||||||
|
return datacenterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InetSocketAddress> getHosts() {
|
||||||
|
List<InetSocketAddress> hosts = new ArrayList<>();
|
||||||
|
String [] ips = host.split(", ");
|
||||||
|
for (String ip: ips){
|
||||||
|
String[] ip_port = ip.split(":");
|
||||||
|
hosts.add(new InetSocketAddress(ip_port[0], Integer.parseInt(ip_port[1])));
|
||||||
|
}
|
||||||
|
return hosts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
|
public class Schema {
|
||||||
|
//Tables
|
||||||
|
public static final String NOTIFICATIONS = "Notifications";
|
||||||
|
public static final String POSTS = "Posts";
|
||||||
|
public static final String COMMENTS = "Comments";
|
||||||
|
public static final String LIKES = "Likes";
|
||||||
|
public static final String INVITES = "Invites";
|
||||||
|
public static final String VRE_TIMELINE_POSTS = "VRETimeline";
|
||||||
|
public static final String USER_TIMELINE_POSTS = "UserTimeline";
|
||||||
|
public static final String APP_TIMELINE_POSTS = "AppTimeline";
|
||||||
|
public static final String USER_LIKED_POSTS = "UserLikes";
|
||||||
|
public static final String USER_NOTIFICATIONS = "UserNotifications"; // regular user notifications timeline (both read and unread, messages are included)
|
||||||
|
public static final String USER_NOTIFICATIONS_UNREAD = "UserUnreadNotifications"; // only unread user notifications/ notifications messages
|
||||||
|
public static final String USER_NOTIFICATIONS_PREFERENCES = "UserNotificationsPreferences"; // preferences for notifications
|
||||||
|
public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type
|
||||||
|
public static final String HASHTAGGED_POSTS = "HashtaggedPosts"; // contains hashtags per type associated with vre and POST
|
||||||
|
public static final String HASHTAGGED_COMMENTS = "HashtaggedComments"; // contains hashtags per type associated with vre and comment
|
||||||
|
public static final String VRE_INVITES = "VREInvites"; //contains the emails that were invited per VRE
|
||||||
|
public static final String EMAIL_INVITES = "EmailInvites"; //contains the list of invitation per email
|
||||||
|
public static final String ATTACHMENTS = "Attachments"; //contains the list of all the attachments in a POST
|
||||||
|
|
||||||
|
//columns
|
||||||
|
public static final String USER_ID = "userid"; //text
|
||||||
|
public static final String TYPE = "type"; //text
|
||||||
|
public static final String PREFERENCE = "preference"; //text
|
||||||
|
public static final String TIMESTAMP = "timestamp"; //timestamp
|
||||||
|
public static final String NOT_ID = "notid"; //UUID
|
||||||
|
public static final String VRE_ID = "vreid"; //text
|
||||||
|
public static final String POST_ID = "postid"; //UUID
|
||||||
|
public static final String APP_ID = "appid"; //text
|
||||||
|
public static final String HASHTAG = "hashtag"; //text
|
||||||
|
public static final String COMMENT_ID = "commentid"; //UUID
|
||||||
|
public static final String COUNT = "count"; //big int
|
||||||
|
public static final String LIKE_ID = "likeid"; //UUID
|
||||||
|
public static final String INVITE_ID = "inviteid"; //UUID
|
||||||
|
public static final String STATUS = "status"; //text
|
||||||
|
public static final String EMAIL = "email"; //text
|
||||||
|
public static final String ATTACH_ID = "attachid"; //UUID
|
||||||
|
public static final String URI = "uri"; //text
|
||||||
|
public static final String NAME = "name"; //text
|
||||||
|
public static final String DESCRIPTION = "description"; //text
|
||||||
|
public static final String URI_THUMBNAIL = "urithumbnail"; //text
|
||||||
|
public static final String MIME_TYPE = "mimetype"; //text
|
||||||
|
public static final String SENDER_USER_ID = "senderuserid"; //text
|
||||||
|
public static final String CONTROL_CODE = "controlcode"; //text
|
||||||
|
public static final String SENDER_FULL_NAME = "senderfullname"; //text
|
||||||
|
public static final String FULL_NAME = "fullname"; //text
|
||||||
|
public static final String THUMBNAIL_URL = "thumbnailurl"; //text
|
||||||
|
public static final String COMMENT = "comment"; //text
|
||||||
|
public static final String IS_EDIT = "isedit"; //bool
|
||||||
|
public static final String LAST_EDIT_TIME = "lastedittime"; //timestamp
|
||||||
|
public static final String SUBJECT_ID = "subjectid"; //text
|
||||||
|
public static final String SENDER_ID = "senderid"; //text
|
||||||
|
public static final String SENDER_THUMBNAIL_URL = "senderthumbnailurl"; //text
|
||||||
|
public static final String IS_READ = "isread"; //bool
|
||||||
|
public static final String LINK_HOST = "linkhost"; //text
|
||||||
|
public static final String LIKES_NO = "likesno"; //big int
|
||||||
|
public static final String LINK_DESCRIPTION = "linkdescription"; //text
|
||||||
|
public static final String IS_APPLICATION_POST = "isapplicationpost"; //bool -->
|
||||||
|
public static final String ENTITY_ID = "entityid"; //text
|
||||||
|
public static final String PRIVACY = "privacy"; //text
|
||||||
|
public static final String MULTI_FILE_UPLOAD = "multifileupload"; //bool
|
||||||
|
public static final String COMMENTS_NO = "commentsno"; //big int
|
||||||
|
public static final String LINK_TITLE = "linktitle"; //text
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
|
import org.gcube.portal.databook.shared.*;
|
||||||
|
import org.gcube.portal.databook.shared.ex.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Tester {
|
||||||
|
private static DBCassandraDatastaxImpl store;
|
||||||
|
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
|
||||||
|
|
||||||
|
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 {
|
||||||
|
Tester test = new Tester();
|
||||||
|
//test.getComment();
|
||||||
|
test.testFunc();
|
||||||
|
System.exit(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||||
|
String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26";
|
||||||
|
Post read = store.readPost(postIdToUpdate);
|
||||||
|
|
||||||
|
List<Comment> readC = store.getAllCommentByPost("047c601d-2291-4974-9224-d6732b1fbe26");
|
||||||
|
System.out.println(read);
|
||||||
|
readC.forEach(c -> System.out.println(c.getText()));
|
||||||
|
}
|
||||||
|
public void getComment(){
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
package org.gcube.portal.databook.shared;
|
package org.gcube.portal.databook.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.cql.Row;
|
||||||
import org.jsonmaker.gwt.client.Jsonizer;
|
import org.jsonmaker.gwt.client.Jsonizer;
|
||||||
|
|
||||||
|
import static org.gcube.portal.databook.server.Schema.*;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Attachment implements Serializable {
|
public class Attachment implements Serializable {
|
||||||
|
|
||||||
|
@ -37,8 +41,18 @@ public class Attachment implements Serializable {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.thumbnailURL = thumbnailURL;
|
this.thumbnailURL = thumbnailURL;
|
||||||
this.mimeType = mimeType;
|
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() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package org.gcube.portal.databook.shared;
|
package org.gcube.portal.databook.shared;
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.cql.Row;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
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 key;
|
||||||
private String userid;
|
private String userid;
|
||||||
private Date time;
|
private Date time;
|
||||||
private String feedid;
|
private String postid;
|
||||||
private String text;
|
private String text;
|
||||||
private String fullName;
|
private String fullName;
|
||||||
private String thumbnailURL;
|
private String thumbnailURL;
|
||||||
|
@ -33,18 +39,18 @@ public class Comment implements Serializable, Comparable<Comment> {
|
||||||
* @param key
|
* @param key
|
||||||
* @param userid
|
* @param userid
|
||||||
* @param time
|
* @param time
|
||||||
* @param feedid
|
* @param postid
|
||||||
* @param text
|
* @param text
|
||||||
* @param fullName
|
* @param fullName
|
||||||
* @param thumbnailURL
|
* @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) {
|
String text, String fullName, String thumbnailURL) {
|
||||||
super();
|
super();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.userid = userid;
|
this.userid = userid;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.feedid = feedid;
|
this.postid = postid;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
this.thumbnailURL = thumbnailURL;
|
this.thumbnailURL = thumbnailURL;
|
||||||
|
@ -58,27 +64,39 @@ public class Comment implements Serializable, Comparable<Comment> {
|
||||||
* @param key
|
* @param key
|
||||||
* @param userid
|
* @param userid
|
||||||
* @param time
|
* @param time
|
||||||
* @param feedid
|
* @param postid
|
||||||
* @param text
|
* @param text
|
||||||
* @param fullName
|
* @param fullName
|
||||||
* @param thumbnailURL
|
* @param thumbnailURL
|
||||||
* @param isEdit
|
* @param isEdit
|
||||||
* @param editDate
|
* @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) {
|
String text, String fullName, String thumbnailURL, boolean isEdit, Date editDate) {
|
||||||
super();
|
super();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.userid = userid;
|
this.userid = userid;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.feedid = feedid;
|
this.postid = postid;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
this.thumbnailURL = thumbnailURL;
|
this.thumbnailURL = thumbnailURL;
|
||||||
this.isEdit = isEdit;
|
this.isEdit = isEdit;
|
||||||
this.lastEditTime = editDate;
|
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
|
* @return the text
|
||||||
|
@ -121,12 +139,12 @@ public class Comment implements Serializable, Comparable<Comment> {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFeedid() {
|
public String getpostid() {
|
||||||
return feedid;
|
return postid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeedid(String feedid) {
|
public void setpostid(String postid) {
|
||||||
this.feedid = feedid;
|
this.postid = postid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
|
@ -168,7 +186,7 @@ public class Comment implements Serializable, Comparable<Comment> {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Comment [key=" + key + ", userid=" + userid + ", time=" + time
|
return "Comment [key=" + key + ", userid=" + userid + ", time=" + time
|
||||||
+ ", feedid=" + feedid + ", text=" + text + ", fullName="
|
+ ", postid=" + postid + ", text=" + text + ", fullName="
|
||||||
+ fullName + ", thumbnailURL=" + thumbnailURL + ", isEdit="
|
+ fullName + ", thumbnailURL=" + thumbnailURL + ", isEdit="
|
||||||
+ isEdit + ", lastEditTime=" + lastEditTime + "]";
|
+ isEdit + ", lastEditTime=" + lastEditTime + "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class EnhancedFeed implements Serializable{
|
public class EnhancedFeed implements Serializable{
|
||||||
private Feed feed;
|
private Post post;
|
||||||
private boolean liked;
|
private boolean liked;
|
||||||
private boolean isUsers;
|
private boolean isUsers;
|
||||||
private ArrayList<Comment> comments;
|
private ArrayList<Comment> comments;
|
||||||
|
@ -20,26 +20,26 @@ public class EnhancedFeed implements Serializable{
|
||||||
public EnhancedFeed() {
|
public EnhancedFeed() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers) {
|
public EnhancedFeed(Post post, boolean liked, boolean isUsers) {
|
||||||
super();
|
super();
|
||||||
this.feed = feed;
|
this.post = post;
|
||||||
this.liked = liked;
|
this.liked = liked;
|
||||||
this.isUsers = isUsers;
|
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();
|
super();
|
||||||
this.isUsers = isUsers;
|
this.isUsers = isUsers;
|
||||||
this.feed = feed;
|
this.post = post;
|
||||||
this.liked = liked;
|
this.liked = liked;
|
||||||
this.comments = comments;
|
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) {
|
ArrayList<Comment> comments, ArrayList<Attachment> attachments) {
|
||||||
super();
|
super();
|
||||||
this.feed = feed;
|
this.post = post;
|
||||||
this.liked = liked;
|
this.liked = liked;
|
||||||
this.isUsers = isUsers;
|
this.isUsers = isUsers;
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
|
@ -51,11 +51,11 @@ public class EnhancedFeed implements Serializable{
|
||||||
public void setComments(ArrayList<Comment> comments) {
|
public void setComments(ArrayList<Comment> comments) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
}
|
}
|
||||||
public Feed getFeed() {
|
public Post getPost() {
|
||||||
return feed;
|
return post;
|
||||||
}
|
}
|
||||||
public void setFeed(Feed feed) {
|
public void setPost(Post post) {
|
||||||
this.feed = feed;
|
this.post = post;
|
||||||
}
|
}
|
||||||
public boolean isLiked() {
|
public boolean isLiked() {
|
||||||
return liked;
|
return liked;
|
||||||
|
@ -77,7 +77,7 @@ public class EnhancedFeed implements Serializable{
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EnhancedFeed [feed=" + feed + ", liked=" + liked + ", isUsers="
|
return "EnhancedFeed [post=" + post + ", liked=" + liked + ", isUsers="
|
||||||
+ isUsers + ", comments=" + comments + ", attachments="
|
+ isUsers + ", comments=" + comments + ", attachments="
|
||||||
+ attachments + "]";
|
+ attachments + "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package org.gcube.portal.databook.shared;
|
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.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static org.gcube.portal.databook.server.Schema.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, ISTI-CNR
|
* @author Massimiliano Assante, ISTI-CNR
|
||||||
|
@ -18,8 +25,23 @@ public class Invite implements Serializable {
|
||||||
private InviteStatus status;
|
private InviteStatus status;
|
||||||
private Date time;
|
private Date time;
|
||||||
private String senderFullName;
|
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() {
|
public Invite() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +63,17 @@ public class Invite implements Serializable {
|
||||||
this.senderFullName = senderFullName;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
package org.gcube.portal.databook.shared;
|
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.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static org.gcube.portal.databook.server.Schema.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, ISTI-CNR
|
* @author Massimiliano Assante, ISTI-CNR
|
||||||
|
@ -14,7 +22,7 @@ public class Like implements Serializable {
|
||||||
private String key;
|
private String key;
|
||||||
private String userid;
|
private String userid;
|
||||||
private Date time;
|
private Date time;
|
||||||
private String feedid;
|
private String postid;
|
||||||
private String fullName;
|
private String fullName;
|
||||||
private String thumbnailURL;
|
private String thumbnailURL;
|
||||||
|
|
||||||
|
@ -22,17 +30,28 @@ public class Like implements Serializable {
|
||||||
super();
|
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) {
|
String fullName, String thumbnailURL) {
|
||||||
super();
|
super();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.userid = userid;
|
this.userid = userid;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.feedid = feedid;
|
this.postid = postid;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
this.thumbnailURL = thumbnailURL;
|
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() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -57,12 +76,12 @@ public class Like implements Serializable {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFeedid() {
|
public String getpostid() {
|
||||||
return feedid;
|
return postid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeedid(String feedid) {
|
public void setpostid(String postid) {
|
||||||
this.feedid = feedid;
|
this.postid = postid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
package org.gcube.portal.databook.shared;
|
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.io.Serializable;
|
||||||
import java.util.Date;
|
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 senderid;
|
||||||
private String senderFullName;
|
private String senderFullName;
|
||||||
private String senderThumbnail;
|
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
|
* default constructor
|
||||||
*/
|
*/
|
||||||
|
@ -32,8 +187,6 @@ public class Notification implements Serializable {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
|
@ -65,41 +218,21 @@ public class Notification implements Serializable {
|
||||||
this.senderFullName = senderFullName;
|
this.senderFullName = senderFullName;
|
||||||
this.senderThumbnail = senderThumbnail;
|
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 .
|
* @return .
|
||||||
|
@ -171,16 +304,6 @@ public class Notification implements Serializable {
|
||||||
this.subjectid = subjectid;
|
this.subjectid = subjectid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommentKey() {
|
|
||||||
return commentKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setCommentKey(String commentKey) {
|
|
||||||
this.commentKey = commentKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Notification [key=" + key + ", type=" + type + ", userid="
|
return "Notification [key=" + key + ", type=" + type + ", userid="
|
||||||
|
@ -188,6 +311,6 @@ public class Notification implements Serializable {
|
||||||
+ ", uri=" + uri + ", description=" + description + ", read="
|
+ ", uri=" + uri + ", description=" + description + ", read="
|
||||||
+ read + ", senderid=" + senderid + ", senderFullName="
|
+ read + ", senderid=" + senderid + ", senderFullName="
|
||||||
+ senderFullName + ", senderThumbnail=" + senderThumbnail
|
+ senderFullName + ", senderThumbnail=" + senderThumbnail
|
||||||
+ ", commentKey=" + commentKey + "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
package org.gcube.portal.databook.shared;
|
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.io.Serializable;
|
||||||
import java.util.Date;
|
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 linkTitle;
|
||||||
private String linkDescription;
|
private String linkDescription;
|
||||||
private String linkHost;
|
private String linkHost;
|
||||||
boolean applicationFeed;
|
boolean applicationPost;
|
||||||
/**
|
/**
|
||||||
* this boolean indicates that the attachments to the post are > 1
|
* this boolean indicates that the attachments to the post are > 1
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +48,7 @@ public class Post implements Serializable, Comparable<Post> {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* To use ONLY for USER Feeds
|
* To use ONLY for USER Posts
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param key a UUID
|
* @param key a UUID
|
||||||
|
@ -79,13 +87,13 @@ public class Post implements Serializable, Comparable<Post> {
|
||||||
this.linkDescription = linkDescription;
|
this.linkDescription = linkDescription;
|
||||||
this.linkTitle = linkTitle;
|
this.linkTitle = linkTitle;
|
||||||
this.linkHost = linkHost;
|
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 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 entityId the user or the app unique indentifier
|
||||||
* @param time when
|
* @param time when
|
||||||
* @param vreid a unique vre id
|
* @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 thumbnailURL this is the user thumbnail url
|
||||||
* @param linkTitle optional to be used when posting links
|
* @param linkTitle optional to be used when posting links
|
||||||
* @param linkDescription 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,
|
public Post(String key, PostType type, String entityId, Date time,
|
||||||
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
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(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,
|
public Post(String key, PostType type, String entityId, Date time,
|
||||||
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
||||||
String fullName, String email, String thumbnailURL, String commentsNo,
|
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();
|
super();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -147,10 +155,34 @@ public class Post implements Serializable, Comparable<Post> {
|
||||||
this.linkDescription = linkDescription;
|
this.linkDescription = linkDescription;
|
||||||
this.linkTitle = linkTitle;
|
this.linkTitle = linkTitle;
|
||||||
this.linkHost = linkHost;
|
this.linkHost = linkHost;
|
||||||
this.applicationFeed = applicationFeed;
|
this.applicationPost = applicationPost;
|
||||||
this.multiFileUpload = multiFileUpload;
|
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
|
* @return post id
|
||||||
*/
|
*/
|
||||||
|
@ -293,11 +325,11 @@ public class Post implements Serializable, Comparable<Post> {
|
||||||
this.linkHost = linkHost;
|
this.linkHost = linkHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicationFeed() {
|
public boolean isApplicationPost() {
|
||||||
return applicationFeed;
|
return applicationPost;
|
||||||
}
|
}
|
||||||
public void setApplicationFeed(boolean applicationFeed) {
|
public void setApplicationPost(boolean applicationPost) {
|
||||||
this.applicationFeed = applicationFeed;
|
this.applicationPost = applicationPost;
|
||||||
}
|
}
|
||||||
public boolean isMultiFileUpload() {
|
public boolean isMultiFileUpload() {
|
||||||
return multiFileUpload;
|
return multiFileUpload;
|
||||||
|
@ -315,8 +347,47 @@ public class Post implements Serializable, Comparable<Post> {
|
||||||
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
|
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
|
||||||
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
|
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
|
||||||
+ linkDescription + ", linkHost=" + linkHost
|
+ linkDescription + ", linkHost=" + linkHost
|
||||||
+ ", applicationFeed=" + applicationFeed
|
+ ", applicationPost=" + applicationPost
|
||||||
+ ", multiFileUpload=" + multiFileUpload + "]";
|
+ ", 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.gcube.portal.databook.shared.ex;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class FeedTypeNotFoundException extends Exception {
|
|
||||||
public FeedTypeNotFoundException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,8 @@ package org.gcube.portal.databook.shared.ex;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FeedIDNotFoundException extends Exception {
|
public class PostIDNotFoundException extends Exception {
|
||||||
public FeedIDNotFoundException(String message, String postId) {
|
public PostIDNotFoundException(String message, String postId) {
|
||||||
super("The Post having id: " + postId + " is not present in the database: " + message);
|
super("The Post having id: " + postId + " is not present in the database: " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.gcube.portal.databook.shared.ex;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class PostTypeNotFoundException extends Exception {
|
||||||
|
public PostTypeNotFoundException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue