Search in sources :

Example 56 with ResultCodeException

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);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 57 with ResultCodeException

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);
    }
}
Also used : RptRenderedReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto) InputStream(java.io.InputStream) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) InputStreamResource(org.springframework.core.io.InputStreamResource) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 58 with ResultCodeException

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;
}
Also used : RptRenderedReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto) ReportRenderer(eu.bcvsolutions.idm.rpt.api.renderer.ReportRenderer) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException)

Example 59 with ResultCodeException

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);
    }
}
Also used : ReportExecutor(eu.bcvsolutions.idm.rpt.api.executor.ReportExecutor) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)

Example 60 with ResultCodeException

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();
    }
}
Also used : IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)162 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)48 ApiOperation (io.swagger.annotations.ApiOperation)47 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)47 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 Test (org.junit.Test)31 ResponseEntity (org.springframework.http.ResponseEntity)22 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)20 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)17 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)17 Transactional (org.springframework.transaction.annotation.Transactional)17 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)15 UUID (java.util.UUID)15 ArrayList (java.util.ArrayList)14 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)13 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)12 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)12 IOException (java.io.IOException)12 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)10