parent
e2c4be4633
commit
b068f92888
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import javax.validation.ValidationException;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
@ -41,6 +42,47 @@ public class Comments {
|
|||
// Logger
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Comments.class);
|
||||
|
||||
/*
|
||||
* Retrieve the list of comments belonging to the post id (key) of the token in the related context
|
||||
* @param key the key as in the POST JSON representation
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("get-comments-by-post-id")
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 200, condition = "The list of comments is put into the 'result' field"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
public Response getAllCommentsByPostId(
|
||||
@NotNull
|
||||
@QueryParam("key")
|
||||
String key) {
|
||||
|
||||
ResponseBean responseBean = new ResponseBean();
|
||||
Status status = Status.OK;
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
String context = ScopeProvider.instance.get();
|
||||
String username = caller.getClient().getId();
|
||||
List<Comment> comments = null;
|
||||
|
||||
try{
|
||||
logger.info("Retrieving comments for user id " + username);
|
||||
comments = CassandraConnection.getInstance().getDatabookStore().getAllCommentByPost(key);
|
||||
Filters.filterCommentsPerContext(comments, context);
|
||||
responseBean.setResult(comments);
|
||||
responseBean.setSuccess(true);
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve such comments.", e);
|
||||
responseBean.setMessage(e.getMessage());
|
||||
responseBean.setSuccess(false);
|
||||
status = Status.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
/*
|
||||
* Retrieve the list of comments belonging to the owner of the token in the related context.
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("get-comments-user")
|
||||
|
@ -48,9 +90,6 @@ public class Comments {
|
|||
@ResponseCode ( code = 200, condition = "The list of comments is put into the 'result' field"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/*
|
||||
* Retrieve the list of comments belonging to the owner of the token in the related context.
|
||||
*/
|
||||
public Response getCommentsUser() {
|
||||
|
||||
ResponseBean responseBean = new ResponseBean();
|
||||
|
@ -76,12 +115,12 @@ public class Comments {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("get-comments-user-by-time")
|
||||
/*
|
||||
* Retrieve comments of the gcube-token's owner in the context bound to the token itself and filter them by date
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("get-comments-user-by-time")
|
||||
public Response getCommentsUserByTime(
|
||||
@QueryParam("time")
|
||||
@Min(value = 0, message="time cannot be negative")
|
||||
|
|
|
@ -104,17 +104,16 @@ public class Notifications {
|
|||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Notifications.class);
|
||||
private static final String INFRASTRUCTURE_MANAGER_ROLE = "Infrastructure-Manager";
|
||||
|
||||
|
||||
@GET
|
||||
@Path("get-range-notifications/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
/**
|
||||
* Retrieve notifications of the gcube-token's owner
|
||||
* Retrieve notifications of the token's owner
|
||||
* @param from must be greater or equal to 1, range[0, infinity]
|
||||
* @param quantity quantity must be greater or equal to 0
|
||||
* @return notifications up to quantity
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-range-notifications/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 200, condition = "Notifications retrieved and reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
|
@ -152,17 +151,16 @@ public class Notifications {
|
|||
|
||||
|
||||
/**
|
||||
* Return whether the notifications for this user are enabled or not
|
||||
* @pathExample /is-user-disabled?username=john.smith
|
||||
* @responseExample application/json { "success": true, "message": null "result": true }
|
||||
*/
|
||||
@GET
|
||||
@Path("is-user-disabled/")
|
||||
/**
|
||||
* Return whether the notifications for this user are enabled or not
|
||||
* @param username the username you want to check
|
||||
* @return true if the notification for the user are disabled (Catalogue and Workspace ones)
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("is-user-disabled/")
|
||||
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 200, condition = "true if the notification for the username given as query param are disabled (Catalogue and Workspace ones), false otherwise"),
|
||||
|
|
|
@ -46,17 +46,17 @@ public class People {
|
|||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(People.class);
|
||||
|
||||
/**
|
||||
* @responseExample application/json { "success" : true, "message" : null, "result" : { "roles" : [ ], "context" : "***", "avatar" : "https://*****3D", "fullname" : "John Smith", "username" : "john.smith" } }
|
||||
* @return the user's profile. The user in this case is the one bound to the token
|
||||
*/
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@GET
|
||||
@Path("profile")
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 200, condition = "Successful retrieval of user's profile, reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* @responseExample application/json { "success" : true, "message" : null, "result" : { "roles" : [ ], "context" : "***", "avatar" : "https://*****3D", "fullname" : "John Smith", "username" : "john.smith" } }
|
||||
* @return the user's profile. The user in this case is the one bound to the token
|
||||
*/
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getProfile(){
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
|
|
@ -56,6 +56,12 @@ public class Posts {
|
|||
// Logger
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Posts.class);
|
||||
|
||||
/**
|
||||
* Retrieve posts of the auth token's owner, and allow to filter them by time"
|
||||
* @param timeInMillis The reference time since when retrieving posts
|
||||
* @return the posts
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-posts-user-since/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -63,12 +69,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve posts of the auth token's owner, and allow to filter them by time"
|
||||
* @param timeInMillis The reference time since when retrieving posts
|
||||
* @return the posts
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public Response getRecentPostsByUserAndDate(
|
||||
@QueryParam("time") @Min(value = 0, message="time cannot be negative")
|
||||
long timeInMillis
|
||||
|
@ -100,6 +100,11 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all user's posts
|
||||
* @return all posts of the auth token's owner in the context identified by the token
|
||||
*/
|
||||
@GET
|
||||
@Path("get-posts-user/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -107,10 +112,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve all user's posts
|
||||
* @return all posts of the auth token's owner in the context identified by the token
|
||||
*/
|
||||
public Response getAllPostsByUser() {
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
@ -137,6 +138,12 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a given quantity of latest user's posts
|
||||
* @param quantity the number of latest post to get
|
||||
* @return all posts of the auth token's owner in the context identified by the token, in reverse chronological order up to quantity (at most)
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-posts-user-quantity/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -144,12 +151,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve a given quantity of latest user's posts
|
||||
* @param quantity the number of latest post to get
|
||||
* @return all posts of the auth token's owner in the context identified by the token, in reverse chronological order up to quantity (at most)
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public Response getQuantityPostsByUser(
|
||||
@DefaultValue("10")
|
||||
@QueryParam("quantity")
|
||||
|
@ -190,6 +191,12 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user post having as owner the auth token's owner
|
||||
* @param post The post to be written
|
||||
* @return
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@POST
|
||||
@Path("write-post-user")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
@ -198,12 +205,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 201, condition = "Successfull created, the new post is reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Create a new user post having as owner the auth token's owner
|
||||
* @param post The post to be written
|
||||
* @return
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public Response writePostUser(
|
||||
@NotNull(message="Post to write is missing")
|
||||
@Valid
|
||||
|
@ -262,6 +263,10 @@ public class Posts {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the application's posts
|
||||
* @return the application (IAM Client) posts belonging to the token's owner (i.e., an application)"
|
||||
*/
|
||||
@GET
|
||||
@Path("get-posts-app/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -270,10 +275,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 403, condition = "\"There is no application profile with such token"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve the application's posts
|
||||
* @return the application's posts belonging to the token's owner (i.e., an application)"
|
||||
*/
|
||||
public Response getAllPostsByApp() {
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
@ -313,6 +314,11 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new application post having as owner-application the token's owner (the IAM Client), note that the application must be registered on the Information System
|
||||
* @param post The post to be written
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("write-post-app")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
@ -322,11 +328,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 403, condition = "\"There is no application profile with such token"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Create a new application post having as owner-application the token's owner (the IAM Client)
|
||||
* @param post The post to be written
|
||||
* @return
|
||||
*/
|
||||
public Response writePostApp(
|
||||
@NotNull(message="Post to write is null")
|
||||
@Valid
|
||||
|
@ -390,6 +391,10 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return all the posts in the context bound to the auth token
|
||||
*/
|
||||
@GET
|
||||
@Path("get-posts-vre/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -397,10 +402,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 201, condition = "Sccessfull retrieved posts, they are reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
*
|
||||
* @return all the posts in the context bound to the auth token
|
||||
*/
|
||||
public Response getAllPostsByVRE() {
|
||||
|
||||
String context = ScopeProvider.instance.get();
|
||||
|
@ -423,13 +424,6 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("get-recent-posts-vre-by-range/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 201, condition = "Sccessfull retrieved posts, they are reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* return the most recent posts for this vre up to quantity param and the last index of the posts in the timeline
|
||||
* lastReturnedPostTimelineIndex is useful to know from where to start the range the next time you ask, because there are deletions
|
||||
|
@ -441,6 +435,13 @@ public class Posts {
|
|||
* @throws PrivacyLevelTypeNotFoundException
|
||||
* @throws ColumnNameNotFoundException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-recent-posts-vre-by-range/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 201, condition = "Sccessfull retrieved posts, they are reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
public Response getRecentPostsByVREAndRange(
|
||||
@QueryParam("from")
|
||||
@Min(value=1, message="from cannot be negative")
|
||||
|
@ -507,6 +508,10 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve ids (UUID) of the liked posts by the user
|
||||
* @return ids (UUID) of the liked posts by the user in the context bound to the auth token
|
||||
*/
|
||||
@GET
|
||||
@Path("get-id-liked-posts/")
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
|
@ -514,10 +519,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 201, condition = "Sccessfull retrieved ids, they are reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve ids (UUID) of the liked by the user
|
||||
* @return ids (UUID) of the liked by the user in the context bound to the auth token
|
||||
*/
|
||||
public Response getAllLikedPostIdsByUser() {
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
@ -546,6 +547,12 @@ public class Posts {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve posts liked by the user
|
||||
* @param limit The maximum number of posts to be retrieved
|
||||
* @return posts liked by the user (up to a given quantity) in the context bound to the auth token
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-liked-posts/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -553,12 +560,6 @@ public class Posts {
|
|||
@ResponseCode ( code = 200, condition = "Successfull retrieved posts, they are reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Retrieve posts liked by the user
|
||||
* @param limit The maximum number of posts to be retrieved
|
||||
* @return posts liked by the user (up to a given quantity) in the context bound to the auth token
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public Response getAllLikedPostsByUser(
|
||||
@DefaultValue("10")
|
||||
@QueryParam("limit")
|
||||
|
|
|
@ -57,6 +57,12 @@ public class Users {
|
|||
private static final String NOT_USER_TOKEN_CONTEXT_USED = "User's information can only be retrieved through a user token (not qualified)";
|
||||
private static final List<String> GLOBAL_ROLES_ALLOWED_BY_LOCAL_CALL_METHOD = Arrays.asList("DataMiner-Manager","Quota-Manager");
|
||||
|
||||
/**
|
||||
* Read a user's custom attribute. The user is the one owning the token
|
||||
* @param attributeKey The key of the attribute to be read
|
||||
* @return the user's custom attribute
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@GET
|
||||
@Path("get-custom-attribute/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -65,12 +71,6 @@ public class Users {
|
|||
@ResponseCode ( code = 404, condition = "Such an attribute doesn't exist"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Read a user's custom attribute. The user is the one owning the token
|
||||
* @param attributeKey The key of the attribute to be read
|
||||
* @return the user's custom attribute
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public Response readCustomAttr(
|
||||
@QueryParam("attribute")
|
||||
@NotNull(message="attribute name is missing")
|
||||
|
@ -106,7 +106,10 @@ public class Users {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read the user's fullname. The user is the one owning the token
|
||||
* @return the user's fullname
|
||||
*/
|
||||
@GET
|
||||
@Path("get-fullname")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -114,10 +117,6 @@ public class Users {
|
|||
@ResponseCode ( code = 200, condition = "The user's fullname is reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Read the user's fullname. The user is the one owning the token
|
||||
* @return the user's fullname
|
||||
*/
|
||||
public Response getUserFullname(){
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
@ -150,6 +149,10 @@ public class Users {
|
|||
return Response.status(status).entity(responseBean).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the user's email address. The user is the one owning the token
|
||||
* @return rhe user's email address
|
||||
*/
|
||||
@GET
|
||||
@Path("get-email")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -157,10 +160,6 @@ public class Users {
|
|||
@ResponseCode ( code = 200, condition = "The user's email is reported in the 'result' field of the returned object"),
|
||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||
})
|
||||
/**
|
||||
* Read the user's email address. The user is the one owning the token
|
||||
* @return rhe user's email address
|
||||
*/
|
||||
public Response getUserEmail(){
|
||||
|
||||
Caller caller = AuthorizationProvider.instance.get();
|
||||
|
|
Loading…
Reference in New Issue