Search in sources :

Example 1 with DumpReportDto

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

the class DatabaseServiceTest method getValidReport.

@Test
public void getValidReport() throws Throwable {
    String xml = null;
    DataSourceDumpReport report = new DataSourceDumpReport(xml);
    when(databaseManager.getBackupReport(ArgumentMatchers.anyString())).thenReturn(report);
    DumpReportDto dto = this.databaseService.getDumpReportDto("reportCode");
    Assert.assertNotNull(dto);
}
Also used : DataSourceDumpReport(org.entando.entando.aps.system.init.model.DataSourceDumpReport) DumpReportDto(org.entando.entando.aps.system.services.database.model.DumpReportDto) Test(org.junit.Test)

Example 2 with DumpReportDto

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

the class DatabaseController method getDumpReport.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/report/{reportCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDumpReport(@PathVariable String reportCode) {
    logger.debug("Required dump report -> code {}", reportCode);
    DumpReportDto result = this.getDatabaseService().getDumpReportDto(reportCode);
    logger.debug("Extracted dump report -> {}", result);
    return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) DumpReportDto(org.entando.entando.aps.system.services.database.model.DumpReportDto) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DumpReportDto

use of org.entando.entando.aps.system.services.database.model.DumpReportDto 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 RestRourceNotFoundException(DatabaseValidator.ERRCODE_NO_DUMP_FOUND, "reportCode", reportCode);
        }
        dtos = new DumpReportDto(report, this.getComponentManager());
    } catch (RestRourceNotFoundException 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 : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) 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)

Aggregations

DumpReportDto (org.entando.entando.aps.system.services.database.model.DumpReportDto)3 DataSourceDumpReport (org.entando.entando.aps.system.init.model.DataSourceDumpReport)2 ShortDumpReportDto (org.entando.entando.aps.system.services.database.model.ShortDumpReportDto)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)1 RestServerError (org.entando.entando.aps.system.exception.RestServerError)1 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)1 RestResponse (org.entando.entando.web.common.model.RestResponse)1 Test (org.junit.Test)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1