social-networking-library-ws/docs/index.rst

4.1 KiB

Welcome to Social Service's documentation!

The Social Service is a RESTful application which exposes operations coming from both the gCube Social-Networking-Library and the User Management components. The former is the bridge between the Cassandra Cluster (on which social data are stored) and the social applications, whereas the latter is the abstraction layer over the enabling technology for the Identity and Access Management service, in terms of: roles, users and organizations and how they are mapped to D4Science concepts.

The web services exposes a subset of such functionalities over https in a standard, reliable and secure way.

See the vailable REST-API at a glance on its API docs.

Base URL

In the production environment, its current value is https://api.d4science.org/rest

Authorization (how to contact the service) ==================

D4Science adopts state-of-the-art industry standards for authentication and authorization. Specifically, the implementation fully adopts OIDC (OpenID Connect) for authentication and UMA 2 (User Managed Authorization) for authorization flows. JSON Web Token (JWT) Access token are used for both authentication and authorization.

Obtain your Bearer token here: https://dev.d4science.org/how-to-access-resources

Java Client

The methods of the Web Service can be called by writing your own REST client application or by using already existing REST client plugins. We provide the following Java Client out-of-the-box.

Tip

If you're coding in Java it is recommended that you use this Java Client.

Maven Coordinates

<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[1.1.0, 2.0.0)</version>

Methods Result

The service exposes its methods using a standard naming approach. Moreover, they accept (in case of http POST/PUT methods) JSON objects.

Important

The result of all methods is always a JSON object as per below:

{
"success": false/true,
"message": ...,
"result": ...,
}
Where
  • success reports if the request succeeded or failed;

- message is a status/error message that can be checked in case of errors (success equals false); -result is the current result object (it can be a list, a single object and so on depending on the invoked method).

Inputs are automatically validated before the request is served.

Usage examples

  • Send a Message
import org.gcube.social_networking.social_networking_client_library.MessageClient;
import org.gcube.social_networking.socialnetworking.model.beans.Message;
import org.gcube.social_networking.socialnetworking.model.beans.Recipient;

//send
MessageClient messagesClient = new MessageClient();
List<Recipient> rec = Arrays.asList(new Recipient("andrea.rossi"));
Message message = new Message(
               "Test message", 
               "Sending message via client " + System.currentTimeMillis(), 
               new ArrayList<Recipient>(rec));
String idMessage = messagesClient.writeMessage(message);
  • Get User Profile
import org.gcube.social_networking.social_networking_client_library.PeopleClient;

   PeopleClient getProfile = new PeopleClient();
   UserProfile profile = getProfile.getProfile();
   logger.debug("Profile retrieved is " + profile);
  • Get Posts in a VRE
import org.gcube.social_networking.social_networking_client_library.PostClient;

   PostClient postClient = new PostClient();
   List<Feed> vrePosts = postClient.getPostsVRE();
   logger.debug("VRE posts are " + vrePosts);