* which are not included in {@code connectors} if and only if
* {@code noremove} is {@code false}.
*/
static final void setConnectors(ImportExportConnectorList connectors,
boolean noRemove) {
Instantiator instantiator = Context.getInstance().getInstantiator();
Set<String> previousConnectorNames =
new HashSet<String>(instantiator.getConnectorNames());
for (ImportExportConnector connector : connectors) {
String name = connector.getName();
try {
// Store the Configuration.
boolean update = previousConnectorNames.contains(name);
Configuration configuration = connector.getConfiguration();
ConfigureResponse configureResponse =
instantiator.setConnectorConfiguration(name, configuration,
Locale.ENGLISH, update);
if (configureResponse != null) {
LOGGER.warning("setConnectorConfiguration(name=" + name + "\"): "
+ configureResponse.getMessage());
continue;
}
// Store the Schedule.
instantiator.setConnectorSchedule(name, connector.getSchedule());
previousConnectorNames.remove(name);
} catch (ConnectorNotFoundException e) {
// This shouldn't happen.
LOGGER.warning("Connector " + name + " not found!");
} catch (ConnectorExistsException e) {
// This shouldn't happen.
LOGGER.warning("Connector " + name + " already exists!");
} catch (ConnectorTypeNotFoundException e) {
LOGGER.warning("Connector Type " + connector.getTypeName()
+ " not found!");
} catch (InstantiatorException e) {
LOGGER.log(Level.WARNING, "Failed to create connector " + name + ": ",
e);
}
}
// Remove previous connectors which no longer exist.
if (!noRemove) {
for (String name : previousConnectorNames) {
try {
instantiator.removeConnector(name);
} catch (InstantiatorException e) {
LOGGER.log(Level.WARNING, "Failed to remove connector " + name + ": ",
e);
}
}