Search in sources :

Example 1 with StateReporter

use of com.evolveum.midpoint.task.api.StateReporter 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, SecurityViolationException, 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 {
        StateReporter reporter = new StateReporter(resourceOid, task);
        return connectorInstance.executeScript(scriptOperation, reporter, 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);
    }
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ExecuteProvisioningScriptOperation(com.evolveum.midpoint.provisioning.ucf.api.ExecuteProvisioningScriptOperation) StateReporter(com.evolveum.midpoint.task.api.StateReporter)

Aggregations

ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)1 ExecuteProvisioningScriptOperation (com.evolveum.midpoint.provisioning.ucf.api.ExecuteProvisioningScriptOperation)1 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)1 StateReporter (com.evolveum.midpoint.task.api.StateReporter)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1