Search in sources :

Example 1 with ActionLogRecordDto

use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.

the class ActivityStreamService method getActivityStream.

@Override
public PagedMetadata<ActionLogRecordDto> getActivityStream(RestListRequest requestList, UserDetails userDetails) {
    try {
        ActionLogRecordSearchBean searchBean = this.buildSearchBean(requestList, userDetails);
        SearcherDaoPaginatedResult<ActionLogRecord> pagedResult = getActionLogManager().getPaginatedActionRecords(searchBean);
        List<ActionLogRecordDto> dtoList = this.getDtoBuilder().convert(pagedResult.getList(), this.getSocialActivityStreamManager());
        PagedMetadata<ActionLogRecordDto> pagedMetadata = new PagedMetadata<>(requestList, pagedResult);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error searching actionLog ", t);
        throw new RestServerError("error searching actionLog ", t);
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ActionLogRecordSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean)

Example 2 with ActionLogRecordDto

use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.

the class ActivityStreamService method removeLike.

@Override
public ActionLogRecordDto removeLike(int recordId, UserDetails userDetails) {
    try {
        this.getSocialActivityStreamManager().editActionLikeRecord(recordId, userDetails.getUsername(), false);
        ActionLogRecordDto dto = getFullDto(recordId);
        return dto;
    } catch (Throwable t) {
        logger.error("error in remove like for id {}", recordId, t);
        throw new RestServerError("error in remove like ", t);
    }
}
Also used : ActionLogRecordDto(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 3 with ActionLogRecordDto

use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto in project entando-core by entando.

the class ActivityStreamController method addLike.

@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/like", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> addLike(@PathVariable int recordId, HttpServletRequest request) throws JsonProcessingException {
    ActionLogRecordDto result = this.getActivityStreamService().addLike(recordId, (UserDetails) request.getSession().getAttribute("user"));
    logger.debug("adding like 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) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 4 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 5 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)

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