Compare commits

...

60 Commits

Author SHA1 Message Date
Ahmed Salah Tawfik Ibrahim 8509015a18 2.0.1 2024-04-16 15:19:38 +02:00
Ahmed Salah Tawfik Ibrahim 9fbec3653d 2.0.1-SNAPSHOT 2024-04-16 15:19:04 +02:00
Ahmed Salah Tawfik Ibrahim 85ab33184d cleaning logs 2024-04-16 15:04:52 +02:00
Ahmed Salah Tawfik Ibrahim 01821f5da3 cleaning logs 2024-04-16 15:03:57 +02:00
Ahmed Salah Tawfik Ibrahim bcbec61646 bug fix 2024-04-12 17:25:49 +02:00
Ahmed Salah Tawfik Ibrahim 93e501d65f bug fix 2024-04-12 17:25:22 +02:00
Ahmed Salah Tawfik Ibrahim 9a64a684d1 bug fix 2024-04-12 17:17:48 +02:00
Ahmed Salah Tawfik Ibrahim 5b5dfb56c4 bug fix 2024-04-12 17:17:23 +02:00
Ahmed Salah Tawfik Ibrahim 1562e6a441 bug fix 2024-04-12 17:02:13 +02:00
Ahmed Salah Tawfik Ibrahim 29471627da bug fix 2024-04-12 17:01:16 +02:00
Ahmed Salah Tawfik Ibrahim 8b6f4ccf2f bug fix 2024-04-12 16:32:02 +02:00
Ahmed Salah Tawfik Ibrahim 82d13b556b snapshot bug fix 2024-04-12 16:31:23 +02:00
Ahmed Salah Tawfik Ibrahim 899640141c possible fix 2024-04-11 18:30:21 +02:00
Ahmed Salah Tawfik Ibrahim 368d420799 possible fix 2024-04-11 18:19:55 +02:00
Ahmed Salah Tawfik Ibrahim 18cb5b7312 bug fixed 2024-04-11 14:44:58 +02:00
Ahmed Salah Tawfik Ibrahim b8f9b0a90a debug_error 2024-04-11 12:39:35 +02:00
Ahmed Salah Tawfik Ibrahim bcd8e29a8c Merge remote-tracking branch 'origin/master' 2023-12-13 13:47:29 +01:00
Ahmed Salah Tawfik Ibrahim 35c8cfdc5a Debug notification 2023-12-13 13:47:19 +01:00
Massimiliano Assante c06e47ea68 ready to release 2023-12-11 12:58:57 +01:00
Massimiliano Assante 5c2e5d5874 SNAPSHOT version 2023-12-11 12:58:08 +01:00
Ahmed Salah Tawfik Ibrahim 2a9bdc6c4a Ready for Release 2023-12-07 14:24:14 +01:00
Ahmed Salah Tawfik Ibrahim 083ca91e45 SNAPSHOT Version Ready 2023-12-07 14:23:28 +01:00
Ahmed Salah Tawfik Ibrahim 7aa3a1244e Ready for release 2023-12-07 14:21:20 +01:00
Ahmed Salah Tawfik Ibrahim 70d7e31540 Test new datacenter name 2023-12-07 14:14:23 +01:00
Ahmed Salah Tawfik Ibrahim 02bc40b6e8 Added Service Discovery 2023-12-06 16:40:46 +01:00
Ahmed Salah Tawfik Ibrahim 68a7532379 Added Service Discovery 2023-12-06 15:53:23 +01:00
Ahmed Salah Tawfik Ibrahim 79f326d906 Ready to release 2023-12-05 16:39:16 +01:00
Ahmed Salah Tawfik Ibrahim 0a9e97f680 Ready to release 2023-12-05 16:38:31 +01:00
Ahmed Salah Tawfik Ibrahim 099432f9a1 Ready to release 2023-12-05 16:31:08 +01:00
Ahmed Salah Tawfik Ibrahim 81542d5c0a Merge remote-tracking branch 'origin/master' 2023-12-05 16:30:09 +01:00
Ahmed Salah Tawfik Ibrahim 0d435d2398 Ready to release 2023-12-05 16:30:00 +01:00
Massimiliano Assante 38fdd5b762 fixed pom 2023-12-05 15:47:12 +01:00
Massimiliano Assante 9d04f4af59 fixed pom 2023-12-05 15:46:36 +01:00
Ahmed Salah Tawfik Ibrahim e8ca4a46a7 Ready to release 2023-12-04 18:16:12 +01:00
Ahmed Salah Tawfik Ibrahim 8a27841094 Snapshot version 2023-12-04 18:15:03 +01:00
Ahmed Salah Tawfik Ibrahim 785511f6a3 Bugs fixed 2023-12-04 17:38:33 +01:00
Ahmed Salah Tawfik Ibrahim b968a6f7dd Attachments bug fixed 2023-11-28 19:40:20 +01:00
Ahmed Salah Tawfik Ibrahim 61723dcc11 DB Write bug fixed 2023-11-27 15:45:26 +01:00
Ahmed Salah Tawfik Ibrahim 36eefcba26 Added author. 2023-11-24 11:49:40 +01:00
Ahmed Salah Tawfik Ibrahim 9ea2895833 Bug fixed - nullpointer exception result.all(), result.one() 2023-11-22 19:40:29 +01:00
Ahmed Salah Tawfik Ibrahim 6cf162bb91 Fixed performance bug 2023-11-15 18:14:57 +01:00
Ahmed Salah Tawfik Ibrahim 03d2b0cdf9 Remove dependencies from jar. 2023-11-14 12:28:57 +01:00
Ahmed Salah Tawfik Ibrahim 204462fcd6 Remove astyanx dependencies and imports. 2023-10-30 19:04:54 +01:00
Ahmed Salah Tawfik Ibrahim 3bd81a415f Datastax Driver Fully Implemented - Partially Tested - return of deprecated methods 2023-10-30 18:52:02 +01:00
Massimiliano Assante 6465e88378 removed obsolete maven plugin for javadoc 2022-12-20 10:34:49 +01:00
Massimiliano Assante 8ac4057526 release version 2022-09-20 18:51:31 +02:00
Massimiliano Assante db817c6326 fixed typo in changelog 2022-09-20 18:41:39 +02:00
Massimiliano Assante e88fd338ee publishing SNAPSHOT 2022-09-20 18:40:31 +02:00
Massimiliano Assante 6bb93b7de2 fixed broken interfsce by mistake, added getAllLikesByFeed back 2022-09-20 18:39:38 +02:00
Massimiliano Assante 60abff8772 ready to release 2022-09-20 18:31:54 +02:00
Massimiliano Assante 539b1f5ee9 minor change 2022-09-20 17:29:14 +02:00
Massimiliano Assante 7cc0917b97 added version source 2022-09-20 17:14:54 +02:00
Massimiliano Assante ad550ed872 added <maven.compiler.target>1.8</maven.compiler.target> 2022-09-20 17:10:05 +02:00
Massimiliano Assante d0a79d55fb should work alpha tests needed 2022-09-20 17:00:25 +02:00
Massimiliano Assante bb8550dd22 fixed about in README 2022-05-25 18:04:26 +02:00
Massimiliano Assante 38c1aab258 release version 2022-05-18 10:26:55 +02:00
Massimiliano Assante ef9a694253 nexus snapshot 2022-05-18 10:25:57 +02:00
Massimiliano Assante a72d6a0771 Added support for Catalogue notifications 2022-05-13 11:46:28 +02:00
Massimiliano Assante 4bcd8abdd0 added support for catalogue notifications 2022-05-06 17:15:00 +02:00
Massimiliano Assante b9b918d7ce revised changelog and pom, no change in the code 2022-04-20 11:47:51 +02:00
31 changed files with 3985 additions and 1757 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -8,9 +8,9 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
@ -21,9 +21,10 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -7,7 +7,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

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

