use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.
the class ActivityStreamController method addComment.
@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/comments", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> addComment(@PathVariable int recordId, @Valid @RequestBody ActivityStreamCommentRequest commentRequest, BindingResult bindingResult, HttpServletRequest request) throws JsonProcessingException {
this.getActivityStreamValidator().validateBodyName(recordId, commentRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
ActionLogRecordDto result = this.getActivityStreamService().addComment(commentRequest, (UserDetails) request.getSession().getAttribute("user"));
logger.debug("adding comment to activity stream record", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.
the class ActivityStreamService method addComment.
@Override
public ActionLogRecordDto addComment(ActivityStreamCommentRequest commentRequest, UserDetails attribute) {
try {
int recordId = commentRequest.getRecordId();
if (null == this.getActionLogManager().getActionRecord(recordId)) {
logger.warn("no record found with id {}", recordId);
throw new ResourceNotFoundException(ActivityStreamValidator.ERRCODE_RECORD_NOT_FOUND, "actionLogRecord", String.valueOf(recordId));
}
this.getSocialActivityStreamManager().addActionCommentRecord(attribute.getUsername(), commentRequest.getComment(), recordId);
ActionLogRecordDto dto = this.getDtoBuilder().toDto(this.getActionLogManager().getActionRecord(recordId), this.getSocialActivityStreamManager().getActionLikeRecords(recordId), this.getSocialActivityStreamManager().getActionCommentRecords(recordId));
return dto;
} catch (ApsSystemException t) {
logger.error("error in add comment for id {}", commentRequest.getRecordId(), t);
throw new RestServerError("error in add comment", t);
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.
the class ActivityStreamService method addLike.
@Override
public ActionLogRecordDto addLike(int recordId, UserDetails userDetails) {
try {
if (null == this.getActionLogManager().getActionRecord(recordId)) {
logger.warn("no record found with id {}", recordId);
throw new ResourceNotFoundException(ActivityStreamValidator.ERRCODE_RECORD_NOT_FOUND, "actionLogRecord", String.valueOf(recordId));
}
this.getSocialActivityStreamManager().editActionLikeRecord(recordId, userDetails.getUsername(), true);
ActionLogRecordDto dto = getFullDto(recordId);
return dto;
} catch (ApsSystemException t) {
logger.error("error add add like for id {}", recordId, t);
throw new RestServerError("error in add like ", t);
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.
the class ActivityStreamService method removeComment.
@Override
public ActionLogRecordDto removeComment(int recordId, int commentId, UserDetails attribute) {
try {
if (null == this.getActionLogManager().getActionRecord(recordId)) {
logger.warn("no record found with id {}", recordId);
throw new ResourceNotFoundException(ActivityStreamValidator.ERRCODE_RECORD_NOT_FOUND, "actionLogRecord", String.valueOf(recordId));
}
this.getSocialActivityStreamManager().deleteActionCommentRecord(commentId, recordId);
ActionLogRecordDto dto = this.getDtoBuilder().toDto(this.getActionLogManager().getActionRecord(recordId), this.getSocialActivityStreamManager().getActionLikeRecords(recordId), this.getSocialActivityStreamManager().getActionCommentRecords(recordId));
return dto;
} catch (Throwable t) {
logger.error("error in delete comment for id {}", recordId, t);
throw new RestServerError("error in remove comment", t);
}
}
Aggregations