use of org.entando.entando.aps.system.init.model.DataSourceDumpReport in project entando-core by entando.
the class DatabaseManager method getDumpReport.
private DataSourceDumpReport getDumpReport(String subFolderName) throws ApsSystemException {
InputStream is = null;
DataSourceDumpReport report = null;
try {
String key = this.getLocalBackupsFolder() + subFolderName + File.separator + DUMP_REPORT_FILE_NAME;
is = this.getStorageManager().getStream(key, true);
String xml = FileTextReader.getText(is);
report = new DataSourceDumpReport(xml);
} catch (Throwable t) {
logger.error("Error while extracting Dump Report of subfolder {}", subFolderName, t);
throw new RuntimeException("Error while extracting Dump Report of subfolder " + subFolderName);
} finally {
if (null != is) {
try {
is.close();
} catch (IOException ex) {
}
}
}
return report;
}
use of org.entando.entando.aps.system.init.model.DataSourceDumpReport in project entando-core by entando.
the class DatabaseManager method getBackupReports.
@Override
public List<DataSourceDumpReport> getBackupReports() throws ApsSystemException {
List<DataSourceDumpReport> reports = new ArrayList<DataSourceDumpReport>();
try {
// backupsFolder.list();
String[] children = this.getStorageManager().listDirectory(this.getLocalBackupsFolder(), true);
if (null == children || children.length == 0) {
return null;
}
for (String subFolderName : children) {
if (this.checkBackupFolder(subFolderName)) {
DataSourceDumpReport report = this.getDumpReport(subFolderName);
reports.add(report);
}
}
Collections.sort(reports, new BeanComparator("date"));
} catch (Throwable t) {
logger.error("Error while extracting Backup Reports", t);
throw new RuntimeException("Error while extracting Backup Reports");
}
return reports;
}
use of org.entando.entando.aps.system.init.model.DataSourceDumpReport 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;
}
use of org.entando.entando.aps.system.init.model.DataSourceDumpReport 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);
}
use of org.entando.entando.aps.system.init.model.DataSourceDumpReport in project entando-core by entando.
the class DatabaseControllerTest method getReport_1.
@Test
public void getReport_1() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String xml = null;
DataSourceDumpReport report = new DataSourceDumpReport(xml);
when(databaseManager.getBackupReport(ArgumentMatchers.anyString())).thenReturn(report);
ResultActions result = mockMvc.perform(get("/database/report/{reportCode}", new Object[] { "develop" }).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
}
Aggregations