84
CHANGELOG.md Normal file
View File

@ -0,0 +1,84 @@
# Changelog for Social Networking Library
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.0.1] - 2023-12-04
- Bug 27218 - Null pointer exception getting notifications preferences fixed
## [v2.0.0] - 2023-12-04
- Support for Cassandra 4.1.3 using DataStax java driver
## [v1.17.0] - 2022-05-13
- Added support for Catalogue notifications
- Ported to git
## [v1.16.1] - 2018-03-07
- Added JsInterop DTOs (ClientPost, ClientAttachment and JSON) for supporting new IPC Client side in NewsFeed
## [v1.16.0] - 2017-05-25
- Added feature for hashtags in comments
## [v1.15.0] - 2017-01-25
- Added support for job completion notifications
- Improved exceptions handling
## [v1.14.0] - 2016-09-29
- Upgraded astyanax dependency to 2.0.2
- Removed support for Document Workflow notification
## [v1.13.0] - 2016-09-05
- Method to close connections pool to Apache Cassandra added
- Added methods to retrieve recent user's commented and liked posts
- Added enum class ShowUserStatisticAction
## [v1.10.0] - 2016-01-22
- Feature #1982, multi attachments to posts
## [v1.9.0] - 2016-01-15
- Feature #1663, for user statistics fast retrieval
- Feature #1493, updated the way we instanciate keyspace, now it is more efficient
- Fix Bug #246, updated methods for editing comments
## [v1.8.0] - 2015-07-03
- Added feature for invites and hashtags
## [v1.6.0] - 2014-04-08
- Added feature for post retrieval by range
- Added feature for notifications retrieval by range
- Added feature for unlike
## [v1.5.0] - 2014-03-05
- Added feature for post alert notifications
## [v1.3.0] - 2013-07-08
- Added feature for calendar notifications
- Added feature for URL encoding decoding js base 6
## [v1.2.0] - 2013-05-29
- Added feature for fine grained notifications
## [v1.1.0] - 2013-04-19
- Added feature for people taggings (mentions)
- Fix for method getAllPortalPrivacyLevelFeeds() not recongnizing application posts
## [v1.0.0] - 2013-01-11
- First release

26
FUNDING.md Normal file
View File

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0
Class-Path:
Main-Class: org.gcube.portal.databook.server.Tester

Binary file not shown.

View File

@ -22,12 +22,15 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/social-util-library/r
## Authors
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Costantino Perciante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
## License
@ -40,12 +43,4 @@ open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- DILIGENT (grant no. 004260);
- the Seventh Framework Programme for research, technological development and demonstration
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
- the H2020 research and innovation programme
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

View File

@ -1 +0,0 @@
${gcube.license}

View File

@ -1,67 +0,0 @@
The gCube System - ${name}
--------------------------------------------------
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Maintainers
-----------
* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Download information
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Installation documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}/
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}/
${gcube.wikiRoot}/
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

View File

@ -1,102 +0,0 @@
<ReleaseNotes>
<Changeset component="org.gcube.portal.social-networking-library.1-16-1"
date="2018-03-07">
<Change>Added JsInterop DTOs (ClientPost, ClientAttachment and JSON) for supporting new IPC Client side in NewsFeed</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-16-0"
date="2017-05-25">
<Change>Added support for hashtags in comments</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-15-0"
date="2017-01-25">
<Change>Added support for job completion notifications</Change>
<Change>Improved exceptions handling</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-14-0"
date="2016-09-29">
<Change>upgrade astyanax dependency to 2.0.2</Change>
<Change>removed support for Document Workflow notification</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-13-0"
date="2016-09-05">
<Change>Method to close connections pool to Cassandra added</Change>
<Change>Added methods to retrieve recent user's commented and liked
feeds
</Change>
<Change>Added enum class ShowUserStatisticAction</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-10-2"
date="2016-02-29">
<Change>Enhanced feed class added</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-10-0"
date="2016-01-22">
<Change>Add support for multi attachments to post, Feature #1982
</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-9-0"
date="2016-01-15">
<Change>Add support for user statistics fast retrieval, Feature #1663
</Change>
<Change>Updated the way we instanciate keyspace, now it is more
efficient, Feature #1493
</Change>
<Change>Updated methods for editing comments, Bug #246</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-8-1"
date="2015-09-30">
<Change>If an index report an NotificationID which does not exist the
other User Notifications are returned #840
</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-8-0"
date="2015-07-03">
<Change>Added support for invites</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-7-0"
date="2014-10-24">
<Change>Added support for hashtags</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-6-1"
date="2014-05-05">
<Change>Fixed bug returning sendNotification false when a Notification
Preference was null for a given Notification Type
</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-6-0"
date="2014-04-08">
<Change>Added support for feed retrieval by range</Change>
<Change>Added support for notifications retrieval by range</Change>
<Change>Added support for unlike feature</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-5-0"
date="2014-03-05">
<Change>Added support for post alert notifications</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-4-0"
date="2013-10-21">
<Change>Ported to Feather Weight Stack</Change>
<Change>Removed GCF Dependency</Change>
<Change>Logging with sl4j Enabled</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-3-0"
date="2013-07-08">
<Change>Added support for calendar notifications</Change>
<Change>Added support for URL encoding decoding js base 64</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-2-0"
date="2013-05-29">
<Change>Added support for fine grained notifications</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-1-0"
date="2013-04-19">
<Change>Added support for people taggings (mentions)</Change>
<Change>Added fix for method getAllPortalPrivacyLevelFeeds() not
recongnizing application feeds
</Change>
</Changeset>
<Changeset component="org.gcube.portal.social-networking-library.1-0-0"
date="2013-01-11">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,42 +0,0 @@
<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>changelog.xml</include>
<include>profile.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>
</files>
</assembly>

View File

@ -1,25 +0,0 @@
<?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>

80
pom.xml
View File

