// get the specified connector.
ConnectorInfo info;
try {
info = connBundleManager.getConnectorManager().findConnectorInfo(key);
if (info == null) {
throw new NotFoundException("Connector Info for key " + key);
}
} catch (MissingConfKeyException e) {
throw new NotFoundException("Connector Info for key " + key, e);
}
// create default configuration
APIConfiguration apiConfig = info.createDefaultAPIConfiguration();
if (apiConfig == null) {
throw new NotFoundException("Default API configuration");
}
// retrieve the ConfigurationProperties.
final ConfigurationProperties properties = apiConfig.getConfigurationProperties();
if (properties == null) {
throw new NotFoundException("Configuration properties");
}
// Print out what the properties are (not necessary)
if (LOG.isDebugEnabled()) {
for (String propName : properties.getPropertyNames()) {
LOG.debug("\nProperty Name: {}\nProperty Type: {}", properties.getProperty(propName).getName(),
properties.getProperty(propName).getType());
}
}
// Set all of the ConfigurationProperties needed by the connector.
for (ConnConfProperty property : connInstance.getConfiguration()) {
final Object propertyValue = getPropertyValue(property);
if (propertyValue != null) {
properties.setPropertyValue(property.getSchema().getName(), propertyValue);
}
}
// Use the ConnectorFacadeFactory's newInstance() method to get
// a new connector.
connector = ConnectorFacadeFactory.getInstance().newInstance(apiConfig);
if (connector == null) {
throw new NotFoundException("Connector");
}
// Make sure we have set up the Configuration properly
connector.validate();
}