use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ProvisioningServiceImpl method deleteObject.
@Override
public <T extends ObjectType> void deleteObject(Class<T> type, String oid, ProvisioningOperationOptions options, OperationProvisioningScriptsType scripts, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
Validate.notNull(oid, "Oid of object to delete must not be null.");
Validate.notNull(parentResult, "Operation result must not be null.");
LOGGER.trace("**PROVISIONING: Start to delete object with oid {}", oid);
OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".deleteObject");
result.addParam("oid", oid);
result.addParam("scripts", scripts);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
//TODO: is critical when shadow does not exits anymore?? do we need to log it?? if not, change null to allowNotFound options
PrismObject<T> object = getRepoObject(type, oid, null, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("**PROVISIONING: Object from repository to delete:\n{}", object.debugDump());
}
if (object.canRepresent(ShadowType.class) && !ProvisioningOperationOptions.isRaw(options)) {
try {
getShadowCache(Mode.STANDARD).deleteShadow((PrismObject<ShadowType>) object, options, scripts, task, result);
} catch (CommunicationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: communication problem: " + e.getMessage(), e);
throw new CommunicationException(e.getMessage(), e);
} catch (GenericFrameworkException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: generic error in the connector: " + e.getMessage(), e);
throw new CommunicationException(e.getMessage(), e);
} catch (SchemaException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: schema problem: " + e.getMessage(), e);
throw new SchemaException(e.getMessage(), e);
} catch (ConfigurationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: configuration problem: " + e.getMessage(), e);
throw e;
} catch (SecurityViolationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: security violation: " + e.getMessage(), e);
throw e;
} catch (ExpressionEvaluationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: expression errror: " + e.getMessage(), e);
throw e;
} catch (RuntimeException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: " + e.getMessage(), e);
throw new SystemException(e);
}
} else if (object.canRepresent(ResourceType.class)) {
resourceManager.deleteResource(oid, options, task, result);
} else {
try {
getCacheRepositoryService().deleteObject(type, oid, result);
} catch (ObjectNotFoundException ex) {
result.recordFatalError(ex);
result.cleanupResult(ex);
throw ex;
}
}
LOGGER.trace("**PROVISIONING: Finished deleting object.");
result.computeStatus();
result.cleanupResult();
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method fetchConnectorObject.
/**
* Returns null if nothing is found.
*/
private ConnectorObject fetchConnectorObject(StateReporter reporter, ObjectClassComplexTypeDefinition objectClassDefinition, ObjectClass icfObjectClass, Uid uid, OperationOptions options, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SecurityViolationException, SchemaException, ConfigurationException {
// Connector operation cannot create result for itself, so we need to
// create result for it
OperationResult icfResult = parentResult.createMinorSubresult(ConnectorFacade.class.getName() + ".getObject");
icfResult.addParam("objectClass", icfObjectClass.toString());
icfResult.addParam("uid", uid.getUidValue());
icfResult.addArbitraryObjectAsParam("options", options);
icfResult.addContext("connector", connIdConnectorFacade.getClass());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Fetching connector object ObjectClass={}, UID={}, options={}", new Object[] { icfObjectClass, uid, ConnIdUtil.dumpOptions(options) });
}
ConnectorObject co = null;
try {
// Invoke the ICF connector
InternalMonitor.recordConnectorOperation("getObject");
recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
co = connIdConnectorFacade.getObject(icfObjectClass, uid, options);
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
icfResult.recordSuccess();
} catch (Throwable ex) {
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, ex, uid);
String desc = this.getHumanReadableName() + " while getting object identified by ICF UID '" + uid.getUidValue() + "'";
Throwable midpointEx = processIcfException(ex, desc, icfResult);
icfResult.computeStatus("Add object failed");
// exception
if (midpointEx instanceof CommunicationException) {
icfResult.muteError();
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof ConfigurationException) {
throw (ConfigurationException) midpointEx;
} else if (midpointEx instanceof SecurityViolationException) {
throw (SecurityViolationException) midpointEx;
} else if (midpointEx instanceof ObjectNotFoundException) {
LOGGER.trace("Got ObjectNotFoundException while looking for resource object ConnId UID: {}", uid);
return null;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof Error) {
// This should not happen. But some connectors are very strange.
throw new SystemException("ERROR: " + midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
} else {
throw new SystemException(midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
}
}
return co;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method executeScript.
@Override
public Object executeScript(ExecuteProvisioningScriptOperation scriptOperation, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".executeScript");
Object output = null;
try {
output = executeScriptIcf(reporter, scriptOperation, result);
} catch (CommunicationException e) {
result.recordFatalError(e);
throw e;
} catch (GenericFrameworkException e) {
result.recordFatalError(e);
throw e;
} catch (RuntimeException e) {
result.recordFatalError(e);
throw e;
}
result.computeStatus();
return output;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method fetchCurrentToken.
@Override
public <T> PrismProperty<T> fetchCurrentToken(ObjectClassComplexTypeDefinition objectClassDef, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".fetchCurrentToken");
result.addParam("objectClass", objectClassDef);
ObjectClass icfObjectClass;
if (objectClassDef == null) {
icfObjectClass = ObjectClass.ALL;
} else {
icfObjectClass = connIdNameMapper.objectClassToIcf(objectClassDef, getSchemaNamespace(), connectorType, legacySchema);
}
OperationResult icfResult = result.createSubresult(ConnectorFacade.class.getName() + ".sync");
icfResult.addContext("connector", connIdConnectorFacade.getClass());
icfResult.addArbitraryObjectAsParam("icfObjectClass", icfObjectClass);
SyncToken syncToken = null;
try {
InternalMonitor.recordConnectorOperation("getLatestSyncToken");
recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
syncToken = connIdConnectorFacade.getLatestSyncToken(icfObjectClass);
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
icfResult.recordSuccess();
icfResult.addReturn("syncToken", syncToken == null ? null : String.valueOf(syncToken.getValue()));
} catch (Throwable ex) {
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef, ex);
Throwable midpointEx = processIcfException(ex, this, icfResult);
result.computeStatus();
// exception
if (midpointEx instanceof CommunicationException) {
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof Error) {
throw (Error) midpointEx;
} else {
throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
if (syncToken == null) {
result.recordWarning("Resource have not provided a current sync token");
return null;
}
PrismProperty<T> property = getToken(syncToken);
result.recordSuccess();
return property;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class AbstractManualConnectorInstance method deleteObject.
@Override
public AsynchronousOperationResult deleteObject(ObjectClassComplexTypeDefinition objectClass, Collection<Operation> additionalOperations, Collection<? extends ResourceAttribute<?>> identifiers, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException {
OperationResult result = parentResult.createSubresult(OPERATION_DELETE);
String ticketIdentifier = null;
try {
ticketIdentifier = createTicketDelete(objectClass, identifiers, result);
} catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ConfigurationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
result.recordInProgress();
result.setAsynchronousOperationReference(ticketIdentifier);
return AsynchronousOperationResult.wrap(result);
}
Aggregations