Compare commits

...

48 Commits

Author SHA1 Message Date
Alfredo Oliviero a786cc7eb1 v2.1.0 2024-10-28 10:34:42 +01:00
Alfredo Oliviero 56c26287c5 Alfredo Oliviero added as author 2024-10-23 14:23:55 +02:00
Alfredo Oliviero 5015d4b49a date for v2.0.2 2024-10-14 14:53:17 +02:00
Alfredo Oliviero 59d23756e2 version number 2024-10-02 16:30:08 +02:00
Alfredo Oliviero 4d28d866f7 v2.1.0-SNAPSHOT.
- maven-portal-bom 4.0.0-SNAPSHOT
2024-10-02 16:29:31 +02:00
Alfredo Oliviero c9c3f10a7d gitignore 2024-10-02 16:28:09 +02:00
Alfredo Oliviero 9e43796935 changelog 2024-10-02 16:20:45 +02:00
Alfredo Oliviero 19a6d96a8e v2.0.2 2024-10-02 16:14:46 +02:00
Alfredo Oliviero 2928931739 v2.0.2-SNAPSHOT patch for production 2024-10-01 14:28:30 +02:00
Alfredo Oliviero f07a17ab95 fixed bug in getUserNotificationChannels, condition for the creation of a mnissing entry was null list instead of empty list
the specific logic for new WP_ notification entries is implemented now also in createNewNotificationType

getUserNotificationPreferences now creates the missing entries if the number of found entries is different from NotificationType.values().length
2024-10-01 14:12:53 +02:00
Ahmed Salah Tawfik Ibrahim 392ab46bc9 2.0.1 2024-05-17 11:34:00 +02:00
Ahmed Salah Tawfik Ibrahim 400cff1076 2.0.1-SNAPSHOT 2024-05-17 10:21:44 +02:00
Ahmed Salah Tawfik Ibrahim 572c7b8199 removed noisy logs 2024-04-22 10:49:02 +02:00
Ahmed Salah Tawfik Ibrahim 8509015a18 2.0.1 2024-04-16 15:19:38 +02:00
Ahmed Salah Tawfik Ibrahim 9fbec3653d 2.0.1-SNAPSHOT 2024-04-16 15:19:04 +02:00
Ahmed Salah Tawfik Ibrahim 85ab33184d cleaning logs 2024-04-16 15:04:52 +02:00
Ahmed Salah Tawfik Ibrahim 01821f5da3 cleaning logs 2024-04-16 15:03:57 +02:00
Ahmed Salah Tawfik Ibrahim bcbec61646 bug fix 2024-04-12 17:25:49 +02:00
Ahmed Salah Tawfik Ibrahim 93e501d65f bug fix 2024-04-12 17:25:22 +02:00
Ahmed Salah Tawfik Ibrahim 9a64a684d1 bug fix 2024-04-12 17:17:48 +02:00
Ahmed Salah Tawfik Ibrahim 5b5dfb56c4 bug fix 2024-04-12 17:17:23 +02:00
Ahmed Salah Tawfik Ibrahim 1562e6a441 bug fix 2024-04-12 17:02:13 +02:00
Ahmed Salah Tawfik Ibrahim 29471627da bug fix 2024-04-12 17:01:16 +02:00
Ahmed Salah Tawfik Ibrahim 8b6f4ccf2f bug fix 2024-04-12 16:32:02 +02:00
Ahmed Salah Tawfik Ibrahim 82d13b556b snapshot bug fix 2024-04-12 16:31:23 +02:00
Ahmed Salah Tawfik Ibrahim 899640141c possible fix 2024-04-11 18:30:21 +02:00
Ahmed Salah Tawfik Ibrahim 368d420799 possible fix 2024-04-11 18:19:55 +02:00
Ahmed Salah Tawfik Ibrahim 18cb5b7312 bug fixed 2024-04-11 14:44:58 +02:00
Ahmed Salah Tawfik Ibrahim b8f9b0a90a debug_error 2024-04-11 12:39:35 +02:00
Ahmed Salah Tawfik Ibrahim bcd8e29a8c Merge remote-tracking branch 'origin/master' 2023-12-13 13:47:29 +01:00
Ahmed Salah Tawfik Ibrahim 35c8cfdc5a Debug notification 2023-12-13 13:47:19 +01:00
Massimiliano Assante c06e47ea68 ready to release 2023-12-11 12:58:57 +01:00
Massimiliano Assante 5c2e5d5874 SNAPSHOT version 2023-12-11 12:58:08 +01:00
Ahmed Salah Tawfik Ibrahim 2a9bdc6c4a Ready for Release 2023-12-07 14:24:14 +01:00
Ahmed Salah Tawfik Ibrahim 083ca91e45 SNAPSHOT Version Ready 2023-12-07 14:23:28 +01:00
Ahmed Salah Tawfik Ibrahim 7aa3a1244e Ready for release 2023-12-07 14:21:20 +01:00
Ahmed Salah Tawfik Ibrahim 70d7e31540 Test new datacenter name 2023-12-07 14:14:23 +01:00
Ahmed Salah Tawfik Ibrahim 02bc40b6e8 Added Service Discovery 2023-12-06 16:40:46 +01:00
Ahmed Salah Tawfik Ibrahim 68a7532379 Added Service Discovery 2023-12-06 15:53:23 +01:00
Ahmed Salah Tawfik Ibrahim 79f326d906 Ready to release 2023-12-05 16:39:16 +01:00
Ahmed Salah Tawfik Ibrahim 0a9e97f680 Ready to release 2023-12-05 16:38:31 +01:00
Ahmed Salah Tawfik Ibrahim 099432f9a1 Ready to release 2023-12-05 16:31:08 +01:00
Ahmed Salah Tawfik Ibrahim 81542d5c0a Merge remote-tracking branch 'origin/master' 2023-12-05 16:30:09 +01:00
Ahmed Salah Tawfik Ibrahim 0d435d2398 Ready to release 2023-12-05 16:30:00 +01:00
Massimiliano Assante 38fdd5b762 fixed pom 2023-12-05 15:47:12 +01:00
Massimiliano Assante 9d04f4af59 fixed pom 2023-12-05 15:46:36 +01:00
Ahmed Salah Tawfik Ibrahim e8ca4a46a7 Ready to release 2023-12-04 18:16:12 +01:00
Ahmed Salah Tawfik Ibrahim 8a27841094 Snapshot version 2023-12-04 18:15:03 +01:00
19 changed files with 351 additions and 226 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

