Search in sources :

Example 6 with ActionLogRecordDto

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 7 with ActionLogRecordDto

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);
    }
}
Also used : ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Example 8 with ActionLogRecordDto

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);
    }
}
Also used : ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Example 9 with ActionLogRecordDto

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);
    }
}
Also used : ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Aggregations

ActionLogRecordDto (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)4 ResponseEntity (org.springframework.http.ResponseEntity)4 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 ActionLogRecord (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord)1 ActionLogRecordSearchBean (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean)1 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)1 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)1