use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class AbstractManagedConnectorInstance method applyConfigurationToConfigurationClass.
private void applyConfigurationToConfigurationClass(PrismContainerValue<?> configurationContainer) throws ConfigurationException {
BeanWrapper connectorBean = new BeanWrapperImpl(this);
PropertyDescriptor connectorConfigurationProp = UcfUtil.findAnnotatedProperty(connectorBean, ManagedConnectorConfiguration.class);
if (connectorConfigurationProp == null) {
return;
}
Class<?> configurationClass = connectorConfigurationProp.getPropertyType();
Object configurationObject;
try {
configurationObject = configurationClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new ConfigurationException("Cannot instantiate configuration " + configurationClass);
}
BeanWrapper configurationClassBean = new BeanWrapperImpl(configurationObject);
for (Item<?, ?> configurationItem : configurationContainer.getItems()) {
if (!(configurationItem instanceof PrismProperty<?>)) {
throw new ConfigurationException("Only properties are supported for now");
}
PrismProperty<?> configurationProperty = (PrismProperty<?>) configurationItem;
Object realValue = configurationProperty.getRealValue();
configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValue);
}
connectorBean.setPropertyValue(connectorConfigurationProp.getName(), configurationObject);
}
use of com.evolveum.midpoint.util.exception.ConfigurationException 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);
}
use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class TestOpenDjNegative method test111GetObjectShadow.
/**
* This is using the shadow to go to the resource. But it cannot as OpenDJ is down.
* It even cannot fetch schema. If there is no schema it does not even know how to process
* identifiers in the shadow. Therefore the expected result is ConfigurationException (CommunicationException).
* It must not be ObjectNotFound as we do NOT know that the shadow does not exist.
*/
@Test
public void test111GetObjectShadow() throws Exception {
final String TEST_NAME = "test111GetObjectShadow";
TestUtil.displayTestTile(TEST_NAME);
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
try {
ShadowType acct = provisioningService.getObject(ShadowType.class, ACCOUNT_JBOND_OID, null, taskManager.createTaskInstance(), result).asObjectable();
AssertJUnit.fail("getObject succeeded unexpectedly");
// } catch (CommunicationException e) {
} catch (ConfigurationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class TestOpenDjNegative method test130AddAccountWill.
@Test
public void test130AddAccountWill() throws Exception {
final String TEST_NAME = "test130AddAccountWill";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
ShadowType object = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class);
display("Account to add", object);
try {
// WHEN
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
AssertJUnit.fail("addObject succeeded unexpectedly");
} catch (ConfigurationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method initialize.
@Override
public void initialize(ResourceSchema resourceSchema, Collection<Object> capabilities, boolean caseIgnoreAttributeNames, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException {
// Result type for this operation
OperationResult result = parentResult.createSubresult(ConnectorInstance.OPERATION_INITIALIZE);
result.addContext("connector", connectorType);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ConnectorFactoryConnIdImpl.class);
if (connIdConnectorFacade == null) {
result.recordFatalError("Attempt to use unconfigured connector");
throw new IllegalStateException("Attempt to use unconfigured connector " + ObjectTypeUtil.toShortString(connectorType));
}
setResourceSchema(resourceSchema);
this.capabilities = capabilities;
this.caseIgnoreAttributeNames = caseIgnoreAttributeNames;
if (resourceSchema != null && legacySchema == null) {
legacySchema = detectLegacySchema(resourceSchema);
}
if (resourceSchema == null || capabilities == null) {
try {
boolean supportsSchema = processOperationCapabilities(result);
if (supportsSchema) {
retrieveResourceSchema(null, result);
}
} catch (CommunicationException ex) {
// This is in fact fatal. There is not schema. Not even the pre-cached one.
// The connector will not be able to work.
result.recordFatalError(ex);
throw ex;
} catch (ConfigurationException ex) {
result.recordFatalError(ex);
throw ex;
} catch (GenericFrameworkException ex) {
result.recordFatalError(ex);
throw ex;
}
}
result.recordSuccess();
}
Aggregations