175
.gitignore vendored
View File

@ -1 +1,174 @@
/target/
#
ignore_me
tomcat
target
.classpath
.visual
.project
.settings
/**/.DS_Store
# Created by https://www.toptal.com/developers/gitignore/api/java,macos,linux,visualstudiocode,eclipse
# Edit at https://www.toptal.com/developers/gitignore?templates=java,macos,linux,visualstudiocode,eclipse
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
### Eclipse Patch ###
# Spring Boot Tooling
.sts4-cache/
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# End of https://www.toptal.com/developers/gitignore/api/java,macos,linux,visualstudiocode,eclipse

View File

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

View File

@ -1,2 +0,0 @@
eclipse.preferences.version=1
warSrcDirIsOutput=false

View File

@ -1,3 +0,0 @@
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=

View File

@ -1,4 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -1,15 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

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

View File

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

View File

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

View File

@ -1,2 +0,0 @@
disabled=06target
eclipse.preferences.version=1

View File

@ -4,9 +4,23 @@
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-10-30
## [v2.1.0] - 2024-10-28
- Feature #25901-fix, same as feature 25901 but with minor fixes related to deprecated methods and classes
- maven-portal-bom 4.0.0-SNAPSHOT
- [StorageHub] downstream components to upgrade in order to work with storagehub 1.5.0 [#27999]
## [v2.0.2] - 2024-10-14
- Mail notification Catalogue Item Rejected [#28020]
## [v2.0.1] - 2024-04-22
- Null pointer exception getting notifications preferences fixed [#27218]
- Removed noisy logs [#27286]
## [v2.0.0] - 2023-12-04
- Support for Cassandra 4.1.3 using DataStax java driver
## [v1.17.0] - 2022-05-13
@ -39,13 +53,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v1.10.0] - 2016-01-22
- Feature #1982, multi attachments to posts
- Multi attachments to posts [#1982]
## [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
- For user statistics fast retrieval [#1663]
- Updated the way we instanciate keyspace, now it is more efficient [#1493]
- Updated methods for editing comments [#246]
## [v1.8.0] - 2015-07-03
@ -55,7 +69,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added feature for post retrieval by range
- Added feature for notifications retrieval by range
- Added feature for unlike
- Added feature for unlike
## [v1.5.0] - 2014-03-05

View File

@ -5,7 +5,7 @@ The social networking facilities exploit a NoSQL data store for their storage. S
## Structure of the project
* The source code is present in the src folder.
* The source code is present in the src folder.
## Built With
@ -23,14 +23,13 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/social-util-library/r
## Authors
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
* **Alfredo Oliviero** ([ORCID]( https://orcid.org/0009-0007-3191-1025)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/A.Oliviero)
## Maintainers
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Ahmed Ibrahim** ([ORCID](https://orcid.org/0009-0001-3009-5755)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/en/about/people-detail/976/Ahmed_Salah_Tawfik_Ibrahim)
* **Alfredo Oliviero** ([ORCID]( https://orcid.org/0009-0007-3191-1025)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/A.Oliviero)
## License
@ -38,6 +37,7 @@ This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LIC
## 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

12
pom.xml
View File

@ -5,13 +5,13 @@
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
<version>1.2.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0</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.
@ -36,7 +36,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.4</version>
<version>4.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -47,16 +47,19 @@
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>${cassandra.driver.oss.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -88,15 +91,18 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

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

View File

@ -46,20 +46,32 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* @param dropSchema set true if you want do drop the current and set up new one
*/
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
conn = new CassandraClusterConnection(dropSchema);
try {
conn = new CassandraClusterConnection(dropSchema);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* public constructor, no dropping schema is allowed
*/
public DBCassandraAstyanaxImpl() {
conn = new CassandraClusterConnection(false);
try {
conn = new CassandraClusterConnection(false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* public constructor, no dropping schema is allowed, infrastructureName is given.
*/
public DBCassandraAstyanaxImpl(String infrastructureName) {
conn = new CassandraClusterConnection(false, infrastructureName);
try {
conn = new CassandraClusterConnection(false, infrastructureName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/*
@ -736,7 +748,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
Boolean result = session.execute(writeBatch).wasApplied();
if (result){
_log.info("Wrote user post with id " + post.getKey());
_log.debug("Wrote user post with id " + post.getKey());
}
@ -784,7 +796,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
Boolean result = session.execute(writeBatch).wasApplied();
if (result){
_log.info("Wrote user post with id " + post.getKey());
_log.debug("Wrote user post with id " + post.getKey());
}
@ -819,7 +831,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
post.setMultiFileUpload(true);
boolean savePostResult = saveUserPost(post);
if (savePostResult) {
_log.info("Post has been saved");
_log.debug("Post has been saved");
String postkey = post.getKey();
for (Attachment attachment : attachments) {
boolean attachSaveResult = saveAttachmentEntry(postkey, attachment);
@ -876,7 +888,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
boolean result = session.execute(writeBatch).wasApplied();
if (result)
_log.info("Wrote app post with id " + post.getKey());
_log.debug("Wrote app post with id " + post.getKey());
return result;
}
@ -924,7 +936,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
boolean result = session.execute(writeBatch).wasApplied();
if (result)
_log.info("Wrote app post with id " + post.getKey());
_log.debug("Wrote app post with id " + post.getKey());
return result;
}
@ -1157,7 +1169,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("Delete Post OK");
_log.debug("Delete Post OK");
return true;
}
/**
@ -1177,7 +1189,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("Delete Post OK");
_log.debug("Delete Post OK");
return true;
}
/**
@ -2176,20 +2188,27 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public List<NotificationChannelType> getUserNotificationChannels(String userid, NotificationType notificationType) throws NotificationChannelTypeNotFoundException, NotificationTypeNotFoundException {
_log.trace("Asking for Single Notification preference of " + userid + " Type: " + notificationType);
_log.debug("Asking for Single Notification preference of " + userid + " Type: " + notificationType);
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
NotificationChannelType[] toProcess = getUserNotificationPreferences(userid).get(notificationType);
if (toProcess == null) {
_log.warn("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
Map<NotificationType, NotificationChannelType[]> userNotPref = getUserNotificationPreferences(userid);
if(userNotPref ==null || ! userNotPref.containsKey(notificationType) || userNotPref.get(notificationType) == null ) {
_log.debug("Single Notification preference of " + userid + " Type: " + notificationType + " not existing ... creating default");
return createNewNotificationType(userid, notificationType);
}
else if (toProcess.length == 0)
NotificationChannelType[] toProcess = userNotPref.get(notificationType);
if (toProcess.length == 0){
_log.debug("size of user notification preferences " + 0);
return toReturn;
else
for (int i = 0; i < toProcess.length; i++) {
toReturn.add(toProcess[i]);
}
}
_log.debug("size of user notification preferences " + toProcess.length);
for (int i = 0; i < toProcess.length; i++) {
toReturn.add(toProcess[i]);
}
return toReturn;
}
/**
* called when you add new notification types where the setting does not exist yet
@ -2197,16 +2216,23 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
private List<NotificationChannelType> createNewNotificationType(String userid, NotificationType notificationType) {
List<NotificationChannelType> toReturn = new ArrayList<NotificationChannelType>();
_log.debug("Create new notification type");
CqlSession session = conn.getKeyspaceSession();
String valueToInsert = "";
NotificationChannelType[] wpTypes = NotificationChannelType.values();
for (int i = 0; i < wpTypes.length; i++) {
valueToInsert += wpTypes[i];
if (i < wpTypes.length-1)
valueToInsert += ",";
toReturn.add(wpTypes[i]); //add the new added notification type
// Set default channels to PORTAL for workspace notifications (starting with WP_), otherwise use all channels
if (notificationType.toString().startsWith("WP_")) {
valueToInsert += NotificationChannelType.PORTAL;
toReturn.add(NotificationChannelType.PORTAL);
} else {
for (int i = 0; i < wpTypes.length; i++) {
valueToInsert += wpTypes[i];
if (i < wpTypes.length-1)
valueToInsert += ",";
toReturn.add(wpTypes[i]); //add the new added notification type
}
}
BatchStatement writeBatch = getBatch().add(
@ -2222,9 +2248,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
if (res) {
_log.trace("Set New Notification Setting for " + userid + " OK");
_log.debug("Set New Notification Setting for " + userid + " OK");
_log.debug("toreturn:" + toReturn.toString());
return toReturn;
}
_log.debug("empty list");
return new ArrayList<NotificationChannelType>(); //no notification if sth fails
}
/**
@ -2237,10 +2265,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
for (NotificationType nType : enabledChannels.keySet()) {
String valueToInsert = "";
_log.info("Type: " + nType.toString());
_log.debug("Type: " + nType.toString());
int channelsNo = (enabledChannels.get(nType) != null) ? enabledChannels.get(nType).length : 0;
for (int i = 0; i < channelsNo; i++) {
_log.info(enabledChannels.get(nType)[i].toString());
_log.debug(enabledChannels.get(nType)[i].toString());
valueToInsert += NotificationChannelType.valueOf(enabledChannels.get(nType)[i].toString());
if (i < channelsNo-1)
valueToInsert += ",";
@ -2256,19 +2284,20 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
BatchStatement writeBatch = getBatch().addAll(boundStatements);
boolean overAllresult = session.execute(writeBatch).wasApplied();
if (overAllresult)
_log.info("Set Notification Map for " + userid + " OK");
_log.debug("Set Notification Map for " + userid + " OK");
else
_log.info("Set Notification Map for " + userid + " FAILED");
_log.debug("Set Notification Map for " + userid + " FAILED");
return overAllresult;
}
/**
* {@inheritDoc}
*
* by default Workspace and Calendar Notifications are set to Portal
* check if the number of preferences found is the same of NotificationType.values().length, if different creates the missing entries
*/
@Override
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferences(String userid) throws NotificationTypeNotFoundException, NotificationChannelTypeNotFoundException {
_log.trace("Asking for Notification preferences of " + userid);
_log.debug("Asking for Notification preferences of " + userid);
Map<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
ResultSet result = null;
@ -2285,44 +2314,69 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
e.printStackTrace();
}
// Check if the number of results is different from the total number of NotificationType values, meaning some preferences are missing
List<Row> results = new ArrayList<>();
if(result!=null) results = result.all();
if (results.size() != NotificationType.values().length) {
_log.debug("Userid " + userid + " settings incomplete, initiating missing preferences...");
//if there are no settings for this user create an entry and put all of them at true
List<Row> results = result.all();
if (results.isEmpty()) {
_log.info("Userid " + userid + " settings not found, initiating its preferences...");
HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
for (int i = 0; i < NotificationType.values().length; i++) {
//TODO: Potential bug in NotificationType for workspace are refactored
//create a map with all notification enabled except for workspace notifications (They start with WP_) it was the only quick way
if (NotificationType.values()[i].toString().startsWith("WP_")) {
NotificationChannelType[] wpTypes = { NotificationChannelType.PORTAL };
toCreate.put(NotificationType.values()[i], wpTypes);
}
else
toCreate.put(NotificationType.values()[i], NotificationChannelType.values());
}
setUserNotificationPreferences(userid, toCreate); //commit the map
return toCreate;
}
else {
_log.trace("Notification preferences Found for " + userid);
for (Row row: results){
String[] channels = row.getString(PREFERENCE).split(",");
if (channels != null && channels.length == 1 && channels[0].toString().equals("") ) { //it is empty, preference is set to no notification at all
toReturn.put(getNotificationType(row.getString(TYPE)), new NotificationChannelType[0]);
} else {
NotificationChannelType[] toAdd = new NotificationChannelType[channels.length];
for (int i = 0; i < channels.length; i++) {
if (channels[i].compareTo("") != 0) {
toAdd[i] = (getChannelType(channels[i]));
}
for (NotificationType notificationType : NotificationType.values()) {
boolean found = false;
for (Row row : results) {
if (getNotificationType(row.getString(TYPE)).equals(notificationType)) {
found = true;
break;
}
toReturn.put(getNotificationType(row.getString(TYPE)), toAdd);
}
// If the preference is missing, add the default value
if (!found) {
_log.debug("Missing preference for " + notificationType + ", setting default.");
NotificationChannelType[] defaultChannels;
// Set default channels to PORTAL for workspace notifications (starting with WP_), otherwise use all channels
if (notificationType.toString().startsWith("WP_")) {
defaultChannels = new NotificationChannelType[]{ NotificationChannelType.PORTAL };
} else {
defaultChannels = NotificationChannelType.values();
}
toCreate.put(notificationType, defaultChannels);
}
}
// Save the missing preferences if any were found
if (!toCreate.isEmpty()) {
setUserNotificationPreferences(userid, toCreate);
}
// Re-execute the query to return the updated values from the database
result = session.execute(stmtFind.bind(userid));
results = (result != null) ? result.all() : new ArrayList<>();
}
_log.debug("Notification preferences Found for " + userid + " : " + results.size()) ;
for (Row row: results){
String[] channels = row.getString(PREFERENCE).split(",");
//_log.debug("Row : " + row.getString(PREFERENCE));
if (channels != null && channels.length == 1 && channels[0].toString().equals("") ) { //it is empty, preference is set to no notification at all
//_log.debug("adding CHANNELS NULL: " + getNotificationType(row.getString(TYPE)) + ", " + new NotificationChannelType[0]);
toReturn.put(getNotificationType(row.getString(TYPE)), new NotificationChannelType[0]);
} else {
NotificationChannelType[] toAdd = new NotificationChannelType[channels.length];
for (int i = 0; i < channels.length; i++) {
if (channels[i].compareTo("") != 0) {
toAdd[i] = (getChannelType(channels[i]));
}
}
//_log.debug("adding channels not null: " + getNotificationType(row.getString(TYPE)) + ", " + toAdd.toString());
toReturn.put(getNotificationType(row.getString(TYPE)), toAdd);
}
}
_log.debug("Returning:"+toReturn.size());
return toReturn;
}
/*
@ -2397,7 +2451,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
e.printStackTrace();
return false;
}
_log.info("Writing comment : {}", comment.toString());
_log.debug("Writing comment : {}", comment.toString());
CqlSession session = conn.getKeyspaceSession();
List<BoundStatement> boundStatements = insertIntoComments(session, comment);
@ -2408,10 +2462,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
try {
ResultSet res = session.execute(writeBatch);
for (ExecutionInfo ex: res.getExecutionInfos()){
_log.info("Writing comment result errors: {}", ex.getErrors());
_log.info("Writing comment result payload: {}", ex.getIncomingPayload());
_log.debug("Writing comment result errors: {}", ex.getErrors());
_log.debug("Writing comment result payload: {}", ex.getIncomingPayload());
}
_log.info("Writing comment result executed?: {}", res.wasApplied());
_log.debug("Writing comment result executed?: {}", res.wasApplied());
} catch (Exception e) {
e.printStackTrace();
@ -2570,7 +2624,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
try {
boolean res = session.execute(writeBatch).wasApplied();
_log.info("Comments update OK to: " + comment2Edit.getText());
_log.debug("Comments update OK to: " + comment2Edit.getText());
return res;
} catch (Exception e) {
@ -2671,7 +2725,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
if (isPostLiked(like.getUserid(), feedId)) {
_log.info("User " + like.getUserid() + " already liked Feed " + feedId);
_log.debug("User " + like.getUserid() + " already liked Feed " + feedId);
return true;
}
else {
@ -3123,7 +3177,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
if(feeds.isEmpty()){
_log.info("There are no feeds containing hashtag " + row.getString(HASHTAG) + " in vre " + vreid);
_log.debug("There are no feeds containing hashtag " + row.getString(HASHTAG) + " in vre " + vreid);
continue;
}
@ -3604,8 +3658,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
BatchStatement writeBatch = getBatch().addAll(boundStatements);
//boundStatements.forEach(stmt->writeBatch.add(stmt));
ResultSet res = session.execute(writeBatch);
_log.info(res.getExecutionInfos().toString());
_log.info(""+res.wasApplied());
_log.debug(res.getExecutionInfos().toString());
_log.debug(""+res.wasApplied());
/*
session.execute(createNewaAttachEntry(session).bind(
UUID.fromString(toSave.getId()),
@ -3917,7 +3971,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("CommentsNo update OK to: " + newCount);
_log.debug("CommentsNo update OK to: " + newCount);
return true;
}
@ -3946,7 +4000,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return false;
}
_log.info("LikesNo update OK to: " + newCount);
_log.debug("LikesNo update OK to: " + newCount);
return true;
}

View File

@ -49,7 +49,7 @@ public class RunningCluster implements Serializable {
/**
* other constants
*/
private final static String RUNTIME_RESOURCE_NAME = "SocialPortalDataStore";
private final static String RUNTIME_RESOURCE_NAME = "SocialDB";
private final static String PLATFORM_NAME = "Cassandra";
private static final String DEFAULT_CONFIGURATION = "/org/gcube/portal/databook/server/resources/databook.properties";
@ -72,7 +72,7 @@ public class RunningCluster implements Serializable {
* @param infrastructureName could be null
* @return an instance of the RunningCluster
*/
public static synchronized RunningCluster getInstance(String infrastructureName) {
public static synchronized RunningCluster getInstance(String infrastructureName){
if (singleton == null) {
singleton = new RunningCluster(infrastructureName);
}
@ -81,9 +81,10 @@ public class RunningCluster implements Serializable {
/**
* private constructor
*/
private RunningCluster(String infrastructureName) {
private RunningCluster(String infrastructureName){
//Query the IS (for the future)
/*List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
try{
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 "
@ -97,17 +98,17 @@ public class RunningCluster implements Serializable {
for (ServiceEndpoint res : resources) {
AccessPoint found = res.profile().accessPoints().iterator().next();
host = found.address();
clusterName = found.description();
datacenterName = found.description();
keyspaceName = found.name();
}
}
} catch (Exception e) {
e.printStackTrace();
}*/
}
host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
/*host = "10.1.28.55:9042, 10.1.30.142:9042, 10.1.28.100:9042";
datacenterName = "1";
keyspaceName = "dev_mig_consistent";
keyspaceName = "dev_mig_consistent";*/
}
/**
@ -115,7 +116,7 @@ public class RunningCluster implements Serializable {
* @return the
* @throws Exception
*/
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) {
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
String scope = "/";
if(infrastructureName != null && !infrastructureName.isEmpty())

View File

@ -20,6 +20,7 @@ public class Tester {
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 {