Search in sources :

Example 66 with ExpressionEvaluationException

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

the class ResourceConnectorPanel method initLayout.

private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
    setOutputMarkupId(true);
    IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<ConnectorOperationalStatus> getObject() {
            PrismObject<ResourceType> resource = model.getObject();
            Task task = parentPage.createSimpleTask(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
            OperationResult result = task.getResult();
            List<ConnectorOperationalStatus> status = null;
            try {
                status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), task, result);
            } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
                LOGGER.error("Error getting connector status for {}: {}", resource, e.getMessage(), e);
                parentPage.showResult(result);
            }
            return status;
        }
    };
    ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
            item.add(new Label("label", item.getModel()));
            IModel<ConnectorOperationalStatus> statModel = item.getModel();
            item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
            item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
        }
    };
    add(listview);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) 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) Label(org.apache.wicket.markup.html.basic.Label) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ListView(org.apache.wicket.markup.html.list.ListView) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 67 with ExpressionEvaluationException

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

the class ResourceContentPanel method deleteAccountConfirmedPerformed.

private void deleteAccountConfirmedPerformed(AjaxRequestTarget target, OperationResult result, List<ShadowType> selected) {
    Task task = pageBase.createSimpleTask(OPERATION_DELETE_OBJECT);
    ModelExecuteOptions opts = createModelOptions();
    for (ShadowType shadow : selected) {
        try {
            ObjectDelta<ShadowType> deleteDelta = ObjectDelta.createDeleteDelta(ShadowType.class, shadow.getOid(), getPageBase().getPrismContext());
            getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(deleteDelta), opts, task, result);
        } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
            result.recordPartialError("Could not delete object " + shadow, e);
            LOGGER.error("Could not delete {}, using option {}", shadow, opts, e);
            continue;
        }
    }
    result.computeStatusIfUnknown();
    getPageBase().showResult(result);
    getTable().refreshTable(null, target);
    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) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 68 with ExpressionEvaluationException

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

the class ResourceContentPanel method changeOwnerInternal.

private void changeOwnerInternal(String ownerOid, Collection<? extends ItemDelta> modifications, AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_CHANGE_OWNER);
    Task task = pageBase.createSimpleTask(OPERATION_CHANGE_OWNER);
    ObjectDelta objectDelta = ObjectDelta.createModifyDelta(ownerOid, modifications, FocusType.class, pageBase.getPrismContext());
    Collection deltas = new ArrayList<>();
    deltas.add(objectDelta);
    try {
        if (!deltas.isEmpty()) {
            pageBase.getModelService().executeChanges(deltas, null, task, result);
        }
    } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
    }
    result.computeStatusIfUnknown();
    pageBase.showResult(result);
    target.add(pageBase.getFeedbackPanel());
    getTable().refreshTable(null, target);
    target.add(ResourceContentPanel.this);
}
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) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 69 with ExpressionEvaluationException

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

the class RunReportPopupPanel method createLookupTableRows.

private <O extends ObjectType> List<LookupTableRowType> createLookupTableRows(JasperReportParameterDto param, String input) {
    ItemPath label = null;
    ItemPath key = null;
    List<LookupTableRowType> rows = new ArrayList<>();
    JasperReportParameterPropertiesDto properties = param.getProperties();
    if (properties == null) {
        return null;
    }
    String pLabel = properties.getLabel();
    if (pLabel != null) {
        label = new ItemPath(pLabel);
    }
    String pKey = properties.getKey();
    if (pKey != null) {
        key = new ItemPath(pKey);
    }
    String pTargetType = properties.getTargetType();
    Class<O> targetType = null;
    if (pTargetType != null) {
        try {
            targetType = (Class<O>) Class.forName(pTargetType);
        } catch (ClassNotFoundException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
        //e.printStackTrace();
        }
    }
    if (label != null && targetType != null && input != null) {
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
        Collection<PrismObject<O>> objects;
        ObjectQuery query = QueryBuilder.queryFor(targetType, getPrismContext()).item(new QName(SchemaConstants.NS_C, pLabel)).startsWith(input).matching(new QName(SchemaConstants.NS_MATCHING_RULE, "origIgnoreCase")).maxSize(AUTO_COMPLETE_BOX_SIZE).build();
        try {
            objects = getPageBase().getModelService().searchObjects(targetType, query, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), task, result);
            for (PrismObject<O> o : objects) {
                Object realKeyValue = null;
                PrismProperty labelItem = o.findProperty(label);
                //TODO: e.g. support not only for property, but also ref, container..
                if (labelItem == null || labelItem.isEmpty()) {
                    continue;
                }
                PrismProperty keyItem = o.findProperty(key);
                if ("oid".equals(pKey)) {
                    realKeyValue = o.getOid();
                }
                if (realKeyValue == null && (keyItem == null || keyItem.isEmpty())) {
                    continue;
                }
                //TODO: support for single/multivalue value 
                if (!labelItem.isSingleValue()) {
                    continue;
                }
                Object realLabelValue = labelItem.getRealValue();
                realKeyValue = (realKeyValue == null) ? keyItem.getRealValue() : realKeyValue;
                // TODO: take definition into account
                QName typeName = labelItem.getDefinition().getTypeName();
                LookupTableRowType row = new LookupTableRowType();
                if (realKeyValue != null) {
                    row.setKey(convertObjectToPolyStringType(realKeyValue).getOrig());
                } else {
                    throw new SchemaException("Cannot create lookup table with null key for label: " + realLabelValue);
                }
                row.setLabel(convertObjectToPolyStringType(realLabelValue));
                rows.add(row);
            }
            return rows;
        } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
        //e.printStackTrace();
        }
    }
    return rows;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) JasperReportParameterPropertiesDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterPropertiesDto) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 70 with ExpressionEvaluationException

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

the class TestRetirement method reconcileAllUsers.

private void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    final Task task = createTask("reconcileAllUsers");
    OperationResult result = task.getResult();
    ResultHandler<UserType> handler = new ResultHandler<UserType>() {

        @Override
        public boolean handle(PrismObject<UserType> object, OperationResult parentResult) {
            try {
                display("reconciling " + object);
                reconcileUser(object.getOid(), task, parentResult);
            } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
                throw new SystemException(e.getMessage(), e);
            }
            return true;
        }
    };
    display("Reconciling all users");
    modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result);
}
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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismObject(com.evolveum.midpoint.prism.PrismObject) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

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