Search in sources :

Example 1 with ShortDumpReportDto

use of org.entando.entando.aps.system.services.database.model.ShortDumpReportDto in project entando-core by entando.

the class DatabaseController method getDumpReports.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDumpReports(@Valid RestListRequest requestList) {
    this.getDatabaseValidator().validateRestListRequest(requestList);
    PagedMetadata<ShortDumpReportDto> result = this.getDatabaseService().getShortDumpReportDtos(requestList);
    this.getDatabaseValidator().validateRestListResult(requestList, result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), new ArrayList<>(), result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ArrayList(java.util.ArrayList) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ShortDumpReportDto

use of org.entando.entando.aps.system.services.database.model.ShortDumpReportDto in project entando-core by entando.

the class DatabaseService method getShortDumpReportDtos.

@Override
public PagedMetadata<ShortDumpReportDto> getShortDumpReportDtos(RestListRequest requestList) {
    PagedMetadata<ShortDumpReportDto> result = null;
    List<ShortDumpReportDto> dtos = new ArrayList<>();
    try {
        List<DataSourceDumpReport> reports = this.getDatabaseManager().getBackupReports();
        if (null != reports) {
            reports.stream().forEach(report -> dtos.add(new ShortDumpReportDto(report)));
        }
        List<ShortDumpReportDto> sublist = requestList.getSublist(dtos);
        int size = (null != reports) ? reports.size() : 0;
        SearcherDaoPaginatedResult searchResult = new SearcherDaoPaginatedResult(size, sublist);
        result = new PagedMetadata<>(requestList, searchResult);
        result.setBody(sublist);
    } catch (Throwable t) {
        logger.error("error extracting database reports", t);
        throw new RestServerError("error extracting database reports", t);
    }
    return result;
}
Also used : DataSourceDumpReport(org.entando.entando.aps.system.init.model.DataSourceDumpReport) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto)

Aggregations

ArrayList (java.util.ArrayList)2 ShortDumpReportDto (org.entando.entando.aps.system.services.database.model.ShortDumpReportDto)2 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 RestServerError (org.entando.entando.aps.system.exception.RestServerError)1 DataSourceDumpReport (org.entando.entando.aps.system.init.model.DataSourceDumpReport)1 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)1 RestResponse (org.entando.entando.web.common.model.RestResponse)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1