use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ConnectorManager method createConnectorInstance.
private ConnectorInstance createConnectorInstance(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException {
ConnectorType connectorBean = getConnector(connectorSpec, result);
ConnectorFactory connectorFactory = determineConnectorFactory(connectorBean);
ConnectorInstance connectorInstance;
try {
InternalMonitor.recordCount(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT);
connectorInstance = connectorFactory.createConnectorInstance(connectorBean, connectorSpec.getResource().getName().toString(), connectorSpec.toString());
// FIXME temporary -- remove when no longer needed (MID-5931)
if (connectorInstance instanceof AbstractManagedConnectorInstance) {
((AbstractManagedConnectorInstance) connectorInstance).setResourceOid(connectorSpec.getResource().getOid());
}
} catch (ObjectNotFoundException e) {
result.recordFatalError(e.getMessage(), e);
throw new ObjectNotFoundException(e.getMessage(), e);
}
// This log message should be INFO level. It happens only occasionally.
// If it happens often, it may be an
// indication of a problem. Therefore it is good for admin to see it.
LOGGER.info("Created new connector instance for {}: {} v{}", connectorSpec, connectorBean.getConnectorType(), connectorBean.getConnectorVersion());
return connectorInstance;
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class TestOpenDj method test004ResourceAndConnectorCaching.
@Test
public void test004ResourceAndConnectorCaching() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
resource = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
resourceBean = resource.asObjectable();
ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance(resource, ReadCapabilityType.class, false, result);
assertNotNull("No configuredConnectorInstance", configuredConnectorInstance);
ResourceSchema resourceSchema = ResourceSchemaFactory.getRawSchema(resource);
assertNotNull("No resource schema", resourceSchema);
// WHEN
PrismObject<ResourceType> resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
// THEN
ResourceType resourceTypeAgain = resourceAgain.asObjectable();
assertNotNull("No connector ref", resourceTypeAgain.getConnectorRef());
assertNotNull("No connector ref OID", resourceTypeAgain.getConnectorRef().getOid());
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismContainer<Containerable> configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain));
assertEquals("Configurations not equals", configurationContainerAgain, configurationContainer);
ResourceSchema resourceSchemaAgain = ResourceSchemaFactory.getRawSchema(resourceAgain);
assertNotNull("No resource schema (again)", resourceSchemaAgain);
assertEquals("Schema serial number mismatch", resourceBean.getSchema().getCachingMetadata().getSerialNumber(), resourceTypeAgain.getSchema().getCachingMetadata().getSerialNumber());
assertSame("Resource schema was not cached", resourceSchema, resourceSchemaAgain);
// Now we stick our nose deep inside the provisioning impl. But we need to make sure that the
// configured connector is properly cached
ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, false, result);
assertSame("Connector instance was not cached", configuredConnectorInstance, configuredConnectorInstanceAgain);
assertShadows(1);
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceObjectReferenceResolver method fetchResourceObject.
PrismObject<ShadowType> fetchResourceObject(ProvisioningContext ctx, Collection<? extends ResourceAttribute<?>> identifiers, AttributesToReturn attributesToReturn, @Nullable PrismObject<ShadowType> repoShadow, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
ConnectorInstance connector = ctx.getConnector(ReadCapabilityType.class, parentResult);
ResourceObjectDefinition objectDefinition = ctx.getObjectDefinitionRequired();
try {
ReadCapabilityType readCapability = ctx.getEffectiveCapability(ReadCapabilityType.class);
if (readCapability == null) {
throw new UnsupportedOperationException("Resource does not support 'read' operation: " + ctx.toHumanReadableDescription());
}
if (Boolean.TRUE.equals(readCapability.isCachingOnly())) {
return repoShadow;
}
ResourceObjectIdentification identification = ResourceObjectIdentification.create(objectDefinition, identifiers);
ResourceObjectIdentification resolvedIdentification = resolvePrimaryIdentifiers(ctx, identification, parentResult);
resolvedIdentification.validatePrimaryIdentifiers();
return connector.fetchObject(resolvedIdentification, attributesToReturn, ctx.getUcfExecutionContext(), parentResult);
} catch (ObjectNotFoundException e) {
// Not finishing the result because we did not create it! (The same for other catch clauses.)
parentResult.recordFatalErrorNotFinish("Object not found. Identifiers: " + identifiers + ". Reason: " + e.getMessage(), e);
throw new ObjectNotFoundException("Object not found. identifiers=" + identifiers + ", objectclass=" + PrettyPrinter.prettyPrint(objectDefinition.getTypeName()) + ": " + e.getMessage(), e, repoShadow != null ? repoShadow.getOid() : null);
} catch (CommunicationException e) {
parentResult.recordFatalErrorNotFinish("Error communication with the connector " + connector + ": " + e.getMessage(), e);
throw e;
} catch (GenericFrameworkException e) {
parentResult.recordFatalErrorNotFinish("Generic error in the connector " + connector + ". Reason: " + e.getMessage(), e);
throw new GenericConnectorException("Generic error in the connector " + connector + ". Reason: " + e.getMessage(), e);
} catch (SchemaException ex) {
parentResult.recordFatalErrorNotFinish("Can't get resource object, schema error: " + ex.getMessage(), ex);
throw ex;
} catch (ExpressionEvaluationException ex) {
parentResult.recordFatalErrorNotFinish("Can't get resource object, expression error: " + ex.getMessage(), ex);
throw ex;
} catch (ConfigurationException e) {
parentResult.recordFatalErrorNotFinish(e);
throw e;
}
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class AbstractProvisioningIntegrationTest method assertConnectorInstanceUnchanged.
protected void assertConnectorInstanceUnchanged(PrismObject<ResourceType> resource) throws SchemaException {
if (lastConfiguredConnectorInstance == null) {
return;
}
ConnectorInstance currentConfiguredConnectorInstance = resourceManager.getConfiguredConnectorInstanceFromCache(resource, ReadCapabilityType.class);
assertSame("Connector instance has changed", lastConfiguredConnectorInstance, currentConfiguredConnectorInstance);
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ProvisioningContext method getConnectorInstance.
private <T extends CapabilityType> ConnectorInstance getConnectorInstance(Class<T> operationCapabilityClass, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
OperationResult connectorResult = parentResult.createMinorSubresult(ProvisioningContext.class.getName() + ".getConnectorInstance");
try {
ConnectorInstance connector = resourceManager.getConfiguredConnectorInstance(getResource().asPrismObject(), operationCapabilityClass, false, parentResult);
connectorResult.recordSuccess();
return connector;
} catch (ObjectNotFoundException | SchemaException e) {
connectorResult.recordPartialError("Could not get connector instance " + getDesc() + ": " + e.getMessage(), e);
// throw ObjectNotFoundException here.
throw new ConfigurationException(e.getMessage(), e);
} catch (CommunicationException | ConfigurationException | SystemException e) {
connectorResult.recordPartialError("Could not get connector instance " + getDesc() + ": " + e.getMessage(), e);
throw e;
}
}
Aggregations