Search in sources :

Example 16 with ExpressionEvaluationException

use of com.evolveum.midpoint.util.exception.ExpressionEvaluationException in project midpoint by Evolveum.

the class TestFilterExpression method test130EvaluateExpressionEmployeeTypeError.

@Test
public void test130EvaluateExpressionEmployeeTypeError() throws Exception {
    final String TEST_NAME = "testEvaluateExpressionEmployeeTypeError";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    try {
        evaluateExpressionAssertFilter("expression-employeeType-error.xml", null, NoneFilter.class, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (ExpressionEvaluationException e) {
        // this is expected
        assertTrue("Unexpected exception message: " + e.getMessage(), e.getMessage().contains("evaluated to no value"));
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 17 with ExpressionEvaluationException

use of com.evolveum.midpoint.util.exception.ExpressionEvaluationException in project midpoint by Evolveum.

the class ObjectDeltaOperationPanel method initLayout.

private void initLayout() {
    // ObjectDeltaType od = getModel().getObjectDelta();
    WebMarkupContainer objectDeltaOperationMarkup = new WebMarkupContainer(ID_OBJECT_DELTA_OPERATION_MARKUP);
    objectDeltaOperationMarkup.setOutputMarkupId(true);
    objectDeltaOperationMarkup.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getBoxCssClass();
        }
    }));
    add(objectDeltaOperationMarkup);
    Label executionResult = new Label(ID_PARAMETERS_EXECUTION_RESULT, new PropertyModel(getModel(), "executionResult.status"));
    executionResult.setOutputMarkupId(true);
    objectDeltaOperationMarkup.add(executionResult);
    Label resourceName = new Label(ID_PARAMETERS_RESOURCE_NAME, new PropertyModel(getModel(), ObjectDeltaOperationType.F_RESOURCE_NAME.getLocalPart()));
    resourceName.setOutputMarkupId(true);
    objectDeltaOperationMarkup.add(resourceName);
    Label objectName = new Label(ID_PARAMETERS_OBJECT_NAME, new PropertyModel(getModel(), ObjectDeltaOperationType.F_OBJECT_NAME.getLocalPart()));
    objectName.setOutputMarkupId(true);
    objectDeltaOperationMarkup.add(objectName);
    final SceneDto sceneDto;
    try {
        sceneDto = loadSceneForDelta();
    } catch (SchemaException | ExpressionEvaluationException e) {
        OperationResult result = new OperationResult(ObjectDeltaOperationPanel.class.getName() + ".loadSceneForDelta");
        result.recordFatalError("Couldn't fetch or visualize the delta: " + e.getMessage(), e);
        parentPage.showResult(result);
        throw parentPage.redirectBackViaRestartResponseException();
    }
    IModel<SceneDto> deltaModel = new AbstractReadOnlyModel<SceneDto>() {

        private static final long serialVersionUID = 1L;

        public SceneDto getObject() {
            return sceneDto;
        }
    };
    ScenePanel deltaPanel = new ScenePanel(ID_DELTA_PANEL, deltaModel) {

        @Override
        public void headerOnClickPerformed(AjaxRequestTarget target, IModel<SceneDto> model) {
            super.headerOnClickPerformed(target, model);
            //				model.getObject().setMinimized(!model.getObject().isMinimized());
            target.add(ObjectDeltaOperationPanel.this);
        }
    };
    deltaPanel.setOutputMarkupId(true);
    objectDeltaOperationMarkup.add(deltaPanel);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ScenePanel(com.evolveum.midpoint.web.component.prism.show.ScenePanel) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SceneDto(com.evolveum.midpoint.web.component.prism.show.SceneDto)

Example 18 with ExpressionEvaluationException

use of com.evolveum.midpoint.util.exception.ExpressionEvaluationException in project midpoint by Evolveum.

the class ObjectDeltaOperationPanel method loadSceneForDelta.

private SceneDto loadSceneForDelta() throws SchemaException, ExpressionEvaluationException {
    Scene scene;
    ObjectDelta<? extends ObjectType> delta;
    ObjectDeltaType deltaType = getModel().getObject().getObjectDelta();
    try {
        delta = DeltaConvertor.createObjectDelta(deltaType, parentPage.getPrismContext());
    } catch (SchemaException e) {
        LoggingUtils.logException(LOGGER, "SchemaException while converting delta:\n{}", e, deltaType);
        throw e;
    }
    try {
        scene = parentPage.getModelInteractionService().visualizeDelta(delta, parentPage.createSimpleTask(ID_PARAMETERS_DELTA), new OperationResult(ID_PARAMETERS_DELTA));
    } catch (SchemaException | ExpressionEvaluationException e) {
        LoggingUtils.logException(LOGGER, "SchemaException while visualizing delta:\n{}", e, DebugUtil.debugDump(delta));
        throw e;
    }
    SceneDto deltaSceneDto = new SceneDto(scene);
    deltaSceneDto.setMinimized(true);
    return deltaSceneDto;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SceneDto(com.evolveum.midpoint.web.component.prism.show.SceneDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Scene(com.evolveum.midpoint.model.api.visualizer.Scene)

Example 19 with ExpressionEvaluationException

use of com.evolveum.midpoint.util.exception.ExpressionEvaluationException in project midpoint by Evolveum.

the class OrgMemberPanel method deleteManagerConfirmPerformed.

private void deleteManagerConfirmPerformed(FocusType manager, AjaxRequestTarget target) {
    getPageBase().hideMainPopup(target);
    OperationResult parentResult = new OperationResult("Remove manager");
    Task task = getPageBase().createSimpleTask("Remove manager");
    try {
        ObjectDelta delta = ObjectDelta.createDeleteDelta(manager.asPrismObject().getCompileTimeClass(), manager.getOid(), getPageBase().getPrismContext());
        getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, parentResult);
        parentResult.computeStatus();
    } catch (SchemaException | ObjectAlreadyExistsException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
        parentResult.recordFatalError("Failed to remove manager " + e.getMessage(), e);
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to remove manager", e);
        getPageBase().showResult(parentResult);
    }
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 20 with ExpressionEvaluationException

use of com.evolveum.midpoint.util.exception.ExpressionEvaluationException in project midpoint by Evolveum.

the class TestMappingDynamicSimple method testGeneratePolicyBad.

@Test
public void testGeneratePolicyBad() throws Exception {
    final String TEST_NAME = "testGeneratePolicy";
    try {
        generatePolicy(TEST_NAME, "mapping-generate-policy-bad.xml", "c0c010c0-d34d-b33f-f00d-999888111113.xml", null, false);
        AssertJUnit.fail("Unexpected success");
    } catch (ExpressionEvaluationException e) {
    // This is expected, the policy is broken
    }
}
Also used : ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Aggregations

ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)120 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)93 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)92 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)71 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)71 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)69 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)59 Task (com.evolveum.midpoint.task.api.Task)35 SystemException (com.evolveum.midpoint.util.exception.SystemException)32 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)28 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)26 QName (javax.xml.namespace.QName)23 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)21 ArrayList (java.util.ArrayList)19 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)13 Collection (java.util.Collection)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12