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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations