use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class TestDummyLegacy method test103NativeTestResource.
@Test
public void test103NativeTestResource() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
// Check that there is no schema before test (pre-condition)
ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result).asObjectable();
assertNotNull("No connector ref", resourceBefore.getConnectorRef());
assertNotNull("No connector ref OID", resourceBefore.getConnectorRef().getOid());
ConnectorType connector = repositoryService.getObject(ConnectorType.class, resourceBefore.getConnectorRef().getOid(), null, result).asObjectable();
assertNotNull(connector);
XmlSchemaType xmlSchemaTypeBefore = resourceBefore.getSchema();
Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
AssertJUnit.assertNull("Found schema before test connection. Bad test setup?", resourceXsdSchemaElementBefore);
// WHEN
OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_NATIVE_OID, task);
// THEN
display("Test result", testResult);
OperationResult connectorResult = assertSingleConnectorTestResult(testResult);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_INITIALIZATION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CONFIGURATION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CONNECTION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CAPABILITIES);
assertSuccess(connectorResult);
assertTestResourceSuccess(testResult, ConnectorTestOperation.RESOURCE_SCHEMA);
assertSuccess(testResult);
PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result);
ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
display("Resource after test", resourceTypeRepoAfter);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class TestDummyLegacy method test203LegacyTestResource.
@Test
public void test203LegacyTestResource() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
// Check that there is no schema before test (pre-condition)
ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result).asObjectable();
assertNotNull("No connector ref", resourceBefore.getConnectorRef());
assertNotNull("No connector ref OID", resourceBefore.getConnectorRef().getOid());
ConnectorType connector = repositoryService.getObject(ConnectorType.class, resourceBefore.getConnectorRef().getOid(), null, result).asObjectable();
assertNotNull(connector);
XmlSchemaType xmlSchemaTypeBefore = resourceBefore.getSchema();
Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
AssertJUnit.assertNull("Found schema before test connection. Bad test setup?", resourceXsdSchemaElementBefore);
// WHEN
OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_LEGACY_OID, task);
// THEN
display("Test result", testResult);
OperationResult connectorResult = assertSingleConnectorTestResult(testResult);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_INITIALIZATION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CONFIGURATION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CONNECTION);
assertTestResourceSuccess(connectorResult, ConnectorTestOperation.CONNECTOR_CAPABILITIES);
assertSuccess(connectorResult);
assertTestResourceSuccess(testResult, ConnectorTestOperation.RESOURCE_SCHEMA);
assertSuccess(testResult);
PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result);
ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
display("Resource after test", resourceTypeRepoAfter);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class DiscoverConnectorsExecutor method determineConnectorMappings.
private void determineConnectorMappings(Map<String, String> rebindMap, ConnectorType connectorType, ExecutionContext context, OperationResult result) throws ScriptExecutionException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Finding obsolete versions for connector: {}", connectorType.asPrismObject().debugDump());
}
ObjectQuery query = prismContext.queryFor(ConnectorType.class).item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(connectorType.getFramework()).and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(connectorType.getConnectorType()).build();
List<PrismObject<ConnectorType>> foundConnectors;
try {
foundConnectors = modelService.searchObjects(ConnectorType.class, query, null, null, result);
} catch (SchemaException | ConfigurationException | ObjectNotFoundException | CommunicationException | SecurityViolationException | ExpressionEvaluationException e) {
throw new ScriptExecutionException("Couldn't get connectors of type: " + connectorType.getConnectorType() + ": " + e.getMessage(), e);
}
for (PrismObject<ConnectorType> foundConnector : foundConnectors) {
ConnectorType foundConnectorType = foundConnector.asObjectable();
// TODO temporary hack. fix it after MID-3355 is implemented.
if (connectorType.getConnectorHostRef() != null && connectorType.getConnectorHostRef().asReferenceValue().getObject() != null) {
String connectorHostOid = connectorType.getConnectorHostRef().getOid();
connectorType.getConnectorHostRef().asReferenceValue().setObject(null);
connectorType.getConnectorHostRef().setOid(connectorHostOid);
}
if (connectorType.getConnectorHostRef().equals(foundConnectorType.getConnectorHostRef()) && foundConnectorType.getConnectorVersion() != null && !foundConnectorType.getConnectorVersion().equals(connectorType.getConnectorVersion())) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Found obsolete connector:\n{}", foundConnectorType.asPrismObject().debugDump(1));
}
rebindMap.put(foundConnectorType.getOid(), connectorType.getOid());
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType 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;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.
the class TestConnectorDiscovery method testSearchConnectorAnd.
@Test
public void testSearchConnectorAnd() throws SchemaException {
OperationResult result = createOperationResult();
ObjectQuery query = prismContext.queryFor(ConnectorType.class).item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(SchemaConstants.ICF_FRAMEWORK_URI).and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(IntegrationTestTools.LDAP_CONNECTOR_TYPE).build();
System.out.println("Query:\n" + query.debugDump());
List<PrismObject<ConnectorType>> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result);
assertEquals("Unexpected number of results", 1, connectors.size());
PrismObject<ConnectorType> ldapConnector = connectors.get(0);
assertEquals("Type does not match", IntegrationTestTools.LDAP_CONNECTOR_TYPE, ldapConnector.asObjectable().getConnectorType());
assertEquals("Framework does not match", SchemaConstants.ICF_FRAMEWORK_URI, ldapConnector.asObjectable().getFramework());
}
Aggregations