use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method checkSystem.
@Override
@Transactional
public void checkSystem(SysSystemDto system) {
Assert.notNull(system);
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Call IC module
icConfigurationFacade.test(system.getConnectorInstance(), connectorConfig);
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class RptReportController method renderReport.
@ResponseBody
@RequestMapping(value = "/{backendId}/render", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> renderReport(@ApiParam(value = "Report's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Renderer's identifier.", required = true) @RequestParam(required = true, name = "renderer") @NotNull String rendererName) {
//
RptReportDto report = getDto(backendId);
if (report == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
try {
RptRenderedReportDto result = reportManager.render(report, rendererName);
InputStream is = result.getRenderedReport();
//
String reportName = report.getExecutorName() + "-" + report.getCreated().toString("yyyyMMddHHmmss");
return ResponseEntity.ok().contentLength(is.available()).contentType(result.getRenderer().getFormat()).header(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=\"%s.%s\"", reportName, result.getRenderer().getExtension())).body(new InputStreamResource(is));
} catch (Exception ex) {
throw new ResultCodeException(CoreResultCode.INTERNAL_SERVER_ERROR, ex);
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultReportManager method render.
@Override
public RptRenderedReportDto render(RptReportDto report, String rendererName) {
Assert.notNull(report);
Assert.hasLength(rendererName);
//
ReportRenderer renderer = reportRendererRegistry.getPluginFor(rendererName);
if (renderer == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("reportRenderer", rendererName));
}
//
RptRenderedReportDto result = new RptRenderedReportDto();
result.setInputReport(report);
result.setRenderer(toDto(renderer));
result.setRenderedReport(renderer.render(report));
return result;
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultReportManager method generate.
@Override
public void generate(EntityEvent<RptReportDto> event) {
Assert.notNull(event, "Report event is required!");
RptReportDto report = event.getContent();
Assert.notNull(report, "Report is required!");
Assert.notNull(report.getId(), "Persisted report is required!");
//
ReportExecutor executor = reportExecutorRegistry.getPluginFor(report.getExecutorName());
if (executor == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("reportExecutor", report.getExecutorName()));
}
// create new executor instance
executor = (ReportExecutor) AutowireHelper.createBean(executor.getClass());
// set event - event will continue after executor is processed
executor.setEvent(event);
// check if lrt for report is already prepared by scheduler
boolean newTask = true;
if (report.getLongRunningTask() != null) {
// preserve exists lrt - execute only
executor.setLongRunningTaskId(report.getLongRunningTask());
newTask = false;
}
// set lrt into report for getting state
LongRunningFutureTask<RptReportDto> lrt = taskManager.execute(executor);
// set new lrt for report
if (newTask) {
report.setLongRunningTask(lrt.getExecutor().getLongRunningTaskId());
fillReportName(report, executor);
reportService.save(report);
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method tryRedeployScript.
@Test
public void tryRedeployScript() {
configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, TEST_BACKUP_FOLDER);
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
assertNotNull(script1);
assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
String changeName = "test_change_" + System.currentTimeMillis();
script1.setName(changeName);
script1 = scriptService.save(script1);
assertEquals(changeName, script1.getName());
try {
script1 = scriptService.redeploy(script1);
assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
} catch (ResultCodeException e) {
fail();
}
}
Aggregations