use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class ConnIdConfigurationTransformer method transformConnectorConfigurationProperties.
private void transformConnectorConfigurationProperties(ConfigurationProperties configProps, PrismContainer<?> configurationPropertiesContainer, String connectorConfNs) throws ConfigurationException, SchemaException {
if (configurationPropertiesContainer == null || configurationPropertiesContainer.getValue() == null) {
throw new SchemaException("No configuration properties container in " + connectorType);
}
int numConfingProperties = 0;
List<QName> wrongNamespaceProperties = new ArrayList<>();
for (PrismProperty prismProperty : configurationPropertiesContainer.getValue().getProperties()) {
QName propertyQName = prismProperty.getElementName();
// namespace.
if (propertyQName.getNamespaceURI() == null || !propertyQName.getNamespaceURI().equals(connectorConfNs)) {
LOGGER.warn("Found element with a wrong namespace ({}) in {}", propertyQName.getNamespaceURI(), connectorType);
wrongNamespaceProperties.add(propertyQName);
} else {
numConfingProperties++;
// Local name of the element is the same as the name
// of ConnId configuration property
String propertyName = propertyQName.getLocalPart();
ConfigurationProperty property = configProps.getProperty(propertyName);
if (property == null) {
throw new ConfigurationException("Unknown configuration property " + propertyName);
}
Class<?> type = property.getType();
if (type.isArray()) {
Object[] connIdArray = convertToConnIdfArray(prismProperty, type.getComponentType());
if (connIdArray != null && connIdArray.length != 0) {
property.setValue(connIdArray);
}
} else {
Object connIdValue = convertToConnIdSingle(prismProperty, type);
if (connIdValue != null) {
property.setValue(connIdValue);
}
}
}
}
// empty configuration is OK e.g. when creating a new resource using wizard
if (numConfingProperties == 0 && !wrongNamespaceProperties.isEmpty()) {
throw new SchemaException("No configuration properties found. Wrong namespace? (expected: " + connectorConfNs + ", present e.g. " + wrongNamespaceProperties.get(0) + ")");
}
}
use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.
the class TestOpenDjNegative method test150ModifyObject.
@Test
public void test150ModifyObject() throws Exception {
final String TEST_NAME = "test150ModifyObject";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext());
display("Object change", delta);
try {
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), 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 TestOpenDjNegative method test120ListResourceObjects.
@Test
public void test120ListResourceObjects() throws Exception {
final String TEST_NAME = "test120ListResourceObjects";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
try {
// WHEN
List<PrismObject<? extends ShadowType>> objectList = provisioningService.listResourceObjects(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, null, null, result);
AssertJUnit.fail("listResourceObjects 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 TestOpenDjNegative method test121SearchAccounts.
@Test
public void test121SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception {
final String TEST_NAME = "test121SearchAccounts";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource);
QName objectClass = new QName(resourceNamespace, OBJECT_CLASS_INETORGPERSON_NAME);
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(resource.getOid(), objectClass, prismContext);
try {
// WHEN
provisioningService.searchObjects(ShadowType.class, query, null, null, result);
AssertJUnit.fail("searchObjectsIterative succeeded unexpectedly");
} catch (ConfigurationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
display(result);
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.util.exception.ConfigurationException 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;
}
Aggregations