first commit
This commit is contained in:
commit
2ae5d38807
|
@ -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.0] - 2023-11-15
|
||||
|
||||
- Feature #25901-fix, same as feature 25901 but with minor fixes related to deprecated methods and classes
|
||||
|
||||
## [v1.18.0-SNAPSHOT] - 2023-10-30
|
||||
|
||||
- Implementation of databookstore using rest api of social service client
|
||||
|
||||
## [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
|
|
@ -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);
|
|
@ -0,0 +1,311 @@
|
|||
#European Union Public Licence V.1.1
|
||||
|
||||
##*EUPL © the European Community 2007*
|
||||
|
||||
|
||||
This **European Union Public Licence** (the **“EUPL”**) applies to the Work or Software
|
||||
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Original Work is provided under the terms of this Licence when the Licensor
|
||||
(as defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Original Work:
|
||||
|
||||
**Licensed under the EUPL V.1.1**
|
||||
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
|
||||
|
||||
##1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- The Licence: this Licence.
|
||||
|
||||
- The Original Work or the Software: the software distributed and/or
|
||||
communicated by the Licensor under this Licence, available as Source Code and
|
||||
also as Executable Code as the case may be.
|
||||
|
||||
- Derivative Works: the works or software that could be created by the Licensee,
|
||||
based upon the Original Work or modifications thereof. This Licence does not
|
||||
define the extent of modification or dependence on the Original Work required
|
||||
in order to classify a work as a Derivative Work; this extent is determined by
|
||||
copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
- The Source Code: the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- The Executable Code: any code which has generally been compiled and which is
|
||||
meant to be interpreted by a computer as a program.
|
||||
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||
Software under the terms of the Licence.
|
||||
|
||||
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, on-line or off-line, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
|
||||
##2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||
sub-licensable licence to do the following, for the duration of copyright vested
|
||||
in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||
- to the public, including the right to make available or display the Work or
|
||||
- copies thereof to the public and perform publicly, as the case may be, the
|
||||
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||
- thereof, sub-license rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make effective
|
||||
the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||
any patents held by the Licensor, to the extent necessary to make use of the
|
||||
rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
|
||||
##3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||
a notice following the copyright notice attached to the Work, a repository where
|
||||
the Source Code is easily and freely accessible for as long as the Licensor
|
||||
continues to distribute and/or communicate the Work.
|
||||
|
||||
|
||||
|
||||
##4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||
any exception or limitation to the exclusive rights of the rights owners in the
|
||||
Original Work or Software, of the exhaustion of those rights or of other
|
||||
applicable limitations thereto.
|
||||
|
||||
|
||||
|
||||
##5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||
Original Works or Derivative Works based upon the Original Work, this
|
||||
Distribution and/or Communication will be done under the terms of this Licence
|
||||
or of a later version of this Licence unless the Original Work is expressly
|
||||
distributed only under this version of the Licence. The Licensee (becoming
|
||||
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||
or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||
Works or copies thereof based upon both the Original Work and another work
|
||||
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||
conflict with his/her obligations under this Licence, the obligations of the
|
||||
Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing and/or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available for
|
||||
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||
trademarks, service marks, or names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
|
||||
##6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work granted
|
||||
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under the
|
||||
terms of this Licence.
|
||||
|
||||
|
||||
|
||||
##7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
contributors. It is not a finished work and may therefore contain defects or
|
||||
“bugs” inherent to this type of software development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||
and without warranties of any kind concerning the Work, including without
|
||||
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||
copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||
for the grant of any rights to the Work.
|
||||
|
||||
|
||||
|
||||
##8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||
of the Work, including without limitation, damages for loss of goodwill, work
|
||||
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||
damage, even if the Licensor has been advised of the possibility of such
|
||||
damage. However, the Licensor will be liable under statutory product liability
|
||||
laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
|
||||
##9. Additional agreements
|
||||
|
||||
While distributing the Original Work or Derivative Works, You may choose to
|
||||
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||
support, warranty, indemnity, or other liability obligations and/or services
|
||||
consistent with this Licence. However, in accepting such obligations, You may
|
||||
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||
the original Licensor or any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against such Contributor by the fact You have accepted
|
||||
any such warranty or additional liability.
|
||||
|
||||
|
||||
|
||||
##10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||
placed under the bottom of a window displaying the text of this Licence or by
|
||||
affirming consent in any other similar way, in accordance with the rules of
|
||||
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||
acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||
Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
|
||||
|
||||
##11. Information to the public
|
||||
|
||||
In case of any Distribution and/or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the Work
|
||||
from a remote location) the distribution channel or media (for example, a
|
||||
website) must at least provide to the public the information requested by the
|
||||
applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
|
||||
##12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon
|
||||
any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
|
||||
##13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new
|
||||
versions of this Licence, so far this is required and reasonable, without
|
||||
reducing the scope of the rights granted by the Licence. New versions of the
|
||||
Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
|
||||
##14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising
|
||||
between the European Commission, as a Licensor, and any Licensee, will be
|
||||
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||
as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and
|
||||
resulting from the interpretation of this License, will be subject to the
|
||||
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||
conducts its primary business.
|
||||
|
||||
|
||||
|
||||
##15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where
|
||||
the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any
|
||||
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||
- or registered office inside a European Union country.
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
##Appendix
|
||||
|
||||
|
||||
**“Compatible Licences”** according to article 5 EUPL are:
|
||||
|
||||
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
|
||||
- Common Public License v. 1.0
|
||||
|
||||
- Eclipse Public License v. 1.0
|
||||
|
||||
- Cecill v. 2.0
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: org.gcube.portal.databook.server.Tester
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
log4j.rootLogger=DEBUG, A1
|
||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Print the date in ISO 8601 format
|
||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||
|
||||
# Print only messages of level TRACE or above in the package org.gcube
|
||||
log4j.logger.org.gcube=TRACE
|
||||
log4j.logger.org.gcube.application.framework.core.session=INFO
|
||||
log4j.logger.com.netflix.astyanax.connectionpool=ERROR
|
||||
log4j.logger.org.gcube.portal.databook.server.DBCassandraAstyanaxImpl=TRACE
|
||||
log4j.logger.org.gcube.common=ERROR
|
|
@ -0,0 +1,42 @@
|
|||
# gCube System - Social Networking Library
|
||||
|
||||
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.
|
||||
|
||||
## Structure of the project
|
||||
|
||||
* The source code is present in the src folder.
|
||||
|
||||
## Built With
|
||||
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
* Use of this service is described in the [Wiki](https://wiki.gcube-system.org/gcube/Social_Networking_Library).
|
||||
|
||||
## Change log
|
||||
|
||||
See [Releases](https://code-repo.d4science.org/gCubeSystem/social-util-library/releases).
|
||||
|
||||
## Authors
|
||||
|
||||
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
|
||||
|
||||
## Maintainers
|
||||
|
||||
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)
|
|
@ -0,0 +1,151 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-library-stubs</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>gCube Social Library stubs</name>
|
||||
<description>
|
||||
The gCube Social Networking Library stubs exploits the social networking facilities using the social-service-client to interface with the NoSQL data store for their storage. Specifically an Apache Cassandra data store.
|
||||
</description>
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<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.4</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.social-networking</groupId>
|
||||
<artifactId>social-service-client</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>gwt-jsonmaker</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<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>
|
||||
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='gcubesocialnetworking'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='org.gcube.portal.databook.client.GCubeSocialNetworking' />
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.portal.databook.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code> and instances the <code>HandlerManager</code> for IPC
|
||||
*/
|
||||
public class GCubeSocialNetworking implements EntryPoint {
|
||||
public static final String USER_PROFILE_OID = "userIdentificationParameter";
|
||||
public static final String HASHTAG_OID = "hashtagIdentificationParameter";
|
||||
public static final String SEARCH_OID = "elasticSearchIdentificationParameter";
|
||||
public static final String SHOW_STATISTICS_ACTION_OID = "showUserStatisticsActionParameter"; // see ShowUserStatisticAction
|
||||
public static final String GROUP_MEMBERS_OID = "teamIdentificationParameter";
|
||||
public void onModuleLoad() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.portal.databook.client.util;
|
||||
/**
|
||||
* simply encode base64 strings
|
||||
* @author massi
|
||||
*
|
||||
*/
|
||||
public class Encoder {
|
||||
public static native String encode(String toEncode) /*-{
|
||||
return btoa(toEncode);
|
||||
}-*/;
|
||||
|
||||
public static native String decode(String toDecode) /*-{
|
||||
return atob(toDecode);
|
||||
}-*/;
|
||||
}
|
|
@ -0,0 +1,945 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.gcube.portal.databook.shared.*;
|
||||
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
||||
import org.gcube.social_networking.social_networking_client_library.CommentClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.HashTagClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.InviteClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.LikeClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.NotificationClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Costantino Perciante ISTI-CNR
|
||||
* This class is used for querying and adding data to Cassandra via Astyanax High Level API
|
||||
*/
|
||||
public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger _log = LoggerFactory.getLogger(DBCassandraAstyanaxImpl.class);
|
||||
private static PostClient postClient;
|
||||
private static NotificationClient notificationClient;
|
||||
private static HashTagClient hashTagClient;
|
||||
private static InviteClient inviteClient;
|
||||
private static CommentClient commentClient;
|
||||
private static LikeClient likeClient;
|
||||
|
||||
|
||||
/**
|
||||
* use this constructor carefully from test classes
|
||||
* @param dropSchema set true if you want do drop the current and set up new one
|
||||
*/
|
||||
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* public constructor, no dropping schema is allowed
|
||||
*/
|
||||
public DBCassandraAstyanaxImpl() {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* public constructor, no dropping schema is allowed, infrastructureName is given.
|
||||
*/
|
||||
public DBCassandraAstyanaxImpl(String infrastructureName) {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
********************** FRIENDSHIPS (CONNECTIONS) ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean requestFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean approveFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean denyFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getFriends(String userid) {
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPendingFriendRequests(String userid) {
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
return toReturn;
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** FEEDS ***********************
|
||||
*
|
||||
*/
|
||||
|
||||
private static Post feed2post(Feed feed){
|
||||
Post post = new Post(feed.getKey(), PostType.valueOf(feed.getType().toString()), feed.getEntityId(), feed.getTime(),
|
||||
feed.getVreid(), feed.getUri(), feed.getUriThumbnail(), feed.getDescription(), feed.getPrivacy(),
|
||||
feed.getFullName(), feed.getEmail(), feed.getThumbnailURL(), feed.getCommentsNo(),
|
||||
feed.getLikesNo(), feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.isApplicationFeed(), feed.isMultiFileUpload());
|
||||
return post;
|
||||
}
|
||||
|
||||
private static Feed post2feed(Post post){
|
||||
Feed feed = new Feed(post.getKey(), FeedType.valueOf(post.getType().toString()), post.getEntityId(), post.getTime(),
|
||||
post.getVreid(), post.getUri(), post.getUriThumbnail(), post.getDescription(), post.getPrivacy(),
|
||||
post.getFullName(), post.getEmail(), post.getThumbnailURL(), post.getCommentsNo(),
|
||||
post.getLikesNo(), post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.isApplicationFeed(), post.isMultiFileUpload());
|
||||
return feed;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveUserFeed(Feed post) {
|
||||
return saveUserPost(feed2post(post));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveUserPost(Post post) {
|
||||
return postClient.saveUserPostLib(post);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveUserFeed(Feed feed, List<Attachment> attachments) {
|
||||
return saveUserPost(feed2post(feed), attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveUserPost(Post post, List<Attachment> attachments) {
|
||||
return postClient.saveUserPostLib(post, attachments);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean saveAppFeed(Feed post) {
|
||||
return saveAppPost(feed2post(post));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAppPost(Post post) {
|
||||
return postClient.saveAppPostLib(post);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveAppFeed(Feed feed, List<Attachment> attachments) {
|
||||
return saveAppPost(feed2post(feed), attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAppPost(Post post, List<Attachment> attachments) {
|
||||
return postClient.saveAppPostLib(post, attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException {
|
||||
return savePostToVRETimeline(feedKey, vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException {
|
||||
return postClient.savePostToVRETimelineLib(postKey, vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Feed readFeed(String feedid)
|
||||
throws PrivacyLevelTypeNotFoundException,
|
||||
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
|
||||
return post2feed(readPost(feedid));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Post readPost(String postid)
|
||||
throws PrivacyLevelTypeNotFoundException,
|
||||
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return postClient.readPostLib(postid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
List<Post> posts = getRecentPostsByUserAndDate(userid, timeInMillis);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
return postClient.getRecentPostsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return deletePost(feedId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return postClient.deletePostLib(postid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByUser(userid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByApp(appid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByAppLib(appid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getRecentCommentedFeedsByUserAndDate(String userid,
|
||||
long timeInMillis) throws Exception {
|
||||
List<Post> posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentCommentedPostsByUserAndDate(String userid,
|
||||
long timeInMillis) throws Exception {
|
||||
return postClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||
List<Post> posts = getAllPortalPrivacyLevelPosts();
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||
return postClient.getAllPortalPrivacyLevelPostsLib();
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getRecentPostsByUser(userid, quantity);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getRecentPostsByUserLib(userid, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByVRE(vreid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByVRELib(vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
_log.info("\n\n in getRecentFeedsByVRE");
|
||||
List<Post> posts = getRecentPostsByVRE(vreid, quantity);
|
||||
_log.info("length of vre posts = " + posts.size());
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
_log.info("length of vre feeds = " + feeds.size());
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
_log.info("\n\n in getRecentPostsByVRE");
|
||||
return postClient.getRecentPostsByVRELib(vreid, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
RangePosts rangePosts = getRecentPostsByVREAndRange(vreid, from, quantity);
|
||||
List<Post> posts = rangePosts.getPosts();
|
||||
ArrayList<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
RangeFeeds rangeFeeds = new RangeFeeds(rangePosts.getLastReturnedPostTimelineIndex(), feeds);
|
||||
return rangeFeeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
********************** NOTIFICATIONS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveNotification(Notification n) {
|
||||
return notificationClient.saveNotificationLib(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.readNotificationLib(notificationid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.setNotificationReadLib(notificationidToSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.getAllNotificationByUserLib(userid, limit);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
||||
return notificationClient.getUnreadNotificationsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getRangeNotificationsByUser(String userid,int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
||||
return notificationClient.getRangeNotificationsByUserLib(userid, from, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setAllNotificationReadByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.setAllNotificationReadByUserLib(userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUnreadNotifications(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.checkUnreadNotificationsLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.checkUnreadMessagesNotificationsLib(userid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** NOTIFICATION SETTINGS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
|
||||
return notificationClient.getUserNotificationChannelsLib(userid, notificationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels) {
|
||||
return notificationClient.setUserNotificationPreferencesLib(userid, enabledChannels);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* by default Workspace and Calendar Notifications are set to Portal
|
||||
*/
|
||||
@Override
|
||||
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
|
||||
return notificationClient.getUserNotificationPreferencesLib(userid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** COMMENTS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addComment(Comment comment) throws FeedIDNotFoundException {
|
||||
return commentClient.addCommentLib(comment)!=null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Comment readCommentById(String commentId) throws CommentIDNotFoundException {
|
||||
return commentClient.readCommentByIdLib(commentId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Comment> getAllCommentByFeed(String feedid) {
|
||||
return getAllCommentByPost(feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getAllCommentByPost(String postid) {
|
||||
return commentClient.getAllCommentsByPostIdLib(postid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getRecentCommentsByUserAndDate(final String userid,
|
||||
final long timeInMillis) throws Exception {
|
||||
|
||||
return commentClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean editComment(Comment comment2Edit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
||||
return commentClient.editCommentLib(comment2Edit)!=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
||||
return commentClient.deleteCommentLib(commentid, feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean like(Like like) throws FeedIDNotFoundException {
|
||||
return likeClient.likeLib(like);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
|
||||
return likeClient.unlikeLib(userid, likeid, feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<String> getAllLikedFeedIdsByUser(String userid) {
|
||||
return getAllLikedPostIdsByUser(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllLikedPostIdsByUser(String userid) {
|
||||
return likeClient.getAllLikedPostIdsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
ArrayList<Feed> toReturn = new ArrayList<>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
//need them in reverse order
|
||||
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
||||
Feed toAdd = readFeed(likedPostIDs.get(i));
|
||||
if (toAdd.getType() == FeedType.TWEET || toAdd.getType() == FeedType.SHARE || toAdd.getType() == FeedType.PUBLISH) {
|
||||
toReturn.add(toAdd);
|
||||
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
||||
} else {
|
||||
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
||||
limit += 1; //increase the quantity in case of removed feed
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
ArrayList<Post> toReturn = new ArrayList<Post>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
//need them in reverse order
|
||||
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
||||
Post toAdd = readPost(likedPostIDs.get(i));
|
||||
if (toAdd.getType() == PostType.TWEET || toAdd.getType() == PostType.SHARE || toAdd.getType() == PostType.PUBLISH) {
|
||||
toReturn.add(toAdd);
|
||||
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
||||
} else {
|
||||
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
||||
limit += 1; //increase the quantity in case of removed feed
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getRecentLikedFeedsByUserAndDate(String userid,
|
||||
long timeInMillis) throws IllegalArgumentException {
|
||||
|
||||
List<Feed> toReturn = new ArrayList<>();
|
||||
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
if(userid == null || userid.isEmpty())
|
||||
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
||||
|
||||
// get the list of liked feeds
|
||||
List<String> likedPostsIdsByUser = getAllLikedFeedIdsByUser(userid);
|
||||
|
||||
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
||||
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
||||
String postid = likedPostsIdsByUser.get(i);
|
||||
try{
|
||||
|
||||
// retrieve the Post
|
||||
Feed toCheck = readFeed(postid);
|
||||
boolean isPostOk = (toCheck.getType() == FeedType.TWEET || toCheck.getType() == FeedType.SHARE || toCheck.getType() == FeedType.PUBLISH);
|
||||
|
||||
// retrieve the like of the user for the post
|
||||
if(isPostOk){
|
||||
List<Like> likes = getAllLikesByFeed(postid);
|
||||
for (Like like : likes) {
|
||||
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
||||
toReturn.add(toCheck);
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
_log.error("Skipped post with id " + postid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// please check consider that if a user made like recently to an old post, well it could happen that this
|
||||
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
||||
Collections.sort(toReturn, Collections.reverseOrder());
|
||||
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentLikedPostsByUserAndDate(String userid,
|
||||
long timeInMillis) throws IllegalArgumentException {
|
||||
|
||||
List<Post> toReturn = new ArrayList<>();
|
||||
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
if(userid == null || userid.isEmpty())
|
||||
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
||||
|
||||
// get the list of liked feeds
|
||||
List<String> likedPostsIdsByUser = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
||||
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
||||
String postid = likedPostsIdsByUser.get(i);
|
||||
try{
|
||||
|
||||
// retrieve the Post
|
||||
Post toCheck = readPost(postid);
|
||||
boolean isPostOk = (toCheck.getType() == PostType.TWEET || toCheck.getType() == PostType.SHARE || toCheck.getType() == PostType.PUBLISH);
|
||||
|
||||
// retrieve the like of the user for the post
|
||||
if(isPostOk){
|
||||
List<Like> likes = getAllLikesByPost(postid);
|
||||
for (Like like : likes) {
|
||||
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
||||
toReturn.add(toCheck);
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
_log.error("Skipped post with id " + postid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// please check consider that if a user made like recently to an old post, well it could happen that this
|
||||
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
||||
Collections.sort(toReturn, Collections.reverseOrder());
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Like> getAllLikesByFeed(String feedid) {
|
||||
return getAllLikesByPost(feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Like> getAllLikesByPost(String postid) {
|
||||
//possible error index
|
||||
return likeClient.getAllLikesByPostLib(postid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** HASHTAGS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
||||
return hashTagClient.saveHashTagsLib(feedid, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
||||
return hashTagClient.deleteHashTagsLib(feedid, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
||||
return hashTagClient.saveHashTagsCommentLib(commentId, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
||||
return hashTagClient.deleteHashTagsCommentLib(commentId, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getVREHashtagsWithOccurrence(String vreid) {
|
||||
return hashTagClient.getVREHashtagsWithOccurrenceLib(vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp){
|
||||
return hashTagClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return hashTagClient.getVREPostsByHashtagLib(vreid, hashtag);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** Invites ***********************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String isExistingInvite(String vreid, String email) {
|
||||
return inviteClient.isExistingInviteLib(vreid, email);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public InviteOperationResult saveInvite(Invite invite) throws AddressException {
|
||||
return inviteClient.saveInviteLib(invite);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
return inviteClient.readInviteLib(inviteid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
return inviteClient.setInviteStatusLib(vreid, email, status);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{
|
||||
return inviteClient.getInvitedEmailsByVRELib(vreid, status);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException {
|
||||
return postClient.getAttachmentsByFeedIdLib(feedId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllVREIds(){
|
||||
return postClient.getAllVREIdsLib();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,690 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class DatabookCassandraTest {
|
||||
private static DBCassandraAstyanaxImpl store;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
store = new DBCassandraAstyanaxImpl(); //set to true if you want to drop the KeySpace and recreate it
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void close(){
|
||||
store.closeConnection();
|
||||
System.out.println("End");
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void getRecentCommentedFeedsByUserAndDate() throws Exception{
|
||||
// String userid = "massimiliano.assante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// long init = System.currentTimeMillis();
|
||||
// List<Feed> res = store.getRecentCommentedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
// long end = System.currentTimeMillis();
|
||||
// System.out.println("Result is " + (end - init));
|
||||
//
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void getRecentCommentsByUserAndDate() throws Exception{
|
||||
//
|
||||
// String userid = "costantino.perciante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// List<Comment> res = store.getRecentCommentsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
//
|
||||
// for (Comment comment : res) {
|
||||
// System.out.println("Result is " + comment);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void getRecentLikedFeedsByUser(){
|
||||
//
|
||||
// String userid = "costantino.perciante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// List<Feed> result = store.getRecentLikedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
//
|
||||
// for (Feed feed : result) {
|
||||
// System.out.println("Result is " + feed);
|
||||
// }
|
||||
// }
|
||||
// @Test
|
||||
// public void getHashTagsFilteredByTime() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{
|
||||
//
|
||||
// int windowSize = 6; // go back windowSize months
|
||||
//
|
||||
// String vreUnderTest = "/gcube/devsec/devVRE";
|
||||
//
|
||||
// // reference time
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// int currentMonth = calendar.get(Calendar.MONTH); // jan = 0, ..... dec = 11
|
||||
// calendar.set(Calendar.MONTH, currentMonth - windowSize); // the year is automatically decreased if needed
|
||||
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// System.out.println("Reference time for trending topics is " + format.format(calendar.getTime()));
|
||||
//
|
||||
// Map<String, Integer> res =
|
||||
// store.getVREHashtagsWithOccurrenceFilteredByTime(
|
||||
// vreUnderTest, calendar.getTimeInMillis());
|
||||
//
|
||||
// // find max score inside the list (counter)
|
||||
// int max = 0;
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// max = max < entry.getValue() ? entry.getValue() : max;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // normalize
|
||||
// Map<String, Double> normalized = new HashMap<String, Double>();
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// normalized.put(entry.getKey(), (double)entry.getValue() / (double)max);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // create the weight for each entry as:
|
||||
// // w = 0.6 * normalized_score + 0.4 * freshness
|
||||
// // freshness is evaluated as (window_size - latest_feed_for_hashtag_in_window_month)/window_size
|
||||
// Map<String, Double> scoredList = new HashMap<String, Double>();
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// double weight = 0.6 * normalized.get(entry.getKey());
|
||||
//
|
||||
// // retrieve the last feed for this hashtag and locate it into the window
|
||||
// List<Feed> mostRecentFeedForHashtag = store.getVREFeedsByHashtag(vreUnderTest, entry.getKey());
|
||||
//
|
||||
// // retrieve the most recent one among these feeds
|
||||
// Collections.sort(mostRecentFeedForHashtag, Collections.reverseOrder());
|
||||
//
|
||||
// // locate into the window
|
||||
// Calendar locateInWindow = Calendar.getInstance();
|
||||
// locateInWindow.setTimeInMillis(mostRecentFeedForHashtag.get(0).getTime().getTime());
|
||||
//
|
||||
// // get the month
|
||||
// int sub = currentMonth - locateInWindow.get(Calendar.MONTH);
|
||||
// int value = sub >= 0? sub : 12 - Math.abs(sub);
|
||||
// double freshness = (double)(windowSize - value) / (double)(windowSize);
|
||||
// System.out.println("freshness is " + freshness + " because the last feed has month " + locateInWindow.get(Calendar.MONTH));
|
||||
//
|
||||
// weight += 0.4 * freshness;
|
||||
//
|
||||
// scoredList.put(entry.getKey(), weight);
|
||||
// }
|
||||
//
|
||||
// // print sorted
|
||||
// Map<String, Double> scoredListSorted = sortByValue(scoredList);
|
||||
// for(Entry<String, Double> entry : scoredListSorted.entrySet()){
|
||||
//
|
||||
// System.out.println("[hashtag=" + entry.getKey() + " , weight=" + entry.getValue() + "]");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static <K, V extends Comparable<? super V>> Map<K, V>
|
||||
// sortByValue( Map<K, V> map )
|
||||
// {
|
||||
// List<Map.Entry<K, V>> list =
|
||||
// new LinkedList<Map.Entry<K, V>>( map.entrySet() );
|
||||
// Collections.sort( list, new Comparator<Map.Entry<K, V>>()
|
||||
// {
|
||||
// public int compare( Map.Entry<K, V> o1, Map.Entry<K, V> o2 )
|
||||
// {
|
||||
// return (o2.getValue()).compareTo( o1.getValue() );
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// Map<K, V> result = new LinkedHashMap<K, V>();
|
||||
// for (Map.Entry<K, V> entry : list)
|
||||
// {
|
||||
// result.put( entry.getKey(), entry.getValue() );
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
// @Test
|
||||
// public void getHashTags() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{
|
||||
// List<Feed> resList = store.getVREFeedsByHashtag("/gcube/devsec/devVRE", "#test");
|
||||
//
|
||||
// for (Feed feed : resList) {
|
||||
// System.out.println(feed.getTime());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void getComment(){
|
||||
//
|
||||
// String uuid = "820969b2-4632-4197-9fd6-5aafab781faa";
|
||||
//
|
||||
// Comment c;
|
||||
// try {
|
||||
// c = store.readCommentById(uuid);
|
||||
// System.err.println(c);
|
||||
// } catch (CommentIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// System.err.println(e.toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void vreIds(){
|
||||
//
|
||||
// try {
|
||||
// List<String> ids = store.getAllVREIds();
|
||||
// System.out.println(ids);
|
||||
// } catch (ConnectionException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testFeedNumberPerUser() {
|
||||
// String userid = "massimiliano.assante";
|
||||
//
|
||||
// List<Feed> feeds = null;
|
||||
// int numComment = 0;
|
||||
// long init = System.currentTimeMillis();
|
||||
// try {
|
||||
// feeds = store.getAllFeedsByUser(userid);
|
||||
//
|
||||
// for (Feed feed : feeds) {
|
||||
// List<Comment> comments = store.getAllCommentByFeed(feed.getKey());
|
||||
//
|
||||
//
|
||||
// for (Comment comment : comments) {
|
||||
// numComment ++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (PrivacyLevelTypeNotFoundException | FeedTypeNotFoundException
|
||||
// | ColumnNameNotFoundException | FeedIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// System.err.println(e.toString());
|
||||
// }
|
||||
// long end = System.currentTimeMillis();
|
||||
// System.err.println("retrieved " + feeds.size() + " and " + numComment + " in " + (end - init) + "ms");
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testAttachments() {
|
||||
// Attachment a1 = new Attachment(UUID.randomUUID().toString(), "www1", "gattino1", "description1", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg", "image/jpg");
|
||||
// Attachment a2 = new Attachment(UUID.randomUUID().toString(), "www2", "name2", "description2", "http://www.gcomegatto.it/wp-content/uploads/2015/01/09gatto.jpg","image/jpg");
|
||||
// Attachment a3 = new Attachment(UUID.randomUUID().toString(), "www3", "name3", "description3", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg","image/jpg");
|
||||
// List<Attachment> toPass = new ArrayList<Attachment>();
|
||||
// toPass.add(a1);
|
||||
// toPass.add(a2);
|
||||
// toPass.add(a3);
|
||||
//
|
||||
// String feedId = UUID.randomUUID().toString();
|
||||
// Feed feed = new Feed(feedId, FeedType.TWEET, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "This post has attachments (gattini) ", PrivacyLevel.SINGLE_VRE,
|
||||
// "Massimiliano Assante",
|
||||
// "massimiliano.assante@isti.cnr.it",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "Gattino",
|
||||
// "linkDesc",
|
||||
// "image/jpeg", false);
|
||||
// feed.setMultiFileUpload(true);
|
||||
// assertTrue(store.saveUserFeed(feed, toPass));
|
||||
// System.out.println("Wrote post? ");
|
||||
// System.out.println("Feed has the following attachments: ");
|
||||
// try {
|
||||
// for (Attachment at : store.getAttachmentsByFeedId(feedId)) {
|
||||
// System.out.println(at);
|
||||
// }
|
||||
// } catch (FeedIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testHashTag() {
|
||||
// try {
|
||||
// final String VREID = "/gcube/devsec/devVRE";
|
||||
// final String HASHTAG1 = "#testHashTag";
|
||||
// final String HASHTAG2 = "#testHashTag3";
|
||||
// List<String> hashtags = new LinkedList<String>();
|
||||
// hashtags.add(HASHTAG1);
|
||||
// hashtags.add(HASHTAG2);
|
||||
//
|
||||
//// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID,
|
||||
//// "www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
//// assertTrue(store.saveUserFeed(feed));
|
||||
//// assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags));
|
||||
//// assertTrue(store.deleteHashTags("d0c64e42-9616-4e24-a65a-7a63a280d676", VREID, hashtags));
|
||||
//// System.out.println(feed);
|
||||
////
|
||||
// System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID);
|
||||
// Map<String, Integer> hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID);
|
||||
// for (String hashtag : hashtagsWithOcc.keySet()) {
|
||||
// System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag));
|
||||
// }
|
||||
//
|
||||
// System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1);
|
||||
// for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) {
|
||||
// System.out.println(theFeed);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
|
||||
// */
|
||||
// @Test
|
||||
// public void addAttachmentStaticColumnFamilies() {
|
||||
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
|
||||
//
|
||||
// try {
|
||||
// String colNameToIndex = "feedId";
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
|
||||
// .put("column_metadata", ImmutableMap.<String, Object>builder()
|
||||
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
|
||||
// .put("validation_class", "UTF8Type")
|
||||
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
|
||||
// .put("index_type", "KEYS")
|
||||
// .build())
|
||||
// .build())
|
||||
// .build());
|
||||
//
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addStaticColumnFamily END");
|
||||
// }
|
||||
//
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Dynamic) CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addInvitesDynamicColumnFamilies() {
|
||||
// System.out.println("UserNotificationsUnread");
|
||||
// ColumnFamily<String, String> cf_UserNotificationsUnreadTimeline = new ColumnFamily<String, String>(
|
||||
// DBCassandraAstyanaxImpl.EMAIL_INVITES, // Column Family Name
|
||||
// StringSerializer.get(), // Key Serializer
|
||||
// StringSerializer.get()); // Column Serializer
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsUnreadTimeline, ImmutableMap.<String, Object>builder()
|
||||
// .put("default_validation_class", "UTF8Type")
|
||||
// .put("key_validation_class", "UTF8Type")
|
||||
// .put("comparator_type", "UTF8Type")
|
||||
// .build());
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("UserNotificationsUnread END");
|
||||
// }
|
||||
|
||||
|
||||
// private List<String> getKeys() {
|
||||
// List<String> toReturn = new ArrayList<String>();
|
||||
// try {
|
||||
//
|
||||
// OperationResult<Rows<String, String>> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences)
|
||||
// .getAllRows()
|
||||
// .setRowLimit(1000) // This is the page size
|
||||
// .execute();
|
||||
// int i = 1;
|
||||
// for (Row<String, String> row : rows.getResult()) {
|
||||
// System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size());
|
||||
// toReturn.add(row.getKey());
|
||||
// i++;
|
||||
// }
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return toReturn;
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testUserNotificationPreferences() {
|
||||
// System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:");
|
||||
// try {
|
||||
// for (String user : getKeys()) {
|
||||
// List<NotificationChannelType> channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT);
|
||||
// if (channels.isEmpty()) {
|
||||
// System.out.println(user);
|
||||
// }
|
||||
// else if (! channels.contains(NotificationChannelType.EMAIL)) {
|
||||
// System.out.println(user + "->" + channels.toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) {
|
||||
// System.out.println(channel);
|
||||
// }
|
||||
// } catch (NotificationChannelTypeNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (NotificationTypeNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testLikes() {
|
||||
// int count = 10;
|
||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
|
||||
// "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
||||
// new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
|
||||
//
|
||||
// try {
|
||||
// assertTrue(store.like(toUnlike));
|
||||
// for (int i = 0; i < count; i++)
|
||||
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
||||
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
|
||||
//
|
||||
// System.out.println("massimiliano.assante liked the following feeds: ");
|
||||
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
|
||||
// System.out.println(feedid);
|
||||
// }
|
||||
//
|
||||
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
|
||||
// System.out.println(like);
|
||||
// }
|
||||
// System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
|
||||
// store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * use exclusively to add a new CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addNotifPreferencesColumnFamily() {
|
||||
// // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
|
||||
// // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
|
||||
// // StringSerializer.get(), // Key Serializer
|
||||
// // StringSerializer.get()); // Column Serializer
|
||||
// //
|
||||
// // try {
|
||||
// // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
|
||||
// // .put("default_validation_class", "UTF8Type")
|
||||
// // .put("key_validation_class", "UTF8Type")
|
||||
// // .put("comparator_type", "UTF8Type")
|
||||
// // .build());
|
||||
// // } catch (ConnectionException e) {
|
||||
// // e.printStackTrace();
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testFriendships() {
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
|
||||
// assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
|
||||
//
|
||||
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
|
||||
// assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
|
||||
//
|
||||
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
|
||||
// System.out.println("Pending Connections for massimiliano.assante:");
|
||||
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
|
||||
// System.out.println(userid);
|
||||
// }
|
||||
//
|
||||
// System.out.println("Connections for massimiliano.assante:");
|
||||
// for (String userid: store.getFriends("massimiliano.assante")) {
|
||||
// System.out.println(userid);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void testLikedFeedsRetrieval() {
|
||||
// try {
|
||||
// for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
|
||||
// System.out.println(feed);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testSingleNotification() {
|
||||
// Notification not = new Notification(
|
||||
// UUID.randomUUID().toString(),
|
||||
// NotificationType.LIKE,
|
||||
// "leonardo.candela",
|
||||
// "MESSAGEID",
|
||||
// new Date(),
|
||||
// "uri",
|
||||
// "This is notification about a like",
|
||||
// false,
|
||||
// "leonardo.candela", "Leonardo Candela",
|
||||
// "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
//
|
||||
// not = new Notification(
|
||||
// UUID.randomUUID().toString(),
|
||||
// NotificationType.MESSAGE,
|
||||
// "massimiliano.assante",
|
||||
// "MESSAGEID",
|
||||
// new Date(),
|
||||
// "uri",
|
||||
// "This is notification about a like",
|
||||
// false,
|
||||
// "antonio.gioia", "Antonio Gioia",
|
||||
// "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// System.out.println("Writing one Notification " + not);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNotifications() {
|
||||
// Notification not = null;
|
||||
// System.out.println("Writing 18 Notifications");
|
||||
// int count = 18;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// if (i % 2 != 0) {
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
|
||||
// "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
|
||||
// } else {
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
|
||||
// "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
|
||||
// }
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Notification rNot= null;
|
||||
// try {
|
||||
//
|
||||
// //read
|
||||
// rNot = store.readNotification(not.getKey().toString());
|
||||
// assertNotNull(rNot);
|
||||
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
|
||||
//
|
||||
// //set Read
|
||||
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
||||
//
|
||||
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
|
||||
//
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
|
||||
// "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// rNot = store.readNotification(not.getKey().toString());
|
||||
// System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
|
||||
// // //set Read
|
||||
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
||||
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
|
||||
// //
|
||||
// Random randomGenerator = new Random();
|
||||
//
|
||||
// System.out.println("leonardo.candela Notifications: ");
|
||||
// List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
|
||||
// assertNotNull(recentNots);
|
||||
// for (Notification notif :recentNots)
|
||||
// System.out.println(notif);
|
||||
//
|
||||
//
|
||||
// System.out.println("massimiliano.assante Notifications: ");
|
||||
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
|
||||
// assertNotNull(recentNots);
|
||||
// for (Notification notif :recentNots)
|
||||
// System.out.println(notif);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
|
||||
// try {
|
||||
// int from = 0;
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// System.out.println("\nFROM="+from);
|
||||
// List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50);
|
||||
// for (Notification notification : range) {
|
||||
// System.out.println(notification.getDescription());
|
||||
// from = 1+i * 50;
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testFeeds() {
|
||||
// int count = 18;
|
||||
// Feed feed = null;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// if (i % 2 != 0) {
|
||||
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
// } else {
|
||||
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
|
||||
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
// }
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Feed rFeed = null;
|
||||
// try {
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// assertNotNull(rFeed);
|
||||
//
|
||||
// String feedIdToDelete = UUID.randomUUID().toString();
|
||||
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// try {
|
||||
// Thread.sleep(250);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("Test Delete Feed ");
|
||||
// assertTrue(store.deleteFeed(feedIdToDelete));
|
||||
//
|
||||
// System.out.println("massimiliano.assante ALL FEEDS: ");
|
||||
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
|
||||
// System.out.println(recFeed);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testComments() {
|
||||
// int count = 10;
|
||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
|
||||
// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
//
|
||||
// Comment toDelete = null;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// try {
|
||||
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
|
||||
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
|
||||
// assertTrue(store.addComment(toDelete));
|
||||
//
|
||||
// } catch (FeedIDNotFoundException e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
// System.out.println("GetAllCOmmentsByFeed ");
|
||||
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
|
||||
// try {
|
||||
// System.out.println(store.readCommentById(cm.getKey()));
|
||||
// } catch (CommentIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// try {
|
||||
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,667 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.gcube.portal.databook.shared.Attachment;
|
||||
import org.gcube.portal.databook.shared.Comment;
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.databook.shared.InviteStatus;
|
||||
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;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Costantino Perciante ISTI-CNR
|
||||
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
|
||||
*/
|
||||
public interface DatabookStore {
|
||||
/**
|
||||
* userid from requests a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean requestFriendship(String from, String to);
|
||||
/**
|
||||
* userid from approves a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean approveFriendship(String from, String to);
|
||||
/**
|
||||
* userid from denies a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean denyFriendship(String from, String to);
|
||||
/**
|
||||
* @param userid the user id you want to know friends
|
||||
* @return a List of userid representing the friends for the given userid
|
||||
*/
|
||||
List<String> getFriends(String userid);
|
||||
/**
|
||||
* @param userid the user id you want to know the pending friend requests
|
||||
* @return a List of userid representing the friends for the given userid
|
||||
*/
|
||||
List<String> getPendingFriendRequests(String userid);
|
||||
/**
|
||||
* @deprecated use saveUserPost
|
||||
* save a Feed instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserFeed(Feed feed);
|
||||
/**
|
||||
* save a Post instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserPost(Post feed);
|
||||
/**
|
||||
* Save a Feed instance in the store having more than one attachment
|
||||
* Use this if you need to attach more than one file to the post
|
||||
*
|
||||
* @deprecated use saveUserPost
|
||||
* @param attachments a list of attachments starting from the second
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserFeed(Feed feed, List<Attachment> attachments);
|
||||
/**
|
||||
* Save a Post instance in the store having more than one attachment
|
||||
* Use this if you need to attach more than one file to the post
|
||||
*
|
||||
* @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;
|
||||
/**
|
||||
* delete a Feed from the store
|
||||
* @throws FeedIDNotFoundException
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* Save a post in the VRES TimeLine in the store
|
||||
* @deprecated use savePostToVRETimeline
|
||||
* @param feedKey feedKey
|
||||
* @param vreid vre identifier
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* 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 Post instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveAppPost(Post feed);
|
||||
/**
|
||||
* @deprecated use saveAppPost
|
||||
* Save a Post instance in the store
|
||||
* Use this if your app needs to attach more than one file to the post
|
||||
*
|
||||
* @param attachments a list of attachments starting from the second
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveAppFeed(Feed feed, List<Attachment> attachments);
|
||||
/**
|
||||
* Save a Post instance in the store
|
||||
* Use this if your app needs to attach more than one file to the post
|
||||
*
|
||||
* @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
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
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
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllPostsByApp instead
|
||||
* @param appid application identifier
|
||||
* return all the feeds belonging to the appid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @param appid application identifier
|
||||
* return all the feeds belonging to the appid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @deprecated use getRecentCommentedPostsByUserAndDate instead
|
||||
* @param userid the user identifier like andrea.rossi
|
||||
* @param timeInMillis the initial time in millis to be considered
|
||||
* @return a list of feeds commented by userid starting from timeInMillis
|
||||
* @throws Exception
|
||||
*/
|
||||
List<Feed> getRecentCommentedFeedsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
||||
/**
|
||||
* @param userid the user identifier like andrea.rossi
|
||||
* @param 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
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* return the most recent feeds for this user up to quantity param
|
||||
* @param userid user identifier
|
||||
* @param quantity the number of most recent feeds for this user
|
||||
* @return a <class>List</class> of most recent feeds for this user
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllPostsByVRE
|
||||
* @param vreid vre identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @param vreid vre identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
|
||||
/**
|
||||
* @deprecated use getRecentPostsByVRE
|
||||
* return the most recent feeds for this vre up to quantity param
|
||||
* @param vreid VRES identifier
|
||||
* @param quantity the number of most recent feeds for this vre
|
||||
* @return a <class>List</class> of most recent feeds for this vre
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* 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
|
||||
* @return a <class>lastReturnedFeedTimelineIndex</class> containing of most recent feeds for this vre
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline
|
||||
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
boolean saveNotification(Notification notification);
|
||||
/**
|
||||
* set an existing Notification instance in the to read
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* read a notification from a given id
|
||||
* @throws {@link ColumnNameNotFoundException}
|
||||
* @throws {@link NotificationIDNotFoundException}
|
||||
* @throws {@link NotificationTypeNotFoundException}
|
||||
*/
|
||||
Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- notifications
|
||||
* return all the notifications belonging to the userid up to limit, set 0 to get everything
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @param from the range start has to be greater than 0
|
||||
* @param quantity the number of most recent notifications for this user starting from "from" param
|
||||
* @return all the notifications for the userid in the range requested
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationIDNotFoundException
|
||||
*/
|
||||
List<Notification> getRangeNotificationsByUser(String userid, int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
* This is a fast way to set all notification to read quickly
|
||||
* @param userid
|
||||
* @return true if everything went fine
|
||||
* @throws {@link ColumnNameNotFoundException}
|
||||
* @throws {@link NotificationIDNotFoundException}
|
||||
* @throws {@link NotificationTypeNotFoundException}
|
||||
*/
|
||||
boolean setAllNotificationReadByUser(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* return the not yet read notifications (not including messages)
|
||||
* @param userid user identifier
|
||||
* @return a <class>List</class> of not yet read notifications for this user
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws NotificationIDNotFoundException
|
||||
* @return true if there are unread notifications (not including messages), false if they are all read
|
||||
*/
|
||||
boolean checkUnreadNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationTypeNotFoundException self explaining
|
||||
* @throws NotificationChannelTypeNotFoundException self explaining
|
||||
* @throws NotificationIDNotFoundException
|
||||
* @return true if there are unread messages notifications (including messages), false if they are all read
|
||||
*/
|
||||
boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* return the channels a user chose for being notified for a given notification type
|
||||
* @param userid user identifier
|
||||
* @param notificationType the type of the notification
|
||||
* @return a list of <class>NotificationChannelType</class> that represents the channels this user wants to be notified
|
||||
*/
|
||||
List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException;
|
||||
/**
|
||||
* set the notification preferences map (enable or disable the channels to be used for notifying the user)
|
||||
* @param userid user identifier
|
||||
* @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
|
||||
*/
|
||||
boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels);
|
||||
/**
|
||||
* get the notification preferences map (enableor disable the channels to be used for notifying the user)
|
||||
* @param userid user identifier
|
||||
* @return the map
|
||||
* @throws NotificationTypeNotFoundException self explaining
|
||||
* @throws NotificationChannelTypeNotFoundException self explaining
|
||||
*/
|
||||
Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException;
|
||||
|
||||
/**
|
||||
* @param commentId comment unique identifier
|
||||
* @return the comment belonging to the commentId
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
Comment readCommentById(String commentId) throws CommentIDNotFoundException;
|
||||
/**
|
||||
* add a comment to a feed
|
||||
* @param comment the Comment instance to add
|
||||
*/
|
||||
boolean addComment(Comment comment) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllCommentByPost
|
||||
* @param feedid feed identifier
|
||||
* return all the comments belonging to the feedid
|
||||
*/
|
||||
List<Comment> getAllCommentByFeed(String feedid);
|
||||
/**
|
||||
* @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
|
||||
* @return a list of comments (sorted starting from the most recent one) made by the user since timeInMillis up to now
|
||||
*/
|
||||
List<Comment> getRecentCommentsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
||||
/**
|
||||
* edit a comment
|
||||
* @param comment the comment to edit
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* deletes a comment
|
||||
* @param commentid the comment identifier to delete
|
||||
* @param feedid the feedid to which the comment is associated
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* add a like to a feed
|
||||
* @param like instance
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean like(Like like) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* unlike a feed
|
||||
* @param userid user identifier
|
||||
* @param likeid the like identifier to delete
|
||||
* @param feedid the feedid to which the comment is associated
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllLikedPostIdsByUser
|
||||
* @param userid user identifier
|
||||
* return all the feedids a user has liked
|
||||
*/
|
||||
List<String> getAllLikedFeedIdsByUser(String userid);
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* return all the feedids a user has liked
|
||||
*/
|
||||
List<String> getAllLikedPostIdsByUser(String userid);
|
||||
/**
|
||||
* @deprecated use getAllLikedPostsByUser
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- liked feeds
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* return all the feeds a user has liked
|
||||
*/
|
||||
List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* return all the feeds a user has liked
|
||||
*/
|
||||
List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @deprecated use getRecentLikedPostsByUserAndDate
|
||||
* @param userid user identifier
|
||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||
* @return the likes made to feeds in the range from: today to: timeInMillis
|
||||
*/
|
||||
List<Feed> getRecentLikedFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||
* @return the likes made to feeds in the range from: today to: timeInMillis
|
||||
*/
|
||||
List<Post> getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
||||
/**
|
||||
* @deprecated use getAllLikesByPost
|
||||
* @param postid postid identifier
|
||||
* return all the likes belonging to the postid
|
||||
*/
|
||||
List<Like> getAllLikesByFeed(String postid);
|
||||
/**
|
||||
* @param postid postid identifier
|
||||
* return all the likes belonging to the postid
|
||||
*/
|
||||
List<Like> getAllLikesByPost(String postid);
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param postid the postid to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean saveHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param commentId the commentId to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param postid the postid to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean deleteHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param commentId the commentId to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException;
|
||||
/**
|
||||
* get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE
|
||||
* @param vreid vre identifier (scope)
|
||||
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
||||
*/
|
||||
Map<String, Integer> getVREHashtagsWithOccurrence(String vreid);
|
||||
/**
|
||||
* get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE
|
||||
* @param vreid vre identifier (scope)
|
||||
* @param timestamp do not consider hashtags used before timestamp
|
||||
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
||||
*/
|
||||
Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp);
|
||||
/**
|
||||
* @deprecated use getVREPostsByHashtag
|
||||
* @param vreid VRE identifier
|
||||
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @return all the feeds having the hashtag passed as parameter
|
||||
*/
|
||||
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param vreid VRE identifier
|
||||
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @return all the feeds having the hashtag passed as parameter
|
||||
*/
|
||||
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
|
||||
* @return {@link InviteOperationResult} SUCCESS, FAILED or ALREADY_INVITED (if an invite is sent to en existing email in the same environment more than once)
|
||||
*/
|
||||
InviteOperationResult saveInvite(Invite invite) throws AddressException;
|
||||
/**
|
||||
*
|
||||
* @param vreid the environment where you want to check the invite
|
||||
* @param email the email of the invite to check in the environmnet
|
||||
* @return the InviteId if present, null otherwise
|
||||
*/
|
||||
String isExistingInvite(String vreid, String email);
|
||||
/**
|
||||
* read an invite from a given id
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* set the status of an invite, see {@link InviteStatus}
|
||||
* @throws InviteIDNotFoundException
|
||||
*/
|
||||
boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* Use to get the list of invites per VRE
|
||||
* @param vreid the vre id
|
||||
* @param status optional, if you want to restict on the status, e.g. all pending invites
|
||||
* @return return the list of invites
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param feedId
|
||||
* @return the list of attachments of the feed feedId, starting from the second one (first attachment is included in Feed instance already)
|
||||
*/
|
||||
List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException;
|
||||
|
||||
/**
|
||||
* Retrieve all the ids of the vre
|
||||
* @return the set of ids of the vre available or empty list in case of errors.
|
||||
*/
|
||||
public List<String> getAllVREIds();
|
||||
|
||||
/**
|
||||
* close the connection to the underlying database
|
||||
*/
|
||||
void closeConnection();
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
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 org.gcube.common.portal.GCubePortalConstants;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.databook.shared.ex.TooManyRunningClustersException;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
|
||||
*
|
||||
* @version 2.0.0 October 2023
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RunningCluster implements Serializable {
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger _log = LoggerFactory.getLogger(RunningCluster.class);
|
||||
|
||||
/**
|
||||
* properties to read
|
||||
*/
|
||||
private static final String HOST_PROPERTY = "host";
|
||||
private static final String HOST_PORT_PROPERTY = "port";
|
||||
private static final String DATACENTER_NAME_PROPERTY = "datacenter";
|
||||
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
|
||||
/**
|
||||
* other constants
|
||||
*/
|
||||
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
|
||||
private final static String PLATFORM_NAME = "Cassandra";
|
||||
|
||||
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
|
||||
|
||||
private static RunningCluster singleton;
|
||||
/**
|
||||
* Host
|
||||
*/
|
||||
private String host;
|
||||
/**
|
||||
* Cluster Name
|
||||
*/
|
||||
private String datacenterName;
|
||||
/**
|
||||
* Keyspace Name
|
||||
*/
|
||||
private String keyspaceName; //to be modified
|
||||
|
||||
/**
|
||||
* @param infrastructureName could be null
|
||||
* @return an instance of the RunningCluster
|
||||
*/
|
||||
public static synchronized RunningCluster getInstance(String infrastructureName) {
|
||||
if (singleton == null) {
|
||||
singleton = new RunningCluster(infrastructureName);
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
/**
|
||||
* private constructor
|
||||
*/
|
||||
private RunningCluster(String infrastructureName) {
|
||||
//Query the IS (for the future)
|
||||
/*List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
||||
if (resources.size() > 1) {
|
||||
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
|
||||
throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name "
|
||||
+ RUNTIME_RESOURCE_NAME + " and Platform " + PLATFORM_NAME + ". Only one allowed per infrasrtucture.");
|
||||
}
|
||||
else if (resources.size() == 0){
|
||||
_log.error("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Platform " + PLATFORM_NAME + " in this scope. Using default configuration properties: " + DEFAULT_CONFIGURATION);
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
else {
|
||||
for (ServiceEndpoint res : resources) {
|
||||
AccessPoint found = res.profile().accessPoints().iterator().next();
|
||||
host = found.address();
|
||||
clusterName = found.description();
|
||||
keyspaceName = found.name();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
|
||||
datacenterName = "1";
|
||||
keyspaceName = "dev_mig_new_schema_test";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
|
||||
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
|
||||
String scope = "/";
|
||||
if(infrastructureName != null && !infrastructureName.isEmpty())
|
||||
scope += infrastructureName;
|
||||
else {
|
||||
scope += readInfrastructureName();
|
||||
_log.debug("infrastrucute name is null, setting root scope=" + scope);
|
||||
}
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_RESOURCE_NAME +"'");
|
||||
query.addCondition("$resource/Profile/Platform/Name/text() eq '"+ PLATFORM_NAME +"'");
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
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);
|
||||
String propertyfile = sb.toString();
|
||||
File propsFile = new File(propertyfile);
|
||||
FileInputStream fis = new FileInputStream(propsFile);
|
||||
props.load( fis);
|
||||
return props.getProperty(GCubePortalConstants.INFRASTRUCTURE_NAME);
|
||||
}
|
||||
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);
|
||||
datacenterName = props.getProperty(DATACENTER_NAME_PROPERTY);
|
||||
keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
||||
public String getKeyspaceName() {
|
||||
return keyspaceName;
|
||||
}
|
||||
|
||||
|
||||
public void setKeyspaceName(String keyspaceName) {
|
||||
this.keyspaceName = keyspaceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
public class Schema {
|
||||
//Tables
|
||||
public static final String NOTIFICATIONS = "Notifications";
|
||||
public static final String POSTS = "Posts";
|
||||
public static final String COMMENTS = "Comments";
|
||||
public static final String LIKES = "Likes";
|
||||
public static final String INVITES = "Invites";
|
||||
public static final String VRE_TIMELINE_POSTS = "VRETimeline";
|
||||
public static final String USER_TIMELINE_POSTS = "UserTimeline";
|
||||
public static final String APP_TIMELINE_POSTS = "AppTimeline";
|
||||
public static final String USER_LIKED_POSTS = "UserLikes";
|
||||
public static final String USER_NOTIFICATIONS = "UserNotifications"; // regular user notifications timeline (both read and unread, messages are included)
|
||||
public static final String USER_NOTIFICATIONS_UNREAD = "UserUnreadNotifications"; // only unread user notifications/ notifications messages
|
||||
public static final String USER_NOTIFICATIONS_PREFERENCES = "UserNotificationsPreferences"; // preferences for notifications
|
||||
public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type
|
||||
public static final String HASHTAGGED_POSTS = "HashtaggedPosts"; // contains hashtags per type associated with vre and POST
|
||||
public static final String HASHTAGGED_COMMENTS = "HashtaggedComments"; // contains hashtags per type associated with vre and comment
|
||||
public static final String VRE_INVITES = "VREInvites"; //contains the emails that were invited per VRE
|
||||
public static final String EMAIL_INVITES = "EmailInvites"; //contains the list of invitation per email
|
||||
public static final String ATTACHMENTS = "Attachments"; //contains the list of all the attachments in a POST
|
||||
|
||||
//columns
|
||||
public static final String USER_ID = "userid"; //text
|
||||
public static final String TYPE = "type"; //text
|
||||
public static final String PREFERENCE = "preference"; //text
|
||||
public static final String TIMESTAMP = "timestamp"; //timestamp
|
||||
public static final String NOT_ID = "notid"; //UUID
|
||||
public static final String VRE_ID = "vreid"; //text
|
||||
public static final String POST_ID = "postid"; //UUID
|
||||
public static final String APP_ID = "appid"; //text
|
||||
public static final String HASHTAG = "hashtag"; //text
|
||||
public static final String COMMENT_ID = "commentid"; //UUID
|
||||
public static final String COUNT = "count"; //big int
|
||||
public static final String LIKE_ID = "likeid"; //UUID
|
||||
public static final String INVITE_ID = "inviteid"; //UUID
|
||||
public static final String STATUS = "status"; //text
|
||||
public static final String EMAIL = "email"; //text
|
||||
public static final String ATTACH_ID = "attachid"; //UUID
|
||||
public static final String URI = "uri"; //text
|
||||
public static final String NAME = "name"; //text
|
||||
public static final String DESCRIPTION = "description"; //text
|
||||
public static final String URI_THUMBNAIL = "urithumbnail"; //text
|
||||
public static final String MIME_TYPE = "mimetype"; //text
|
||||
public static final String SENDER_USER_ID = "senderuserid"; //text
|
||||
public static final String CONTROL_CODE = "controlcode"; //text
|
||||
public static final String SENDER_FULL_NAME = "senderfullname"; //text
|
||||
public static final String FULL_NAME = "fullname"; //text
|
||||
public static final String THUMBNAIL_URL = "thumbnailurl"; //text
|
||||
public static final String COMMENT = "comment"; //text
|
||||
public static final String IS_EDIT = "isedit"; //bool
|
||||
public static final String LAST_EDIT_TIME = "lastedittime"; //timestamp
|
||||
public static final String SUBJECT_ID = "subjectid"; //text
|
||||
public static final String SENDER_ID = "senderid"; //text
|
||||
public static final String SENDER_THUMBNAIL_URL = "senderthumbnailurl"; //text
|
||||
public static final String IS_READ = "isread"; //bool
|
||||
public static final String LINK_HOST = "linkhost"; //text
|
||||
public static final String LIKES_NO = "likesno"; //big int
|
||||
public static final String LINK_DESCRIPTION = "linkdescription"; //text
|
||||
public static final String IS_APPLICATION_POST = "isapplicationpost"; //bool -->
|
||||
public static final String ENTITY_ID = "entityid"; //text
|
||||
public static final String PRIVACY = "privacy"; //text
|
||||
public static final String MULTI_FILE_UPLOAD = "multifileupload"; //bool
|
||||
public static final String COMMENTS_NO = "commentsno"; //big int
|
||||
public static final String LINK_TITLE = "linktitle"; //text
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import org.gcube.portal.databook.shared.*;
|
||||
import org.gcube.portal.databook.shared.ex.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Tester {
|
||||
private static 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
host = node1.d.cassandra.research-infrastructures.eu
|
||||
port = 9160
|
||||
cluster = D4Science Cluster
|
||||
keyspace = DevKeySpace
|
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 Dec 2012
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ApplicationProfile implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String imageUrl;
|
||||
private String scope;
|
||||
private String url;
|
||||
|
||||
public ApplicationProfile() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.imageUrl = imageUrl;
|
||||
this.scope = scope;
|
||||
this.url = url;
|
||||
}
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
|
||||
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
|
||||
+ ", url=" + url + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jsonmaker.gwt.client.Jsonizer;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Attachment implements Serializable {
|
||||
|
||||
public interface AttachmentJsonizer extends Jsonizer {}
|
||||
|
||||
private String id;
|
||||
private String uri;
|
||||
private String name;
|
||||
private String description;
|
||||
private String thumbnailURL;
|
||||
private String mimeType;
|
||||
|
||||
public Attachment() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id in the cassandra CF
|
||||
* @param uri where you can download the file from
|
||||
* @param name the name of the attached file
|
||||
* @param description the description of the attached file
|
||||
* @param thumbnailURL the URL of the image representing the attached file
|
||||
* @param mimeType the type of file
|
||||
*/
|
||||
public Attachment(String id, String uri, String name, String description,
|
||||
String thumbnailURL, String mimeType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.uri = uri;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attachment [uri=" + uri + ", name=" + name + ", description="
|
||||
+ description + ", thumbnailURL=" + thumbnailURL
|
||||
+ ", mimeType=" + mimeType + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import jsinterop.annotations.JsOverlay;
|
||||
import jsinterop.annotations.JsPackage;
|
||||
import jsinterop.annotations.JsType;
|
||||
|
||||
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
|
||||
public class ClientAttachment {
|
||||
public String id;
|
||||
public String uri;
|
||||
public String name;
|
||||
public String description;
|
||||
public String thumbnailURL;
|
||||
public String mimeType;
|
||||
/**
|
||||
* @param id the id in the cassandra CF
|
||||
* @param uri where you can download the file from
|
||||
* @param name the name of the attached file
|
||||
* @param description the description of the attached file
|
||||
* @param thumbnailURL the URL of the image representing the attached file
|
||||
* @param mimeType the type of file
|
||||
*/
|
||||
@JsOverlay
|
||||
public static ClientAttachment create(String id, String uri, String name, String description, String thumbnailURL, String mimeType) {
|
||||
ClientAttachment o = new ClientAttachment();
|
||||
o.id = id;
|
||||
o.uri = uri;
|
||||
o.name = name;
|
||||
o.description = description;
|
||||
o.thumbnailURL = thumbnailURL;
|
||||
o.mimeType = mimeType;
|
||||
return o;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jsonmaker.gwt.client.Jsonizer;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ClientFeed implements Serializable {
|
||||
|
||||
public interface ClientFeedJsonizer extends Jsonizer {}
|
||||
|
||||
private String key;
|
||||
private String type;
|
||||
private String userid;
|
||||
private Date time;
|
||||
private String uri;
|
||||
private String description;
|
||||
private String fullName;
|
||||
private String email;
|
||||
private String thumbnailURL;
|
||||
private String linkTitle;
|
||||
private String linkDescription;
|
||||
private String linkUrlThumbnail;
|
||||
private String linkHost;
|
||||
private List<Attachment> attachments;
|
||||
|
||||
public ClientFeed() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ClientFeed(String key, String type, String userid, Date time,
|
||||
String uri, String description, String fullName, String email,
|
||||
String thumbnailURL, String linkTitle, String linkDescription,
|
||||
String linkUrlThumbnail, String linkHost, List<Attachment> attachments) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.userid = userid;
|
||||
this.time = time;
|
||||
this.uri = uri;
|
||||
this.description = description;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.linkTitle = linkTitle;
|
||||
this.linkDescription = linkDescription;
|
||||
this.linkUrlThumbnail = linkUrlThumbnail;
|
||||
this.linkHost = linkHost;
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getLinkTitle() {
|
||||
return linkTitle;
|
||||
}
|
||||
|
||||
public void setLinkTitle(String linkTitle) {
|
||||
this.linkTitle = linkTitle;
|
||||
}
|
||||
|
||||
public String getLinkDescription() {
|
||||
return linkDescription;
|
||||
}
|
||||
|
||||
public void setLinkDescription(String linkDescription) {
|
||||
this.linkDescription = linkDescription;
|
||||
}
|
||||
|
||||
public String getLinkUrlThumbnail() {
|
||||
return linkUrlThumbnail;
|
||||
}
|
||||
|
||||
public void setLinkUrlThumbnail(String linkUrlThumbnail) {
|
||||
this.linkUrlThumbnail = linkUrlThumbnail;
|
||||
}
|
||||
|
||||
public String getLinkHost() {
|
||||
return linkHost;
|
||||
}
|
||||
|
||||
public void setLinkHost(String linkHost) {
|
||||
this.linkHost = linkHost;
|
||||
}
|
||||
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void setAttachments(List<Attachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientFeed [key=" + key + ", type=" + type + ", userid="
|
||||
+ userid + ", time=" + time + ", uri=" + uri + ", description="
|
||||
+ description + ", fullName=" + fullName + ", email=" + email
|
||||
+ ", thumbnailURL=" + thumbnailURL + ", linkTitle=" + linkTitle
|
||||
+ ", linkDescription=" + linkDescription
|
||||
+ ", linkUrlThumbnail=" + linkUrlThumbnail + ", linkHost="
|
||||
+ linkHost + ", attachments=" + attachments + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import jsinterop.annotations.JsOverlay;
|
||||
import jsinterop.annotations.JsPackage;
|
||||
import jsinterop.annotations.JsType;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, CNR-ISTI
|
||||
* Uses JsInterop annotations to deserialize the object
|
||||
*/
|
||||
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
|
||||
public class ClientPost {
|
||||
public String key;
|
||||
public String type;
|
||||
public String userid;
|
||||
public Date time;
|
||||
public String uri;
|
||||
public String description;
|
||||
public String fullName;
|
||||
public String email;
|
||||
public String thumbnailURL;
|
||||
public String linkTitle;
|
||||
public String linkDescription;
|
||||
public String linkUrlThumbnail;
|
||||
public String linkHost;
|
||||
public ClientAttachment[] attachments;
|
||||
@JsOverlay
|
||||
public static ClientPost create(String key, String type, String userid, Date time,
|
||||
String uri, String description, String fullName, String email,
|
||||
String thumbnailURL, String linkTitle, String linkDescription,
|
||||
String linkUrlThumbnail, String linkHost, ClientAttachment[] attachments) {
|
||||
ClientPost o = new ClientPost();
|
||||
o.key = key;
|
||||
o.type = type;
|
||||
o.userid = userid;
|
||||
o.time = time;
|
||||
o.uri = uri;
|
||||
o.description = description;
|
||||
o.fullName = fullName;
|
||||
o.email = email;
|
||||
o.thumbnailURL = thumbnailURL;
|
||||
o.linkTitle = linkTitle;
|
||||
o.linkDescription = linkDescription;
|
||||
o.linkUrlThumbnail = linkUrlThumbnail;
|
||||
o.linkHost = linkHost;
|
||||
o.attachments = attachments;
|
||||
return o;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 July 2012
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Comment implements Serializable, Comparable<Comment> {
|
||||
|
||||
private String key;
|
||||
private String userid;
|
||||
private Date time;
|
||||
private String feedid;
|
||||
private String text;
|
||||
private String fullName;
|
||||
private String thumbnailURL;
|
||||
private boolean isEdit; // false default
|
||||
private Date lastEditTime; // null default
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Comment() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param userid
|
||||
* @param time
|
||||
* @param feedid
|
||||
* @param text
|
||||
* @param fullName
|
||||
* @param thumbnailURL
|
||||
*/
|
||||
public Comment(String key, String userid, Date time, String feedid,
|
||||
String text, String fullName, String thumbnailURL) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.userid = userid;
|
||||
this.time = time;
|
||||
this.feedid = feedid;
|
||||
this.text = text;
|
||||
this.fullName = fullName;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.isEdit = false;
|
||||
this.lastEditTime = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for edited comment
|
||||
* @param key
|
||||
* @param userid
|
||||
* @param time
|
||||
* @param feedid
|
||||
* @param text
|
||||
* @param fullName
|
||||
* @param thumbnailURL
|
||||
* @param isEdit
|
||||
* @param editDate
|
||||
*/
|
||||
public Comment(String key, String userid, Date time, String feedid,
|
||||
String text, String fullName, String thumbnailURL, boolean isEdit, Date editDate) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.userid = userid;
|
||||
this.time = time;
|
||||
this.feedid = feedid;
|
||||
this.text = text;
|
||||
this.fullName = fullName;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.isEdit = isEdit;
|
||||
this.lastEditTime = editDate;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the text
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param text text to add as string
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the uuid
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getFeedid() {
|
||||
return feedid;
|
||||
}
|
||||
|
||||
public void setFeedid(String feedid) {
|
||||
this.feedid = feedid;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public boolean isEdit() {
|
||||
return isEdit;
|
||||
}
|
||||
public void setEdit(boolean isEdit) {
|
||||
this.isEdit = isEdit;
|
||||
}
|
||||
public Date getLastEditTime() {
|
||||
return lastEditTime;
|
||||
}
|
||||
public void setLastEditTime(Date lastEditTime) {
|
||||
this.lastEditTime = lastEditTime;
|
||||
}
|
||||
public int compareTo(Comment toCompare) {
|
||||
if (this.time.after(toCompare.getTime()))
|
||||
return 1;
|
||||
if (this.time.before(toCompare.getTime()))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Comment [key=" + key + ", userid=" + userid + ", time=" + time
|
||||
+ ", feedid=" + feedid + ", text=" + text + ", fullName="
|
||||
+ fullName + ", thumbnailURL=" + thumbnailURL + ", isEdit="
|
||||
+ isEdit + ", lastEditTime=" + lastEditTime + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
/**
|
||||
*
|
||||
* @author massi
|
||||
* This class contains addtional user related information about a Feed
|
||||
* e.g. if this user has liked it
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EnhancedFeed implements Serializable{
|
||||
private Feed feed;
|
||||
private boolean liked;
|
||||
private boolean isUsers;
|
||||
private ArrayList<Comment> comments;
|
||||
private ArrayList<Attachment> attachments;
|
||||
|
||||
|
||||
public EnhancedFeed() {
|
||||
super();
|
||||
}
|
||||
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers) {
|
||||
super();
|
||||
this.feed = feed;
|
||||
this.liked = liked;
|
||||
this.isUsers = isUsers;
|
||||
}
|
||||
|
||||
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers, ArrayList<Comment> comments) {
|
||||
super();
|
||||
this.isUsers = isUsers;
|
||||
this.feed = feed;
|
||||
this.liked = liked;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
|
||||
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers,
|
||||
ArrayList<Comment> comments, ArrayList<Attachment> attachments) {
|
||||
super();
|
||||
this.feed = feed;
|
||||
this.liked = liked;
|
||||
this.isUsers = isUsers;
|
||||
this.comments = comments;
|
||||
this.attachments = attachments;
|
||||
}
|
||||
public ArrayList<Comment> getComments() {
|
||||
return comments;
|
||||
}
|
||||
public void setComments(ArrayList<Comment> comments) {
|
||||
this.comments = comments;
|
||||
}
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
public void setFeed(Feed feed) {
|
||||
this.feed = feed;
|
||||
}
|
||||
public boolean isLiked() {
|
||||
return liked;
|
||||
}
|
||||
public void setLiked(boolean liked) {
|
||||
this.liked = liked;
|
||||
}
|
||||
public boolean isUsers() {
|
||||
return isUsers;
|
||||
}
|
||||
public void setUsers(boolean isUsers) {
|
||||
this.isUsers = isUsers;
|
||||
}
|
||||
public ArrayList<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
public void setAttachments(ArrayList<Attachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnhancedFeed [feed=" + feed + ", liked=" + liked + ", isUsers="
|
||||
+ isUsers + ", comments=" + comments + ", attachments="
|
||||
+ attachments + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,322 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @deprecated use <class>org.gcube.portal.databook.shared.Post</class> instead
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Feed implements Serializable, Comparable<Feed> {
|
||||
|
||||
private String key;
|
||||
private FeedType type;
|
||||
private String entityId;
|
||||
private Date time;
|
||||
private String vreid;
|
||||
private String uri;
|
||||
private String uriThumbnail;
|
||||
private String description;
|
||||
private PrivacyLevel privacy;
|
||||
private String fullName;
|
||||
private String email;
|
||||
private String thumbnailURL;
|
||||
private String commentsNo;
|
||||
private String likesNo;
|
||||
private String linkTitle;
|
||||
private String linkDescription;
|
||||
private String linkHost;
|
||||
boolean applicationFeed;
|
||||
/**
|
||||
* this boolean indicates that the attachments to the post are > 1
|
||||
*/
|
||||
boolean multiFileUpload;
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public Feed() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* To use ONLY for USER Feeds
|
||||
*
|
||||
*
|
||||
* @param key a UUID
|
||||
* @param type an instance of <class>FeedType</class>
|
||||
* @param entityId the user or the app unique indentifier
|
||||
* @param time when
|
||||
* @param vreid a unique vre id
|
||||
* @param uri optional uri
|
||||
* @param uriThumbnail the thumbnail for the link posted
|
||||
* @param description optional description
|
||||
* @param privacy the privacy level of <class>PrivacyLevel</class>
|
||||
* @param fullName
|
||||
* @param email
|
||||
* @param thumbnailURL this is the user thumbnail url
|
||||
* @param linkTitle optional to be used when posting links
|
||||
* @param linkDescription optional to be used when posting links
|
||||
* @param linkHost option to be used when posting linkgs
|
||||
*/
|
||||
public Feed(String key, FeedType type, String entityId, Date time,
|
||||
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
||||
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.entityId = entityId;
|
||||
this.time = time;
|
||||
this.vreid = vreid;
|
||||
this.uri = uri;
|
||||
this.uriThumbnail = uriThumbnail;
|
||||
this.description = description;
|
||||
this.privacy = privacy;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.commentsNo = "0";
|
||||
this.likesNo = "0";
|
||||
this.linkDescription = linkDescription;
|
||||
this.linkTitle = linkTitle;
|
||||
this.linkHost = linkHost;
|
||||
this.applicationFeed = false;
|
||||
}
|
||||
/**
|
||||
* To use for USER and ApplicationProfile Feeds
|
||||
*
|
||||
* @param key a UUID
|
||||
* @param type an instance of <class>FeedType</class>
|
||||
* @param entityId the user or the app unique indentifier
|
||||
* @param time when
|
||||
* @param vreid a unique vre id
|
||||
* @param uri optional uri
|
||||
* @param uriThumbnail the thumbnail for the link posted
|
||||
* @param description optional description
|
||||
* @param privacy the privacy level of <class>PrivacyLevel</class>
|
||||
* @param fullName
|
||||
* @param email
|
||||
* @param thumbnailURL this is the user thumbnail url
|
||||
* @param linkTitle optional to be used when posting links
|
||||
* @param linkDescription optional to be used when posting links
|
||||
* @param applicationFeed tell if this is an application feed or a user feed
|
||||
*/
|
||||
public Feed(String key, FeedType type, String entityId, Date time,
|
||||
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
||||
String fullName, String email, String thumbnailURL, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed) {
|
||||
this(key, type, entityId, time, vreid, uri, uriThumbnail, description, privacy, fullName, email, thumbnailURL, linkTitle, linkDescription, linkHost);
|
||||
this.applicationFeed = applicationFeed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* for serialization purposes
|
||||
* @param key a UUID
|
||||
* @param type an instance of <class>FeedType</class>
|
||||
* @param entityId the user or the app unique indentifier
|
||||
* @param time when
|
||||
* @param vreid a unique vre id
|
||||
* @param uri optional uri
|
||||
* @param uriThumbnail the thumbnail for the link posted
|
||||
* @param description optional description
|
||||
* @param privacy the privacy level of <class>PrivacyLevel</class>
|
||||
* @param fullName
|
||||
* @param email
|
||||
* @param thumbnailURL this is the user thumbnail url
|
||||
* @param linkTitle optional to be used when posting links
|
||||
* @param linkDescription optional to be used when posting links
|
||||
*/
|
||||
public Feed(String key, FeedType type, String entityId, Date time,
|
||||
String vreid, String uri, String uriThumbnail, String description, PrivacyLevel privacy,
|
||||
String fullName, String email, String thumbnailURL, String commentsNo,
|
||||
String likesNo, String linkTitle, String linkDescription, String linkHost, boolean applicationFeed, boolean multiFileUpload) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.entityId = entityId;
|
||||
this.time = time;
|
||||
this.vreid = vreid;
|
||||
this.uri = uri;
|
||||
this.uriThumbnail = uriThumbnail;
|
||||
this.description = description;
|
||||
this.privacy = privacy;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.commentsNo = commentsNo;
|
||||
this.likesNo = likesNo;
|
||||
this.linkDescription = linkDescription;
|
||||
this.linkTitle = linkTitle;
|
||||
this.linkHost = linkHost;
|
||||
this.applicationFeed = applicationFeed;
|
||||
this.multiFileUpload = multiFileUpload;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public FeedType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(FeedType type) {
|
||||
this.type = type;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the User or the App id
|
||||
*/
|
||||
public String getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
/**
|
||||
* set the User or the App id
|
||||
* @param entityId the UserId or the AppId id
|
||||
*/
|
||||
public void setEntityId(String entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getVreid() {
|
||||
return vreid;
|
||||
}
|
||||
|
||||
public void setVreid(String vreid) {
|
||||
this.vreid = vreid;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public PrivacyLevel getPrivacy() {
|
||||
return privacy;
|
||||
}
|
||||
|
||||
public void setPrivacy(PrivacyLevel privacy) {
|
||||
this.privacy = privacy;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getCommentsNo() {
|
||||
return commentsNo;
|
||||
}
|
||||
public void setCommentsNo(String commentsNo) {
|
||||
this.commentsNo = commentsNo;
|
||||
}
|
||||
public String getLikesNo() {
|
||||
return likesNo;
|
||||
}
|
||||
public void setLikesNo(String likesNo) {
|
||||
this.likesNo = likesNo;
|
||||
}
|
||||
public String getUriThumbnail() {
|
||||
return uriThumbnail;
|
||||
}
|
||||
public void setUriThumbnail(String uriThumbnail) {
|
||||
this.uriThumbnail = uriThumbnail;
|
||||
}
|
||||
|
||||
public String getLinkTitle() {
|
||||
return linkTitle;
|
||||
}
|
||||
public void setLinkTitle(String linkTitle) {
|
||||
this.linkTitle = linkTitle;
|
||||
}
|
||||
public String getLinkDescription() {
|
||||
return linkDescription;
|
||||
}
|
||||
public void setLinkDescription(String linkDescription) {
|
||||
this.linkDescription = linkDescription;
|
||||
}
|
||||
public int compareTo(Feed toCompare) {
|
||||
if (this.time.after(toCompare.getTime()))
|
||||
return 1;
|
||||
if (this.time.before(toCompare.getTime()))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
public String getLinkHost() {
|
||||
return linkHost;
|
||||
}
|
||||
public void setLinkHost(String linkHost) {
|
||||
this.linkHost = linkHost;
|
||||
}
|
||||
|
||||
public boolean isApplicationFeed() {
|
||||
return applicationFeed;
|
||||
}
|
||||
public void setApplicationFeed(boolean applicationFeed) {
|
||||
this.applicationFeed = applicationFeed;
|
||||
}
|
||||
public boolean isMultiFileUpload() {
|
||||
return multiFileUpload;
|
||||
}
|
||||
public void setMultiFileUpload(boolean multiFileUpload) {
|
||||
this.multiFileUpload = multiFileUpload;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Feed [key=" + key + ", type=" + type + ", entityId=" + entityId
|
||||
+ ", time=" + time + ", vreid=" + vreid + ", uri=" + uri
|
||||
+ ", uriThumbnail=" + uriThumbnail + ", description="
|
||||
+ description + ", privacy=" + privacy + ", fullName="
|
||||
+ fullName + ", email=" + email + ", thumbnailURL="
|
||||
+ thumbnailURL + ", commentsNo=" + commentsNo + ", likesNo="
|
||||
+ likesNo + ", linkTitle=" + linkTitle + ", linkDescription="
|
||||
+ linkDescription + ", linkHost=" + linkHost
|
||||
+ ", applicationFeed=" + applicationFeed
|
||||
+ ", multiFileUpload=" + multiFileUpload + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @deprecated use PostType
|
||||
* @version 1.2 October 2012
|
||||
*/
|
||||
public enum FeedType {
|
||||
JOIN, SHARE, PUBLISH, TWEET, CONNECTED,
|
||||
/**
|
||||
* Special case used when accounting
|
||||
*/
|
||||
ACCOUNTING,
|
||||
/**
|
||||
* Special case used when a Feed is removed
|
||||
*/
|
||||
DISABLED;
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum ImageType {
|
||||
JPG, GIF, PNG, TIFF, PDF, BMP;
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Invite implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String senderUserId;
|
||||
private String vreid;
|
||||
private String invitedEmail;
|
||||
private String controlCode;
|
||||
private InviteStatus status;
|
||||
private Date time;
|
||||
private String senderFullName;
|
||||
|
||||
|
||||
public Invite() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Invite(String key, String senderUserId, String vreid,
|
||||
String invitedEmail, String controlCode, InviteStatus status,
|
||||
Date time, String senderFullName) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.senderUserId = senderUserId;
|
||||
this.vreid = vreid;
|
||||
this.invitedEmail = invitedEmail;
|
||||
this.controlCode = controlCode;
|
||||
this.status = status;
|
||||
this.time = time;
|
||||
this.senderFullName = senderFullName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getSenderUserId() {
|
||||
return senderUserId;
|
||||
}
|
||||
|
||||
|
||||
public void setSenderUserId(String senderUserId) {
|
||||
this.senderUserId = senderUserId;
|
||||
}
|
||||
|
||||
|
||||
public String getVreid() {
|
||||
return vreid;
|
||||
}
|
||||
|
||||
|
||||
public void setVreid(String vreid) {
|
||||
this.vreid = vreid;
|
||||
}
|
||||
|
||||
|
||||
public String getInvitedEmail() {
|
||||
return invitedEmail;
|
||||
}
|
||||
|
||||
|
||||
public void setInvitedEmail(String invitedEmail) {
|
||||
this.invitedEmail = invitedEmail;
|
||||
}
|
||||
|
||||
|
||||
public String getControlCode() {
|
||||
return controlCode;
|
||||
}
|
||||
|
||||
|
||||
public void setControlCode(String controlCode) {
|
||||
this.controlCode = controlCode;
|
||||
}
|
||||
|
||||
|
||||
public InviteStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(InviteStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
public String getSenderFullName() {
|
||||
return senderFullName;
|
||||
}
|
||||
|
||||
|
||||
public void setSenderFullName(String senderFullName) {
|
||||
this.senderFullName = senderFullName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Invite [key=" + key + ", senderUserId=" + senderUserId
|
||||
+ ", vreid=" + vreid + ", invitedEmail=" + invitedEmail
|
||||
+ ", controlCode=" + controlCode + ", status=" + status
|
||||
+ ", time=" + time + ", senderFullName=" + senderFullName + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum InviteOperationResult {
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
//If I send an invite the same email in the same environment more than once
|
||||
ALREADY_INVITED;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum InviteStatus {
|
||||
/**
|
||||
* First status of anyh invite
|
||||
*/
|
||||
PENDING,
|
||||
/**
|
||||
* User accepted the invite
|
||||
*/
|
||||
ACCEPTED,
|
||||
/**
|
||||
* User rejected the invite
|
||||
*/
|
||||
REJECTED,
|
||||
/**
|
||||
* Manager withdrawed the invite
|
||||
*/
|
||||
RETRACTED;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import jsinterop.annotations.JsPackage;
|
||||
import jsinterop.annotations.JsType;
|
||||
|
||||
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
|
||||
public class JSON {
|
||||
public static native String stringify(Object o);
|
||||
public static native <O> O parse(String json);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 Dec 2012
|
||||
*
|
||||
*/
|
||||
public enum JobStatusType {
|
||||
/**
|
||||
* The job has been cancelled.
|
||||
*/
|
||||
CANCELLED,
|
||||
/**
|
||||
* The job is in the process of being cancelled.
|
||||
*/
|
||||
CANCELLING,
|
||||
/**
|
||||
* The job has been deleted.
|
||||
*/
|
||||
DELETED,
|
||||
/**
|
||||
* The job is in the process of being deleted.
|
||||
*/
|
||||
DELETING,//
|
||||
/**
|
||||
* The job is being executed by job processor.
|
||||
*/
|
||||
EXECUTING,//
|
||||
/**
|
||||
* he job execution has failed.
|
||||
*/
|
||||
FAILED,
|
||||
/**
|
||||
* The job is new.
|
||||
*/
|
||||
NEW,//
|
||||
/**
|
||||
* The job is submitted for execution.
|
||||
*/
|
||||
SUBMITTED,
|
||||
/**
|
||||
* The job has completed successfully
|
||||
*/
|
||||
SUCCEEDED,
|
||||
/**
|
||||
* The job execution has timed out.
|
||||
*/
|
||||
TIMED_OUT,
|
||||
/**
|
||||
* The job is waiting for available job processor.
|
||||
*/
|
||||
WAITING
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 July 2012
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Like implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String userid;
|
||||
private Date time;
|
||||
private String feedid;
|
||||
private String fullName;
|
||||
private String thumbnailURL;
|
||||
|
||||
public Like() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Like(String key, String userid, Date time, String feedid,
|
||||
String fullName, String thumbnailURL) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.userid = userid;
|
||||
this.time = time;
|
||||
this.feedid = feedid;
|
||||
this.fullName = fullName;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getFeedid() {
|
||||
return feedid;
|
||||
}
|
||||
|
||||
public void setFeedid(String feedid) {
|
||||
this.feedid = feedid;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "KEY: " + key + " Time: "+ time + "\nuserid: "+userid + " Full name: " + fullName;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Notification implements Serializable {
|
||||
|
||||
private String key;
|
||||
private NotificationType type;
|
||||
private String userid;
|
||||
private String subjectid;
|
||||
private Date time;
|
||||
private String uri;
|
||||
private String description;
|
||||
private boolean read;
|
||||
private String senderid;
|
||||
private String senderFullName;
|
||||
private String senderThumbnail;
|
||||
private String commentKey;
|
||||
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public Notification() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @param userid
|
||||
* @param subjectid the subject id of this notification, if is a like on a feed then is the feedid, it is a message then is the messageid and so on
|
||||
* @param time
|
||||
* @param uri
|
||||
* @param description
|
||||
* @param read
|
||||
* @param senderid
|
||||
* @param senderFullName
|
||||
* @param senderThumbnail
|
||||
*/
|
||||
public Notification(String key, NotificationType type, String userid,
|
||||
String subjectid, Date time, String uri, String description,
|
||||
boolean read, String senderid, String senderFullName,
|
||||
String senderThumbnail) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.userid = userid;
|
||||
this.subjectid = subjectid;
|
||||
this.time = time;
|
||||
this.uri = uri;
|
||||
this.description = description;
|
||||
this.read = read;
|
||||
this.senderid = senderid;
|
||||
this.senderFullName = senderFullName;
|
||||
this.senderThumbnail = senderThumbnail;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @param userid
|
||||
* @param subjectid the subject id of this notification, if is a like on a feed then is the feedid, it is a message then is the messageid and so on
|
||||
* @param time
|
||||
* @param uri
|
||||
* @param description
|
||||
* @param read
|
||||
* @param senderid
|
||||
* @param senderFullName
|
||||
* @param senderThumbnail
|
||||
* @param commentKey when a mail notification must be sent, stop the embedded discussion at this comment
|
||||
*/
|
||||
public Notification(String key, NotificationType type, String userid,
|
||||
String subjectid, Date time, String uri, String description,
|
||||
boolean read, String senderid, String senderFullName,
|
||||
String senderThumbnail, String commentKey) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.userid = userid;
|
||||
this.subjectid = subjectid;
|
||||
this.time = time;
|
||||
this.uri = uri;
|
||||
this.description = description;
|
||||
this.read = read;
|
||||
this.senderid = senderid;
|
||||
this.senderFullName = senderFullName;
|
||||
this.senderThumbnail = senderThumbnail;
|
||||
this.commentKey = commentKey;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return .
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
public NotificationType getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(NotificationType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
public void setRead(boolean read) {
|
||||
this.read = read;
|
||||
}
|
||||
public String getSenderid() {
|
||||
return senderid;
|
||||
}
|
||||
public void setSenderid(String senderid) {
|
||||
this.senderid = senderid;
|
||||
}
|
||||
public String getSenderFullName() {
|
||||
return senderFullName;
|
||||
}
|
||||
public void setSenderFullName(String senderFullName) {
|
||||
this.senderFullName = senderFullName;
|
||||
}
|
||||
public String getSenderThumbnail() {
|
||||
return senderThumbnail;
|
||||
}
|
||||
public void setSenderThumbnail(String senderThumbnail) {
|
||||
this.senderThumbnail = senderThumbnail;
|
||||
}
|
||||
public String getSubjectid() {
|
||||
return subjectid;
|
||||
}
|
||||
public void setSubjectid(String subjectid) {
|
||||
this.subjectid = subjectid;
|
||||
}
|
||||
|
||||
public String getCommentKey() {
|
||||
return commentKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setCommentKey(String commentKey) {
|
||||
this.commentKey = commentKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Notification [key=" + key + ", type=" + type + ", userid="
|
||||
+ userid + ", subjectid=" + subjectid + ", time=" + time
|
||||
+ ", uri=" + uri + ", description=" + description + ", read="
|
||||
+ read + ", senderid=" + senderid + ", senderFullName="
|
||||
+ senderFullName + ", senderThumbnail=" + senderThumbnail
|
||||
+ ", commentKey=" + commentKey + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*
|
||||
* @version 1.0 January 2012
|
||||
*/
|
||||
public enum NotificationChannelType {
|
||||
/**
|
||||
* PORTAL
|
||||
*/
|
||||
PORTAL,
|
||||
/**
|
||||
* EMAIL
|
||||
*/
|
||||
EMAIL,
|
||||
/**
|
||||
* TWITTER
|
||||
*/
|
||||
TWITTER;
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*
|
||||
* TODO: Buggy if NotificationType for WP_* are refactored see DBCassandraAstyanaxImpl#getUserNotificationPreferences(String userid)
|
||||
* introduced due to urgent matters
|
||||
*/
|
||||
public enum NotificationType {
|
||||
/**
|
||||
* use to notify a user he got a Tabular Resource shared
|
||||
*/
|
||||
TDM_TAB_RESOURCE_SHARE,
|
||||
/**
|
||||
* use to notify a user he got a TDM Rule shared
|
||||
*/
|
||||
TDM_RULE_SHARE,
|
||||
/**
|
||||
* use to notify a user he got a TDM Templated shared
|
||||
*/
|
||||
TDM_TEMPLATE_SHARE,
|
||||
/**
|
||||
* use to notify a user he got a workspace folder shared
|
||||
*/
|
||||
WP_FOLDER_SHARE,
|
||||
/**
|
||||
* use to notify a user that a user in the share unshared
|
||||
*/
|
||||
WP_FOLDER_UNSHARE,
|
||||
/**
|
||||
* use to notify a user that he got upgraded to administrator of a shared folder
|
||||
*/
|
||||
WP_ADMIN_UPGRADE,
|
||||
/**
|
||||
* use to notify a user that he got downgraded from administrator of a shared folder
|
||||
*/
|
||||
WP_ADMIN_DOWNGRADE,
|
||||
/**
|
||||
* use to notify a user that a new user was added in on of his workspace shared folder
|
||||
*/
|
||||
WP_FOLDER_ADDEDUSER,
|
||||
/**
|
||||
* use to notify a user that an existing user was removed from one of his workspace shared folder
|
||||
*/
|
||||
WP_FOLDER_REMOVEDUSER,
|
||||
/**
|
||||
* use to notify a user he got a workspace folder renamed
|
||||
*/
|
||||
WP_FOLDER_RENAMED,
|
||||
/**
|
||||
* use to notify a user he got a workspace item deleted from one of his workspace shared folder
|
||||
*/
|
||||
WP_ITEM_DELETE,
|
||||
/**
|
||||
* use to notify a user he got a workspace item updated from one of his workspace shared folder
|
||||
*/
|
||||
WP_ITEM_UPDATED,
|
||||
/**
|
||||
* use to notify a user he got a workspace item renamed from one of his workspace shared folder
|
||||
*/
|
||||
WP_ITEM_RENAMED,
|
||||
/**
|
||||
* use to notify a user he got a workspace item new in some of his workspace shared folder
|
||||
*/
|
||||
WP_ITEM_NEW,
|
||||
/**
|
||||
* use to notify a user he got one of his feed commented
|
||||
*/
|
||||
OWN_COMMENT,
|
||||
/**
|
||||
* use to notify a user that commented on a feed (Not his) that someone commented too
|
||||
*/
|
||||
COMMENT,
|
||||
/**
|
||||
* use to notify a user that he got mentioned in one post
|
||||
*/
|
||||
MENTION,
|
||||
/**
|
||||
* use to notify a user he got one of his feed liked
|
||||
*/
|
||||
LIKE,
|
||||
/**
|
||||
* use to notify a user he got a message
|
||||
*/
|
||||
MESSAGE,
|
||||
/**
|
||||
* use to notify every user of a VRE/Group that the post was made
|
||||
*/
|
||||
POST_ALERT,
|
||||
/**
|
||||
* use to notify a user that someone in his VRE created a new Event in the Calendar
|
||||
*/
|
||||
CALENDAR_ADDED_EVENT,
|
||||
/**
|
||||
* use to notify a user that someone in his VRE updated an Event in the Calendar
|
||||
*/
|
||||
CALENDAR_UPDATED_EVENT,
|
||||
/**
|
||||
* use to notify a user that someone in his VRE deleted an Event in the Calendar
|
||||
*/
|
||||
CALENDAR_DELETED_EVENT,
|
||||
/**
|
||||
* use to notify a user he got a connections request
|
||||
*/
|
||||
REQUEST_CONNECTION,
|
||||
/**
|
||||
* use to notify a user he got a job completed ok
|
||||
*/
|
||||
JOB_COMPLETED_OK,
|
||||
/**
|
||||
* use to notify a user he got a job completed not ok
|
||||
*/
|
||||
JOB_COMPLETED_NOK,
|
||||
/**
|
||||
* use to notify a document workflow owner that someone
|
||||
* has edited a document involved in a worflow he created
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_EDIT,
|
||||
/**
|
||||
* use to notify a document workflow owner that someone
|
||||
* has viewed a document involved in a worflow he created
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_VIEW,
|
||||
/**
|
||||
* use to notify a document workflow user (user that in the same document workflow)
|
||||
* that forwarded to a step where he is requested to do a task
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,
|
||||
/**
|
||||
* use to notify a document workflow user that he was involved into a new Document Workflow
|
||||
* and he is requested to do a task
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT,
|
||||
/**
|
||||
* use to notify a document workflow owner that a user performed a forward action to another step a document worflow he created
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER,
|
||||
/**
|
||||
* use to notify a document workflow owner that someone
|
||||
* forwarded and the workflow moved to another step a document worflow he created
|
||||
*/
|
||||
@Deprecated
|
||||
DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER,
|
||||
/**
|
||||
* use to notify a document workflow peer (user that in the same step has your same role)
|
||||
* that someone performed a forward action to another step in a document worflow he is involved into
|
||||
*/
|
||||
@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
|
||||
*/
|
||||
GENERIC;
|
||||
}
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*
|
||||
* @version 1.0 July 6th 2012
|
||||
*/
|
||||
public enum PrivacyLevel {
|
||||
PRIVATE, CONNECTION, VRES, SINGLE_VRE, PORTAL, PUBLIC;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @deprecated use RangePosts
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RangeFeeds implements Serializable {
|
||||
|
||||
private int lastReturnedFeedTimelineIndex;
|
||||
private ArrayList<Feed> feeds;
|
||||
|
||||
public RangeFeeds() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RangeFeeds(int lastReturnedFeedTimelineIndex, ArrayList<Feed> feeds) {
|
||||
super();
|
||||
this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex;
|
||||
this.feeds = feeds;
|
||||
}
|
||||
|
||||
public int getLastReturnedFeedTimelineIndex() {
|
||||
return lastReturnedFeedTimelineIndex;
|
||||
}
|
||||
public void setLastReturnedFeedTimelineIndex(int lastReturnedFeedTimelineIndex) {
|
||||
this.lastReturnedFeedTimelineIndex = lastReturnedFeedTimelineIndex;
|
||||
}
|
||||
public ArrayList<Feed> getFeeds() {
|
||||
return feeds;
|
||||
}
|
||||
public void setFeeds(ArrayList<Feed> feeds) {
|
||||
this.feeds = feeds;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The RunningJob class.
|
||||
* @author Massimiliano Assante, ISTI-CNR (massimiliano.assante@isti.cnr.it)
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RunningJob implements Serializable {
|
||||
|
||||
private String jobId;
|
||||
private String jobName;
|
||||
private JobStatusType status;
|
||||
private String message;
|
||||
private String serviceName; // i.e., Dataminer, SmartExecutor..
|
||||
|
||||
public RunningJob() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** Buind a RunningJob object.
|
||||
* @param jobId
|
||||
* @param jobName
|
||||
* @param status
|
||||
* @param message
|
||||
* @param serviceName
|
||||
*/
|
||||
public RunningJob(String jobId, String jobName, JobStatusType status,
|
||||
String message, String serviceName) {
|
||||
super();
|
||||
this.jobId = jobId;
|
||||
this.jobName = jobName;
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
public JobStatusType getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(JobStatusType status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RunningJob [" + (jobId != null ? "jobId=" + jobId + ", " : "")
|
||||
+ (jobName != null ? "jobName=" + jobName + ", " : "")
|
||||
+ (status != null ? "status=" + status + ", " : "")
|
||||
+ (message != null ? "message=" + message + ", " : "")
|
||||
+ (serviceName != null ? "serviceName=" + serviceName : "")
|
||||
+ "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
/**
|
||||
* Enum class that specify the possible actions to take when the GCubeSocialNetworking.SHOW_STATISTICS_ACTION_OID parameter
|
||||
* is found in the page url
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum ShowUserStatisticAction {
|
||||
|
||||
POSTS_MADE_BY_USER("Your recent posts"),
|
||||
LIKES_MADE_BY_USER("Posts you liked"),
|
||||
COMMENTS_MADE_BY_USER("Posts you commented"),
|
||||
LIKES_GOT_BY_USER("Likes to your posts"),
|
||||
COMMENTS_GOT_BY_USER("Replies to your posts");
|
||||
|
||||
private final String actionHumanFriendly;
|
||||
|
||||
private ShowUserStatisticAction(String s) {
|
||||
actionHumanFriendly = s;
|
||||
}
|
||||
|
||||
public String getHumanFriendlyAction() {
|
||||
return this.actionHumanFriendly;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class UserInfo implements Serializable {
|
||||
|
||||
public transient final static String USER_INFO_ATTR = "USER_INFO_ATTR";
|
||||
|
||||
private String username;
|
||||
|
||||
private String fullName;
|
||||
|
||||
private String avatarId;
|
||||
|
||||
private String emailaddress;
|
||||
|
||||
private String accountURL;
|
||||
|
||||
private boolean male;
|
||||
|
||||
private boolean admin;
|
||||
|
||||
private HashMap<String, String> ownVREs;
|
||||
|
||||
public UserInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserInfo(String username, String fullName, String avatarId,
|
||||
String emailaddress, String accountURL, boolean male,
|
||||
boolean admin, HashMap<String, String> ownVREs) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
this.avatarId = avatarId;
|
||||
this.emailaddress = emailaddress;
|
||||
this.accountURL = accountURL;
|
||||
this.male = male;
|
||||
this.admin = admin;
|
||||
this.ownVREs = ownVREs;
|
||||
}
|
||||
|
||||
public String getAccountURL() {
|
||||
return accountURL;
|
||||
}
|
||||
|
||||
public void setAccountURL(String accountURL) {
|
||||
this.accountURL = accountURL;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(String avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public String getEmailaddress() {
|
||||
return emailaddress;
|
||||
}
|
||||
|
||||
public void setEmailaddress(String emailaddress) {
|
||||
this.emailaddress = emailaddress;
|
||||
}
|
||||
|
||||
public boolean isMale() {
|
||||
return male;
|
||||
}
|
||||
|
||||
public void setMale(boolean male) {
|
||||
this.male = male;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getOwnVREs() {
|
||||
return ownVREs;
|
||||
}
|
||||
|
||||
public void setOwnVREs(HashMap<String, String> vreMap) {
|
||||
this.ownVREs = vreMap;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return admin;
|
||||
}
|
||||
|
||||
public void setAdmin(boolean admin) {
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserInfo [username=" + username + ", fullName=" + fullName
|
||||
+ ", avatarId=" + avatarId + ", emailaddress=" + emailaddress
|
||||
+ ", accountURL=" + accountURL + ", male=" + male + ", admin="
|
||||
+ admin + ", ownVREs=" + ownVREs + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ColumnNameNotFoundException extends Exception {
|
||||
public ColumnNameNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CommentIDNotFoundException extends Exception {
|
||||
public CommentIDNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedIDNotFoundException extends Exception {
|
||||
public FeedIDNotFoundException(String message, String postId) {
|
||||
super("The Post having id: " + postId + " is not present in the database: " + message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedTypeNotFoundException extends Exception {
|
||||
public FeedTypeNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InviteIDNotFoundException extends Exception {
|
||||
public InviteIDNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InviteStatusNotFoundException extends Exception {
|
||||
public InviteStatusNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class LikeIDNotFoundException extends Exception {
|
||||
public LikeIDNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NotificationChannelTypeNotFoundException extends Exception {
|
||||
public NotificationChannelTypeNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NotificationIDNotFoundException extends Exception {
|
||||
public NotificationIDNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NotificationTypeNotFoundException extends Exception {
|
||||
public NotificationTypeNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PrivacyLevelTypeNotFoundException extends Exception {
|
||||
public PrivacyLevelTypeNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TooManyRunningClustersException extends Exception {
|
||||
public TooManyRunningClustersException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="maven-antrun-" default="printOutputDirectories">
|
||||
<target name="printOutputDirectories">
|
||||
<echo level="info">******** Displaying value of *.outputDirectory properties ********</echo>
|
||||
<echo level="info">project.metainf.outputDirectory=${project.metainf.outputDirectory}</echo>
|
||||
<echo level="info">project.webinf.outputDirectory=${project.webinf.outputDirectory}</echo>
|
||||
</target>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="maven-antrun-" default="seOuttputDirectories">
|
||||
<target name="seOuttputDirectories">
|
||||
<condition property="isService">
|
||||
<contains string="jar" substring="war" />
|
||||
</condition>
|
||||
<condition property="project.webinf.outputDirectory" value="/Users/massi/workspace/social-networking-library/target/social-networking-library-1.18.0-SNAPSHOT/WEB-INF">
|
||||
<isset property="isService" />
|
||||
</condition>
|
||||
<condition property="project.metainf.outputDirectory" value="/Users/massi/workspace/social-networking-library/target/social-networking-library-1.18.0-SNAPSHOT/META-INF">
|
||||
<isset property="isService" />
|
||||
</condition>
|
||||
<property name="project.webinf.outputDirectory" value="/Users/massi/workspace/social-networking-library/target/classes/WEB-INF" />
|
||||
<property name="project.metainf.outputDirectory" value="/Users/massi/workspace/social-networking-library/target/classes/META-INF" />
|
||||
</target>
|
||||
</project>
|
|
@ -0,0 +1,311 @@
|
|||
#European Union Public Licence V.1.1
|
||||
|
||||
##*EUPL © the European Community 2007*
|
||||
|
||||
|
||||
This **European Union Public Licence** (the **“EUPL”**) applies to the Work or Software
|
||||
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Original Work is provided under the terms of this Licence when the Licensor
|
||||
(as defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Original Work:
|
||||
|
||||
**Licensed under the EUPL V.1.1**
|
||||
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
|
||||
|
||||
##1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- The Licence: this Licence.
|
||||
|
||||
- The Original Work or the Software: the software distributed and/or
|
||||
communicated by the Licensor under this Licence, available as Source Code and
|
||||
also as Executable Code as the case may be.
|
||||
|
||||
- Derivative Works: the works or software that could be created by the Licensee,
|
||||
based upon the Original Work or modifications thereof. This Licence does not
|
||||
define the extent of modification or dependence on the Original Work required
|
||||
in order to classify a work as a Derivative Work; this extent is determined by
|
||||
copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
- The Source Code: the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- The Executable Code: any code which has generally been compiled and which is
|
||||
meant to be interpreted by a computer as a program.
|
||||
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||
Software under the terms of the Licence.
|
||||
|
||||
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, on-line or off-line, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
|
||||
##2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||
sub-licensable licence to do the following, for the duration of copyright vested
|
||||
in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||
- to the public, including the right to make available or display the Work or
|
||||
- copies thereof to the public and perform publicly, as the case may be, the
|
||||
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||
- thereof, sub-license rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make effective
|
||||
the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||
any patents held by the Licensor, to the extent necessary to make use of the
|
||||
rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
|
||||
##3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||
a notice following the copyright notice attached to the Work, a repository where
|
||||
the Source Code is easily and freely accessible for as long as the Licensor
|
||||
continues to distribute and/or communicate the Work.
|
||||
|
||||
|
||||
|
||||
##4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||
any exception or limitation to the exclusive rights of the rights owners in the
|
||||
Original Work or Software, of the exhaustion of those rights or of other
|
||||
applicable limitations thereto.
|
||||
|
||||
|
||||
|
||||
##5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||
Original Works or Derivative Works based upon the Original Work, this
|
||||
Distribution and/or Communication will be done under the terms of this Licence
|
||||
or of a later version of this Licence unless the Original Work is expressly
|
||||
distributed only under this version of the Licence. The Licensee (becoming
|
||||
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||
or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||
Works or copies thereof based upon both the Original Work and another work
|
||||
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||
conflict with his/her obligations under this Licence, the obligations of the
|
||||
Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing and/or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available for
|
||||
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||
trademarks, service marks, or names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
|
||||
##6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work granted
|
||||
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under the
|
||||
terms of this Licence.
|
||||
|
||||
|
||||
|
||||
##7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
contributors. It is not a finished work and may therefore contain defects or
|
||||
“bugs” inherent to this type of software development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||
and without warranties of any kind concerning the Work, including without
|
||||
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||
copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||
for the grant of any rights to the Work.
|
||||
|
||||
|
||||
|
||||
##8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||
of the Work, including without limitation, damages for loss of goodwill, work
|
||||
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||
damage, even if the Licensor has been advised of the possibility of such
|
||||
damage. However, the Licensor will be liable under statutory product liability
|
||||
laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
|
||||
##9. Additional agreements
|
||||
|
||||
While distributing the Original Work or Derivative Works, You may choose to
|
||||
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||
support, warranty, indemnity, or other liability obligations and/or services
|
||||
consistent with this Licence. However, in accepting such obligations, You may
|
||||
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||
the original Licensor or any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against such Contributor by the fact You have accepted
|
||||
any such warranty or additional liability.
|
||||
|
||||
|
||||
|
||||
##10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||
placed under the bottom of a window displaying the text of this Licence or by
|
||||
affirming consent in any other similar way, in accordance with the rules of
|
||||
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||
acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||
Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
|
||||
|
||||
##11. Information to the public
|
||||
|
||||
In case of any Distribution and/or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the Work
|
||||
from a remote location) the distribution channel or media (for example, a
|
||||
website) must at least provide to the public the information requested by the
|
||||
applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
|
||||
##12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon
|
||||
any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
|
||||
##13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new
|
||||
versions of this Licence, so far this is required and reasonable, without
|
||||
reducing the scope of the rights granted by the Licence. New versions of the
|
||||
Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
|
||||
##14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising
|
||||
between the European Commission, as a Licensor, and any Licensee, will be
|
||||
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||
as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and
|
||||
resulting from the interpretation of this License, will be subject to the
|
||||
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||
conducts its primary business.
|
||||
|
||||
|
||||
|
||||
##15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where
|
||||
the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any
|
||||
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||
- or registered office inside a European Union country.
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
##Appendix
|
||||
|
||||
|
||||
**“Compatible Licences”** according to article 5 EUPL are:
|
||||
|
||||
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
|
||||
- Common Public License v. 1.0
|
||||
|
||||
- Eclipse Public License v. 1.0
|
||||
|
||||
- Cecill v. 2.0
|
|
@ -0,0 +1,13 @@
|
|||
Manifest-Version: 1.0
|
||||
Build-Jdk-Spec: 15
|
||||
Specification-Title: gCube Social Networking Library
|
||||
Specification-Version: 1.18
|
||||
Implementation-Title: gCube Social Networking Library
|
||||
Implementation-Version: 1.18.0-SNAPSHOT
|
||||
Build-Time: 20231127-152422
|
||||
Created-By: Maven Integration for Eclipse
|
||||
SCM-Branch:
|
||||
SCM-Revision:
|
||||
SCM-Revision-URL: https://code-repo.d4science.org/gCubeSystem/social-net
|
||||
working-library/commit/${buildNumber}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#Generated by Maven Integration for Eclipse
|
||||
#Mon Nov 27 16:24:30 CET 2023
|
||||
m2e.projectLocation=/Users/massi/workspace/social-networking-library
|
||||
m2e.projectName=social-networking-library
|
||||
groupId=org.gcube.portal
|
||||
artifactId=social-networking-library
|
||||
version=1.18.0-SNAPSHOT
|
|
@ -0,0 +1,152 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<version>1.18.0-SNAPSHOT</version>
|
||||
<name>gCube Social Networking Library</name>
|
||||
<description>
|
||||
The gCube Social Networking Library is the 'bridge' between your gCube Applications and the social networking facilities.
|
||||
The social networking facilities exploit a NoSQL data store for their storage. Specifically an Apache Cassandra data store.
|
||||
</description>
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<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.4</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.social-networking</groupId>
|
||||
<artifactId>social-service-client</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>gwt-jsonmaker</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<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>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='gcubesocialnetworking'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='org.gcube.portal.databook.client.GCubeSocialNetworking' />
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
Binary file not shown.
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.portal.databook.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code> and instances the <code>HandlerManager</code> for IPC
|
||||
*/
|
||||
public class GCubeSocialNetworking implements EntryPoint {
|
||||
public static final String USER_PROFILE_OID = "userIdentificationParameter";
|
||||
public static final String HASHTAG_OID = "hashtagIdentificationParameter";
|
||||
public static final String SEARCH_OID = "elasticSearchIdentificationParameter";
|
||||
public static final String SHOW_STATISTICS_ACTION_OID = "showUserStatisticsActionParameter"; // see ShowUserStatisticAction
|
||||
public static final String GROUP_MEMBERS_OID = "teamIdentificationParameter";
|
||||
public void onModuleLoad() {
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.portal.databook.client.util;
|
||||
/**
|
||||
* simply encode base64 strings
|
||||
* @author massi
|
||||
*
|
||||
*/
|
||||
public class Encoder {
|
||||
public static native String encode(String toEncode) /*-{
|
||||
return btoa(toEncode);
|
||||
}-*/;
|
||||
|
||||
public static native String decode(String toDecode) /*-{
|
||||
return atob(toDecode);
|
||||
}-*/;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,945 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.gcube.portal.databook.shared.*;
|
||||
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
||||
import org.gcube.social_networking.social_networking_client_library.CommentClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.HashTagClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.InviteClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.LikeClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.NotificationClient;
|
||||
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Costantino Perciante ISTI-CNR
|
||||
* This class is used for querying and adding data to Cassandra via Astyanax High Level API
|
||||
*/
|
||||
public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger _log = LoggerFactory.getLogger(DBCassandraAstyanaxImpl.class);
|
||||
private static PostClient postClient;
|
||||
private static NotificationClient notificationClient;
|
||||
private static HashTagClient hashTagClient;
|
||||
private static InviteClient inviteClient;
|
||||
private static CommentClient commentClient;
|
||||
private static LikeClient likeClient;
|
||||
|
||||
|
||||
/**
|
||||
* use this constructor carefully from test classes
|
||||
* @param dropSchema set true if you want do drop the current and set up new one
|
||||
*/
|
||||
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* public constructor, no dropping schema is allowed
|
||||
*/
|
||||
public DBCassandraAstyanaxImpl() {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* public constructor, no dropping schema is allowed, infrastructureName is given.
|
||||
*/
|
||||
public DBCassandraAstyanaxImpl(String infrastructureName) {
|
||||
try {
|
||||
postClient = new PostClient();
|
||||
notificationClient = new NotificationClient();
|
||||
hashTagClient = new HashTagClient();
|
||||
commentClient = new CommentClient();
|
||||
inviteClient = new InviteClient();
|
||||
likeClient = new LikeClient();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
********************** FRIENDSHIPS (CONNECTIONS) ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean requestFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean approveFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean denyFriendship(String from, String to) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getFriends(String userid) {
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPendingFriendRequests(String userid) {
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
return toReturn;
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** FEEDS ***********************
|
||||
*
|
||||
*/
|
||||
|
||||
private static Post feed2post(Feed feed){
|
||||
Post post = new Post(feed.getKey(), PostType.valueOf(feed.getType().toString()), feed.getEntityId(), feed.getTime(),
|
||||
feed.getVreid(), feed.getUri(), feed.getUriThumbnail(), feed.getDescription(), feed.getPrivacy(),
|
||||
feed.getFullName(), feed.getEmail(), feed.getThumbnailURL(), feed.getCommentsNo(),
|
||||
feed.getLikesNo(), feed.getLinkTitle(), feed.getLinkDescription(), feed.getLinkHost(), feed.isApplicationFeed(), feed.isMultiFileUpload());
|
||||
return post;
|
||||
}
|
||||
|
||||
private static Feed post2feed(Post post){
|
||||
Feed feed = new Feed(post.getKey(), FeedType.valueOf(post.getType().toString()), post.getEntityId(), post.getTime(),
|
||||
post.getVreid(), post.getUri(), post.getUriThumbnail(), post.getDescription(), post.getPrivacy(),
|
||||
post.getFullName(), post.getEmail(), post.getThumbnailURL(), post.getCommentsNo(),
|
||||
post.getLikesNo(), post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.isApplicationFeed(), post.isMultiFileUpload());
|
||||
return feed;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveUserFeed(Feed post) {
|
||||
return saveUserPost(feed2post(post));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveUserPost(Post post) {
|
||||
return postClient.saveUserPostLib(post);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveUserFeed(Feed feed, List<Attachment> attachments) {
|
||||
return saveUserPost(feed2post(feed), attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveUserPost(Post post, List<Attachment> attachments) {
|
||||
return postClient.saveUserPostLib(post, attachments);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean saveAppFeed(Feed post) {
|
||||
return saveAppPost(feed2post(post));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAppPost(Post post) {
|
||||
return postClient.saveAppPostLib(post);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveAppFeed(Feed feed, List<Attachment> attachments) {
|
||||
return saveAppPost(feed2post(feed), attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAppPost(Post post, List<Attachment> attachments) {
|
||||
return postClient.saveAppPostLib(post, attachments);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException {
|
||||
return savePostToVRETimeline(feedKey, vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean savePostToVRETimeline(String postKey, String vreid) throws FeedIDNotFoundException {
|
||||
return postClient.savePostToVRETimelineLib(postKey, vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Feed readFeed(String feedid)
|
||||
throws PrivacyLevelTypeNotFoundException,
|
||||
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
|
||||
return post2feed(readPost(feedid));
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Post readPost(String postid)
|
||||
throws PrivacyLevelTypeNotFoundException,
|
||||
FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return postClient.readPostLib(postid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getRecentFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
List<Post> posts = getRecentPostsByUserAndDate(userid, timeInMillis);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException {
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
return postClient.getRecentPostsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean deleteFeed(String feedId) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return deletePost(feedId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return postClient.deletePostLib(postid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByUser(userid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByApp(appid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByAppLib(appid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getRecentCommentedFeedsByUserAndDate(String userid,
|
||||
long timeInMillis) throws Exception {
|
||||
List<Post> posts = getRecentCommentedPostsByUserAndDate(userid, timeInMillis);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentCommentedPostsByUserAndDate(String userid,
|
||||
long timeInMillis) throws Exception {
|
||||
return postClient.getRecentCommentedPostsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getAllPortalPrivacyLevelFeeds() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||
List<Post> posts = getAllPortalPrivacyLevelPosts();
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getAllPortalPrivacyLevelPosts() throws FeedTypeNotFoundException, ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException {
|
||||
return postClient.getAllPortalPrivacyLevelPostsLib();
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getRecentPostsByUser(userid, quantity);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getRecentPostsByUserLib(userid, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
List<Post> posts = getAllPostsByVRE(vreid);
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
return feeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getAllPostsByVRELib(vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
_log.info("\n\n in getRecentFeedsByVRE");
|
||||
List<Post> posts = getRecentPostsByVRE(vreid, quantity);
|
||||
_log.info("length of vre posts = " + posts.size());
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
_log.info("length of vre feeds = " + feeds.size());
|
||||
return feeds;
|
||||
}
|
||||
@Override
|
||||
public List<Post> getRecentPostsByVRE(String vreid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
_log.info("\n\n in getRecentPostsByVRE");
|
||||
return postClient.getRecentPostsByVRELib(vreid, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
RangePosts rangePosts = getRecentPostsByVREAndRange(vreid, from, quantity);
|
||||
List<Post> posts = rangePosts.getPosts();
|
||||
ArrayList<Feed> feeds = new ArrayList<>();
|
||||
for(Post post: posts){
|
||||
feeds.add(post2feed(post));
|
||||
}
|
||||
RangeFeeds rangeFeeds = new RangeFeeds(rangePosts.getLastReturnedPostTimelineIndex(), feeds);
|
||||
return rangeFeeds;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RangePosts getRecentPostsByVREAndRange(String vreid, int from, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
return postClient.getRecentPostsByVREAndRangeLib(vreid, from, quantity);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
********************** NOTIFICATIONS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveNotification(Notification n) {
|
||||
return notificationClient.saveNotificationLib(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.readNotificationLib(notificationid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.setNotificationReadLib(notificationidToSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.getAllNotificationByUserLib(userid, limit);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
||||
return notificationClient.getUnreadNotificationsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Notification> getRangeNotificationsByUser(String userid,int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
|
||||
return notificationClient.getRangeNotificationsByUserLib(userid, from, quantity);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setAllNotificationReadByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.setAllNotificationReadByUserLib(userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUnreadNotifications(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.checkUnreadNotificationsLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
|
||||
return notificationClient.checkUnreadMessagesNotificationsLib(userid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** NOTIFICATION SETTINGS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
|
||||
return notificationClient.getUserNotificationChannelsLib(userid, notificationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels) {
|
||||
return notificationClient.setUserNotificationPreferencesLib(userid, enabledChannels);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* by default Workspace and Calendar Notifications are set to Portal
|
||||
*/
|
||||
@Override
|
||||
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
|
||||
return notificationClient.getUserNotificationPreferencesLib(userid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** COMMENTS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addComment(Comment comment) throws FeedIDNotFoundException {
|
||||
return commentClient.addCommentLib(comment)!=null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Comment readCommentById(String commentId) throws CommentIDNotFoundException {
|
||||
return commentClient.readCommentByIdLib(commentId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<Comment> getAllCommentByFeed(String feedid) {
|
||||
return getAllCommentByPost(feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getAllCommentByPost(String postid) {
|
||||
return commentClient.getAllCommentsByPostIdLib(postid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getRecentCommentsByUserAndDate(final String userid,
|
||||
final long timeInMillis) throws Exception {
|
||||
|
||||
return commentClient.getRecentCommentsByUserAndDateLib(userid, timeInMillis);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean editComment(Comment comment2Edit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
||||
return commentClient.editCommentLib(comment2Edit)!=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException {
|
||||
return commentClient.deleteCommentLib(commentid, feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean like(Like like) throws FeedIDNotFoundException {
|
||||
return likeClient.likeLib(like);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
|
||||
return likeClient.unlikeLib(userid, likeid, feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<String> getAllLikedFeedIdsByUser(String userid) {
|
||||
return getAllLikedPostIdsByUser(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllLikedPostIdsByUser(String userid) {
|
||||
return likeClient.getAllLikedPostIdsByUserLib(userid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
ArrayList<Feed> toReturn = new ArrayList<>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
//need them in reverse order
|
||||
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
||||
Feed toAdd = readFeed(likedPostIDs.get(i));
|
||||
if (toAdd.getType() == FeedType.TWEET || toAdd.getType() == FeedType.SHARE || toAdd.getType() == FeedType.PUBLISH) {
|
||||
toReturn.add(toAdd);
|
||||
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
||||
} else {
|
||||
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
||||
limit += 1; //increase the quantity in case of removed feed
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException {
|
||||
ArrayList<Post> toReturn = new ArrayList<Post>();
|
||||
List<String> likedPostIDs = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
|
||||
//need them in reverse order
|
||||
for (int i = likedPostIDs.size()-1; i >= (likedPostIDs.size()-limit); i--) {
|
||||
Post toAdd = readPost(likedPostIDs.get(i));
|
||||
if (toAdd.getType() == PostType.TWEET || toAdd.getType() == PostType.SHARE || toAdd.getType() == PostType.PUBLISH) {
|
||||
toReturn.add(toAdd);
|
||||
_log.trace("Read recent post: " + likedPostIDs.get(i));
|
||||
} else {
|
||||
_log.trace("Read and skipped post: " + likedPostIDs.get(i) + " (Removed post)");
|
||||
limit += 1; //increase the quantity in case of removed feed
|
||||
//check if quantity is greater than user feeds
|
||||
limit = (limit > likedPostIDs.size()) ? likedPostIDs.size() : limit;
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getRecentLikedFeedsByUserAndDate(String userid,
|
||||
long timeInMillis) throws IllegalArgumentException {
|
||||
|
||||
List<Feed> toReturn = new ArrayList<>();
|
||||
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
if(userid == null || userid.isEmpty())
|
||||
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
||||
|
||||
// get the list of liked feeds
|
||||
List<String> likedPostsIdsByUser = getAllLikedFeedIdsByUser(userid);
|
||||
|
||||
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
||||
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
||||
String postid = likedPostsIdsByUser.get(i);
|
||||
try{
|
||||
|
||||
// retrieve the Post
|
||||
Feed toCheck = readFeed(postid);
|
||||
boolean isPostOk = (toCheck.getType() == FeedType.TWEET || toCheck.getType() == FeedType.SHARE || toCheck.getType() == FeedType.PUBLISH);
|
||||
|
||||
// retrieve the like of the user for the post
|
||||
if(isPostOk){
|
||||
List<Like> likes = getAllLikesByFeed(postid);
|
||||
for (Like like : likes) {
|
||||
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
||||
toReturn.add(toCheck);
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
_log.error("Skipped post with id " + postid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// please check consider that if a user made like recently to an old post, well it could happen that this
|
||||
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
||||
Collections.sort(toReturn, Collections.reverseOrder());
|
||||
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getRecentLikedPostsByUserAndDate(String userid,
|
||||
long timeInMillis) throws IllegalArgumentException {
|
||||
|
||||
List<Post> toReturn = new ArrayList<>();
|
||||
|
||||
Date now = new Date();
|
||||
if (timeInMillis > now.getTime())
|
||||
throw new IllegalArgumentException("the timeInMillis must be before today");
|
||||
|
||||
if(userid == null || userid.isEmpty())
|
||||
throw new IllegalArgumentException("the userId parameter cannot be null/empty");
|
||||
|
||||
// get the list of liked feeds
|
||||
List<String> likedPostsIdsByUser = getAllLikedPostIdsByUser(userid);
|
||||
|
||||
if(likedPostsIdsByUser != null && !likedPostsIdsByUser.isEmpty()){
|
||||
for(int i = likedPostsIdsByUser.size() - 1; i >= 0; i--){
|
||||
String postid = likedPostsIdsByUser.get(i);
|
||||
try{
|
||||
|
||||
// retrieve the Post
|
||||
Post toCheck = readPost(postid);
|
||||
boolean isPostOk = (toCheck.getType() == PostType.TWEET || toCheck.getType() == PostType.SHARE || toCheck.getType() == PostType.PUBLISH);
|
||||
|
||||
// retrieve the like of the user for the post
|
||||
if(isPostOk){
|
||||
List<Like> likes = getAllLikesByPost(postid);
|
||||
for (Like like : likes) {
|
||||
if(like.getTime().getTime() >= timeInMillis && like.getUserid().equals(userid))
|
||||
toReturn.add(toCheck);
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
_log.error("Skipped post with id " + postid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// please check consider that if a user made like recently to an old post, well it could happen that this
|
||||
// post comes first than a newer post in the toReturn list. Thus we need to sort it.
|
||||
Collections.sort(toReturn, Collections.reverseOrder());
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<Like> getAllLikesByFeed(String feedid) {
|
||||
return getAllLikesByPost(feedid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Like> getAllLikesByPost(String postid) {
|
||||
//possible error index
|
||||
return likeClient.getAllLikesByPostLib(postid);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** HASHTAGS ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
||||
return hashTagClient.saveHashTagsLib(feedid, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteHashTags(String feedid, String vreid, List<String> hashtags) throws FeedIDNotFoundException {
|
||||
return hashTagClient.deleteHashTagsLib(feedid, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
||||
return hashTagClient.saveHashTagsCommentLib(commentId, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException {
|
||||
return hashTagClient.deleteHashTagsCommentLib(commentId, vreid, hashtags);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getVREHashtagsWithOccurrence(String vreid) {
|
||||
return hashTagClient.getVREHashtagsWithOccurrenceLib(vreid);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp){
|
||||
return hashTagClient.getVREHashtagsWithOccurrenceFilteredByTimeLib(vreid, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Post> getVREPostsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException {
|
||||
return hashTagClient.getVREPostsByHashtagLib(vreid, hashtag);
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** Invites ***********************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String isExistingInvite(String vreid, String email) {
|
||||
return inviteClient.isExistingInviteLib(vreid, email);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public InviteOperationResult saveInvite(Invite invite) throws AddressException {
|
||||
return inviteClient.saveInviteLib(invite);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
return inviteClient.readInviteLib(inviteid);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
return inviteClient.setInviteStatusLib(vreid, email, status);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException{
|
||||
return inviteClient.getInvitedEmailsByVRELib(vreid, status);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException {
|
||||
return postClient.getAttachmentsByFeedIdLib(feedId);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllVREIds(){
|
||||
return postClient.getAllVREIdsLib();
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,690 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class DatabookCassandraTest {
|
||||
private static DBCassandraAstyanaxImpl store;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
store = new DBCassandraAstyanaxImpl(); //set to true if you want to drop the KeySpace and recreate it
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void close(){
|
||||
store.closeConnection();
|
||||
System.out.println("End");
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void getRecentCommentedFeedsByUserAndDate() throws Exception{
|
||||
// String userid = "massimiliano.assante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// long init = System.currentTimeMillis();
|
||||
// List<Feed> res = store.getRecentCommentedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
// long end = System.currentTimeMillis();
|
||||
// System.out.println("Result is " + (end - init));
|
||||
//
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void getRecentCommentsByUserAndDate() throws Exception{
|
||||
//
|
||||
// String userid = "costantino.perciante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// List<Comment> res = store.getRecentCommentsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
//
|
||||
// for (Comment comment : res) {
|
||||
// System.out.println("Result is " + comment);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void getRecentLikedFeedsByUser(){
|
||||
//
|
||||
// String userid = "costantino.perciante";
|
||||
// Calendar oneYearAgo = Calendar.getInstance();
|
||||
// oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
|
||||
//
|
||||
// List<Feed> result = store.getRecentLikedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
|
||||
//
|
||||
// for (Feed feed : result) {
|
||||
// System.out.println("Result is " + feed);
|
||||
// }
|
||||
// }
|
||||
// @Test
|
||||
// public void getHashTagsFilteredByTime() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{
|
||||
//
|
||||
// int windowSize = 6; // go back windowSize months
|
||||
//
|
||||
// String vreUnderTest = "/gcube/devsec/devVRE";
|
||||
//
|
||||
// // reference time
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// int currentMonth = calendar.get(Calendar.MONTH); // jan = 0, ..... dec = 11
|
||||
// calendar.set(Calendar.MONTH, currentMonth - windowSize); // the year is automatically decreased if needed
|
||||
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// System.out.println("Reference time for trending topics is " + format.format(calendar.getTime()));
|
||||
//
|
||||
// Map<String, Integer> res =
|
||||
// store.getVREHashtagsWithOccurrenceFilteredByTime(
|
||||
// vreUnderTest, calendar.getTimeInMillis());
|
||||
//
|
||||
// // find max score inside the list (counter)
|
||||
// int max = 0;
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// max = max < entry.getValue() ? entry.getValue() : max;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // normalize
|
||||
// Map<String, Double> normalized = new HashMap<String, Double>();
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// normalized.put(entry.getKey(), (double)entry.getValue() / (double)max);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // create the weight for each entry as:
|
||||
// // w = 0.6 * normalized_score + 0.4 * freshness
|
||||
// // freshness is evaluated as (window_size - latest_feed_for_hashtag_in_window_month)/window_size
|
||||
// Map<String, Double> scoredList = new HashMap<String, Double>();
|
||||
// for(Entry<String, Integer> entry : res.entrySet()){
|
||||
//
|
||||
// double weight = 0.6 * normalized.get(entry.getKey());
|
||||
//
|
||||
// // retrieve the last feed for this hashtag and locate it into the window
|
||||
// List<Feed> mostRecentFeedForHashtag = store.getVREFeedsByHashtag(vreUnderTest, entry.getKey());
|
||||
//
|
||||
// // retrieve the most recent one among these feeds
|
||||
// Collections.sort(mostRecentFeedForHashtag, Collections.reverseOrder());
|
||||
//
|
||||
// // locate into the window
|
||||
// Calendar locateInWindow = Calendar.getInstance();
|
||||
// locateInWindow.setTimeInMillis(mostRecentFeedForHashtag.get(0).getTime().getTime());
|
||||
//
|
||||
// // get the month
|
||||
// int sub = currentMonth - locateInWindow.get(Calendar.MONTH);
|
||||
// int value = sub >= 0? sub : 12 - Math.abs(sub);
|
||||
// double freshness = (double)(windowSize - value) / (double)(windowSize);
|
||||
// System.out.println("freshness is " + freshness + " because the last feed has month " + locateInWindow.get(Calendar.MONTH));
|
||||
//
|
||||
// weight += 0.4 * freshness;
|
||||
//
|
||||
// scoredList.put(entry.getKey(), weight);
|
||||
// }
|
||||
//
|
||||
// // print sorted
|
||||
// Map<String, Double> scoredListSorted = sortByValue(scoredList);
|
||||
// for(Entry<String, Double> entry : scoredListSorted.entrySet()){
|
||||
//
|
||||
// System.out.println("[hashtag=" + entry.getKey() + " , weight=" + entry.getValue() + "]");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static <K, V extends Comparable<? super V>> Map<K, V>
|
||||
// sortByValue( Map<K, V> map )
|
||||
// {
|
||||
// List<Map.Entry<K, V>> list =
|
||||
// new LinkedList<Map.Entry<K, V>>( map.entrySet() );
|
||||
// Collections.sort( list, new Comparator<Map.Entry<K, V>>()
|
||||
// {
|
||||
// public int compare( Map.Entry<K, V> o1, Map.Entry<K, V> o2 )
|
||||
// {
|
||||
// return (o2.getValue()).compareTo( o1.getValue() );
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// Map<K, V> result = new LinkedHashMap<K, V>();
|
||||
// for (Map.Entry<K, V> entry : list)
|
||||
// {
|
||||
// result.put( entry.getKey(), entry.getValue() );
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
// @Test
|
||||
// public void getHashTags() throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException{
|
||||
// List<Feed> resList = store.getVREFeedsByHashtag("/gcube/devsec/devVRE", "#test");
|
||||
//
|
||||
// for (Feed feed : resList) {
|
||||
// System.out.println(feed.getTime());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void getComment(){
|
||||
//
|
||||
// String uuid = "820969b2-4632-4197-9fd6-5aafab781faa";
|
||||
//
|
||||
// Comment c;
|
||||
// try {
|
||||
// c = store.readCommentById(uuid);
|
||||
// System.err.println(c);
|
||||
// } catch (CommentIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// System.err.println(e.toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void vreIds(){
|
||||
//
|
||||
// try {
|
||||
// List<String> ids = store.getAllVREIds();
|
||||
// System.out.println(ids);
|
||||
// } catch (ConnectionException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testFeedNumberPerUser() {
|
||||
// String userid = "massimiliano.assante";
|
||||
//
|
||||
// List<Feed> feeds = null;
|
||||
// int numComment = 0;
|
||||
// long init = System.currentTimeMillis();
|
||||
// try {
|
||||
// feeds = store.getAllFeedsByUser(userid);
|
||||
//
|
||||
// for (Feed feed : feeds) {
|
||||
// List<Comment> comments = store.getAllCommentByFeed(feed.getKey());
|
||||
//
|
||||
//
|
||||
// for (Comment comment : comments) {
|
||||
// numComment ++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (PrivacyLevelTypeNotFoundException | FeedTypeNotFoundException
|
||||
// | ColumnNameNotFoundException | FeedIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// System.err.println(e.toString());
|
||||
// }
|
||||
// long end = System.currentTimeMillis();
|
||||
// System.err.println("retrieved " + feeds.size() + " and " + numComment + " in " + (end - init) + "ms");
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testAttachments() {
|
||||
// Attachment a1 = new Attachment(UUID.randomUUID().toString(), "www1", "gattino1", "description1", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg", "image/jpg");
|
||||
// Attachment a2 = new Attachment(UUID.randomUUID().toString(), "www2", "name2", "description2", "http://www.gcomegatto.it/wp-content/uploads/2015/01/09gatto.jpg","image/jpg");
|
||||
// Attachment a3 = new Attachment(UUID.randomUUID().toString(), "www3", "name3", "description3", "http://cdn.tuttozampe.com/wp-content/uploads/2010/09/ipoglicemia-gatto.jpg","image/jpg");
|
||||
// List<Attachment> toPass = new ArrayList<Attachment>();
|
||||
// toPass.add(a1);
|
||||
// toPass.add(a2);
|
||||
// toPass.add(a3);
|
||||
//
|
||||
// String feedId = UUID.randomUUID().toString();
|
||||
// Feed feed = new Feed(feedId, FeedType.TWEET, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "This post has attachments (gattini) ", PrivacyLevel.SINGLE_VRE,
|
||||
// "Massimiliano Assante",
|
||||
// "massimiliano.assante@isti.cnr.it",
|
||||
// "http://www.dailybest.it/wp-content/uploads/2015/10/gattini-nele-ciotole-e1344352237289.jpg",
|
||||
// "Gattino",
|
||||
// "linkDesc",
|
||||
// "image/jpeg", false);
|
||||
// feed.setMultiFileUpload(true);
|
||||
// assertTrue(store.saveUserFeed(feed, toPass));
|
||||
// System.out.println("Wrote post? ");
|
||||
// System.out.println("Feed has the following attachments: ");
|
||||
// try {
|
||||
// for (Attachment at : store.getAttachmentsByFeedId(feedId)) {
|
||||
// System.out.println(at);
|
||||
// }
|
||||
// } catch (FeedIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testHashTag() {
|
||||
// try {
|
||||
// final String VREID = "/gcube/devsec/devVRE";
|
||||
// final String HASHTAG1 = "#testHashTag";
|
||||
// final String HASHTAG2 = "#testHashTag3";
|
||||
// List<String> hashtags = new LinkedList<String>();
|
||||
// hashtags.add(HASHTAG1);
|
||||
// hashtags.add(HASHTAG2);
|
||||
//
|
||||
//// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID,
|
||||
//// "www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
//// assertTrue(store.saveUserFeed(feed));
|
||||
//// assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags));
|
||||
//// assertTrue(store.deleteHashTags("d0c64e42-9616-4e24-a65a-7a63a280d676", VREID, hashtags));
|
||||
//// System.out.println(feed);
|
||||
////
|
||||
// System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID);
|
||||
// Map<String, Integer> hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID);
|
||||
// for (String hashtag : hashtagsWithOcc.keySet()) {
|
||||
// System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag));
|
||||
// }
|
||||
//
|
||||
// System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1);
|
||||
// for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) {
|
||||
// System.out.println(theFeed);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Static) CF to a keyspace with a secondary index
|
||||
// */
|
||||
// @Test
|
||||
// public void addAttachmentStaticColumnFamilies() {
|
||||
// ColumnFamily<String, String> CF_ATTACHMENTS = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.ATTACHMENTS, StringSerializer.get(), StringSerializer.get());
|
||||
//
|
||||
// try {
|
||||
// String colNameToIndex = "feedId";
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_ATTACHMENTS, ImmutableMap.<String, Object>builder()
|
||||
// .put("column_metadata", ImmutableMap.<String, Object>builder()
|
||||
// .put(colNameToIndex, ImmutableMap.<String, Object>builder()
|
||||
// .put("validation_class", "UTF8Type")
|
||||
// .put("index_name", "FeedIndex_"+UUID.randomUUID().toString().substring(0,5))
|
||||
// .put("index_type", "KEYS")
|
||||
// .build())
|
||||
// .build())
|
||||
// .build());
|
||||
//
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addStaticColumnFamily END");
|
||||
// }
|
||||
//
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Dynamic) CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addInvitesDynamicColumnFamilies() {
|
||||
// System.out.println("UserNotificationsUnread");
|
||||
// ColumnFamily<String, String> cf_UserNotificationsUnreadTimeline = new ColumnFamily<String, String>(
|
||||
// DBCassandraAstyanaxImpl.EMAIL_INVITES, // Column Family Name
|
||||
// StringSerializer.get(), // Key Serializer
|
||||
// StringSerializer.get()); // Column Serializer
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsUnreadTimeline, ImmutableMap.<String, Object>builder()
|
||||
// .put("default_validation_class", "UTF8Type")
|
||||
// .put("key_validation_class", "UTF8Type")
|
||||
// .put("comparator_type", "UTF8Type")
|
||||
// .build());
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("UserNotificationsUnread END");
|
||||
// }
|
||||
|
||||
|
||||
// private List<String> getKeys() {
|
||||
// List<String> toReturn = new ArrayList<String>();
|
||||
// try {
|
||||
//
|
||||
// OperationResult<Rows<String, String>> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences)
|
||||
// .getAllRows()
|
||||
// .setRowLimit(1000) // This is the page size
|
||||
// .execute();
|
||||
// int i = 1;
|
||||
// for (Row<String, String> row : rows.getResult()) {
|
||||
// System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size());
|
||||
// toReturn.add(row.getKey());
|
||||
// i++;
|
||||
// }
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return toReturn;
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testUserNotificationPreferences() {
|
||||
// System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:");
|
||||
// try {
|
||||
// for (String user : getKeys()) {
|
||||
// List<NotificationChannelType> channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT);
|
||||
// if (channels.isEmpty()) {
|
||||
// System.out.println(user);
|
||||
// }
|
||||
// else if (! channels.contains(NotificationChannelType.EMAIL)) {
|
||||
// System.out.println(user + "->" + channels.toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) {
|
||||
// System.out.println(channel);
|
||||
// }
|
||||
// } catch (NotificationChannelTypeNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (NotificationTypeNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testLikes() {
|
||||
// int count = 10;
|
||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
|
||||
// "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
||||
// new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
|
||||
//
|
||||
// try {
|
||||
// assertTrue(store.like(toUnlike));
|
||||
// for (int i = 0; i < count; i++)
|
||||
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
||||
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
|
||||
//
|
||||
// System.out.println("massimiliano.assante liked the following feeds: ");
|
||||
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
|
||||
// System.out.println(feedid);
|
||||
// }
|
||||
//
|
||||
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
|
||||
// System.out.println(like);
|
||||
// }
|
||||
// System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
|
||||
// store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * use exclusively to add a new CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addNotifPreferencesColumnFamily() {
|
||||
// // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
|
||||
// // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
|
||||
// // StringSerializer.get(), // Key Serializer
|
||||
// // StringSerializer.get()); // Column Serializer
|
||||
// //
|
||||
// // try {
|
||||
// // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
|
||||
// // .put("default_validation_class", "UTF8Type")
|
||||
// // .put("key_validation_class", "UTF8Type")
|
||||
// // .put("comparator_type", "UTF8Type")
|
||||
// // .build());
|
||||
// // } catch (ConnectionException e) {
|
||||
// // e.printStackTrace();
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testFriendships() {
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
|
||||
// assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
|
||||
// assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
|
||||
//
|
||||
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
|
||||
// assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
|
||||
//
|
||||
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
|
||||
// System.out.println("Pending Connections for massimiliano.assante:");
|
||||
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
|
||||
// System.out.println(userid);
|
||||
// }
|
||||
//
|
||||
// System.out.println("Connections for massimiliano.assante:");
|
||||
// for (String userid: store.getFriends("massimiliano.assante")) {
|
||||
// System.out.println(userid);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// @Test
|
||||
// public void testLikedFeedsRetrieval() {
|
||||
// try {
|
||||
// for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
|
||||
// System.out.println(feed);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testSingleNotification() {
|
||||
// Notification not = new Notification(
|
||||
// UUID.randomUUID().toString(),
|
||||
// NotificationType.LIKE,
|
||||
// "leonardo.candela",
|
||||
// "MESSAGEID",
|
||||
// new Date(),
|
||||
// "uri",
|
||||
// "This is notification about a like",
|
||||
// false,
|
||||
// "leonardo.candela", "Leonardo Candela",
|
||||
// "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
//
|
||||
// not = new Notification(
|
||||
// UUID.randomUUID().toString(),
|
||||
// NotificationType.MESSAGE,
|
||||
// "massimiliano.assante",
|
||||
// "MESSAGEID",
|
||||
// new Date(),
|
||||
// "uri",
|
||||
// "This is notification about a like",
|
||||
// false,
|
||||
// "antonio.gioia", "Antonio Gioia",
|
||||
// "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// System.out.println("Writing one Notification " + not);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNotifications() {
|
||||
// Notification not = null;
|
||||
// System.out.println("Writing 18 Notifications");
|
||||
// int count = 18;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// if (i % 2 != 0) {
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
|
||||
// "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
|
||||
// } else {
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
|
||||
// "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
|
||||
// }
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Notification rNot= null;
|
||||
// try {
|
||||
//
|
||||
// //read
|
||||
// rNot = store.readNotification(not.getKey().toString());
|
||||
// assertNotNull(rNot);
|
||||
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
|
||||
//
|
||||
// //set Read
|
||||
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
||||
//
|
||||
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
|
||||
//
|
||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
|
||||
// "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
|
||||
// assertTrue(store.saveNotification(not));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// rNot = store.readNotification(not.getKey().toString());
|
||||
// System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
|
||||
// // //set Read
|
||||
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
||||
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
|
||||
// //
|
||||
// Random randomGenerator = new Random();
|
||||
//
|
||||
// System.out.println("leonardo.candela Notifications: ");
|
||||
// List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
|
||||
// assertNotNull(recentNots);
|
||||
// for (Notification notif :recentNots)
|
||||
// System.out.println(notif);
|
||||
//
|
||||
//
|
||||
// System.out.println("massimiliano.assante Notifications: ");
|
||||
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
|
||||
// assertNotNull(recentNots);
|
||||
// for (Notification notif :recentNots)
|
||||
// System.out.println(notif);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
|
||||
// try {
|
||||
// int from = 0;
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// System.out.println("\nFROM="+from);
|
||||
// List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50);
|
||||
// for (Notification notification : range) {
|
||||
// System.out.println(notification.getDescription());
|
||||
// from = 1+i * 50;
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testFeeds() {
|
||||
// int count = 18;
|
||||
// Feed feed = null;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// if (i % 2 != 0) {
|
||||
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
// } else {
|
||||
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
|
||||
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
// }
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// try {
|
||||
// Thread.sleep(150);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Feed rFeed = null;
|
||||
// try {
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// rFeed = store.readFeed(feed.getKey().toString());
|
||||
// assertNotNull(rFeed);
|
||||
//
|
||||
// String feedIdToDelete = UUID.randomUUID().toString();
|
||||
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// try {
|
||||
// Thread.sleep(250);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("Test Delete Feed ");
|
||||
// assertTrue(store.deleteFeed(feedIdToDelete));
|
||||
//
|
||||
// System.out.println("massimiliano.assante ALL FEEDS: ");
|
||||
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
|
||||
// System.out.println(recFeed);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testComments() {
|
||||
// int count = 10;
|
||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||
// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
|
||||
// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
//
|
||||
// Comment toDelete = null;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// try {
|
||||
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
|
||||
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
|
||||
// assertTrue(store.addComment(toDelete));
|
||||
//
|
||||
// } catch (FeedIDNotFoundException e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
// System.out.println("GetAllCOmmentsByFeed ");
|
||||
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
|
||||
// try {
|
||||
// System.out.println(store.readCommentById(cm.getKey()));
|
||||
// } catch (CommentIDNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// try {
|
||||
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Exception feed id not found");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,667 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.gcube.portal.databook.shared.Attachment;
|
||||
import org.gcube.portal.databook.shared.Comment;
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.databook.shared.InviteStatus;
|
||||
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;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Costantino Perciante ISTI-CNR
|
||||
* <class>DatabookStore</class> is the high level interface for querying and adding data to DatabookStore
|
||||
*/
|
||||
public interface DatabookStore {
|
||||
/**
|
||||
* userid from requests a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean requestFriendship(String from, String to);
|
||||
/**
|
||||
* userid from approves a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean approveFriendship(String from, String to);
|
||||
/**
|
||||
* userid from denies a friendship to userid to
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean denyFriendship(String from, String to);
|
||||
/**
|
||||
* @param userid the user id you want to know friends
|
||||
* @return a List of userid representing the friends for the given userid
|
||||
*/
|
||||
List<String> getFriends(String userid);
|
||||
/**
|
||||
* @param userid the user id you want to know the pending friend requests
|
||||
* @return a List of userid representing the friends for the given userid
|
||||
*/
|
||||
List<String> getPendingFriendRequests(String userid);
|
||||
/**
|
||||
* @deprecated use saveUserPost
|
||||
* save a Feed instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserFeed(Feed feed);
|
||||
/**
|
||||
* save a Post instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserPost(Post feed);
|
||||
/**
|
||||
* Save a Feed instance in the store having more than one attachment
|
||||
* Use this if you need to attach more than one file to the post
|
||||
*
|
||||
* @deprecated use saveUserPost
|
||||
* @param attachments a list of attachments starting from the second
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveUserFeed(Feed feed, List<Attachment> attachments);
|
||||
/**
|
||||
* Save a Post instance in the store having more than one attachment
|
||||
* Use this if you need to attach more than one file to the post
|
||||
*
|
||||
* @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;
|
||||
/**
|
||||
* delete a Feed from the store
|
||||
* @throws FeedIDNotFoundException
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean deletePost(String postid) throws FeedIDNotFoundException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* Save a post in the VRES TimeLine in the store
|
||||
* @deprecated use savePostToVRETimeline
|
||||
* @param feedKey feedKey
|
||||
* @param vreid vre identifier
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean saveFeedToVRETimeline(String feedKey, String vreid) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* 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 Post instance in the store
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveAppPost(Post feed);
|
||||
/**
|
||||
* @deprecated use saveAppPost
|
||||
* Save a Post instance in the store
|
||||
* Use this if your app needs to attach more than one file to the post
|
||||
*
|
||||
* @param attachments a list of attachments starting from the second
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean saveAppFeed(Feed feed, List<Attachment> attachments);
|
||||
/**
|
||||
* Save a Post instance in the store
|
||||
* Use this if your app needs to attach more than one file to the post
|
||||
*
|
||||
* @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
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
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
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByUser(String userid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllPostsByApp instead
|
||||
* @param appid application identifier
|
||||
* return all the feeds belonging to the appid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @param appid application identifier
|
||||
* return all the feeds belonging to the appid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* @deprecated use getRecentCommentedPostsByUserAndDate instead
|
||||
* @param userid the user identifier like andrea.rossi
|
||||
* @param timeInMillis the initial time in millis to be considered
|
||||
* @return a list of feeds commented by userid starting from timeInMillis
|
||||
* @throws Exception
|
||||
*/
|
||||
List<Feed> getRecentCommentedFeedsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
||||
/**
|
||||
* @param userid the user identifier like andrea.rossi
|
||||
* @param 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
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getRecentFeedsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* return the most recent feeds for this user up to quantity param
|
||||
* @param userid user identifier
|
||||
* @param quantity the number of most recent feeds for this user
|
||||
* @return a <class>List</class> of most recent feeds for this user
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getRecentPostsByUser(String userid, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllPostsByVRE
|
||||
* @param vreid vre identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getAllFeedsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @param vreid vre identifier
|
||||
* return all the feeds belonging to the userid
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Post> getAllPostsByVRE(String vreid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
|
||||
/**
|
||||
* @deprecated use getRecentPostsByVRE
|
||||
* return the most recent feeds for this vre up to quantity param
|
||||
* @param vreid VRES identifier
|
||||
* @param quantity the number of most recent feeds for this vre
|
||||
* @return a <class>List</class> of most recent feeds for this vre
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Feed> getRecentFeedsByVRE(String vreid, int quantity) throws IllegalArgumentException, PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* 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
|
||||
* @return a <class>lastReturnedFeedTimelineIndex</class> containing of most recent feeds for this vre
|
||||
* @throws FeedTypeNotFoundException
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
RangeFeeds getRecentFeedsByVREAndRange(String vreid, int from, int quantity) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline
|
||||
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
boolean saveNotification(Notification notification);
|
||||
/**
|
||||
* set an existing Notification instance in the to read
|
||||
* @return true if everything went fine
|
||||
*/
|
||||
boolean setNotificationRead(String notificationidToSet) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* read a notification from a given id
|
||||
* @throws {@link ColumnNameNotFoundException}
|
||||
* @throws {@link NotificationIDNotFoundException}
|
||||
* @throws {@link NotificationTypeNotFoundException}
|
||||
*/
|
||||
Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- notifications
|
||||
* return all the notifications belonging to the userid up to limit, set 0 to get everything
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @param from the range start has to be greater than 0
|
||||
* @param quantity the number of most recent notifications for this user starting from "from" param
|
||||
* @return all the notifications for the userid in the range requested
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationIDNotFoundException
|
||||
*/
|
||||
List<Notification> getRangeNotificationsByUser(String userid, int from, int quantity) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
* This is a fast way to set all notification to read quickly
|
||||
* @param userid
|
||||
* @return true if everything went fine
|
||||
* @throws {@link ColumnNameNotFoundException}
|
||||
* @throws {@link NotificationIDNotFoundException}
|
||||
* @throws {@link NotificationTypeNotFoundException}
|
||||
*/
|
||||
boolean setAllNotificationReadByUser(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* return the not yet read notifications (not including messages)
|
||||
* @param userid user identifier
|
||||
* @return a <class>List</class> of not yet read notifications for this user
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
List<Notification> getUnreadNotificationsByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationTypeNotFoundException
|
||||
* @throws NotificationIDNotFoundException
|
||||
* @return true if there are unread notifications (not including messages), false if they are all read
|
||||
*/
|
||||
boolean checkUnreadNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param userid user identifier
|
||||
* @throws ColumnNameNotFoundException
|
||||
* @throws NotificationTypeNotFoundException self explaining
|
||||
* @throws NotificationChannelTypeNotFoundException self explaining
|
||||
* @throws NotificationIDNotFoundException
|
||||
* @return true if there are unread messages notifications (including messages), false if they are all read
|
||||
*/
|
||||
boolean checkUnreadMessagesNotifications(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* return the channels a user chose for being notified for a given notification type
|
||||
* @param userid user identifier
|
||||
* @param notificationType the type of the notification
|
||||
* @return a list of <class>NotificationChannelType</class> that represents the channels this user wants to be notified
|
||||
*/
|
||||
List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException;
|
||||
/**
|
||||
* set the notification preferences map (enable or disable the channels to be used for notifying the user)
|
||||
* @param userid user identifier
|
||||
* @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
|
||||
*/
|
||||
boolean setUserNotificationPreferences(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels);
|
||||
/**
|
||||
* get the notification preferences map (enableor disable the channels to be used for notifying the user)
|
||||
* @param userid user identifier
|
||||
* @return the map
|
||||
* @throws NotificationTypeNotFoundException self explaining
|
||||
* @throws NotificationChannelTypeNotFoundException self explaining
|
||||
*/
|
||||
Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException;
|
||||
|
||||
/**
|
||||
* @param commentId comment unique identifier
|
||||
* @return the comment belonging to the commentId
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
Comment readCommentById(String commentId) throws CommentIDNotFoundException;
|
||||
/**
|
||||
* add a comment to a feed
|
||||
* @param comment the Comment instance to add
|
||||
*/
|
||||
boolean addComment(Comment comment) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllCommentByPost
|
||||
* @param feedid feed identifier
|
||||
* return all the comments belonging to the feedid
|
||||
*/
|
||||
List<Comment> getAllCommentByFeed(String feedid);
|
||||
/**
|
||||
* @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
|
||||
* @return a list of comments (sorted starting from the most recent one) made by the user since timeInMillis up to now
|
||||
*/
|
||||
List<Comment> getRecentCommentsByUserAndDate(String userid, long timeInMillis) throws Exception;
|
||||
/**
|
||||
* edit a comment
|
||||
* @param comment the comment to edit
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* deletes a comment
|
||||
* @param commentid the comment identifier to delete
|
||||
* @param feedid the feedid to which the comment is associated
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* add a like to a feed
|
||||
* @param like instance
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean like(Like like) throws FeedIDNotFoundException;
|
||||
/**
|
||||
* unlike a feed
|
||||
* @param userid user identifier
|
||||
* @param likeid the like identifier to delete
|
||||
* @param feedid the feedid to which the comment is associated
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
|
||||
/**
|
||||
* @deprecated use getAllLikedPostIdsByUser
|
||||
* @param userid user identifier
|
||||
* return all the feedids a user has liked
|
||||
*/
|
||||
List<String> getAllLikedFeedIdsByUser(String userid);
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* return all the feedids a user has liked
|
||||
*/
|
||||
List<String> getAllLikedPostIdsByUser(String userid);
|
||||
/**
|
||||
* @deprecated use getAllLikedPostsByUser
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- liked feeds
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* return all the feeds a user has liked
|
||||
*/
|
||||
List<Feed> getAllLikedFeedsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param limit set 0 to get everything, an int to get the most recent -limit- liked posts
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* return all the feeds a user has liked
|
||||
*/
|
||||
List<Post> getAllLikedPostsByUser(String userid, int limit) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
|
||||
/**
|
||||
* @deprecated use getRecentLikedPostsByUserAndDate
|
||||
* @param userid user identifier
|
||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||
* @return the likes made to feeds in the range from: today to: timeInMillis
|
||||
*/
|
||||
List<Feed> getRecentLikedFeedsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
||||
/**
|
||||
* @param userid user identifier
|
||||
* @param timeInMillis time in milliseconds from which you want to start retrieve the feeds
|
||||
* @return the likes made to feeds in the range from: today to: timeInMillis
|
||||
*/
|
||||
List<Post> getRecentLikedPostsByUserAndDate(String userid, long timeInMillis) throws IllegalArgumentException;
|
||||
/**
|
||||
* @deprecated use getAllLikesByPost
|
||||
* @param postid postid identifier
|
||||
* return all the likes belonging to the postid
|
||||
*/
|
||||
List<Like> getAllLikesByFeed(String postid);
|
||||
/**
|
||||
* @param postid postid identifier
|
||||
* return all the likes belonging to the postid
|
||||
*/
|
||||
List<Like> getAllLikesByPost(String postid);
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param postid the postid to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean saveHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param commentId the commentId to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
boolean saveHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param postid the postid to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws FeedIDNotFoundException
|
||||
*/
|
||||
boolean deleteHashTags(String postid, String vreid, List<String> hashtags) throws FeedIDNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param hashtags the hashtag including the '#'
|
||||
* @param commentId the commentId to which the hashtag is associated
|
||||
* @param vreid VRE identifier
|
||||
* @return true if success, false otherwise
|
||||
* @throws CommentIDNotFoundException
|
||||
*/
|
||||
boolean deleteHashTagsComment(String commentId, String vreid, List<String> hashtags) throws CommentIDNotFoundException;
|
||||
/**
|
||||
* get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE
|
||||
* @param vreid vre identifier (scope)
|
||||
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
||||
*/
|
||||
Map<String, Integer> getVREHashtagsWithOccurrence(String vreid);
|
||||
/**
|
||||
* get a map of vre hashtags where the key is the hashtag and the value is the occurrence of the hashtag in the VRE
|
||||
* @param vreid vre identifier (scope)
|
||||
* @param timestamp do not consider hashtags used before timestamp
|
||||
* @return a HashMap<String, Integer> of vre Hashtags associated with their occurrence
|
||||
*/
|
||||
Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTime(String vreid, long timestamp);
|
||||
/**
|
||||
* @deprecated use getVREPostsByHashtag
|
||||
* @param vreid VRE identifier
|
||||
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @return all the feeds having the hashtag passed as parameter
|
||||
*/
|
||||
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param vreid VRE identifier
|
||||
* @param hashtag the hashtag to look for including the '#', it is case sensitive
|
||||
* @throws ColumnNameNotFoundException .
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @throws FeedTypeNotFoundException .
|
||||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws FeedIDNotFoundException .
|
||||
* @return all the feeds having the hashtag passed as parameter
|
||||
*/
|
||||
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
|
||||
* @return {@link InviteOperationResult} SUCCESS, FAILED or ALREADY_INVITED (if an invite is sent to en existing email in the same environment more than once)
|
||||
*/
|
||||
InviteOperationResult saveInvite(Invite invite) throws AddressException;
|
||||
/**
|
||||
*
|
||||
* @param vreid the environment where you want to check the invite
|
||||
* @param email the email of the invite to check in the environmnet
|
||||
* @return the InviteId if present, null otherwise
|
||||
*/
|
||||
String isExistingInvite(String vreid, String email);
|
||||
/**
|
||||
* read an invite from a given id
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* set the status of an invite, see {@link InviteStatus}
|
||||
* @throws InviteIDNotFoundException
|
||||
*/
|
||||
boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* Use to get the list of invites per VRE
|
||||
* @param vreid the vre id
|
||||
* @param status optional, if you want to restict on the status, e.g. all pending invites
|
||||
* @return return the list of invites
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
List<Invite> getInvitedEmailsByVRE(String vreid, InviteStatus... status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
*
|
||||
* @param feedId
|
||||
* @return the list of attachments of the feed feedId, starting from the second one (first attachment is included in Feed instance already)
|
||||
*/
|
||||
List<Attachment> getAttachmentsByFeedId(String feedId) throws FeedIDNotFoundException;
|
||||
|
||||
/**
|
||||
* Retrieve all the ids of the vre
|
||||
* @return the set of ids of the vre available or empty list in case of errors.
|
||||
*/
|
||||
public List<String> getAllVREIds();
|
||||
|
||||
/**
|
||||
* close the connection to the underlying database
|
||||
*/
|
||||
void closeConnection();
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,220 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
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 org.gcube.common.portal.GCubePortalConstants;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.databook.shared.ex.TooManyRunningClustersException;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @author Ahmed Salah Tawfik Ibrahim ISTI-CNR
|
||||
*
|
||||
* @version 2.0.0 October 2023
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RunningCluster implements Serializable {
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger _log = LoggerFactory.getLogger(RunningCluster.class);
|
||||
|
||||
/**
|
||||
* properties to read
|
||||
*/
|
||||
private static final String HOST_PROPERTY = "host";
|
||||
private static final String HOST_PORT_PROPERTY = "port";
|
||||
private static final String DATACENTER_NAME_PROPERTY = "datacenter";
|
||||
private static final String KEY_SPACE_NAME_PROPERTY = "keyspace";
|
||||
/**
|
||||
* other constants
|
||||
*/
|
||||
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
|
||||
private final static String PLATFORM_NAME = "Cassandra";
|
||||
|
||||
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
|
||||
|
||||
private static RunningCluster singleton;
|
||||
/**
|
||||
* Host
|
||||
*/
|
||||
private String host;
|
||||
/**
|
||||
* Cluster Name
|
||||
*/
|
||||
private String datacenterName;
|
||||
/**
|
||||
* Keyspace Name
|
||||
*/
|
||||
private String keyspaceName; //to be modified
|
||||
|
||||
/**
|
||||
* @param infrastructureName could be null
|
||||
* @return an instance of the RunningCluster
|
||||
*/
|
||||
public static synchronized RunningCluster getInstance(String infrastructureName) {
|
||||
if (singleton == null) {
|
||||
singleton = new RunningCluster(infrastructureName);
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
/**
|
||||
* private constructor
|
||||
*/
|
||||
private RunningCluster(String infrastructureName) {
|
||||
//Query the IS (for the future)
|
||||
/*List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
||||
if (resources.size() > 1) {
|
||||
_log.error("Too many Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" in this scope ");
|
||||
throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name "
|
||||
+ RUNTIME_RESOURCE_NAME + " and Platform " + PLATFORM_NAME + ". Only one allowed per infrasrtucture.");
|
||||
}
|
||||
else if (resources.size() == 0){
|
||||
_log.error("There is no Runtime Resource having name " + RUNTIME_RESOURCE_NAME +" and Platform " + PLATFORM_NAME + " in this scope. Using default configuration properties: " + DEFAULT_CONFIGURATION);
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
else {
|
||||
for (ServiceEndpoint res : resources) {
|
||||
AccessPoint found = res.profile().accessPoints().iterator().next();
|
||||
host = found.address();
|
||||
clusterName = found.description();
|
||||
keyspaceName = found.name();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
|
||||
datacenterName = "1";
|
||||
keyspaceName = "dev_mig_new_schema_test";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
|
||||
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
|
||||
String scope = "/";
|
||||
if(infrastructureName != null && !infrastructureName.isEmpty())
|
||||
scope += infrastructureName;
|
||||
else {
|
||||
scope += readInfrastructureName();
|
||||
_log.debug("infrastrucute name is null, setting root scope=" + scope);
|
||||
}
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_RESOURCE_NAME +"'");
|
||||
query.addCondition("$resource/Profile/Platform/Name/text() eq '"+ PLATFORM_NAME +"'");
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
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);
|
||||
String propertyfile = sb.toString();
|
||||
File propsFile = new File(propertyfile);
|
||||
FileInputStream fis = new FileInputStream(propsFile);
|
||||
props.load( fis);
|
||||
return props.getProperty(GCubePortalConstants.INFRASTRUCTURE_NAME);
|
||||
}
|
||||
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);
|
||||
datacenterName = props.getProperty(DATACENTER_NAME_PROPERTY);
|
||||
keyspaceName = props.getProperty(KEY_SPACE_NAME_PROPERTY);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
||||
public String getKeyspaceName() {
|
||||
return keyspaceName;
|
||||
}
|
||||
|
||||
|
||||
public void setKeyspaceName(String keyspaceName) {
|
||||
this.keyspaceName = keyspaceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
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;
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
public class Schema {
|
||||
//Tables
|
||||
public static final String NOTIFICATIONS = "Notifications";
|
||||
public static final String POSTS = "Posts";
|
||||
public static final String COMMENTS = "Comments";
|
||||
public static final String LIKES = "Likes";
|
||||
public static final String INVITES = "Invites";
|
||||
public static final String VRE_TIMELINE_POSTS = "VRETimeline";
|
||||
public static final String USER_TIMELINE_POSTS = "UserTimeline";
|
||||
public static final String APP_TIMELINE_POSTS = "AppTimeline";
|
||||
public static final String USER_LIKED_POSTS = "UserLikes";
|
||||
public static final String USER_NOTIFICATIONS = "UserNotifications"; // regular user notifications timeline (both read and unread, messages are included)
|
||||
public static final String USER_NOTIFICATIONS_UNREAD = "UserUnreadNotifications"; // only unread user notifications/ notifications messages
|
||||
public static final String USER_NOTIFICATIONS_PREFERENCES = "UserNotificationsPreferences"; // preferences for notifications
|
||||
public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type
|
||||
public static final String HASHTAGGED_POSTS = "HashtaggedPosts"; // contains hashtags per type associated with vre and POST
|
||||
public static final String HASHTAGGED_COMMENTS = "HashtaggedComments"; // contains hashtags per type associated with vre and comment
|
||||
public static final String VRE_INVITES = "VREInvites"; //contains the emails that were invited per VRE
|
||||
public static final String EMAIL_INVITES = "EmailInvites"; //contains the list of invitation per email
|
||||
public static final String ATTACHMENTS = "Attachments"; //contains the list of all the attachments in a POST
|
||||
|
||||
//columns
|
||||
public static final String USER_ID = "userid"; //text
|
||||
public static final String TYPE = "type"; //text
|
||||
public static final String PREFERENCE = "preference"; //text
|
||||
public static final String TIMESTAMP = "timestamp"; //timestamp
|
||||
public static final String NOT_ID = "notid"; //UUID
|
||||
public static final String VRE_ID = "vreid"; //text
|
||||
public static final String POST_ID = "postid"; //UUID
|
||||
public static final String APP_ID = "appid"; //text
|
||||
public static final String HASHTAG = "hashtag"; //text
|
||||
public static final String COMMENT_ID = "commentid"; //UUID
|
||||
public static final String COUNT = "count"; //big int
|
||||
public static final String LIKE_ID = "likeid"; //UUID
|
||||
public static final String INVITE_ID = "inviteid"; //UUID
|
||||
public static final String STATUS = "status"; //text
|
||||
public static final String EMAIL = "email"; //text
|
||||
public static final String ATTACH_ID = "attachid"; //UUID
|
||||
public static final String URI = "uri"; //text
|
||||
public static final String NAME = "name"; //text
|
||||
public static final String DESCRIPTION = "description"; //text
|
||||
public static final String URI_THUMBNAIL = "urithumbnail"; //text
|
||||
public static final String MIME_TYPE = "mimetype"; //text
|
||||
public static final String SENDER_USER_ID = "senderuserid"; //text
|
||||
public static final String CONTROL_CODE = "controlcode"; //text
|
||||
public static final String SENDER_FULL_NAME = "senderfullname"; //text
|
||||
public static final String FULL_NAME = "fullname"; //text
|
||||
public static final String THUMBNAIL_URL = "thumbnailurl"; //text
|
||||
public static final String COMMENT = "comment"; //text
|
||||
public static final String IS_EDIT = "isedit"; //bool
|
||||
public static final String LAST_EDIT_TIME = "lastedittime"; //timestamp
|
||||
public static final String SUBJECT_ID = "subjectid"; //text
|
||||
public static final String SENDER_ID = "senderid"; //text
|
||||
public static final String SENDER_THUMBNAIL_URL = "senderthumbnailurl"; //text
|
||||
public static final String IS_READ = "isread"; //bool
|
||||
public static final String LINK_HOST = "linkhost"; //text
|
||||
public static final String LIKES_NO = "likesno"; //big int
|
||||
public static final String LINK_DESCRIPTION = "linkdescription"; //text
|
||||
public static final String IS_APPLICATION_POST = "isapplicationpost"; //bool -->
|
||||
public static final String ENTITY_ID = "entityid"; //text
|
||||
public static final String PRIVACY = "privacy"; //text
|
||||
public static final String MULTI_FILE_UPLOAD = "multifileupload"; //bool
|
||||
public static final String COMMENTS_NO = "commentsno"; //big int
|
||||
public static final String LINK_TITLE = "linktitle"; //text
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,45 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import org.gcube.portal.databook.shared.*;
|
||||
import org.gcube.portal.databook.shared.ex.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Tester {
|
||||
private static 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
host = node1.d.cassandra.research-infrastructures.eu
|
||||
port = 9160
|
||||
cluster = D4Science Cluster
|
||||
keyspace = DevKeySpace
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 Dec 2012
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ApplicationProfile implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String imageUrl;
|
||||
private String scope;
|
||||
private String url;
|
||||
|
||||
public ApplicationProfile() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.imageUrl = imageUrl;
|
||||
this.scope = scope;
|
||||
this.url = url;
|
||||
}
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
|
||||
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
|
||||
+ ", url=" + url + "]";
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,104 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jsonmaker.gwt.client.Jsonizer;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Attachment implements Serializable {
|
||||
|
||||
public interface AttachmentJsonizer extends Jsonizer {}
|
||||
|
||||
private String id;
|
||||
private String uri;
|
||||
private String name;
|
||||
private String description;
|
||||
private String thumbnailURL;
|
||||
private String mimeType;
|
||||
|
||||
public Attachment() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id in the cassandra CF
|
||||
* @param uri where you can download the file from
|
||||
* @param name the name of the attached file
|
||||
* @param description the description of the attached file
|
||||
* @param thumbnailURL the URL of the image representing the attached file
|
||||
* @param mimeType the type of file
|
||||
*/
|
||||
public Attachment(String id, String uri, String name, String description,
|
||||
String thumbnailURL, String mimeType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.uri = uri;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attachment [uri=" + uri + ", name=" + name + ", description="
|
||||
+ description + ", thumbnailURL=" + thumbnailURL
|
||||
+ ", mimeType=" + mimeType + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import jsinterop.annotations.JsOverlay;
|
||||
import jsinterop.annotations.JsPackage;
|
||||
import jsinterop.annotations.JsType;
|
||||
|
||||
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
|
||||
public class ClientAttachment {
|
||||
public String id;
|
||||
public String uri;
|
||||
public String name;
|
||||
public String description;
|
||||
public String thumbnailURL;
|
||||
public String mimeType;
|
||||
/**
|
||||
* @param id the id in the cassandra CF
|
||||
* @param uri where you can download the file from
|
||||
* @param name the name of the attached file
|
||||
* @param description the description of the attached file
|
||||
* @param thumbnailURL the URL of the image representing the attached file
|
||||
* @param mimeType the type of file
|
||||
*/
|
||||
@JsOverlay
|
||||
public static ClientAttachment create(String id, String uri, String name, String description, String thumbnailURL, String mimeType) {
|
||||
ClientAttachment o = new ClientAttachment();
|
||||
o.id = id;
|
||||
o.uri = uri;
|
||||
o.name = name;
|
||||
o.description = description;
|
||||
o.thumbnailURL = thumbnailURL;
|
||||
o.mimeType = mimeType;
|
||||
return o;
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,183 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jsonmaker.gwt.client.Jsonizer;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ClientFeed implements Serializable {
|
||||
|
||||
public interface ClientFeedJsonizer extends Jsonizer {}
|
||||
|
||||
private String key;
|
||||
private String type;
|
||||
private String userid;
|
||||
private Date time;
|
||||
private String uri;
|
||||
private String description;
|
||||
private String fullName;
|
||||
private String email;
|
||||
private String thumbnailURL;
|
||||
private String linkTitle;
|
||||
private String linkDescription;
|
||||
private String linkUrlThumbnail;
|
||||
private String linkHost;
|
||||
private List<Attachment> attachments;
|
||||
|
||||
public ClientFeed() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ClientFeed(String key, String type, String userid, Date time,
|
||||
String uri, String description, String fullName, String email,
|
||||
String thumbnailURL, String linkTitle, String linkDescription,
|
||||
String linkUrlThumbnail, String linkHost, List<Attachment> attachments) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.userid = userid;
|
||||
this.time = time;
|
||||
this.uri = uri;
|
||||
this.description = description;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
this.linkTitle = linkTitle;
|
||||
this.linkDescription = linkDescription;
|
||||
this.linkUrlThumbnail = linkUrlThumbnail;
|
||||
this.linkHost = linkHost;
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
|
||||
public String getLinkTitle() {
|
||||
return linkTitle;
|
||||
}
|
||||
|
||||
public void setLinkTitle(String linkTitle) {
|
||||
this.linkTitle = linkTitle;
|
||||
}
|
||||
|
||||
public String getLinkDescription() {
|
||||
return linkDescription;
|
||||
}
|
||||
|
||||
public void setLinkDescription(String linkDescription) {
|
||||
this.linkDescription = linkDescription;
|
||||
}
|
||||
|
||||
public String getLinkUrlThumbnail() {
|
||||
return linkUrlThumbnail;
|
||||
}
|
||||
|
||||
public void setLinkUrlThumbnail(String linkUrlThumbnail) {
|
||||
this.linkUrlThumbnail = linkUrlThumbnail;
|
||||
}
|
||||
|
||||
public String getLinkHost() {
|
||||
return linkHost;
|
||||
}
|
||||
|
||||
public void setLinkHost(String linkHost) {
|
||||
this.linkHost = linkHost;
|
||||
}
|
||||
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void setAttachments(List<Attachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientFeed [key=" + key + ", type=" + type + ", userid="
|
||||
+ userid + ", time=" + time + ", uri=" + uri + ", description="
|
||||
+ description + ", fullName=" + fullName + ", email=" + email
|
||||
+ ", thumbnailURL=" + thumbnailURL + ", linkTitle=" + linkTitle
|
||||
+ ", linkDescription=" + linkDescription
|
||||
+ ", linkUrlThumbnail=" + linkUrlThumbnail + ", linkHost="
|
||||
+ linkHost + ", attachments=" + attachments + "]";
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import jsinterop.annotations.JsOverlay;
|
||||
import jsinterop.annotations.JsPackage;
|
||||
import jsinterop.annotations.JsType;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, CNR-ISTI
|
||||
* Uses JsInterop annotations to deserialize the object
|
||||
*/
|
||||
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
|
||||
public class ClientPost {
|
||||
public String key;
|
||||
public String type;
|
||||
public String userid;
|
||||
public Date time;
|
||||
public String uri;
|
||||
public String description;
|
||||
public String fullName;
|
||||
public String email;
|
||||
public String thumbnailURL;
|
||||
public String linkTitle;
|
||||
public String linkDescription;
|
||||
public String linkUrlThumbnail;
|
||||
public String linkHost;
|
||||
public ClientAttachment[] attachments;
|
||||
@JsOverlay
|
||||
public static ClientPost create(String key, String type, String userid, Date time,
|
||||
String uri, String description, String fullName, String email,
|
||||
String thumbnailURL, String linkTitle, String linkDescription,
|
||||
String linkUrlThumbnail, String linkHost, ClientAttachment[] attachments) {
|
||||
ClientPost o = new ClientPost();
|
||||
o.key = key;
|
||||
o.type = type;
|
||||
o.userid = userid;
|
||||
o.time = time;
|
||||
o.uri = uri;
|
||||
o.description = description;
|
||||
o.fullName = fullName;
|
||||
o.email = email;
|
||||
o.thumbnailURL = thumbnailURL;
|
||||
o.linkTitle = linkTitle;
|
||||
o.linkDescription = linkDescription;
|
||||
o.linkUrlThumbnail = linkUrlThumbnail;
|
||||
o.linkHost = linkHost;
|
||||
o.attachments = attachments;
|
||||
return o;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue