Compare commits

...

49 Commits

Author SHA1 Message Date
Ahmed Salah Tawfik Ibrahim 2b523df4fb Maven parent 1.2.0 2024-05-17 11:47:42 +02:00
Ahmed Salah Tawfik Ibrahim 6e17205ed8 Maven parent 1.2.0 2024-05-17 11:47:13 +02:00
Ahmed Salah Tawfik Ibrahim 1bf94640ce 2.0.1 2024-04-17 18:58:14 +02:00
Ahmed Salah Tawfik Ibrahim d770fb89eb 2.0.1 2024-04-17 18:57:43 +02:00
Ahmed Salah Tawfik Ibrahim 0adb1272aa 2.0.0 2024-04-17 17:18:41 +02:00
Ahmed Salah Tawfik Ibrahim 3193f8a98b 2.0.0 2024-04-17 17:17:02 +02:00
Ahmed Salah Tawfik Ibrahim b9215ba78b fixed POM 2024-04-17 13:41:31 +02:00
Ahmed Salah Tawfik Ibrahim d0e441e1d1 fixed POM 2024-04-17 13:41:04 +02:00
Ahmed Salah Tawfik Ibrahim 0528ea2f1b fixed java version 2024-04-17 13:33:12 +02:00
Ahmed Salah Tawfik Ibrahim 5e83765b45 fixed java version 2024-04-17 13:32:53 +02:00
Ahmed Salah Tawfik Ibrahim 461a50d1f1 2.0.1 2024-04-16 15:59:16 +02:00
Ahmed Salah Tawfik Ibrahim 7e1316a45c 2.0.1-SNAPSHOT 2024-04-16 15:58:37 +02:00
Ahmed Salah Tawfik Ibrahim 011fba9c3e snl dependency fixed 2024-04-16 15:40:44 +02:00
Ahmed Salah Tawfik Ibrahim 9a21211184 fixed java version 2024-04-11 15:07:47 +02:00
Ahmed Salah Tawfik Ibrahim b0c2b752b1 fixed dependency snl 2024-04-11 14:56:59 +02:00
Ahmed Salah Tawfik Ibrahim 5772d95c97 fixed dependency snl 2024-04-11 14:54:48 +02:00
Massimiliano Assante 635efcb599 just removed a log 2023-12-21 08:57:19 +01:00
Massimiliano Assante da4789b56b ready to release 2023-12-11 12:56:21 +01:00
Massimiliano Assante 23bd836f2c snapshot 2023-12-11 12:51:45 +01:00
Ahmed Salah Tawfik Ibrahim bb4a4afeaa Ready for release 2023-12-06 12:32:39 +01:00
Ahmed Salah Tawfik Ibrahim 57c3a05bea SNAPSHOT version release 2023-12-06 12:31:39 +01:00
Ahmed Salah Tawfik Ibrahim 54fd5cc71c Merge remote-tracking branch 'origin/master' 2023-12-06 12:30:47 +01:00
Ahmed Salah Tawfik Ibrahim 5f81e7e664 BaseClient service discovery 2023-12-06 12:29:53 +01:00
Massimiliano Assante 995f88cb67 ready to release 2023-12-04 18:02:26 +01:00
Massimiliano Assante cebe0b454a snapshot release 2023-12-04 18:01:03 +01:00
Massimiliano Assante 8ae547a606 releasing 2.0 version 2023-12-04 17:55:33 +01:00
Ahmed Salah Tawfik Ibrahim b3d7ef8c85 Debug notification preferences 2023-12-04 17:12:05 +01:00
Ahmed Salah Tawfik Ibrahim 39b76c1476 Merge remote-tracking branch 'origin/Feature/26044' into Feature/26044 2023-12-04 16:06:39 +01:00
Ahmed Salah Tawfik Ibrahim 48417a3255 Fix notifications 2023-12-04 16:06:26 +01:00
Massimiliano Assante 23daa62c05 version 2.0 Snapshot 2023-12-01 15:17:11 +01:00
Massimiliano Assante 04fef1f26d fixed changelog 2023-12-01 15:14:37 +01:00
Massimiliano Assante 11f052ebef new beta version 2023-12-01 15:13:38 +01:00
Ahmed Salah Tawfik Ibrahim dadf817c3a New social client 2023-12-01 15:01:35 +01:00
Ahmed Salah Tawfik Ibrahim 5088ed448e New social client 2023-11-28 19:41:04 +01:00
Ahmed Salah Tawfik Ibrahim a32f4f8038 Added Author 2023-11-24 11:54:53 +01:00
Ahmed Salah Tawfik Ibrahim 7b97d4f630 API corresponding to each social networking library function. 2023-11-22 19:39:31 +01:00
Ahmed Salah Tawfik Ibrahim 86cf7f6d70 API corresponding to each social networking library function. 2023-11-21 18:36:28 +01:00
Ahmed Salah Tawfik Ibrahim a8aa40c1cd API corresponding to each social networking library function. 2023-11-21 17:58:34 +01:00
Ahmed Salah Tawfik Ibrahim 3400f6539d API corresponding to each social networking library function. 2023-11-21 14:08:50 +01:00
Massimiliano Assante 1809eec72e ready to release 2022-10-20 19:15:52 +02:00
Massimiliano Assante f1dc5ed095 ready to release 2022-10-20 19:08:05 +02:00
Massimiliano Assante 97d939bbaa added lombok dep for JDK 11 2022-10-20 19:06:42 +02:00
Massimiliano Assante b232c7ead6 revised range for model 2022-10-20 19:01:15 +02:00
Massimiliano Assante aa434744ab impl. complete 2022-10-20 18:57:58 +02:00
Massimiliano Assante 631461b31f Feature #23887 possibility to get-usernames-by-role in UserClient 2022-10-20 14:38:51 +02:00
Massimiliano Assante de923b5f61 Feature #23887 possibility to get-usernames-by-role in UserClient 2022-10-20 14:38:36 +02:00
Massimiliano Assante 34dc31ced0 feature #23887 implemented 2022-09-20 11:26:48 +02:00
Massimiliano Assante 6baee4ca85 fix test 2022-07-27 11:36:58 +02:00
Massimiliano Assante 4036de44f0 fixed the test 2022-07-27 11:01:43 +02:00
14 changed files with 794 additions and 131 deletions

View File

@ -8,9 +8,9 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">

View File

@ -1,5 +1,20 @@
# Changelog
## [v2.0.1] - 2024-04-16
- fixed dependency versions
## [v2.0.0] - 2023-12-04
- Integrated corresponding API calls for all the public functions in Social Networking Library
## [v1.2.0] - 2022-10-20
- Minor fix on a method name
- Feature #23887 possibility to get-usernames-by-role in UserClient
- Feature #23995 Social Service add support for set Message read / unread
## [v1.1.0] - 2022-04-06
- First release

View File

@ -20,10 +20,12 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/social-service-client
## 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)
## 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)
## License
@ -38,4 +40,4 @@ 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)

44
pom.xml
View File

@ -1,16 +1,18 @@
<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">
<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>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>1.1.0</version>
<version>2.0.1</version>
<name>social-networking-service-client</name>
<packaging>jar</packaging>
<description>The social networking web service client library</description>
@ -20,14 +22,14 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -35,7 +37,7 @@
</dependencyManagement>
<properties>
<java-version>1.8</java-version>
<java-version>1.8</java-version>
<jaxrs.version>2.0.1</jaxrs.version>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<gCubeSubsystem>social-networking</gCubeSubsystem>
@ -54,9 +56,29 @@
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>[1.16.0, 2.0.0)</version>
<version>[2.0.0, 3.0.0)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-generic-clients</artifactId>
@ -65,7 +87,13 @@
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-model</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
<version>[1.2.0-SNAPSHOT, 2.0.0)</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -10,20 +10,18 @@ import org.slf4j.LoggerFactory;
*/
public abstract class BaseClient {
private static Logger logger = LoggerFactory.getLogger(BaseClient.class);
private String serviceEndpoint;
public BaseClient(String subPath) throws Exception {
ServiceDiscoverer discoverer = new ServiceDiscoverer();
logger.debug("Discovering service...");
serviceEndpoint = discoverer.getEntryPoint();
serviceEndpoint = serviceEndpoint.endsWith("/") ? serviceEndpoint + subPath :
serviceEndpoint + "/" + subPath;
logger.debug("Discovered service " + serviceEndpoint);
}
private static Logger logger = LoggerFactory.getLogger(BaseClient.class);
private String serviceEndpoint;
public String getServiceEndpoint() {
return serviceEndpoint;
}
public BaseClient(String subPath) throws Exception {
ServiceDiscoverer discoverer = new ServiceDiscoverer();
serviceEndpoint = discoverer.getEntryPoint();
logger.debug("Discovering service...");
serviceEndpoint = serviceEndpoint.endsWith("/") ? serviceEndpoint + subPath : serviceEndpoint + "/" + subPath;
logger.info("Discovered service " + serviceEndpoint);
}
public String getServiceEndpoint() {
return serviceEndpoint;
}
}

View File

@ -1,10 +1,16 @@
package org.gcube.social_networking.social_networking_client_library;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.GenericType;
import org.apache.commons.lang.Validate;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Post;
import org.gcube.portal.databook.shared.ex.*;
import org.gcube.social_networking.social_networking_client_library.utils.HttpClient;
import org.gcube.social_networking.socialnetworking.model.output.ResponseBean;
import org.slf4j.Logger;
@ -13,6 +19,7 @@ import org.slf4j.LoggerFactory;
/**
* HashTags client.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @author Ahmed Ibrahim at ISTI-CNR (ahmed.ibrahim@isti.cnr.it)
*/
public class HashTagClient extends BaseClient{
@ -34,5 +41,4 @@ public class HashTagClient extends BaseClient{
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<HashMap<String, Integer>>>(){}, request);
}
}

View File

