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);
}
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations