Search in sources :

Example 11 with ConnectorHostType

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

the class AbstractAdTest method test001ConnectorHostDiscovery.

@Test
public void test001ConnectorHostDiscovery() throws Exception {
    final String TEST_NAME = "test001ConnectorHostDiscovery";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.discoverConnectors(connectorHostType, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    SearchResultList<PrismObject<ConnectorType>> connectors = modelService.searchObjects(ConnectorType.class, null, null, task, result);
    boolean found = false;
    for (PrismObject<ConnectorType> connector : connectors) {
        if (CONNECTOR_AD_TYPE.equals(connector.asObjectable().getConnectorType())) {
            display("Found connector", connector);
            found = true;
        }
    }
    assertTrue("AD Connector not found", found);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 12 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<ConnectorType>();
    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 {}: {}", getConnctorDesc(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) ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) HashSet(java.util.HashSet)

Example 13 with ConnectorHostType

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

the class ProvisioningServiceImpl method discoverConnectors.

@Override
public Set<ConnectorType> discoverConnectors(ConnectorHostType hostType, OperationResult parentResult) throws CommunicationException {
    OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".discoverConnectors");
    result.addParam("host", hostType);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    Set<ConnectorType> discoverConnectors;
    try {
        discoverConnectors = connectorManager.discoverConnectors(hostType, result);
    } catch (CommunicationException ex) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Discovery failed: " + ex.getMessage(), ex);
        throw ex;
    }
    result.computeStatus("Connector discovery failed");
    result.cleanupResult();
    return discoverConnectors;
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 14 with ConnectorHostType

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

the class ConnectorManager method getConnectorTypeReadOnly.

public ConnectorType getConnectorTypeReadOnly(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException {
    if (connectorSpec.getConnectorOid() == null) {
        result.recordFatalError("Connector OID missing in " + connectorSpec);
        throw new ObjectNotFoundException("Connector OID missing in " + connectorSpec);
    }
    String connOid = connectorSpec.getConnectorOid();
    ConnectorType connectorType = connectorTypeCache.get(connOid);
    if (connectorType == null) {
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly());
        PrismObject<ConnectorType> repoConnector = repositoryService.getObject(ConnectorType.class, connOid, options, result);
        connectorType = repoConnector.asObjectable();
        connectorTypeCache.put(connOid, connectorType);
    } else {
        String currentConnectorVersion = repositoryService.getVersion(ConnectorType.class, connOid, result);
        if (!currentConnectorVersion.equals(connectorType.getVersion())) {
            Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly());
            PrismObject<ConnectorType> repoConnector = repositoryService.getObject(ConnectorType.class, connOid, options, result);
            connectorType = repoConnector.asObjectable();
            connectorTypeCache.put(connOid, connectorType);
        }
    }
    if (connectorType.getConnectorHost() == null && connectorType.getConnectorHostRef() != null) {
        // We need to resolve the connector host
        String connectorHostOid = connectorType.getConnectorHostRef().getOid();
        PrismObject<ConnectorHostType> connectorHost = repositoryService.getObject(ConnectorHostType.class, connectorHostOid, null, result);
        connectorType.setConnectorHost(connectorHost.asObjectable());
    }
    PrismObject<ConnectorType> connector = connectorType.asPrismObject();
    Object userDataEntry = connector.getUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA);
    if (userDataEntry == null) {
        InternalMonitor.recordConnectorSchemaParse();
        PrismSchema connectorSchema = ConnectorTypeUtil.parseConnectorSchema(connectorType, prismContext);
        if (connectorSchema == null) {
            throw new SchemaException("No connector schema in " + connectorType);
        }
        connector.setUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA, connectorSchema);
    }
    return connectorType;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 15 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 {
    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, context, globalResult);
        context.checkTaskStop();
        if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ConnectorHostType) {
            PrismObject<ConnectorHostType> connectorHostTypePrismObject = ((PrismObjectValue) value).asPrismObject();
            Set<ConnectorType> newConnectors;
            long started = operationsHelper.recordStart(context, connectorHostTypePrismObject.asObjectable());
            Throwable exception = null;
            try {
                newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), context.getTask(), result);
                operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, null);
            } catch (CommunicationException | SecurityViolationException | SchemaException | ConfigurationException | ObjectNotFoundException | RuntimeException e) {
                operationsHelper.recordEnd(context, connectorHostTypePrismObject.asObjectable(), started, e);
                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());
            }
            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, globalResult, context);
    }
    // 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) 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.model.api.ScriptExecutionException) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

ConnectorHostType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType)9 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)2 HashSet (java.util.HashSet)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ConnectorKey (org.identityconnectors.framework.api.ConnectorKey)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 ScriptExecutionException (com.evolveum.midpoint.model.api.ScriptExecutionException)1 PipelineData (com.evolveum.midpoint.model.impl.scripting.PipelineData)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1