parent
e2c4be4633
commit
b068f92888
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.validation.ValidationException;
|
import javax.validation.ValidationException;
|
||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
@ -40,7 +41,48 @@ public class Comments {
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Comments.class);
|
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
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("get-comments-user")
|
@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 = 200, condition = "The list of comments is put into the 'result' field"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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() {
|
public Response getCommentsUser() {
|
||||||
|
|
||||||
ResponseBean responseBean = new ResponseBean();
|
ResponseBean responseBean = new ResponseBean();
|
||||||
|
@ -76,12 +115,12 @@ public class Comments {
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
* 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(
|
public Response getCommentsUserByTime(
|
||||||
@QueryParam("time")
|
@QueryParam("time")
|
||||||
@Min(value = 0, message="time cannot be negative")
|
@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 org.slf4j.Logger logger = LoggerFactory.getLogger(Notifications.class);
|
||||||
private static final String INFRASTRUCTURE_MANAGER_ROLE = "Infrastructure-Manager";
|
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 from must be greater or equal to 1, range[0, infinity]
|
||||||
* @param quantity quantity must be greater or equal to 0
|
* @param quantity quantity must be greater or equal to 0
|
||||||
* @return notifications up to quantity
|
* @return notifications up to quantity
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("get-range-notifications/")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@StatusCodes ({
|
@StatusCodes ({
|
||||||
@ResponseCode ( code = 200, condition = "Notifications retrieved and reported in the 'result' field of the returned object"),
|
@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)
|
@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
|
* @pathExample /is-user-disabled?username=john.smith
|
||||||
* @responseExample application/json { "success": true, "message": null "result": true }
|
* @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
|
* @param username the username you want to check
|
||||||
* @return true if the notification for the user are disabled (Catalogue and Workspace ones)
|
* @return true if the notification for the user are disabled (Catalogue and Workspace ones)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("is-user-disabled/")
|
||||||
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@StatusCodes ({
|
@StatusCodes ({
|
||||||
@ResponseCode ( code = 200, condition = "true if the notification for the username given as query param are disabled (Catalogue and Workspace ones), false otherwise"),
|
@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);
|
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
|
@GET
|
||||||
@Path("profile")
|
@Path("profile")
|
||||||
@StatusCodes ({
|
@StatusCodes ({
|
||||||
@ResponseCode ( code = 200, condition = "Successful retrieval of user's profile, reported in the 'result' field of the returned object"),
|
@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)
|
@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(){
|
public Response getProfile(){
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
|
|
@ -55,7 +55,13 @@ public class Posts {
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Posts.class);
|
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
|
@GET
|
||||||
@Path("get-posts-user-since/")
|
@Path("get-posts-user-since/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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(
|
public Response getRecentPostsByUserAndDate(
|
||||||
@QueryParam("time") @Min(value = 0, message="time cannot be negative")
|
@QueryParam("time") @Min(value = 0, message="time cannot be negative")
|
||||||
long timeInMillis
|
long timeInMillis
|
||||||
|
@ -99,7 +99,12 @@ public class Posts {
|
||||||
|
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-posts-user/")
|
@Path("get-posts-user/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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() {
|
public Response getAllPostsByUser() {
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
@ -136,7 +137,13 @@ public class Posts {
|
||||||
|
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-posts-user-quantity/")
|
@Path("get-posts-user-quantity/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 200, condition = "Successful retrieval of posts, reported in the 'result' field of the returned object"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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(
|
public Response getQuantityPostsByUser(
|
||||||
@DefaultValue("10")
|
@DefaultValue("10")
|
||||||
@QueryParam("quantity")
|
@QueryParam("quantity")
|
||||||
|
@ -189,7 +190,13 @@ public class Posts {
|
||||||
}
|
}
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@POST
|
||||||
@Path("write-post-user")
|
@Path("write-post-user")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@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 = 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)
|
@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(
|
public Response writePostUser(
|
||||||
@NotNull(message="Post to write is missing")
|
@NotNull(message="Post to write is missing")
|
||||||
@Valid
|
@Valid
|
||||||
|
@ -261,7 +262,11 @@ public class Posts {
|
||||||
return Response.status(status).entity(responseBean).build();
|
return Response.status(status).entity(responseBean).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the application's posts
|
||||||
|
* @return the application (IAM Client) posts belonging to the token's owner (i.e., an application)"
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("get-posts-app/")
|
@Path("get-posts-app/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 403, condition = "\"There is no application profile with such token"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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() {
|
public Response getAllPostsByApp() {
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
@ -312,7 +313,12 @@ public class Posts {
|
||||||
|
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@POST
|
||||||
@Path("write-post-app")
|
@Path("write-post-app")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@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 = 403, condition = "\"There is no application profile with such token"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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(
|
public Response writePostApp(
|
||||||
@NotNull(message="Post to write is null")
|
@NotNull(message="Post to write is null")
|
||||||
@Valid
|
@Valid
|
||||||
|
@ -390,6 +391,10 @@ public class Posts {
|
||||||
return Response.status(status).entity(responseBean).build();
|
return Response.status(status).entity(responseBean).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return all the posts in the context bound to the auth token
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("get-posts-vre/")
|
@Path("get-posts-vre/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 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)
|
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
||||||
})
|
})
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return all the posts in the context bound to the auth token
|
|
||||||
*/
|
|
||||||
public Response getAllPostsByVRE() {
|
public Response getAllPostsByVRE() {
|
||||||
|
|
||||||
String context = ScopeProvider.instance.get();
|
String context = ScopeProvider.instance.get();
|
||||||
|
@ -423,13 +424,6 @@ public class Posts {
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
* 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
|
* 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 PrivacyLevelTypeNotFoundException
|
||||||
* @throws ColumnNameNotFoundException
|
* @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(
|
public Response getRecentPostsByVREAndRange(
|
||||||
@QueryParam("from")
|
@QueryParam("from")
|
||||||
@Min(value=1, message="from cannot be negative")
|
@Min(value=1, message="from cannot be negative")
|
||||||
|
@ -506,7 +507,11 @@ public class Posts {
|
||||||
}
|
}
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-id-liked-posts/")
|
@Path("get-id-liked-posts/")
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@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 = 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)
|
@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() {
|
public Response getAllLikedPostIdsByUser() {
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
@ -545,7 +546,13 @@ public class Posts {
|
||||||
|
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-liked-posts/")
|
@Path("get-liked-posts/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 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)
|
@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(
|
public Response getAllLikedPostsByUser(
|
||||||
@DefaultValue("10")
|
@DefaultValue("10")
|
||||||
@QueryParam("limit")
|
@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 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");
|
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
|
@GET
|
||||||
@Path("get-custom-attribute/")
|
@Path("get-custom-attribute/")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -65,12 +71,6 @@ public class Users {
|
||||||
@ResponseCode ( code = 404, condition = "Such an attribute doesn't exist"),
|
@ResponseCode ( code = 404, condition = "Such an attribute doesn't exist"),
|
||||||
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
|
@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(
|
public Response readCustomAttr(
|
||||||
@QueryParam("attribute")
|
@QueryParam("attribute")
|
||||||
@NotNull(message="attribute name is missing")
|
@NotNull(message="attribute name is missing")
|
||||||
|
@ -106,7 +106,10 @@ public class Users {
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-fullname")
|
@Path("get-fullname")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 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)
|
@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(){
|
public Response getUserFullname(){
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
@ -150,6 +149,10 @@ public class Users {
|
||||||
return Response.status(status).entity(responseBean).build();
|
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
|
@GET
|
||||||
@Path("get-email")
|
@Path("get-email")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@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 = 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)
|
@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(){
|
public Response getUserEmail(){
|
||||||
|
|
||||||
Caller caller = AuthorizationProvider.instance.get();
|
Caller caller = AuthorizationProvider.instance.get();
|
||||||
|
|
Loading…
Reference in New Issue