@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
@ -11,11 +11,11 @@
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.16.2</version>
<version>2.0.1</version>
<name>gCube Social Networking Library</name>
<description>
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
The social networking facilities exploit a NoSQL data store for their storage. Specifically an Apache Cassandra data store.
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
The social networking facilities exploit a NoSQL data store for their storage. Specifically an Apache Cassandra data store.
</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</connection>
@ -23,54 +23,49 @@
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<properties>
<gwtVersion>2.8.1</gwtVersion>
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<gwtVersion>2.8.1</gwtVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<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>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
</dependency>
<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>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>1.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
@ -96,10 +91,18 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -119,7 +122,6 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@ -138,24 +140,6 @@
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
<version>3.1.0</version>
<executions>
<execution>
<id>generate-doc</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -1,33 +1,25 @@
package org.gcube.portal.databook.server;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.net.InetSocketAddress;
import java.time.Duration;
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.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 Costantino Perciante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
*/
public class CassandraClusterConnection {
@ -39,304 +31,473 @@ public class CassandraClusterConnection {
/**
* keyspace location
*/
private static String clusterName;
private static String host;
private static String keyspaceName;
private static List<InetSocketAddress> hosts;
private static String datacenterName;
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
* @return the connection to cassandra cluster
* the connection to cassandra cluster
*/
protected CassandraClusterConnection(boolean dropSchema) {
if (clusterName == null || host == null || keyspaceName == null) {
protected CassandraClusterConnection(boolean dropSchema) throws Exception {
if (hosts == null || datacenterName == null || keyspaceName == null) {
RunningCluster cluster = RunningCluster.getInstance(null);
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(100)
.setSeeds(host))
.withConnectionPoolMonitor(
new CountingConnectionPoolMonitor())
.buildCluster(ThriftFamilyFactory.getInstance());
//host = cluster.getHost();
hosts = cluster.getHosts();
datacenterName = cluster.getDatacenterName();
keyspaceName = cluster.getKeyspaceName();
}
_log.info(keyspaceName + " KeySpace SetUp ...");
SetUpKeySpaces(clusterContext, dropSchema);
SetUpKeySpaces(dropSchema);
myKeyspaceSession = connect(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
* the connection to cassandra cluster
*/
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
* @return the connection to cassandra cluster
*/
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) {
if (clusterName == null || host == null || keyspaceName == null) {
protected CassandraClusterConnection(boolean dropSchema, String infrastructureName) throws Exception {
if (hosts == null || datacenterName == null || keyspaceName == null) {
RunningCluster cluster = RunningCluster.getInstance(infrastructureName);
clusterName = cluster.getClusterName();
host = cluster.getHost();
//host = cluster.getHost();
hosts = cluster.getHosts();
datacenterName = cluster.getDatacenterName();
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 ...");
SetUpKeySpaces(clusterContext, dropSchema);
SetUpKeySpaces(dropSchema);
myKeyspaceSession = connect(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)");
}
public CqlSession getKeyspaceSession(){
if (myKeyspaceSession.isClosed()){
myKeyspaceSession = connect(keyspaceName);
}
return myKeyspaceSession;
}
/**
* Get the reference to the current keyspace
* @return keyspace reference
* @param dropSchema set true if you want to drop the current and set up new one
* the connection to cassandra cluster
*/
public Keyspace getKeyspace() {
// The Keyspace instance can be shared among different requests
if(myKeyspace == null){
synchronized(this){
if(myKeyspace == null){ // double checked lock
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspaceName)
.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();
}
public void SetUpKeySpaces(boolean dropSchema) {
boolean createNew = false;
boolean found = false;
CqlSession session = connect();
Metadata metaData = session.getMetadata();
for (KeyspaceMetadata meta : metaData.getKeyspaces().values()) {
if (meta.getName().toString().equals(keyspaceName)){
found = true;
break;
}
}
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) {
if (dropSchema && found) {
_log.info("Dropping Keyspace: " + keyspaceName + " ...");
try {
OperationResult<SchemaChangeResult> returned = cluster.dropKeyspace(keyspaceName);
ResultSet returned = dropKeyspace();
Thread.sleep(2000);
_log.info("Dropped " + returned.getResult().toString());
} catch (ConnectionException e) {
if (returned.wasApplied())
_log.info("Dropped " + keyspaceName);
else
_log.info("Couldn't drop " + keyspaceName);
} catch (Exception 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) {
if (!found || createNew) {
_log.info("Keyspace does not exist, triggering schema creation ... ");
createSchema(cluster);
_log.info("Cluster " + clusterName + " on " + host + " Initialized OK!");
int replicationFactor = 2;
createKeyspace(keyspaceName, replicationFactor);
closeSession(session);
createTables();
_log.info("Using Keyspace " + keyspaceName);
}
} catch (ConnectionException e) {
} catch (Exception 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");
/**
* 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);
private static CqlSession connect() {
CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withLocalDatacenter(datacenterName)
.build();
_log.info("[OK] Connected to Cassandra Cluster");
return cqlSession;
}
private static CqlSession connect(String KEYSPACE_NAME) {
CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts)
.withKeyspace(KEYSPACE_NAME)
.withLocalDatacenter(datacenterName)
.build();
_log.info("[OK] Connected to Keyspace {} ", KEYSPACE_NAME);
return cqlSession;
}
/**
* 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;
public static void closeSession(CqlSession session) {
if (session != null) session.close();
_log.info("[OK]Session is now closed");
}
/**
* 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;
public void closeConnection(){
if(!myKeyspaceSession.isClosed()){
try{
_log.info("Closing connection");
closeSession(myKeyspaceSession);
_log.info("Connection closed!");
}catch(Exception e){
_log.error("Unable to close connection", e);
}
}
}
}
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(datacenterName)
.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(datacenterName)
.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(datacenterName)
.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");
}
}

View File

@ -5,10 +5,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
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 {
private static DBCassandraAstyanaxImpl store;

View File

@ -15,7 +15,9 @@ import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.Post;
import org.gcube.portal.databook.shared.RangeFeeds;
import org.gcube.portal.databook.shared.RangePosts;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
@ -28,8 +30,6 @@ 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 Costantino Perciante ISTI-CNR
@ -62,46 +62,91 @@ public interface DatabookStore {
*/
List<String> getPendingFriendRequests(String userid);
/**
* @deprecated use saveUserPost
* save a Feed instance in the store
* @return true if everything went fine
*/
boolean saveUserFeed(Feed feed);
/**
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveUserPost(Post feed);
/**
* Save a Feed instance in the store having more than one attachment
* Use this if you need to attach more than one file to the post
*
* @param attachments, a list of attachments starting from the second
* @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);
/**
* delete a Feed from the store
* 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
*
* @param attachments a list of attachments starting from the second
* @return true if everything went fine
*/
boolean saveUserPost(Post post, List<Attachment> attachments);
/**
* Delete a Feed from the store
* @deprecated use saveUserPost
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deleteFeed(String feedid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
* save a post in the VRES TimeLine in the store
* delete a Feed from the store
* @throws FeedIDNotFoundException
* @return true if everything went fine
*/
boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
/**
* Save a post in the VRES TimeLine in the store
* @deprecated use savePostToVRETimeline
* @param feedKey feedKey
* @param vreid vre identifier
* @return
* @throws FeedIDNotFoundException
*/
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
/**
* save a post in the VRES TimeLine in the store
* @param postKey the post id
* @param vreid vre identifier
* @throws FeedIDNotFoundException
*/
boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException;
/**
* @deprecated use saveAppPost
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed);
/**
* Save a feed instance in the store
* save a Post instance in the store
* @return true if everything went fine
*/
boolean saveAppPost(Post feed);
/**
* @deprecated use saveAppPost
* Save a Post instance in the store
* Use this if your app needs to attach more than one file to the post
*
* @param attachments, a list of attachments starting from the second
* @param attachments a list of attachments starting from the second
* @return true if everything went fine
*/
boolean saveAppFeed(Feed feed, List<Attachment> attachments);
/**
* Save a Post instance in the store
* Use this if your app needs to attach more than one file to the post
*
* @param attachments a list of attachments starting from the second
* @return true if everything went fine
*/
boolean saveAppPost(Post feed, List<Attachment> attachments);
/**
* @deprecated use readPost
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
@ -109,6 +154,14 @@ public interface DatabookStore {
*/
Feed readFeed(String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* read a feed from a given id
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
Post readPost(String postid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getAllPostsByUser instead
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
@ -117,6 +170,15 @@ public interface DatabookStore {
*/
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getAllPostsByApp instead
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
@ -125,6 +187,15 @@ public interface DatabookStore {
*/
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param appid application identifier
* return all the feeds belonging to the appid
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @deprecated use getRecentCommentedPostsByUserAndDate instead
* @param userid the user identifier like andrea.rossi
* @param timeInMillis the initial time in millis to be considered
* @return a list of feeds commented by userid starting from timeInMillis
@ -132,15 +203,31 @@ public interface DatabookStore {
*/
List<Feed> getRecentCommentedFeedsByUserAndDate(String userid, long timeInMillis) throws Exception;
/**
* @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<Post> getRecentCommentedPostsByUserAndDate(String userid, long timeInMillis) throws Exception;
/**
* @deprecated use getAllPortalPrivacyLevelPosts instead
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
/**
* return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
* @throws PrivacyLevelTypeNotFoundException
*/
List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException;
/**
* 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
@ -150,6 +237,17 @@ public interface DatabookStore {
*/
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* return the most recent feeds for this user up to quantity param
* @param userid user identifier
* @param quantity the number of most recent feeds for this user
* @return a <class>List</class> of most recent feeds for this user
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @deprecated use getAllPostsByVRE
* @param vreid vre identifier
* return all the feeds belonging to the userid
* @throws FeedTypeNotFoundException
@ -157,8 +255,17 @@ public interface DatabookStore {
* @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
* 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
@ -169,10 +276,22 @@ public interface DatabookStore {
*/
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* return the most recent feeds for this vre up to quantity param and the last index of the feeds in the timeline
* return the most recent posts for this vre up to quantity param
* @param vreid VRES identifier
* @param quantity the number of most recent posts for this vre
* @return a <class>List</class> of most recent posts for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
List<Post> getRecentPostsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* 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
@ -183,11 +302,32 @@ public interface DatabookStore {
*/
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
*
* @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>RangePosts</class> containing of most recent feeds for this vre
* @throws FeedTypeNotFoundException
* @throws PrivacyLevelTypeNotFoundException
* @throws ColumnNameNotFoundException
*/
RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
/**
* @deprecated use getRecentPostsByUserAndDate
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
* @return the number of feeds in the range from: today to: timeInMillis
*/
List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
* @return the number of feeds in the range from: today to: timeInMillis
*/
List<Post> getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* save a Notification instance in the store
* @return true if everything went fine
@ -272,7 +412,6 @@ public interface DatabookStore {
/**
* set the notification preferences map (enable or disable the channels to be used for notifying the user)
* @param userid user identifier
* @param notificationType the type of the notification
* @param enabledChannels a map of the channels to which reach the user per notification, empty array or null values to set the key notification type off
* @return true if everything was fine
*/
@ -298,10 +437,16 @@ public interface DatabookStore {
*/
boolean addComment(Comment comment) throws FeedIDNotFoundException;
/**
* @deprecated use getAllCommentByPost
* @param feedid feed identifier
* return all the comments belonging to the feedid
*/
List<Comment> getAllCommentByFeed(String feedid);
/**
* @param postid the post identifier
* return all the comments belonging to the postid
*/
List<Comment> getAllCommentByPost(String postid);
/**
* @param userid user identifier
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
@ -310,20 +455,20 @@ public interface DatabookStore {
List<Comment> getRecentCommentsByUserAndDate(String userid, long timeInMillis) throws Exception;
/**
* edit a comment
* @param commentid the comment identifier to edit
* @param comment the comment to edit
* @return true if success, false otherwise
*/
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/**
* delete a comment
* deletes a comment
* @param commentid the comment identifier to delete
* @parma 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
*/
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/**
* add a like to a feed
* @param the like instance
* @param like instance
* @throws FeedIDNotFoundException
*/
boolean like(Like like) throws FeedIDNotFoundException;
@ -336,11 +481,18 @@ public interface DatabookStore {
*/
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
/**
* @deprecated use getAllLikedPostIdsByUser
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedFeedIdsByUser(String userid);
/**
* @param userid user identifier
* return all the feedids a user has liked
*/
List<String> getAllLikedPostIdsByUser(String userid);
/**
* @deprecated use getAllLikedPostsByUser
* @param userid user identifier
* @param limit set 0 to get everything, an int to get the most recent -limit- liked feeds
* @throws ColumnNameNotFoundException .
@ -353,25 +505,50 @@ public interface DatabookStore {
List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @param userid user identifier
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* return all the feeds a user has liked
*/
List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* @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 feedid feed identifier
* return all the likes belonging to the feedid
* @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<Like> getAllLikesByFeed(String feedid);
List<Post> getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
/**
* @deprecated use getAllLikesByPost
* @param postid postid identifier
* return all the likes belonging to the postid
*/
List<Like> getAllLikesByFeed(String postid);
/**
* @param postid postid identifier
* return all the likes belonging to the postid
*/
List<Like> getAllLikesByPost(String postid);
/**
*
* @param hashtags the hashtag including the '#'
* @param feedid the feedid to which the hashtag is associated
* @param postid the postid to which the hashtag is associated
* @param vreid VRE identifier
* @return true if success, false otherwise
* @throws FeedIDNotFoundException
*/
boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
boolean saveHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
/**
*
* @param hashtags the hashtag including the '#'
@ -384,12 +561,12 @@ public interface DatabookStore {
/**
*
* @param hashtags the hashtag including the '#'
* @param feedid the feedid to which the hashtag is associated
* @param postid the postid to which the hashtag is associated
* @param vreid VRE identifier
* @return true if success, false otherwise
* @throws FeedIDNotFoundException
*/
boolean deleteHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
boolean deleteHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
/**
*
* @param hashtags the hashtag including the '#'
@ -413,7 +590,7 @@ public interface DatabookStore {
*/
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 .
@ -424,6 +601,19 @@ public interface DatabookStore {
* @return all the feeds having the hashtag passed as parameter
*/
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
*
* @param vreid VRE identifier
* @param hashtag the hashtag to look for including the '#', it is case sensitive
* @throws ColumnNameNotFoundException .
* @throws FeedIDNotFoundException .
* @throws FeedTypeNotFoundException .
* @throws PrivacyLevelTypeNotFoundException
* @throws FeedIDNotFoundException .
* @return all the feeds having the hashtag passed as parameter
*/
List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/**
* Save the invite for a given email into a given vre
* @param invite the invite object instanc to save
@ -464,12 +654,16 @@ public interface DatabookStore {
*/
List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException;
/**
* save an attachment
*/
boolean saveAttachmentEntry(String feedId, Attachment toSave);
/**
* Retrieve all the ids of the vre
* @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

View File

@ -7,9 +7,14 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
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.PortalContext;
import org.gcube.common.resources.gcore.ServiceEndpoint;
@ -22,8 +27,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @version 0.1 Dec 2012
* @author Ahmed Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
@SuppressWarnings("serial")
@ -36,14 +42,14 @@ public class RunningCluster implements Serializable {
/**
* properties to read
*/
private static final String HOST_PROPERTY = "host";
private static final String HOST_PROPERTY = "host";
private static final String HOST_PORT_PROPERTY = "port";
private static final String CLUSTER_NAME_PROPERTY = "cluster";
private static final String DATACENTER_NAME_PROPERTY = "datacenter";
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
/**
* other constants
*/
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
private final static String RUNTIME_RESOURCE_NAME = "SocialDB";
private final static String PLATFORM_NAME = "Cassandra";
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
@ -56,27 +62,28 @@ public class RunningCluster implements Serializable {
/**
* Cluster Name
*/
private String clusterName;
private String datacenterName;
/**
* Keyspace Name
*/
private String keyspaceName;
private String keyspaceName; //to be modified
/**
* @param infrastructureName could be null
* @return an instance of the RunningCluster
*/
public static synchronized RunningCluster getInstance(String infrastructureName) {
public static synchronized RunningCluster getInstance(String infrastructureName){
if (singleton == null) {
singleton = new RunningCluster(infrastructureName);
}
return singleton;
}
}
/**
* private constructor
*/
private RunningCluster(String infrastructureName) {
try {
private RunningCluster(String infrastructureName){
//Query the IS (for the future)
try{
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
if (resources.size() > 1) {
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
@ -91,20 +98,25 @@ public class RunningCluster implements Serializable {
for (ServiceEndpoint res : resources) {
AccessPoint found = res.profile().accessPoints().iterator().next();
host = found.address();
clusterName = found.description();
datacenterName = found.description();
keyspaceName = found.name();
}
}
} catch (Exception e) {
e.printStackTrace();
}
/*host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
datacenterName = "1";
keyspaceName = "dev_mig_consistent";*/
}
/**
*
*
* @return the
* @throws Exception
*/
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) {
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
String scope = "/";
if(infrastructureName != null && !infrastructureName.isEmpty())
@ -122,16 +134,17 @@ public class RunningCluster implements Serializable {
List<ServiceEndpoint> toReturn = client.submit(query);
ScopeProvider.instance.set(currScope);
return toReturn;
}
}
private String readInfrastructureName() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
sb.append(File.separator)
.append(PortalContext.CONFIGURATION_FOLDER)
.append(File.separator)
.append(PortalContext.INFRA_PROPERTY_FILENAME);
.append(PortalContext.CONFIGURATION_FOLDER)
.append(File.separator)
.append(PortalContext.INFRA_PROPERTY_FILENAME);
String propertyfile = sb.toString();
File propsFile = new File(propertyfile);
FileInputStream fis = new FileInputStream(propsFile);
@ -141,19 +154,19 @@ public class RunningCluster implements Serializable {
catch(IOException e) {
_log.error("infrastructure.properties file not found under $CATALINA_HOME/conf/ dir, setting default infrastructure Name " + "gcube");
return "gcube";
}
}
}
/**
*
*
*/
private void loadDefaultConfiguration() {
Properties props = new Properties();
try {
props.load(CassandraClusterConnection.class.getResourceAsStream(DEFAULT_CONFIGURATION));
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);
} catch (IOException e) {
e.printStackTrace();
@ -169,32 +182,43 @@ public class RunningCluster implements Serializable {
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
return "RunningCluster [host=" + host + ", datacenterName=" + datacenterName
+ ", keyspaceName=" + keyspaceName + "]";
}
/**
*
*
* @return $CATALINA_HOME
*/
private static String getCatalinaHome() {
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;
}
}

View File

@ -0,0 +1,76 @@
package org.gcube.portal.databook.server;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
public class Schema {
//Tables
public static final String NOTIFICATIONS = "Notifications";
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
}

View File

@ -0,0 +1,52 @@
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;
/**
* @author Massimiliano Assante ISTI-CNR
* @author Ahmed Ibrahim ISTI-CNR
*
* @version 2.0.0 October 2023
*
*/
public class Tester {
private static DBCassandraAstyanaxImpl store;
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
public Tester() {
store = new DBCassandraAstyanaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it
}
public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
Tester test = new Tester();
//test.getComment();
test.testFunc();
System.exit(0);
}
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
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());
}
}
}

View File

@ -32,7 +32,7 @@ public class Comment implements Serializable, Comparable<Comment> {
*
* @param key
* @param userid
* @param timestamp
* @param time
* @param feedid
* @param text
* @param fullName

View File

@ -6,7 +6,7 @@ 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> {
@ -46,7 +46,7 @@ public class Feed implements Serializable, Comparable<Feed> {
* @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 time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
@ -87,7 +87,7 @@ public class Feed implements Serializable, Comparable<Feed> {
* @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 time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
@ -113,7 +113,7 @@ public class Feed implements Serializable, Comparable<Feed> {
* @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 time when
* @param vreid a unique vre id
* @param uri optional uri
* @param uriThumbnail the thumbnail for the link posted
@ -152,7 +152,7 @@ public class Feed implements Serializable, Comparable<Feed> {
}
/**
*
* @return
* @return the key
*/
public String getKey() {
return key;

View File

@ -2,7 +2,7 @@ package org.gcube.portal.databook.shared;
/**
* @author Massimiliano Assante ISTI-CNR
*
* @deprecated use PostType
* @version 1.2 October 2012
*/
public enum FeedType {

View File

@ -154,6 +154,26 @@ public enum NotificationType {
*/
@Deprecated
DOCUMENT_WORKFLOW_STEP_FORWARD_PEER,
/**
* catalogue, use to notify someone submits an item for consideration
*/
CAT_ITEM_SUBMITTED,
/**
* catalogue, use to notify someone rejected a submitted item
*/
CAT_ITEM_REJECTED,
/**
* catalogue, use to notify someone published an item
*/
CAT_ITEM_PUBLISHED,
/**
* catalogue, use to notify someone updated an item
*/
CAT_ITEM_UPDATED,
/**
* catalogue, use to notify someone removed an item
*/
CAT_ITEM_DELETE,
/**
* generic notification
*/

View File

@ -0,0 +1,322 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
*/
@SuppressWarnings("serial")
public class Post implements Serializable, Comparable<Post> {
private String key;
private PostType 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 Post() {
super();
}
/**
* To use ONLY for USER Feeds
*
*
* @param key a UUID
* @param type an instance of <class>PostType</class>
* @param entityId the user or the app unique indentifier
* @param time when
* @param vreid a unique vre id
* @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 Post(String key, PostType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost) {
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 Post(String key, PostType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) {
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>PostType</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 Post(String key, PostType type, String entityId, Date time,
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
String fullName, String email, String thumbnailURL, String commentsNo,
String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) {
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 post id
*/
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public PostType getType() {
return type;
}
public void setType(PostType 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(Post 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 "Post [key=" + key + ", type=" + type + ", entityId=" + entityId
+ ", time=" + time + ", vreid=" + vreid + ", uri=" + uri
+ ", uriThumbnail=" + uriThumbnail + ", description="
+ description + ", privacy=" + privacy + ", fullName="
+ fullName + ", email=" + email + ", thumbnailURL="
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
+ linkDescription + ", linkHost=" + linkHost
+ ", applicationFeed=" + applicationFeed
+ ", multiFileUpload=" + multiFileUpload + "]";
}
}

View File

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

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
* @deprecated use RangePosts
*/
@SuppressWarnings("serial")
public class RangeFeeds implements Serializable {

View File

@ -0,0 +1,40 @@
package org.gcube.portal.databook.shared;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Massimiliano Assante, ISTI-CNR
*
*/
@SuppressWarnings("serial")
public class RangePosts implements Serializable {
private int lastReturnedPostTimelineIndex;
private ArrayList<Post> posts;
public RangePosts() {
super();
}
public RangePosts(int lastReturnedPostTimelineIndex, ArrayList<Post> feeds) {
super();
this.lastReturnedPostTimelineIndex = lastReturnedPostTimelineIndex;
this.posts = feeds;
}
public int getLastReturnedPostTimelineIndex() {
return lastReturnedPostTimelineIndex;
}
public void setLastReturnedPostTimelineIndex(int lastReturnedPostTimelineIndex) {
this.lastReturnedPostTimelineIndex = lastReturnedPostTimelineIndex;
}
public ArrayList<Post> getPosts() {
return posts;
}
public void setPosts(ArrayList<Post> posts) {
this.posts = posts;
}
}