merged conflicts

This commit is contained in:
Massimiliano Assante 2023-02-09 12:55:34 +01:00
parent 77b1c20854
commit 735bb8149b
3 changed files with 2 additions and 100 deletions

View File

@ -168,90 +168,6 @@ public class Comments {
return Response.status(status).entity(responseBean).build();
}
<<<<<<< HEAD
/**
* Create a new comment to a post having as owner the auth token's owner
* @param post The post to be written
* @return
* @throws ValidationException
*/
@POST
@Path("comment-post")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@StatusCodes ({
@ResponseCode ( code = 201, condition = "Successfull created, the new comment is reported in the 'result' field of the returned object"),
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
})
public Response writeComment(
@NotNull(message="Comment to write is missing")
@Valid
CommentInputBean comment) throws ValidationException{
Caller caller = AuthorizationProvider.instance.get();
String username = caller.getClient().getId();
logger.debug("Request of writing a comment coming from user " + username);
String context = ScopeProvider.instance.get();
ResponseBean responseBean = new ResponseBean();
Status status = Status.OK;
SocialMessageParser messageParser = new SocialMessageParser(comment.getText());
String escapedCommentText = messageParser.getParsedMessage();
// parse
String key = UUID.randomUUID().toString();
String postId = comment.getPostid();
String commentText = escapedCommentText;
String userid = username;
Date time = new Date();
GCubeUser user;
// retrieve group information
UserManager uManager = UserManagerWSBuilder.getInstance().getUserManager();
try {
user = uManager.getUserByUsername(userid);
} catch(Exception e){
logger.error("Unable to get user informations, comment write fails.", e);
responseBean.setMessage("Unable to get user informations, comment write fails with username " + userid + " that does not exist ");
responseBean.setSuccess(false);
status = Status.INTERNAL_SERVER_ERROR;
return Response.status(status).entity(responseBean).build();
}
String fullName = user.getFirstName() + " " + user.getLastName();
String thumbnailURL = user.getUserAvatarURL();
Comment theComment = new Comment(key, userid, time, postId, commentText, fullName, thumbnailURL);
boolean result = false;
try {
result = CassandraConnection.getInstance().getDatabookStore().addComment(theComment);
logger.info("Added comment? " + theComment.toString() + " Result is " +result);
} catch(Exception e){
e.printStackTrace();
responseBean.setMessage("Could not reach the DB to write the comment, something went wrong");
responseBean.setSuccess(false);
status = Status.INTERNAL_SERVER_ERROR;
return Response.status(status).entity(responseBean).build();
}
if(result){
logger.info("Comment correctly written by user " + username);
responseBean.setResult(result);
responseBean.setSuccess(true);
return Response.status(status).entity(responseBean).build();
}
logger.error("Unable to write comment.");
responseBean.setMessage("Unable to write comment");
responseBean.setSuccess(false);
status = Status.INTERNAL_SERVER_ERROR;
return Response.status(status).entity(responseBean).build();
}
=======
/**
* Create a new comment to a post having as owner the auth token's owner
* @param comment The CommentInputBean object
@ -314,5 +230,5 @@ public class Comments {
}
}
>>>>>>> refs/remotes/origin/Feature/24456
}

View File

@ -151,13 +151,8 @@ public class Posts {
@ResponseCode ( code = 500, condition = ErrorMessages.ERROR_IN_API_RESULT)
})
public Response getPost(@QueryParam("id") String id) {
<<<<<<< HEAD
Caller caller = AuthorizationProvider.instance.get();
String context = ScopeProvider.instance.get();
=======
String context = ScopeProvider.instance.get();
Caller caller = AuthorizationProvider.instance.get();
>>>>>>> refs/remotes/origin/Feature/24456
ResponseBean responseBean = new ResponseBean();
Status status = Status.OK;
List<Post> posts = new ArrayList<>();

View File

@ -32,16 +32,10 @@ import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.portal.databook.shared.ApplicationProfile;
<<<<<<< HEAD
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.Post;
=======
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.Post;
import org.gcube.portal.databook.shared.PostType;
>>>>>>> refs/remotes/origin/Feature/24456
import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
import org.gcube.portal.notifications.bean.GenericItemBean;
@ -519,9 +513,6 @@ public class SocialUtils {
}
return toShare;
}
<<<<<<< HEAD
=======
/**
* Allows to comment post in a certain vre.
@ -734,5 +725,5 @@ public class SocialUtils {
return unlikeCommitResult;
}
>>>>>>> refs/remotes/origin/Feature/24456
}