Search in sources :

Example 16 with ConnectorHostType

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

the class DiscoverConnectorsExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
    boolean rebind = expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_REBIND_RESOURCES, input, context, false, PARAM_REBIND_RESOURCES, globalResult);
    PipelineData output = PipelineData.createEmpty();
    for (PipelineItem item : input.getData()) {
        PrismValue value = item.getValue();
        OperationResult result = operationsHelper.createActionResult(item, this, globalResult);
        context.checkTaskStop();
        if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ConnectorHostType) {
            PrismObject<ConnectorHostType> connectorHostTypePrismObject = ((PrismObjectValue) value).asPrismObject();
            Set<ConnectorType> newConnectors;
            Operation op = operationsHelper.recordStart(context, connectorHostTypePrismObject.asObjectable());
            Throwable exception = null;
            try {
                newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), context.getTask(), result);
                operationsHelper.recordEnd(context, op, null, result);
            } catch (CommunicationException | SecurityViolationException | SchemaException | ConfigurationException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException e) {
                operationsHelper.recordEnd(context, op, e, result);
                exception = processActionException(e, NAME, value, context);
                newConnectors = Collections.emptySet();
            }
            context.println((exception != null ? "Attempted to discover " : "Discovered " + newConnectors.size()) + " new connector(s) from " + connectorHostTypePrismObject + exceptionSuffix(exception));
            for (ConnectorType connectorType : newConnectors) {
                output.addValue(connectorType.asPrismObject().getValue(), item.getResult(), item.getVariables());
            }
            try {
                if (rebind) {
                    rebindConnectors(newConnectors, context, result);
                }
            } catch (ScriptExecutionException e) {
                // noinspection ThrowableNotThrown
                // TODO better message
                processActionException(e, NAME, value, context);
            }
        } else {
            // noinspection ThrowableNotThrown
            processActionException(new ScriptExecutionException("Input item is not a PrismObject<ConnectorHost>"), NAME, value, context);
        }
        operationsHelper.trimAndCloneResult(result, item.getResult());
    }
    // TODO configurable output (either connector hosts or discovered connectors)
    return output;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ScriptExecutionException(com.evolveum.midpoint.util.exception.ScriptExecutionException) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Operation(com.evolveum.midpoint.schema.statistics.Operation) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 17 with ConnectorHostType

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

the class ConnectorFactoryConnIdImpl method listRemoteConnectors.

private Set<ConnectorType> listRemoteConnectors(ConnectorHostType host) {
    ConnectorInfoManager remoteConnectorInfoManager = getRemoteConnectorInfoManager(host);
    Set<ConnectorType> connectorTypes = new HashSet<>();
    List<ConnectorInfo> connectorInfos = remoteConnectorInfoManager.getConnectorInfos();
    for (ConnectorInfo connectorInfo : connectorInfos) {
        try {
            ConnectorType connectorType = convertToConnectorType(connectorInfo, host);
            connectorTypes.add(connectorType);
        } catch (SchemaException e) {
            LOGGER.error("Schema error while initializing ConnId connector {}: {}", getConnectorDesc(connectorInfo), e.getMessage(), e);
        }
    }
    return connectorTypes;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)

Aggregations

ConnectorHostType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType)13 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 IModel (org.apache.wicket.model.IModel)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2 CheckBoxColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)2 DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)2 ArrayList (java.util.ArrayList)2 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)2 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 PipelineData (com.evolveum.midpoint.model.impl.scripting.PipelineData)1