use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceManager method updateResourceSchema.
private void updateResourceSchema(List<ConnectorSpec> allConnectorSpecs, OperationResult parentResult, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException {
ResourceSchema resourceSchema = ResourceSchemaFactory.getRawSchema(resource);
if (resourceSchema != null) {
for (ConnectorSpec connectorSpec : allConnectorSpecs) {
ConnectorInstance instance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult);
instance.updateSchema(resourceSchema);
}
}
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceManager method executeScript.
public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
PrismObject<ResourceType> resource = getResource(resourceOid, null, task, result);
ConnectorSpec connectorSpec = selectConnectorSpec(resource, ScriptCapabilityType.class);
if (connectorSpec == null) {
throw new UnsupportedOperationException("No connector supports script capability");
}
ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
ExecuteProvisioningScriptOperation scriptOperation = ProvisioningUtil.convertToScriptOperation(script, "script on " + resource, prismContext);
try {
UcfExecutionContext ucfCtx = new UcfExecutionContext(lightweightIdentifierGenerator, resource.asObjectable(), task);
return connectorInstance.executeScript(scriptOperation, ucfCtx, result);
} catch (GenericFrameworkException e) {
// Not expected. Transform to system exception
result.recordFatalError("Generic provisioning framework error", e);
throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceManager method completeConnectorCapabilities.
private void completeConnectorCapabilities(ConnectorSpec connectorSpec, CapabilitiesType capType, ItemPath itemPath, boolean forceRefresh, Collection<Object> retrievedCapabilities, Collection<ItemDelta<?, ?>> modifications, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
if (capType.getNative() != null && !capType.getNative().getAny().isEmpty()) {
if (!forceRefresh) {
CachingMetadataType cachingMetadata = capType.getCachingMetadata();
if (cachingMetadata == null) {
cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
modifications.add(prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_CACHING_METADATA), connectorSpec.getResource().getDefinition(), cachingMetadata));
}
return;
}
}
if (retrievedCapabilities == null) {
try {
InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT);
ConnectorInstance connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
retrievedCapabilities = connector.fetchCapabilities(result);
} catch (GenericFrameworkException e) {
throw new GenericConnectorException("Generic error in connector " + connectorSpec + ": " + e.getMessage(), e);
}
}
CapabilityCollectionType nativeCapType = new CapabilityCollectionType();
capType.setNative(nativeCapType);
nativeCapType.getAny().addAll(retrievedCapabilities);
CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
capType.setCachingMetadata(cachingMetadata);
// noinspection unchecked
ObjectDelta<ResourceType> capabilitiesReplaceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), itemPath, capType.asPrismContainerValue().clone());
modifications.addAll(capabilitiesReplaceDelta.getModifications());
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceManager method getConnectorOperationalStatus.
public List<ConnectorOperationalStatus> getConnectorOperationalStatus(PrismObject<ResourceType> resource, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
List<ConnectorOperationalStatus> statuses = new ArrayList<>();
for (ConnectorSpec connectorSpec : getAllConnectorSpecs(resource)) {
ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
ConnectorOperationalStatus operationalStatus = connectorInstance.getOperationalStatus();
if (operationalStatus != null) {
operationalStatus.setConnectorName(connectorSpec.getConnectorName());
statuses.add(operationalStatus);
}
}
return statuses;
}
use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance in project midpoint by Evolveum.
the class ResourceManager method fetchResourceSchema.
private ResourceSchema fetchResourceSchema(PrismObject<ResourceType> resource, Map<String, Collection<Object>> capabilityMap, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException, ObjectNotFoundException, SchemaException {
ConnectorSpec connectorSpec = selectConnectorSpec(resource, capabilityMap, SchemaCapabilityType.class);
if (connectorSpec == null) {
LOGGER.debug("No connector has schema capability, cannot fetch resource schema");
return null;
}
InternalMonitor.recordCount(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT);
List<QName> generateObjectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource);
ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult);
LOGGER.debug("Trying to get schema from {}, objectClasses to generate: {}", connectorSpec, generateObjectClasses);
ResourceSchema rawResourceSchema = connectorInstance.fetchResourceSchema(parentResult);
if (ResourceTypeUtil.isValidateSchema(resource.asObjectable())) {
ResourceTypeUtil.validateSchema(rawResourceSchema, resource);
}
return rawResourceSchema;
}
Aggregations