This commit is contained in:
Massimiliano Assante 2013-01-10 13:19:53 +00:00
commit 8566ca2bd1
49 changed files with 57134 additions and 0 deletions

11
.classpath Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>

53076
.gwt/.gwt-log Normal file

File diff suppressed because it is too large Load Diff

47
.project Normal file
View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GCubeSocialAstyanax</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
#Tue Dec 04 18:19:08 CET 2012
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=

View File

@ -0,0 +1,4 @@
#Tue Dec 04 18:20:03 CET 2012
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,9 @@
#Tue Dec 04 18:04:58 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,5 @@
#Wed Sep 05 15:38:59 CEST 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

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

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.6"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>

3
META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

2
distro/INSTALL Normal file
View File

@ -0,0 +1,2 @@

7
distro/LICENSE Normal file
View File

@ -0,0 +1,7 @@
gCube System - License
------------------------------------------------------------
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
The software and documentation is provided by its authors/distributors "as is" and no expressed or
implied warranty is given for its use, quality or fitness for a particular case.

6
distro/MAINTAINERS Normal file
View File

@ -0,0 +1,6 @@
Mantainers
-------
* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".

35
distro/README Normal file
View File

@ -0,0 +1,35 @@
The gCube System - Social Library
------------------------------------------------------------
This work is partially funded by the European Commission in the
context of the iMarine project (www.i-marine.eu), under the 1st call of FP7 IST priority.
Authors
-------
Massimiliano Assante
*
Version and Release Date
------------------------
Jan 2013
Description
-----------
Social networking Library
Download information
--------------------
Source code is available from SVN:
https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/social-library
Binaries can be downloaded from:
http://software.d4science.research-infrastructures.eu/
Documentation
-------------
Documentation is available on-line from the Projects Documentation Wiki:
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

5
distro/changelog.xml Normal file
View File

@ -0,0 +1,5 @@
<ReleaseNotes>
<Changeset component="org.gcube.portal.social-networking-library.1-0-0" date="2013-01-11">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

48
distro/descriptor.xml Normal file
View File

@ -0,0 +1,48 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>target/apidocs</directory>
<outputDirectory>/${artifactId}/doc/api</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>./</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>

25
distro/profile.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>gCube Social Networking Library</Description>
<Class>Portal</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

1
distro/svnpath.txt Normal file
View File

@ -0,0 +1 @@
${scm.url}

211
pom.xml Normal file
View File

@ -0,0 +1,211 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>gCube Social Networking Library</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.4.0</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<!-- Don't let your Mac use a crazy non-standard encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<!-- TODO: Update version to 2.5.0 once gwt-maven-plugin 2.5.0 final
is released (post-GWT 2.5.0) -->
<version>2.4.0</version>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
</dependency>
</dependencies>
<!-- JS is only needed in the package phase, this speeds up testing -->
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.netflix.astyanax</groupId>
<artifactId>astyanax</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>
<version>[1.4.0,1.5.0]</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>ghn-client-runtime</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<!-- Google Web Toolkit (GWT) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<!-- "provided" so that we don't deploy -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='gcubesocialnetworking'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portal.databook.client.GCubeSocialNetworking' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>

View File

@ -0,0 +1,14 @@
package org.gcube.portal.databook.client;
import com.google.gwt.core.client.EntryPoint;
/**
* Entry point classes define <code>onModuleLoad()</code> and instances the <code>HandlerManager</code> for IPC
*/
public class GCubeSocialNetworking implements EntryPoint {
public static final String USER_PROFILE_LINK = "/group/data-e-infrastructure-gateway/profile";
public void onModuleLoad() {
}
}

View File

@ -0,0 +1,249 @@
package org.gcube.portal.databook.server;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
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.exceptions.ConnectionException;
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
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.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
*
* @version 1.0 July 17th 2012
*
*/
public class CassandraClusterConnection {
/**
* logger
*/
static GCUBEClientLog _log = new GCUBEClientLog(CassandraClusterConnection.class);
/**
* keyspace location
*/
private static String clusterName;
private static String host;
private static String keyspaceName;
private Keyspace myKeyspace;
/**
*
* @param dropSchema set true if you want do drop the current and set up new one
* @return the connection to cassandra cluster
*/
protected CassandraClusterConnection(boolean dropSchema) {
if (clusterName == null || host == null || keyspaceName == null) {
RunningCluster cluster = RunningCluster.getInstance();
clusterName = cluster.getClusterName();
host = cluster.getHost();
keyspaceName = cluster.getKeyspaceName();
}
AstyanaxContext<Cluster> clusterContext = new AstyanaxContext.Builder()
.forCluster(clusterName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl())
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl(
clusterName).setMaxConnsPerHost(1)
.setSeeds(host))
.withConnectionPoolMonitor(
new CountingConnectionPoolMonitor())
.buildCluster(ThriftFamilyFactory.getInstance());
_log.info(keyspaceName + " KeySpace SetUp ...");
SetUpKeySpaces(clusterContext, dropSchema);
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
}
/**
*
* @return
*/
public Keyspace getKeyspace() {
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.NONE)
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
.setPort(9160)
.setMaxConnsPerHost(1)
.setSeeds(host)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
myKeyspace = context.getEntity();
return myKeyspace;
}
/**
*
* @param cluster
* @param dropIfExists
* @throws ConnectionException
*/
public void SetUpKeySpaces(AstyanaxContext<Cluster> clusterContext, boolean dropSchema) {
boolean createNew = false;
clusterContext.start();
try {
Cluster cluster = clusterContext.getEntity();
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
if (dropSchema && keyspaceDef != null) {
_log.info("Dropping Keyspace: " + keyspaceName + " ...");
try {
String returned = cluster.dropKeyspace(keyspaceName);
Thread.sleep(2000);
_log.info("Dropped " + returned);
} catch (ConnectionException e) {
_log.error("Dropping Keyspace operation Failed ... " + keyspaceName + " does NOT exists");
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
createNew = true;
}
keyspaceDef = cluster.makeKeyspaceDefinition();
keyspaceDef = cluster.describeKeyspace(keyspaceName);
if (keyspaceDef == null || keyspaceDef.getName() == null || createNew) {
_log.info("Keyspace does not exist, triggering schema creation ... ");
createSchema(cluster);
_log.info("Cluster " + clusterName + " on " + host + " Initialized OK!");
_log.info("Using Keyspace " + keyspaceName);
}
} catch (ConnectionException e) {
e.printStackTrace();
}
}
/*
*
********************** CASSANDRA KEYSPACE CREATION ***********************
*
*/
/**
* create the databook schema
* @return
* @throws ConnectionException
*/
private void createSchema(Cluster cluster) throws ConnectionException {
Map<String, String> stratOptions = new HashMap<String, String>();
stratOptions.put("replication_factor", "1");
KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();
//get static column families with secondary indexes
/**
* define Notifications CF with Type as secondary index
*/
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");
//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 cfDefUserMessagesNotifications = getDynamicCFDef(DBCassandraAstyanaxImpl.USER_MESSAGES_NOTIFICATIONS);
ksDef.setName(keyspaceName)
.setStrategyOptions(stratOptions)
.setStrategyClass("SimpleStrategy")
.addColumnFamily(cfDefNotifications)
.addColumnFamily(cfDefFeeds)
.addColumnFamily(cfDefComments)
.addColumnFamily(cfDefLikes)
.addColumnFamily(cfDefConn)
.addColumnFamily(cfDefPendingConn)
.addColumnFamily(cfDefVRETimeline)
.addColumnFamily(cfDefAPPTimeline)
.addColumnFamily(cfDefUserTimeline)
.addColumnFamily(cfDefUserNotifications)
.addColumnFamily(cfDefUserMessagesNotifications)
.addColumnFamily(cfDefUserLikedFeeds);
cluster.addKeyspace(ksDef);
}
/**
* create a dynamic column family to be added in a keyspace
*
* @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;
}
/**
* create a static column family to be added in a keyspace with possibility to add a secondary index for a given column
*
* @param cfName the CF name
* @param secondaryIndexedField the column name of the column to index
* @return the instance to be added to the keyspace
*/
private ColumnFamilyDefinition getStaticCFDef(String cfName, String secondaryIndexedField) {
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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,311 @@
package org.gcube.portal.databook.server;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class DatabookCassandraTest {
private static DatabookStore store;
@BeforeClass
public static void setup() throws Exception {
store = new DBCassandraAstyanaxImpl(false); //set to true if you want to drop the KeySpace and recreate it
}
@AfterClass
public static void close(){
store.closeConnection();
System.out.println("End");
}
@Test
public void testFriendships() {
assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
System.out.println("Pending Connections for massimiliano.assante:");
for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
System.out.println(userid);
}
System.out.println("Connections for massimiliano.assante:");
for (String userid: store.getFriends("massimiliano.assante")) {
System.out.println(userid);
}
}
@Test
public void testSingleNotification() {
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.LIKE,
"leonardo.candela",
"MESSAGEID",
new Date(),
"uri",
"This is notification about a like",
false,
"leonardo.candela", "Leonardo Candela",
"thumburl");
assertTrue(store.saveNotification(not));
not = new Notification(
UUID.randomUUID().toString(),
NotificationType.MESSAGE,
"massimiliano.assante",
"MESSAGEID",
new Date(),
"uri",
"This is notification about a like",
false,
"antonio.gioia", "Antonio Gioia",
"thumburl");
assertTrue(store.saveNotification(not));
System.out.println("Writing one Notification " + not);
}
@Test
public void testNotifications() {
Notification not = null;
System.out.println("Writing 18 Notifications");
int count = 18;
for (int i = 0; i < count; i++) {
if (i % 2 != 0) {
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
"leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
} else {
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
"massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
}
assertTrue(store.saveNotification(not));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Notification rNot= null;
try {
//read
rNot = store.readNotification(not.getKey().toString());
assertNotNull(rNot);
System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
//set Read
assertTrue(store.setNotificationRead(rNot.getKey().toString()));
System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
"leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
assertTrue(store.saveNotification(not));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
rNot = store.readNotification(not.getKey().toString());
System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
// //set Read
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
//
Random randomGenerator = new Random();
System.out.println("leonardo.candela Notifications: ");
List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
assertNotNull(recentNots);
for (Notification notif :recentNots)
System.out.println(notif);
System.out.println("massimiliano.assante Notifications: ");
recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
assertNotNull(recentNots);
for (Notification notif :recentNots)
System.out.println(notif);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testFeeds() {
int count = 18;
Feed feed = null;
for (int i = 0; i < count; i++) {
if (i % 2 != 0) {
feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
} else {
feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
"www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
}
assertTrue(store.saveUserFeed(feed));
try {
Thread.sleep(150);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Feed rFeed = null;
try {
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
rFeed = store.readFeed(feed.getKey().toString());
assertNotNull(rFeed);
String feedIdToDelete = UUID.randomUUID().toString();
feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
try {
Thread.sleep(250);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Test Delete Feed ");
assertTrue(store.deleteFeed(feedIdToDelete));
System.out.println("massimiliano.assante ALL FEEDS: ");
for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
System.out.println(recFeed);
Random randomGenerator = new Random();
System.out.println("leonardo.candela TIMELINE: ");
List<Feed> recentFeeds = store.getRecentFeedsByUser("leonardo.candela", randomGenerator.nextInt(50));
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
System.out.println("/gcube/devsec/devVRE TIMELINE: ");
recentFeeds = store.getRecentFeedsByVRE("/gcube/devsec/devVRE", randomGenerator.nextInt(50));
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
System.out.println("PORTAL TIMELINE: ");
recentFeeds = store.getAllPortalPrivacyLevelFeeds();
assertNotNull(recentFeeds);
for (Feed recFeed :recentFeeds)
System.out.println(recFeed);
} catch (Exception e) {
e.printStackTrace();
}
}
// @Test
// public void testNotifications() {
// int count = 10;
// Notification notf = null;
// for (int i = 0; i < count; i++) {
// notf = new Notification(UUID.randomUUID().toString(), NotificationType.MESSAGE, "massimiliano.assante", new Date(), "http://urir.com", "Desc #"+i, "Gino Camillo", false);
// assertTrue(store.saveNotification(notf));
// }
// try {
// assertNotNull(store.getAllNotificationByUser("massimiliano.assante"));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
@Test
public void testComments() {
int count = 10;
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
"massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
Comment toDelete = null;
for (int i = 0; i < count; i++) {
try {
toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
assertTrue(store.addComment(toDelete));
} catch (FeedIDNotFoundException e) {
System.out.println("Exception feed id not found");
}
}
System.out.println("GetAllCOmmentsByFeed ");
for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
System.out.println(cm.getText());
};
try {
assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
} catch (Exception e) {
System.out.println("Exception feed id not found");
}
}
@Test
public void testLikes() {
int count = 10;
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
"Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
try {
assertTrue(store.like(toUnlike));
for (int i = 0; i < count; i++)
assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
System.out.println("massimiliano.assante liked the following feeds: ");
for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
System.out.println(feedid);
}
for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
System.out.println(like);
}
System.out.println("trying unlike");
assertTrue(store.unlike(toUnlike.getKey(), toUnlike.getFeedid()));
} catch (Exception e) {
System.out.println("Exception feed id not found");
}
}
}

View File

@ -0,0 +1,249 @@
package org.gcube.portal.databook.server;
import java.util.List;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 0.5 Oct 5th 2012
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
*/
public interface DatabookStore {
/**
* userid from requests a friendship to userid to
* @return true if everything went fine
*/
boolean requestFriendship(String from, String to);
/**
* userid from approves a friendship to userid to
* @return true if everything went fine
*/
boolean approveFriendship(String from, String to);
/**
* userid from denies a friendship to userid to
* @return true if everything went fine
*/
boolean denyFriendship(String from, String to);
/**
* @param userid the user id you want to know friends
* @return a List of userid representing the friends for the given userid
*/
List<String> getFriends(String userid);
/**
* @param userid the user id you want to know the pending friend requests
* @return a List of userid representing the friends for the given userid
*/
List<String> getPendingFriendRequests(String userid);
/**
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveUserFeed(Feed feed);
/**
* delete a Feed from the store
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deleteFeed(String feedid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
* save a Feed in the VRES TimeLine in the store
* @param feedKey feedKey
* @param vreid vre identifier
* @return
* @throws FeedIDNotFoundException
*/
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
/**
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed);
/**
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
Feed readFeed(String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
/**
* return the most recent feeds for this user up to quantity param
* @param userid user identifier
* @param quantity the number of most recent feeds for this user
* @return a <class>List</class> of most recent feeds for this user
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @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;
/**
* return the most recent feeds for this vre up to quantity param
* @param vreid VRES identifier
* @param quantity the number of most recent feeds for this vre
* @return a <class>List</class> of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* save a Notification instance in the store
* @return true if everything went fine
*/
boolean saveNotification(Notification notification);
/**
* set an existing Notification instance in the to read
* @return true if everything went fine
*/
boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/**
* read a notification from a given id
* @throws {@link ColumnNameNotFoundException}
* @throws {@link NotificationIDNotFoundException}
* @throws {@link NotificationTypeNotFoundException}
*/
Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* @param limit set 0 to get everything, an int to get the most -limit- notifications
* return all the notifications belonging to the userid up to limit, set 0 to get everything
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/**
* return the not yet read notifications (not including messages)
* @param userid user identifier
* @return a <class>List</class> of not yet read notifications for this user
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/**
* return the not yet read notification messages
* @param userid user identifier
* @return a <class>List</class> of not yet read notifications for this user
* @throws NotificationTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Notification> getUnreadNotificationMessagesByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/**
*
* @param userid user identifier
* @throws ColumnNameNotFoundException
* @throws NotificationTypeNotFoundException
* @throws NotificationIDNotFoundException
* @return true if there are unread notifications (not including messages), false if they are all read
*/
boolean checkUnreadNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/**
*
* @param userid user identifier
* @throws ColumnNameNotFoundException
* @throws NotificationTypeNotFoundException
* @throws NotificationIDNotFoundException
* @return true if there are unread messages notifications (including messages), false if they are all read
*/
boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/**
* add a comment to a feed
* @param comment the Comment instance to add
*/
boolean addComment(Comment comment) throws FeedIDNotFoundException;
/**
* @param feedid feed identifier
* return all the comments belonging to the feedid
*/
List<Comment> getAllCommentByFeed(String feedid);
/**
* edit a comment
* @param commentid the comment identifier to edit
* @return true if success, false otherwise
*/
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/**
* delete a comment
* @param commentid the comment identifier to delete
* @parma feedid the feedid to shich the comment is associated
* @return true if success, false otherwise
*/
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/**
* add a like to a feed
* @param the like instance
* @throws FeedIDNotFoundException
*/
boolean like(Like like) throws FeedIDNotFoundException;
/**
* unlike a feed
* @param likeid the like identifier to delete
* @parma feedid the feedid to shich the comment is associated
* @return true if success, false otherwise
*/
boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
/**
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedFeedIdsByUser(String userid);
/**
* @param feedid feed identifier
* return all the likes belonging to the feedid
*/
List<Like> getAllLikesByFeed(String feedid);
/**
* close the connection to the underlying database
*/
void closeConnection();
}

View File

@ -0,0 +1,157 @@
package org.gcube.portal.databook.server;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.MalformedParameterizedTypeException;
import java.util.List;
import java.util.Properties;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.ISException;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.ISClient.ISMalformedQueryException;
import org.gcube.common.core.informationsystem.client.ISClient.ISUnsupportedQueryException;
import org.gcube.common.core.informationsystem.client.queries.GCUBERuntimeResourceQuery;
import org.gcube.common.core.resources.GCUBERuntimeResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.databook.shared.ex.TooManyRunningClustersException;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 0.1 Dec 2012
*
*/
@SuppressWarnings("serial")
public class RunningCluster implements Serializable {
/**
* logger
*/
static GCUBEClientLog _log = new GCUBEClientLog(RunningCluster.class);
/**
* properties to read
*/
private static final String HOST_PROPERTY = "host";
private static final String HOST_PORT_PROPERTY = "port";
private static final String CLUSTER_NAME_PROPERTY = "cluster";
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
/**
* other constants
*/
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
private final static String PLATFORM_NAME = "Cassandra";
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
private static RunningCluster singleton;
/**
* Host
*/
private String host;
/**
* Cluster Name
*/
private String clusterName;
/**
* Keyspace Name
*/
private String keyspaceName;
/**
*
* @return an instance of the RunningCluster
*/
public static synchronized RunningCluster getInstance() {
if (singleton == null) {
singleton = new RunningCluster();
}
return singleton;
}
/**
* private constructor
*/
private RunningCluster() {
try {
List<GCUBERuntimeResource> resources = getConfigurationFromIS();
if (resources.size() > 1) {
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name "
+ RUNTIME_RESOURCE_NAME + " and Platform " + PLATFORM_NAME + ". Only one allowed per infrasrtucture.");
}
else if (resources.size() == 0){
_log.error("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Platform " + PLATFORM_NAME + " in this scope. Using default configuration properties: " + DEFAULT_CONFIGURATION);
loadDefaultConfiguration();
}
else {
for (GCUBERuntimeResource res : resources) {
host = res.getAccessPoints().get(0).getEndpoint();
clusterName = res.getAccessPoints().get(0).getDescription();
keyspaceName = res.getAccessPoints().get(0).getEntryname();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* @return the
* @throws Exception
*/
private List<GCUBERuntimeResource> getConfigurationFromIS() throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class);
GHNContext ctx = GHNContext.getContext();
String scope = "/" + (String) ctx.getProperty(GHNContext.INFRASTRUCTURE_NAME, true);
GCUBERuntimeResourceQuery query = client.getQuery(GCUBERuntimeResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name", RUNTIME_RESOURCE_NAME));
query.addAtomicConditions(new AtomicCondition("/Profile/Platform/Name", PLATFORM_NAME));
List<GCUBERuntimeResource> toReturn;
return client.execute(query, GCUBEScope.getScope(scope));
}
/**
*
*/
private void loadDefaultConfiguration() {
Properties props = new Properties();
try {
props.load(CassandraClusterConnection.class.getResourceAsStream(DEFAULT_CONFIGURATION));
host = props.getProperty(HOST_PROPERTY) + ":" + props.getProperty(HOST_PORT_PROPERTY);
clusterName = props.getProperty(CLUSTER_NAME_PROPERTY);
keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY);
} catch (IOException e) {
e.printStackTrace();
}
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getClusterName() {
return clusterName;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
public String getKeyspaceName() {
return keyspaceName;
}
public void setKeyspaceName(String keyspaceName) {
this.keyspaceName = keyspaceName;
}
@Override
public String toString() {
return "RunningCluster [host=" + host + ", clusterName=" + clusterName
+ ", keyspaceName=" + keyspaceName + "]";
}
}

View File

@ -0,0 +1,4 @@
host = node1.p.cassandra.research-infrastructures.eu
port = 9160
cluster = D4Science Cluster
keyspace = TestKS

View File

@ -0,0 +1,77 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
*
*/
@SuppressWarnings("serial")
public class ApplicationProfile implements Serializable {
private String key;
private String name;
private String description;
private String imageUrl;
private String scope;
private String url;
public ApplicationProfile() {
super();
}
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
super();
this.key = key;
this.name = name;
this.description = description;
this.imageUrl = imageUrl;
this.scope = scope;
this.url = url;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
+ ", url=" + url + "]";
}
}

View File

@ -0,0 +1,161 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import org.jsonmaker.gwt.client.Jsonizer;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 July 2012
*
*/
@SuppressWarnings("serial")
public class ClientFeed implements Serializable{
public interface ClientFeedJsonizer extends Jsonizer{}
private String key;
private String type;
private String userid;
private String uri;
private String description;
private String fullName;
private String email;
private String thumbnailURL;
private String linkTitle;
private String linkDescription;
private String linkUrlThumbnail;
private String linkHost;
public ClientFeed() {
super();
}
public ClientFeed(String key, String type, String userid, String uri,
String description, String fullName, String email,
String thumbnailURL, String linkTitle, String linkDescription,
String linkUrlThumbnail, String linkHost) {
super();
this.key = key;
this.type = type;
this.userid = userid;
this.uri = uri;
this.description = description;
this.fullName = fullName;
this.email = email;
this.thumbnailURL = thumbnailURL;
this.linkTitle = linkTitle;
this.linkDescription = linkDescription;
this.linkUrlThumbnail = linkUrlThumbnail;
this.linkHost = linkHost;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
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 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 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 String getLinkUrlThumbnail() {
return linkUrlThumbnail;
}
public void setLinkUrlThumbnail(String linkUrlThumbnail) {
this.linkUrlThumbnail = linkUrlThumbnail;
}
public String getLinkHost() {
return linkHost;
}
public void setLinkHost(String linkHost) {
this.linkHost = linkHost;
}
@Override
public String toString() {
return "ClientFeed [key=" + key + ", type=" + type + ", userid="
+ userid + ", uri=" + uri + ", description=" + description
+ ", fullName=" + fullName + ", email=" + email
+ ", thumbnailURL=" + thumbnailURL + ", linkTitle=" + linkTitle
+ ", linkDescription=" + linkDescription
+ ", linkUrlThumbnail=" + linkUrlThumbnail + ", linkHost="
+ linkHost + "]";
}
}

View File

@ -0,0 +1,122 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 July 2012
*
*/
@SuppressWarnings("serial")
public class Comment implements Serializable, Comparable<Comment> {
private String key;
private String userid;
private Date time;
private String feedid;
private String text;
private String fullName;
private String thumbnailURL;
/**
*
*/
public Comment() {
super();
}
/**
*
* @param key
* @param userid
* @param timestamp
* @param feedid
* @param text
* @param fullName
* @param thumbnailURL
*/
public Comment(String key, String userid, Date time, String feedid,
String text, String fullName, String thumbnailURL) {
super();
this.key = key;
this.userid = userid;
this.time = time;
this.feedid = feedid;
this.text = text;
this.fullName = fullName;
this.thumbnailURL = thumbnailURL;
}
/**
*
* @return the text
*/
public String getText() {
return text;
}
/**
*
* @param text text to add as string
*/
public void setText(String text) {
this.text = text;
}
/**
*
* @return the uuid
*/
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getFeedid() {
return feedid;
}
public void setFeedid(String feedid) {
this.feedid = feedid;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getThumbnailURL() {
return thumbnailURL;
}
public void setThumbnailURL(String thumbnailURL) {
this.thumbnailURL = thumbnailURL;
}
public int compareTo(Comment toCompare) {
if (this.time.after(toCompare.getTime()))
return 1;
if (this.time.before(toCompare.getTime()))
return -1;
return 0;
}
}

View File

@ -0,0 +1,308 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 July 2012
*
*/
@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;
/**
* 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 timestamp 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 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 timestamp 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 timestamp 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) {
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;
}
/**
*
* @return
*/
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;
}
@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 + "]";
}
}

View File

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

View File

@ -0,0 +1,5 @@
package org.gcube.portal.databook.shared;
public enum ImageType {
JPG, GIF, PNG, TIFF, PDF, BMP;
}

View File

@ -0,0 +1,53 @@
package org.gcube.portal.databook.shared;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
*
*/
public enum JobStatusType {
/**
* The job has been cancelled.
*/
STATUS_CANCELLED,
/**
* The job is in the process of being cancelled.
*/
STATUS_CANCELLING,
/**
* The job has been deleted.
*/
STATUS_DELETED,
/**
* The job is in the process of being deleted.
*/
STATUS_DELETING,//
/**
* The job is being executed by job processor.
*/
STATUS_EXECUTING,//
/**
* he job execution has failed.
*/
STATUS_FAILED,
/**
* The job is new.
*/
STATUS_NEW,//
/**
* The job is submitted for execution.
*/
STATUS_SUBMITTED,
/**
* The job has completed successfully
*/
STATUS_SUCCEEDED,
/**
* The job execution has timed out.
*/
STATUS_TIMED_OUT,
/**
* The job is waiting for available job processor.
*/
STATUS_WAITING
}

View File

@ -0,0 +1,88 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 July 2012
*
*/
@SuppressWarnings("serial")
public class Like implements Serializable {
private String key;
private String userid;
private Date time;
private String feedid;
private String fullName;
private String thumbnailURL;
public Like() {
super();
}
public Like(String key, String userid, Date time, String feedid,
String fullName, String thumbnailURL) {
super();
this.key = key;
this.userid = userid;
this.time = time;
this.feedid = feedid;
this.fullName = fullName;
this.thumbnailURL = thumbnailURL;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getFeedid() {
return feedid;
}
public void setFeedid(String feedid) {
this.feedid = feedid;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getThumbnailURL() {
return thumbnailURL;
}
public void setThumbnailURL(String thumbnailURL) {
this.thumbnailURL = thumbnailURL;
}
public String toString() {
return "KEY: " + key + " Time: "+ time + "\nuserid: "+userid + " Full name: " + fullName;
}
}

View File

@ -0,0 +1,153 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.2 Nov 2012
*
*/
@SuppressWarnings("serial")
public class Notification implements Serializable {
private String key;
private NotificationType type;
private String userid;
private String subjectid;
private Date time;
private String uri;
private String description;
private boolean read;
private String senderid;
private String senderFullName;
private String senderThumbnail;
/**
* default constructor
*/
public Notification() {
super();
}
/**
*
* @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
*/
public Notification(String key, NotificationType type, String userid,
String subjectid, Date time, String uri, String description,
boolean read, String senderid, String senderFullName,
String senderThumbnail) {
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;
}
/**
*
* @return .
*/
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public NotificationType getType() {
return type;
}
public void setType(NotificationType type) {
this.type = type;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
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 boolean isRead() {
return read;
}
public void setRead(boolean read) {
this.read = read;
}
public String getSenderid() {
return senderid;
}
public void setSenderid(String senderid) {
this.senderid = senderid;
}
public String getSenderFullName() {
return senderFullName;
}
public void setSenderFullName(String senderFullName) {
this.senderFullName = senderFullName;
}
public String getSenderThumbnail() {
return senderThumbnail;
}
public void setSenderThumbnail(String senderThumbnail) {
this.senderThumbnail = senderThumbnail;
}
public String getSubjectid() {
return subjectid;
}
public void setSubjectid(String subjectid) {
this.subjectid = subjectid;
}
@Override
public String toString() {
return "Notification [key=" + key + ", type=" + type + ", userid="
+ userid + ", subjectid=" + subjectid + ", time=" + time
+ ", uri=" + uri + ", description=" + description + ", read="
+ read + ", senderid=" + senderid + ", senderFullName="
+ senderFullName + ", senderThumbnail=" + senderThumbnail + "]";
}
}

View File

@ -0,0 +1,66 @@
package org.gcube.portal.databook.shared;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 1.0 July 6th 2012
*/
public enum NotificationType {
/**
* use to notify a user he got a workspace folder shared
*/
WP_FOLDER_SHARE,
/**
* use to notify a user that a new user was added in on of his workspace shared folder
*/
WP_FOLDER_ADDEDUSER,
/**
* use to notify a user that an existing user was removed from one of his workspace shared folder
*/
WP_FOLDER_REMOVEDUSER,
/**
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
*/
WP_ITEM_DELETE,
/**
* use to notify a user he got a workspace item updated from one of his workspace shared folder
*/
WP_ITEM_UPDATED,
/**
* use to notify a user he got a workspace item new in some of his workspace shared folder
*/
WP_ITEM_NEW,
/**
* use to notify a user he got one of his feed commented
*/
OWN_COMMENT,
/**
* use to notify a user that commented on a feed (Not his) that someone commented too
*/
COMMENT,
/**
* use to notify a user he got one of his feed liked
*/
LIKE,
/**
* use to notify a user he got a message
*/
MESSAGE,
/**
* use to notify a user he got a connections request
*/
REQUEST_CONNECTION,
/**
* use to notify a user he got a job completed ok
*/
JOB_COMPLETED_OK,
/**
* use to notify a user he got a job completed not ok
*/
JOB_COMPLETED_NOK,
/**
* generic notification
*/
GENERIC;
}

View File

@ -0,0 +1,9 @@
package org.gcube.portal.databook.shared;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 1.0 July 6th 2012
*/
public enum PrivacyLevel {
PRIVATE, CONNECTION, VRES, SINGLE_VRE, PORTAL, PUBLIC;
}

View File

@ -0,0 +1,53 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
*
*/
@SuppressWarnings("serial")
public class RunningJob implements Serializable {
private String jobId;
private String jobName;
private JobStatusType status;
public RunningJob() {
super();
}
public RunningJob(String jobId, String jobName, JobStatusType status) {
super();
this.jobId = jobId;
this.jobName = jobName;
this.status = status;
}
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
public JobStatusType getStatus() {
return status;
}
public void setStatus(JobStatusType status) {
this.status = status;
}
@Override
public String toString() {
return "RunningJob [jobId=" + jobId + ", jobName=" + jobName
+ ", status=" + status + "]";
}
}

View File

@ -0,0 +1,115 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.HashMap;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 1.0 July 12th 2012
*/
@SuppressWarnings("serial")
public class UserInfo implements Serializable {
public transient final static String USER_INFO_ATTR = "USER_INFO_ATTR";
private String username;
private String fullName;
private String avatarId;
private String emailaddress;
private String accountURL;
private boolean male;
private boolean admin;
private HashMap<String, String> ownVREs;
public UserInfo() {
super();
}
public UserInfo(String username, String fullName, String avatarId,
String emailaddress, String accountURL, boolean male,
boolean admin, HashMap<String, String> ownVREs) {
super();
this.username = username;
this.fullName = fullName;
this.avatarId = avatarId;
this.emailaddress = emailaddress;
this.accountURL = accountURL;
this.male = male;
this.admin = admin;
this.ownVREs = ownVREs;
}
public String getAccountURL() {
return accountURL;
}
public void setAccountURL(String accountURL) {
this.accountURL = accountURL;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getAvatarId() {
return avatarId;
}
public void setAvatarId(String avatarId) {
this.avatarId = avatarId;
}
public String getEmailaddress() {
return emailaddress;
}
public void setEmailaddress(String emailaddress) {
this.emailaddress = emailaddress;
}
public boolean isMale() {
return male;
}
public void setMale(boolean male) {
this.male = male;
}
public HashMap<String, String> getOwnVREs() {
return ownVREs;
}
public void setOwnVREs(HashMap<String, String> vreMap) {
this.ownVREs = vreMap;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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