Search in sources :

Example 31 with ResourceNotFoundException

use of org.entando.entando.aps.system.exception.ResourceNotFoundException 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 32 with ResourceNotFoundException

use of org.entando.entando.aps.system.exception.ResourceNotFoundException 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 33 with ResourceNotFoundException

use of org.entando.entando.aps.system.exception.ResourceNotFoundException 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)

Example 34 with ResourceNotFoundException

use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.

the class ProfileTypeController method getUserProfileType.

@RestAccessControl(permission = Permission.MANAGE_USER_PROFILES)
@RequestMapping(value = "/profileTypes/{profileTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<UserProfileTypeDto>> getUserProfileType(@PathVariable String profileTypeCode) throws JsonProcessingException {
    logger.debug("Requested profile type -> {}", profileTypeCode);
    if (!this.getProfileTypeValidator().existType(profileTypeCode)) {
        throw new ResourceNotFoundException(AbstractEntityTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "Profile Type", profileTypeCode);
    }
    UserProfileTypeDto dto = this.getUserProfileTypeService().getUserProfileType(profileTypeCode);
    logger.debug("Main Response -> {}", dto);
    return new ResponseEntity<>(new SimpleRestResponse<>(dto), HttpStatus.OK);
}
Also used : UserProfileTypeDto(org.entando.entando.aps.system.services.userprofile.model.UserProfileTypeDto) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 35 with ResourceNotFoundException

use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.

the class DatabaseService method getDumpReportDto.

@Override
public DumpReportDto getDumpReportDto(String reportCode) {
    DumpReportDto dtos = null;
    try {
        DataSourceDumpReport report = this.getDatabaseManager().getBackupReport(reportCode);
        if (null == report) {
            logger.warn("no dump found with code {}", reportCode);
            throw new ResourceNotFoundException(DatabaseValidator.ERRCODE_NO_DUMP_FOUND, "reportCode", reportCode);
        }
        dtos = new DumpReportDto(report, this.getComponentManager());
    } catch (ResourceNotFoundException r) {
        throw r;
    } catch (Throwable t) {
        logger.error("error extracting database report {}", reportCode, t);
        throw new RestServerError("error extracting database report " + reportCode, t);
    }
    return dtos;
}
Also used : DataSourceDumpReport(org.entando.entando.aps.system.init.model.DataSourceDumpReport) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto) DumpReportDto(org.entando.entando.aps.system.services.database.model.DumpReportDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)53 RestServerError (org.entando.entando.aps.system.exception.RestServerError)27 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)20 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)15 IPage (com.agiletec.aps.system.services.page.IPage)9 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)9 Category (com.agiletec.aps.system.services.category.Category)7 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)7 ResponseEntity (org.springframework.http.ResponseEntity)7 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)5 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 Group (com.agiletec.aps.system.services.group.Group)3 Widget (com.agiletec.aps.system.services.page.Widget)3 Role (com.agiletec.aps.system.services.role.Role)3