Search in sources :

Example 1 with MappingEvaluationRequestType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.MappingEvaluationRequestType in project midpoint by Evolveum.

the class PageEvaluateMapping method executeMappingPerformed.

private void executeMappingPerformed(AjaxRequestTarget target) {
    Task task = createSimpleTask(OPERATION_EXECUTE_MAPPING);
    OperationResult result = new OperationResult(OPERATION_EXECUTE_MAPPING);
    ExecuteMappingDto dto = model.getObject();
    if (StringUtils.isBlank(dto.getMapping())) {
        warn(getString("PageEvaluateMapping.message.emptyString"));
        target.add(getFeedbackPanel());
        return;
    }
    try {
        MappingEvaluationRequestType request;
        if (StringUtils.isNotBlank(dto.getRequest())) {
            request = getPrismContext().parserFor(dto.getRequest()).xml().parseRealValue(MappingEvaluationRequestType.class);
        } else {
            request = new MappingEvaluationRequestType();
        }
        if (StringUtils.isNotBlank(dto.getMapping())) {
            request.setMapping(getPrismContext().parserFor(dto.getMapping()).xml().parseRealValue(MappingType.class));
        }
        MappingEvaluationResponseType response = getModelDiagnosticService().evaluateMapping(request, task, result);
        dto.setResultText(response.getResponse());
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError(getString("PageEvaluateMapping.message.executeMappingPerformed.fatalError"), e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute mapping", e);
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        pw.close();
        dto.setResultText(sw.toString());
    } finally {
        result.computeStatus();
    }
    showResult(result);
    target.add(this);
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) ExecuteMappingDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ExecuteMappingDto) Task(com.evolveum.midpoint.task.api.Task) StringWriter(java.io.StringWriter) MappingEvaluationResponseType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingEvaluationResponseType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) MappingEvaluationRequestType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingEvaluationRequestType) PrintWriter(java.io.PrintWriter)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 ExecuteMappingDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ExecuteMappingDto)1 MappingEvaluationRequestType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingEvaluationRequestType)1 MappingEvaluationResponseType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingEvaluationResponseType)1 MappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1