use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method listConnectors.
/**
* Returns a list XML representation of the ICF connectors.
*
* @throws CommunicationException
*/
@Override
public Set<ConnectorType> listConnectors(ConnectorHostType host, OperationResult parentRestul) throws CommunicationException {
OperationResult result = parentRestul.createSubresult(ConnectorFactory.OPERATION_LIST_CONNECTOR);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ConnectorFactoryConnIdImpl.class);
result.addParam("host", host);
try {
if (host == null) {
Set<ConnectorType> connectors = listLocalConnectors();
result.recordSuccess();
return connectors;
} else {
// This is necessary as list of the remote connectors is cached locally.
// So if any remote connector is added then it will not be discovered unless we
// clear the cache. This may look like inefficiency but in fact the listConnectors() method is
// used only when discovering new connectors. Normal connector operation is using connector objects
// stored in repository.
connectorInfoManagerFactory.clearRemoteCache();
Set<ConnectorType> connectors = listRemoteConnectors(host);
result.recordSuccess();
return connectors;
}
} catch (Throwable icfException) {
Throwable ex = processIcfException(icfException, "list connectors", result);
result.recordFatalError(ex.getMessage(), ex);
if (ex instanceof CommunicationException) {
throw (CommunicationException) ex;
} else if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
} else if (ex instanceof Error) {
throw (Error) ex;
} else {
throw new SystemException("Unexpected ICF exception: " + ex.getMessage(), ex);
}
}
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method scanDirectory.
/**
* Scan directory for bundles only on first lval we do the scan
*
* @param path
* @return
*/
private Set<URL> scanDirectory(String path) {
// Prepare return object
Set<URL> bundle = new HashSet<URL>();
// COnvert path to object File
File dir = new File(path);
// Test if this path is single jar or need to do deep examination
if (isThisJarFileBundle(dir)) {
try {
if (isThisBundleCompatible(dir.toURI().toURL())) {
bundle.add(dir.toURI().toURL());
} else {
LOGGER.warn("Skip loading budle {} due error occured", dir.toURI().toURL());
}
} catch (MalformedURLException e) {
LOGGER.error("This never happend we hope.", e);
throw new SystemException(e);
}
return bundle;
}
// Test if it is a directory
if (!dir.isDirectory()) {
LOGGER.error("Provided Icf connector path {} is not a directory.", dir.getAbsolutePath());
}
// List directory items
File[] dirEntries = dir.listFiles();
if (null == dirEntries) {
LOGGER.warn("No bundles found in directory {}", dir.getAbsolutePath());
return bundle;
}
// test all entires for bundle
for (int i = 0; i < dirEntries.length; i++) {
if (isThisJarFileBundle(dirEntries[i])) {
try {
if (isThisBundleCompatible(dirEntries[i].toURI().toURL())) {
bundle.add(dirEntries[i].toURI().toURL());
} else {
LOGGER.warn("Skip loading budle {} due error occured", dirEntries[i].toURI().toURL());
}
} catch (MalformedURLException e) {
LOGGER.error("This never happend we hope.", e);
throw new SystemException(e);
}
}
}
return bundle;
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method getRemoteConnectorInfoManager.
/**
* Returns ICF connector info manager that manages local connectors. The
* manager will be created if it does not exist yet.
*
* @return ICF connector info manager that manages local connectors
*/
private ConnectorInfoManager getRemoteConnectorInfoManager(ConnectorHostType hostType) {
String hostname = hostType.getHostname();
int port = Integer.parseInt(hostType.getPort());
GuardedString key;
try {
key = new GuardedString(protector.decryptString(hostType.getSharedSecret()).toCharArray());
} catch (EncryptionException e) {
throw new SystemException("Shared secret decryption error: " + e.getMessage(), e);
}
Integer timeout = hostType.getTimeout();
if (timeout == null) {
timeout = 0;
}
boolean useSSL = false;
if (hostType.isProtectConnection() != null) {
useSSL = hostType.isProtectConnection();
}
List<TrustManager> trustManagers = protector.getTrustManagers();
LOGGER.trace("Creating RemoteFrameworkConnectionInfo: hostname={}, port={}, key={}, useSSL={}, trustManagers={}, timeout={}", new Object[] { hostname, port, key, useSSL, trustManagers, timeout });
RemoteFrameworkConnectionInfo remoteFramewrorkInfo = new RemoteFrameworkConnectionInfo(hostname, port, key, useSSL, trustManagers, timeout);
return connectorInfoManagerFactory.getRemoteManager(remoteFramewrorkInfo);
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class TestOpenDj method test701ConfiguredCapabilityNoRead.
@Test
public void test701ConfiguredCapabilityNoRead() throws Exception {
final String TEST_NAME = "test701ConfiguredCapabilityNoRead";
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
addResourceFromFile(new File(TEST_DIR, "resource-opendj-no-read.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result);
try {
provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
AssertJUnit.fail("Expected unsupported operation exception, but haven't got one.");
} catch (SystemException ex) {
// this is expected..
}
}
use of com.evolveum.midpoint.util.exception.SystemException 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