@ -0,0 +1,487 @@
package org.gcube.social_networking.social_networking_client_library;
import org.apache.commons.lang.Validate;
import org.gcube.portal.databook.shared.*;
import org.gcube.social_networking.social_networking_client_library.utils.HttpClient;
import org.gcube.social_networking.socialnetworking.model.output.ResponseBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.GenericType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LibClient extends BaseClient{
private static final String SUB_SERVICE_PATH = "2/lib/";
private static Logger logger = LoggerFactory.getLogger(LibClient.class);
public LibClient() throws Exception {
super(SUB_SERVICE_PATH);
}
//Comments
public Boolean addCommentLib(Comment comment){
Validate.isTrue(comment != null, "Comment to write cannot be null");
logger.debug("Request for writing comment");
String thisMethodSignature = "add-comment-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, comment);
}
public Comment readCommentByIdLib(String commentid){
Validate.isTrue(commentid != null, "Commentid to read cannot be null");
logger.debug("Request for reading commentid");
String thisMethodSignature = "read-comment-by-id-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?commentid=" + commentid;
return HttpClient.get(new GenericType<ResponseBean<Comment>>(){}, request);
}
public List<Comment> getAllCommentsByPostIdLib(String postid){
Validate.isTrue(postid != null, "Postid to read cannot be null");
logger.debug("Request for reading comments of post");
String thisMethodSignature = "get-comments-by-post-id-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postid;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Comment>>>(){}, request);
}
public List<Comment> getRecentCommentsByUserAndDateLib(final String userid,
final long timeInMillis){
Validate.isTrue(userid != null, "username to read cannot be null");
logger.debug("Request for reading recent comments of user");
String thisMethodSignature = "get-recent-comments-by-user-and-date-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?time=" + timeInMillis + "&username=" + userid;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Comment>>>(){}, request);
}
public Boolean editCommentLib(Comment comment){
Validate.isTrue(comment != null, "Comment to write cannot be null");
logger.debug("Request for writing comment");
String thisMethodSignature = "edit-comment-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, comment);
}
public boolean deleteCommentLib(String commentid, String postid){
Validate.isTrue(commentid != null, "Comment to write cannot be null");
logger.debug("Request for del comment");
String thisMethodSignature = "delete-comment-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?commentid=" + commentid + "&postid=" + postid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, postid);
}
//Hashtags
public boolean saveHashTagsLib(String feedid, String vreid, List<String> hashtags) {
Validate.isTrue(hashtags != null, "hashtags to write cannot be null");
logger.debug("Request for saving hashtags");
String thisMethodSignature = "save-hashtag-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?feedid=" + feedid + "&vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, hashtags);
}
public boolean deleteHashTagsLib(String feedid, String vreid, List<String> hashtags) {
Validate.isTrue(hashtags != null, "hashtags to delete cannot be null");
logger.debug("Request for deleting hashtags");
String thisMethodSignature = "delete-hashtag-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?feedid=" + feedid + "&vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, hashtags);
}
public boolean saveHashTagsCommentLib(String commentId, String vreid, List<String> hashtags){
Validate.isTrue(hashtags != null, "hashtags to comment cannot be null");
logger.debug("Request for saving hashtags comment");
String thisMethodSignature = "save-hashtag-comment-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?commentid=" + commentId + "&vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, hashtags);
}
public boolean deleteHashTagsCommentLib(String commentId, String vreid, List<String> hashtags) {
Validate.isTrue(hashtags != null, "hashtags to comment delete cannot be null");
logger.debug("Request for deleting hashtags comment");
String thisMethodSignature = "delete-hashtag-comment-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?commentid=" + commentId + "&vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, hashtags);
}
public Map<String, Integer> getVREHashtagsWithOccurrenceLib(String vreid) {
logger.debug("Request for vre hashtags occurrences");
String thisMethodSignature = "get-vre-hashtags-occurrences-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid;
return HttpClient.get(new GenericType<ResponseBean<HashMap<String, Integer>>>(){}, request);
}
public Map<String, Integer> getVREHashtagsWithOccurrenceFilteredByTimeLib(String vreid, long timestamp){
logger.debug("Request for vre hashtags occurrences with time");
String thisMethodSignature = "get-vre-hashtags-occurrences-time-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&time=" + timestamp;
return HttpClient.get(new GenericType<ResponseBean<HashMap<String, Integer>>>(){}, request);
}
public List<Post> getVREPostsByHashtagLib(String vreid, String hashtag){
hashtag = hashtag.substring(1);
logger.debug("Request for vre of hashtags");
String thisMethodSignature = "get-vre-post-by-hashtag-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&hashtag=" + hashtag;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
//Invites
public String isExistingInviteLib(String vreid, String email){
Validate.isTrue(email != null, "email to invite cannot be null");
logger.debug("Request for inviting to vre");
String thisMethodSignature = "is-existing-invite-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&email=" + email;
return HttpClient.get(new GenericType<ResponseBean<String>>(){}, request);
}
public InviteOperationResult saveInviteLib(Invite invite){
Validate.isTrue(invite != null, "likeid to unlike cannot be null");
logger.debug("Request for saving invite");
String thisMethodSignature = "save-invite-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<InviteOperationResult>>(){}, request, invite);
}
public Invite readInviteLib(String inviteid){
Validate.isTrue(inviteid != null, "inviteid to read likes cannot be null");
logger.debug("Request for reading invite");
String thisMethodSignature = "read-invite-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?inviteid=" + inviteid;
return HttpClient.get(new GenericType<ResponseBean<Invite>>(){}, request);
}
public boolean setInviteStatusLib(String vreid, String email, InviteStatus status){
Validate.isTrue(status != null, "status to set cannot be null");
logger.debug("Request for setting invite status");
String thisMethodSignature = "set-invite-status-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&email=" + email;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, status);
}
public List<Invite> getInvitedEmailsByVRELib(String vreid, InviteStatus... status){
Validate.isTrue(status != null, "status to get cannot be null");
logger.debug("Request for getting email invites");
String thisMethodSignature = "get-invited-email-by-vre-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<ArrayList<Invite>>>(){}, request, status);
}
//Likes
public boolean likeLib(Like like){
Validate.isTrue(like != null, "like to write cannot be null");
logger.debug("Request for liking post");
String thisMethodSignature = "like-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, like);
}
public boolean unlikeLib(String userid, String likeid, String feedid){
Validate.isTrue(likeid != null, "likeid to unlike cannot be null");
logger.debug("Request for unliking post");
String thisMethodSignature = "unlike-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&likeid=" + likeid + "&feedid=" + feedid ;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, likeid);
}
public List<String>getAllLikedPostIdsByUserLib(String userid){
Validate.isTrue(userid != null, "userid to read likes cannot be null");
logger.debug("Request for reading likes of user");
String thisMethodSignature = "get-all-liked-posts-by-user-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
public List<Like>getAllLikesByPostLib(String postid){
Validate.isTrue(postid != null, "postid to read likes cannot be null");
logger.debug("Request for reading likes of post");
String thisMethodSignature = "get-all-likes-by-post-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postid;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Like>>>(){}, request);
}
//Notifications
public boolean saveNotificationLib(Notification n){
Validate.isTrue(n != null, "Notification cannot be null");
logger.debug("Request for saving notification");
String thisMethodSignature = "save-notification-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, n);
}
public Notification readNotificationLib(String notificationid){
logger.debug("Request for getting notification by id");
String thisMethodSignature = "read-notification-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?notid=" + notificationid;
return HttpClient.get(new GenericType<ResponseBean<Notification>>(){}, request);
}
public boolean setNotificationReadLib(String notificationid){
Validate.isTrue(notificationid != null, "Notificationid cannot be null");
logger.debug("Request for setting notification read");
String thisMethodSignature = "set-notification-read-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?notid=" + notificationid;;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, notificationid);
}
public List<Notification> getAllNotificationByUserLib(String userid, int limit) {
logger.debug("Request for getting notification by user");
String thisMethodSignature = "get-all-notifications-user";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&limit=" + limit;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Notification>>>(){}, request);
}
public List<Notification> getUnreadNotificationsByUserLib(String userid) {
logger.debug("Request for getting unread notification by user");
String thisMethodSignature = "get-unread-notifications-user";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Notification>>>(){}, request);
}
public List<Notification> getRangeNotificationsByUserLib(String userid,int from, int quantity) {
logger.debug("Request for getting range notification by user");
String thisMethodSignature = "get-range-notifications-user";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&from=" + from + "&quantity=" + quantity;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Notification>>>(){}, request);
}
public boolean setAllNotificationReadByUserLib(String userid) {
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for setting all notification read");
String thisMethodSignature = "set-all-notification-read-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, userid);
}
public boolean checkUnreadNotificationsLib(String userid) {
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for check unread notifications");
String thisMethodSignature = "check-unread-notification-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, userid);
}
public boolean checkUnreadMessagesNotificationsLib(String userid) {
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for check unread messages notifications");
String thisMethodSignature = "check-unread-messages-notification-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, userid);
}
public List<NotificationChannelType> getUserNotificationChannelsLib(String userid, NotificationType notificationType) {
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for get user notification channels");
String thisMethodSignature = "get-user-notification-channels-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&type=" + notificationType.toString();
return HttpClient.get(new GenericType<ResponseBean<ArrayList<NotificationChannelType>>>(){}, request);
}
public boolean setUserNotificationPreferencesLib(String userid, Map<NotificationType, NotificationChannelType[]> enabledChannels){
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for set user notification preferences");
String thisMethodSignature = "set-notification-preference-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;
for(NotificationType notificationType: enabledChannels.keySet()){
logger.info("Type: " + notificationType.toString());
for(NotificationChannelType channelType: enabledChannels.get(notificationType)){
logger.info(channelType.toString());
}
}
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, enabledChannels);
}
public Map<NotificationType, NotificationChannelType[]> getUserNotificationPreferencesLib(String userid){
Validate.isTrue(userid != null, "userid cannot be null");
logger.debug("Request for getting notification preferences");
String thisMethodSignature = "get-notification-preference-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid;;
return HttpClient.get(new GenericType<ResponseBean<HashMap<NotificationType, NotificationChannelType[]>>>(){}, request);
}
public boolean saveUserPostLib(Post post){
Validate.isTrue(post != null, "Post to write cannot be null");
logger.debug("Request for save user post");
String thisMethodSignature = "save-user-post-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, post);
} //bool
public boolean saveAttachmentEntryLib(String postkey, Attachment attachment){
Validate.isTrue(attachment != null, "Attachment to write cannot be null");
logger.debug("Request for save attachment");
String thisMethodSignature = "save-attachment-lib" + "?postid=" + postkey;
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, attachment);
}
public boolean saveUserPostLib(Post post, List<Attachment> attachments ){
Validate.isTrue(post != null, "Post to write cannot be null");
if (attachments != null && !attachments.isEmpty())
post.setMultiFileUpload(true);
boolean savePostResult = saveUserPostLib(post);
if (savePostResult) {
logger.info("Post has been saved");
String postkey = post.getKey();
for (Attachment attachment : attachments) {
boolean attachSaveResult = saveAttachmentEntryLib(postkey, attachment);
if (!attachSaveResult)
logger.info("Some of the attachments failed to be saved: " + attachment.getName());
}
return true;
}
else return false;
}
public boolean saveAppPostLib(Post post, List<Attachment> attachments) {
Validate.isTrue(post != null, "Post to write cannot be null");
if (attachments != null && !attachments.isEmpty())
post.setMultiFileUpload(true);
boolean savePostResult = saveAppPostLib(post);
if (savePostResult) {
logger.info("Post has been saved");
String postkey = post.getKey();
for (Attachment attachment : attachments) {
boolean attachSaveResult = saveAttachmentEntryLib(postkey, attachment);
if (!attachSaveResult)
logger.info("Some of the attachments failed to be saved: " + attachment.getName());
}
return true;
}
else return false;
}
public boolean saveAppPostLib(Post post){
Validate.isTrue(post != null, "Post to write cannot be null");
logger.debug("Request for saving application post");
String thisMethodSignature = "save-app-post-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, post);
} //bool
public boolean savePostToVRETimelineLib(String postkey, String vreid){
Validate.isTrue(postkey != null, "Post to write cannot be null");
logger.debug("Request for writing post to vretimeline");
String thisMethodSignature = "save-post-to-vretimeline-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postkey + "&vreid=" + vreid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, postkey);
} //bool
public Post readPostLib(String postid){
logger.debug("Request for getting post with id");
String thisMethodSignature = "read-post-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postid;
return HttpClient.get(new GenericType<ResponseBean<Post>>(){}, request);
} //post
public List<Post> getRecentPostsByUserAndDateLib(String userid, long timeinmillis){
logger.debug("Request for getting recent posts by user");
String thisMethodSignature = "get-recent-posts-by-user-date-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&time=" + timeinmillis;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
} //list<post>
public boolean deletePostLib(String postid){
Validate.isTrue(postid != null, "feed to delete cannot be null");
logger.debug("Request for delete user post");
String thisMethodSignature = "delete-post-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postid;
return HttpClient.post(new GenericType<ResponseBean<Boolean>>(){}, request, postid);
} //bool
public List<Post> getAllPostsByUserLib(String userid) {
logger.debug("Request for getting all posts by user");
String thisMethodSignature = "get-all-posts-by-user-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public List<Post> getAllPostsByAppLib(String appid) {
logger.debug("Request for getting all posts by app");
String thisMethodSignature = "get-all-posts-by-app-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?appid=" + appid ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public List<Post> getRecentCommentedPostsByUserAndDateLib(String userid,
long timeInMillis) {
logger.debug("Request for getting recent commented posts by user and date");
String thisMethodSignature = "get-recent-commented-posts-by-user-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&time=" + timeInMillis;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public List<Post> getAllPortalPrivacyLevelPostsLib(){
logger.debug("Request for getting portal privacy level posts");
String thisMethodSignature = "get-portal-privacy-level-posts-lib";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
} //list<post>
public List<Post> getRecentPostsByUserLib(String userid, int quantity) {
logger.debug("Request for getting recent posts by user");
String thisMethodSignature = "get-recent-posts-by-user-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&quantity=" + quantity ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public List<Post> getAllPostsByVRELib(String vreid) {
logger.debug("Request for getting all posts by vre");
String thisMethodSignature = "get-all-posts-by-vre-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public List<Post> getRecentPostsByVRELib(String vreid, int quantity) {
logger.debug("Request for getting recent posts by vre");
String thisMethodSignature = "get-recent-posts-by-vre-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&quantity=" + quantity ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
public RangePosts getRecentPostsByVREAndRangeLib(String vreid, int from, int quantity) {
logger.debug("Request for getting recent posts by vre and range");
String thisMethodSignature = "get-recent-posts-by-vre-range-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?vreid=" + vreid + "&from=" + from + "&quantity=" + quantity;
return HttpClient.get(new GenericType<ResponseBean<RangePosts>>(){}, request);
}
public List<Attachment> getAttachmentsByFeedIdLib(String feedId) {
logger.debug("Request for getting attachment by postid");
String thisMethodSignature = "get-attachment-by-postid-lib";
String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + feedId ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Attachment>>>(){}, request);
}
public List<String> getAllVREIdsLib(){
logger.debug("Request for getting all vre ids");
String thisMethodSignature = "get-all-vre-ids-lib";
String request = getServiceEndpoint() + thisMethodSignature ;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
}

View File

@ -3,12 +3,13 @@ package org.gcube.social_networking.social_networking_client_library;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import org.apache.commons.lang.Validate;
import org.gcube.social_networking.social_networking_client_library.utils.HttpClient;
import org.gcube.social_networking.socialnetworking.model.beans.Message;
import org.gcube.social_networking.socialnetworking.model.beans.MessageInbox;
import org.gcube.social_networking.socialnetworking.model.beans.MessageInputBean;
import org.gcube.social_networking.socialnetworking.model.output.ResponseBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -57,7 +58,7 @@ public class MessageClient extends BaseClient{
* Write message
* @return message id
*/
public String writeMessage(Message m){
public String writeMessage(MessageInputBean m){
Validate.isTrue(m != null, "Message cannot be null");
@ -67,4 +68,26 @@ public class MessageClient extends BaseClient{
return HttpClient.post(new GenericType<ResponseBean<String>>(){}, request, m);
}
/**
* mark the message read or not
* @param messageId the message identifier
* @param read true to set read, false to set unread
* @return the result of the operation
*/
public String markMessageRead(String messageId, boolean read) {
Validate.isTrue(messageId != null, "Message id cannot be null");
logger.debug("set Message id:" + messageId + " read?" + read);
String thisMethodSignature = "set-message-read";
String request = getServiceEndpoint() + thisMethodSignature;
Form form = new Form();
form.param("messageId", messageId);
form.param("read", read+"");
return HttpClient.postFormData(new GenericType<ResponseBean<String>>(){}, request, form);
}
}

View File

@ -1,12 +1,20 @@
package org.gcube.social_networking.social_networking_client_library;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.GenericType;
import org.apache.commons.lang.Validate;
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.ex.ColumnNameNotFoundException;
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.social_networking.social_networking_client_library.utils.HttpClient;
import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean;
import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEvent;
@ -20,6 +28,7 @@ import org.slf4j.LoggerFactory;
/**
* Notifications client.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @author Ahmed Ibrahim at ISTI-CNR (ahmed.ibrahim@isti.cnr.it)
*/
public class NotificationClient extends BaseClient{
@ -40,7 +49,7 @@ public class NotificationClient extends BaseClient{
public List<Notification> getNotifications(int from, int quantity){
Validate.isTrue(from >= 1, "From cannot be negative");
Validate.isTrue(from >= 0, "Quantity cannot be negative");
Validate.isTrue(quantity >= 0, "Quantity cannot be negative");
logger.debug("Request for getting notifications");
String thisMethodSignature = "get-range-notifications";
@ -89,5 +98,4 @@ public class NotificationClient extends BaseClient{
HttpClient.post(new GenericType<ResponseBean<String>>(){}, request, event);
}
}

View File

@ -3,12 +3,15 @@ package org.gcube.social_networking.social_networking_client_library;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.GenericType;
import org.apache.commons.lang.Validate;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.*;
import org.gcube.social_networking.social_networking_client_library.utils.HttpClient;
import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
import org.gcube.social_networking.socialnetworking.model.output.ResponseBean;
@ -18,6 +21,7 @@ import org.slf4j.LoggerFactory;
/**
* Posts client.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @author Ahmed Ibrahim at ISTI-CNR (ahmed.ibrahim@isti.cnr.it)
*/
public class PostClient extends BaseClient{
@ -33,14 +37,14 @@ public class PostClient extends BaseClient{
* Get posts since date
* @return
*/
public List<Feed> getUserPostsSinceDate(long timeInMillis){
public List<Post> getUserPostsSinceDate(long timeInMillis){
Validate.isTrue(timeInMillis >= 0, "time cannot be negative");
logger.debug("Request for getting posts");
String thisMethodSignature = "get-posts-user-since";
String request = getServiceEndpoint() + thisMethodSignature + "?time=" + timeInMillis;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -48,12 +52,12 @@ public class PostClient extends BaseClient{
* Get all posts
* @return
*/
public List<Feed> getAllUserPosts(){
public List<Post> getAllUserPosts(){
logger.debug("Request for getting posts");
String thisMethodSignature = "get-posts-user";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -61,14 +65,14 @@ public class PostClient extends BaseClient{
* Get posts quantity
* @return
*/
public List<Feed> getUserPostsQuantity(int quantity){
public List<Post> getUserPostsQuantity(int quantity){
Validate.isTrue(quantity >= 0, "quantity cannot be negative");
logger.debug("Request for getting posts");
String thisMethodSignature = "get-posts-user-quantity";
String request = getServiceEndpoint() + thisMethodSignature + "?quantity=" + quantity;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -76,14 +80,14 @@ public class PostClient extends BaseClient{
* Write post
* @return
*/
public Feed writeUserPost(PostInputBean toWrite){
public Post writeUserPost(PostInputBean toWrite){
Validate.isTrue(toWrite != null, "Post to write cannot be null");
logger.debug("Request for writing post");
String thisMethodSignature = "write-post-user";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Feed>>(){}, request, toWrite);
return HttpClient.post(new GenericType<ResponseBean<Post>>(){}, request, toWrite);
}
@ -91,12 +95,12 @@ public class PostClient extends BaseClient{
* Get posts application (token set must belong to the application)
* @return
*/
public List<Feed> getAllApplicationPosts(){
public List<Post> getAllApplicationPosts(){
logger.debug("Request for getting posts");
String thisMethodSignature = "get-posts-app";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -104,18 +108,19 @@ public class PostClient extends BaseClient{
* Write post application (token set must belong to the application)
* @return
*/
public Feed writeApplicationPost(PostInputBean toWrite){
public Post writeApplicationPost(PostInputBean toWrite){
Validate.isTrue(toWrite != null, "Post to write cannot be null");
logger.debug("Request for writing application post");
String thisMethodSignature = "write-post-app";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.post(new GenericType<ResponseBean<Feed>>(){}, request, toWrite);
return HttpClient.post(new GenericType<ResponseBean<Post>>(){}, request, toWrite);
}
/**
* @deprecated use List<Post> getVREPosts()
* Get posts vre
* @return
*/
@ -126,6 +131,18 @@ public class PostClient extends BaseClient{
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
}
/**
* Get posts vre
* @return
*/
public List<Post> getVREPosts(){
logger.debug("Request for getting posts vre");
String thisMethodSignature = "get-posts-vre";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
/**
@ -133,14 +150,14 @@ public class PostClient extends BaseClient{
* @return
* @throws UnsupportedEncodingException
*/
public List<Feed> getHashtagPosts(String hashtag) throws UnsupportedEncodingException{
public List<Post> getHashtagPosts(String hashtag) throws UnsupportedEncodingException{
Validate.isTrue(hashtag != null, "hashtag cannot be null");
logger.debug("Request for getting posts with hashtag " + hashtag);
String thisMethodSignature = "get-posts-by-hashtag";
String request = getServiceEndpoint() + thisMethodSignature + "?hashtag=" + URLEncoder.encode(hashtag, "UTF-8");
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -148,12 +165,12 @@ public class PostClient extends BaseClient{
* Get liked posts
* @return
*/
public List<Feed> getUserLikedPost(){
public List<Post> getUserLikedPost(){
logger.debug("Request for getting posts liked");
String thisMethodSignature = "get-liked-posts";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Feed>>>(){}, request);
return HttpClient.get(new GenericType<ResponseBean<ArrayList<Post>>>(){}, request);
}
@ -169,5 +186,4 @@ public class PostClient extends BaseClient{
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
}

View File

@ -2,8 +2,10 @@ package org.gcube.social_networking.social_networking_client_library;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.core.GenericType;
@ -27,130 +29,146 @@ public class UserClient extends BaseClient{
public UserClient() throws Exception {
super(SUB_SERVICE_PATH);
}
/**
* Get attribute value
* @return
*/
public String getCustomAttribute(String attributeKey){
Validate.isTrue(attributeKey != null, "attribute key cannot be null");
logger.debug("Request for attribute value");
String thisMethodSignature = "get-custom-attribute";
String request = getServiceEndpoint() + thisMethodSignature + "?attribute=" + attributeKey;
return HttpClient.get(new GenericType<ResponseBean<String>>(){}, request);
}
/**
* Get fullname
* @return user's fullname
*/
public String getFullName(){
logger.debug("Request for fullname");
String thisMethodSignature = "get-fullname";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<String>>(){}, request);
}
/**
* Get email
* @return users'email
*/
public String getEmail(){
logger.debug("Request for email");
String thisMethodSignature = "get-email";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<String>>(){}, request);
}
/**
* Get profile
* @return
*/
public UserProfileExtended getProfile(){
logger.debug("Request for getting profile");
String thisMethodSignature = "get-profile";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<UserProfileExtended>>(){}, request);
}
/**
* Get all usernames in this context
* @return
*/
public List<String> getAllUsernamesContext(){
logger.debug("Request for getting usernames in this context");
String thisMethodSignature = "get-all-usernames";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
/**
* Get all usernames and fullnames in this context
* @return
*/
public Map<String, String> getAllUsernamesFullnamesContext(){
logger.debug("Request for getting usernames and fullnames in this context");
String thisMethodSignature = "get-all-fullnames-and-usernames";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType<ResponseBean<HashMap<String, String>>>(){}, request);
}
/**
* Get usernames by global role
* @return
*/
public List<String> getAllUsernamesByGlobalRole(String globalRole){
Validate.isTrue(globalRole != null, "role cannot be null");
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "get-usernames-by-global-role";
String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + globalRole;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
/**
* Get usernames by local role
* @return
* Get usernames by role
* @deprecated use #getAllUsernamesByRole(String rolename) instead
* @return the usernames having such role
*/
@Deprecated
public List<String> getAllUsernamesByLocalRole(String localRole){
Validate.isTrue(localRole != null, "role cannot be null");
logger.debug("Request for getting usernames with global role");
logger.debug("Request for getting usernames by role role");
String thisMethodSignature = "get-usernames-by-role";
String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + localRole;
return HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
}
/**
* Get usernames by role, the environment (i.e. VRE/VLab) is inferred from the token
* @return the usernames having such role
*/
public Set<String>getAllUsernamesByRole(String rolename){
Validate.isTrue(rolename != null, "role cannot be null");
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "get-usernames-by-role";
String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + rolename;
ArrayList<String> sourceList = HttpClient.get(new GenericType<ResponseBean<ArrayList<String>>>(){}, request);
Set<String> usernames = new HashSet<>(sourceList);
return usernames;
}
/**
* Check if user exists
* @return
*/
public Boolean userExists(String username){
Validate.isTrue(username != null, "username cannot be null");
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "user-exists";
String request = getServiceEndpoint() + thisMethodSignature + "?username=" + username;
return HttpClient.get(new GenericType<ResponseBean<Boolean>>(){}, request);
}
}

View File

@ -4,7 +4,9 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@ -86,4 +88,36 @@ public class HttpClient{
return result.getResult();
}
/**
* Executes a post request
* @param returnType
* @param requestUrl
* @param obj
* @return
*/
public static <R> R postFormData(GenericType<ResponseBean<R>> returnType, String requestUrl, Form form){
logger.debug("Executing post request at url " + requestUrl);
ClientConfig cc = new ClientConfig().register(new JacksonFeature()).register(new AuthorizationFilter()).register(new CustomObjectMapper());;
Client client = ClientBuilder.newClient(cc);
WebTarget webResourceGet = client.target(requestUrl);
Builder basicRequest = webResourceGet.request();
Response response = basicRequest.post(Entity.form(form), Response.class);
if(response == null)
throw new WebApplicationException("Response returned by the service is null");
if(response.getStatus() >= 300)
throw new WebApplicationException("There was an error at server side: " + response.getStatusInfo());
ResponseBean<R> result = response.readEntity(returnType);
if (!result.isSuccess())
throw new WebApplicationException(
"Error message is " + result.getMessage());
return result.getResult();
}
}

View File

@ -3,16 +3,18 @@ package org.gcube.portal.social_networking_client_library;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.databook.shared.EnhancedFeed;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.Post;
import org.gcube.social_networking.social_networking_client_library.FullTextSearchClient;
import org.gcube.social_networking.social_networking_client_library.HashTagClient;
import org.gcube.social_networking.social_networking_client_library.MessageClient;
@ -25,8 +27,8 @@ import org.gcube.social_networking.social_networking_client_library.VREClient;
import org.gcube.social_networking.socialnetworking.model.beans.ApplicationId;
import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean;
import org.gcube.social_networking.socialnetworking.model.beans.JobStatusModelType;
import org.gcube.social_networking.socialnetworking.model.beans.Message;
import org.gcube.social_networking.socialnetworking.model.beans.MessageInbox;
import org.gcube.social_networking.socialnetworking.model.beans.MessageInputBean;
import org.gcube.social_networking.socialnetworking.model.beans.MyVRE;
import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
import org.gcube.social_networking.socialnetworking.model.beans.Recipient;
@ -49,28 +51,34 @@ public class TestClientServices {
private static Logger logger = LoggerFactory.getLogger(TestClientServices.class);
@SuppressWarnings("deprecation")
@Before
public void setContextAndToken(){
//ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/gCube");
//String umaToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJySUJPYjZZY3p2ZE4xNVpuNHFkUTRLdEQ5VUhyY1dwNWJCT3NaLXpYbXM0In0.eyJleHAiOjE2NjM2NjU2NTgsImlhdCI6MTY2MzY2NTM1OCwiYXV0aF90aW1lIjoxNjYzNjY0MTg1LCJqdGkiOiIxMjNhYmY0MS1lZmE1LTQ4ZjEtYmE2Zi03MjNkOWZjNDAwMWQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmQ0c2NpZW5jZS5vcmcvYXV0aC9yZWFsbXMvZDRzY2llbmNlIiwiYXVkIjoiJTJGZDRzY2llbmNlLnJlc2VhcmNoLWluZnJhc3RydWN0dXJlcy5ldSUyRmdDdWJlQXBwcyUyRmdDdWJlIiwic3ViIjoiMzM4OGQ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RooZtZYj3Pm7-Ac4XSir9w5eG1xKOyiGbIlvJZU4FQwXINntUVTVPVfPaXZ_ZbOw";
AccessTokenProvider.instance.set(umaToken);
//SecurityTokenProvider.instance.set("");
SecurityTokenProvider.instance.set("");
}
@Test
public void testCatalogueEvents() throws Exception {
NotificationClient nc = new NotificationClient();
String[] idstoNotify = {"andrea.rossi", "mister.pink"};
String[] idstoNotify = {"andrea.rossi"};
CatalogueEvent event =
new CatalogueEvent(
CatalogueEventType.ITEM_SUBMITTED,
idstoNotify,
"Wyscout soccer-logs dataset",
"submitted \"Wyscout soccer-logs dataset\", a dataset of soccer-logs for all the main soccer leagues in the world, from season 2014/2015 to the current one. ",
new URL("http://data.d4science.org/ctlg/ResourceCatalogue/wyscout_soccer-logs_dataset"));
"Submitted item RESTful Transaction Model",
"Giorgino Giorgetti created the item RESTful Transaction Model. You are kindly requested to review it and decide either to APPROVE or REJECT it. ",
new URL("https://data-dev.d4science.net/rU7T"));
nc.sendCatalogueEvent(event);
}
@Test
@ -82,7 +90,7 @@ public class TestClientServices {
FileItemBean fileItem = new FileItemBean("90b8da48-d363-441a-f0a2-4f413ae747d7", "updated item.pdf", "updated item.pdf",
"/Workspace/_shared attachments/test updated item from client", folder);
String[] idstoNotify = {"andrea.rossi", "mister.pink"};
String[] idstoNotify = {"andrea.rossi"};
WorkspaceEvent event = new UpdatedItemEvent(idstoNotify, fileItem);
nc.sendWorkspaceEvent(event);
event = new AddedItemEvent(idstoNotify, fileItem);
@ -90,7 +98,7 @@ public class TestClientServices {
event = new DeletedItemEvent(idstoNotify, "theDeletedFilenName.pdf", folder);
nc.sendWorkspaceEvent(event);
String[] contextIdstoNotify = {"/gcube/devsec/devVRE"};
String[] contextIdstoNotify = {"/pred4s/preprod/preVRE"};
event = new UpdatedItemEvent(contextIdstoNotify, true, fileItem);
nc.sendWorkspaceEvent(event);
}
@ -146,14 +154,24 @@ public class TestClientServices {
public void sendMessage() throws Exception{
logger.debug("Sending message ");
MessageClient messagesClient = new MessageClient();
List<Recipient> rec = Arrays.asList(new Recipient("andrea.rossi"));
Message message = new Message(
List<Recipient> rec = Arrays.asList(new Recipient("andrea.rossi"), new Recipient("giancarlo.panichi"));
MessageInputBean message = new MessageInputBean(
"Test message",
"Sending message via client " + System.currentTimeMillis(),
new ArrayList<Recipient>(rec));
String idMessage = messagesClient.writeMessage(message);
assert(idMessage != null);
}
@Test
public void markMessageRead() throws Exception{
logger.debug("markMessageRead message ");
MessageClient messagesClient = new MessageClient();
String idMessage = messagesClient.markMessageRead("a7b825c3-a0ca-42d7-b228-00b9e8f015e4", false);
assert(idMessage != null);
}
//@Test
public void testNotifications() throws Exception {
@ -199,23 +217,19 @@ public class TestClientServices {
logger.debug("My Vres " + myVres);
}
//@Test
public void UsersClientTests() throws Exception{
@Test
public void TestUsersClient() throws Exception{
UserClient userClient = new UserClient();
// Requires user token bound to the root context
// List<String> administrators = userClient.getAllUsernamesByGlobalRole("administrator");
//
// assert(administrators != null && !administrators.isEmpty());
// logger.debug("Administrators are " + administrators);
List<String> vreManagers = userClient.getAllUsernamesByLocalRole("vre-manager");
Set<String> vreManagers = userClient.getAllUsernamesByRole("Data-Manager");
assert(vreManagers != null && !vreManagers.isEmpty());
logger.debug("Vre Managers are " + vreManagers);
System.out.println("Data Managers are " + vreManagers);
List<String> moderators = userClient.getAllUsernamesByLocalRole("VRE-Managers");
assert(moderators != null && !moderators.isEmpty());
System.out.println("Catalogue-Moderators are " + moderators);
String myEmail = userClient.getEmail();
@ -231,7 +245,7 @@ public class TestClientServices {
String industry = userClient.getCustomAttribute("Industry");
assert(industry != null && !industry.isEmpty());
//assert(industry != null && !industry.isEmpty());
logger.debug("My Industry is " + industry);
@ -262,40 +276,51 @@ public class TestClientServices {
}
//@Test
@Test
public void getUserPostsSinceDate() throws Exception{
PostClient postClient = new PostClient();
List<Feed> sinceLastYearPost = postClient.getUserPostsSinceDate(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 12);
List<Post> sinceLastYearPost = postClient.getUserPostsSinceDate(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 12);
logger.debug("Posts are " + sinceLastYearPost);
}
//@Test
@Test
public void getAllUserPosts() throws Exception{
PostClient postClient = new PostClient();
List<Feed> allposts = postClient.getAllUserPosts();
logger.debug("All posts are " + allposts);
List<Post> allposts = postClient.getAllUserPosts();
logger.debug("All posts found:");
for (Post post : allposts) {
logger.debug(post.toString());
}
}
//@Test
@Test
public void getUserPostsQuantity() throws Exception{
PostClient postClient = new PostClient();
List<Feed> quantityPosts = postClient.getUserPostsQuantity(3);
logger.debug("Some posts are " + quantityPosts);
List<Post> quantityPosts = postClient.getUserPostsQuantity(3);
logger.debug("Some posts are ");
logger.debug(quantityPosts + " posts found:");
for (Post post : quantityPosts) {
logger.debug(post.toString());
}
}
//@Test
@Test
public void writeUserPost() throws Exception{
PostClient postClient = new PostClient();
PostInputBean toWrite = new PostInputBean("Testing social networking rest client", null, null, null, null, null, false, null);
Feed written = postClient.writeUserPost(toWrite);
logger.debug("Written post is " + written);
PostInputBean postInputBean = new PostInputBean();
postInputBean.setText("Testing social networking rest client at " + new Date());
//Post post = postClient.writeApplicationPost(postInputBean);
PostInputBean post = new PostInputBean("Testing social networking rest client", null, null, null, null, null, false, null);
Post written = postClient.writeUserPost(postInputBean);
logger.debug("Written post is " + post);
}
@ -310,7 +335,7 @@ public class TestClientServices {
SecurityTokenProvider.instance.set(token);
PostClient postClient = new PostClient();
List<Feed> applicationPosts = postClient.getAllApplicationPosts();
List<Post> applicationPosts = postClient.getAllApplicationPosts();
logger.debug("Application posts are " + applicationPosts);
SecurityTokenProvider.instance.set(currentToken);
@ -329,19 +354,22 @@ public class TestClientServices {
PostClient postClient = new PostClient();
PostInputBean toWrite = new PostInputBean("Testing social networking rest client [via application token] #apptoken #rest #client #java", null, null, null, null, null, false, null);
Feed written = postClient.writeApplicationPost(toWrite);
Post written = postClient.writeApplicationPost(toWrite);
logger.debug("Written post is " + written);
SecurityTokenProvider.instance.set(currentToken);
}
//@Test
@Test
public void getPostsVRE() throws Exception{
PostClient postClient = new PostClient();
List<Feed> vrePosts = postClient.getPostsVRE();
logger.debug("VRE posts are " + vrePosts);
List<Post> vrePosts = postClient.getVREPosts();
logger.debug("VRE posts : ");
for (Post post : vrePosts) {
logger.debug(post.toString());
}
}
@ -349,21 +377,21 @@ public class TestClientServices {
public void getHashtagPosts() throws Exception{
PostClient postClient = new PostClient();
List<Feed> postsWithHashtag = postClient.getHashtagPosts("#connect");
List<Post> postsWithHashtag = postClient.getHashtagPosts("#connect");
logger.debug("Posts with hashtag #connect are " + postsWithHashtag);
}
//@Test
@Test
public void getUserLikedPost() throws Exception{
PostClient postClient = new PostClient();
List<Feed> postsLiked = postClient.getUserLikedPost();
List<Post> postsLiked = postClient.getUserLikedPost();
logger.debug("Posts liked are " + postsLiked);
}
//@Test
@Test
public void getUserLikedPostIds() throws Exception{
PostClient postClient = new PostClient();