final Map<String, String> props) throws Exception {
Runnable registrationTask = new Runnable() {
@Override
public void run() {
try {
Configuration configuration = findOrCreateFactoryConfiguration(configurationAdmin, "org.jclouds.chef", name, api);
if (configuration != null) {
@SuppressWarnings("unchecked")
Dictionary<String, Object> dictionary = configuration.getProperties();
if (dictionary == null) {
dictionary = new Hashtable<String, Object>();
}
String apiValue = ChefHelper.getChefApi(api);
String clientNameValue = ChefHelper.getClientName(clientName);
String clientKeyFileValue = ChefHelper.getClientKeyFile(clientKeyFile);
String validatorNameValue = ChefHelper.getValidatorName(validator);
String validatorKeyFileValue = ChefHelper.getValidatorKeyFile(validatorKeyFile);
String endpointValue = ChefHelper.getChefEndpoint(endpoint);
if (name != null) {
dictionary.put(ChefConstants.NAME, name);
}
if (apiValue != null) {
dictionary.put(ChefConstants.API, apiValue);
}
if (endpointValue != null) {
dictionary.put(ChefConstants.ENDPOINT, endpointValue);
}
if (clientNameValue != null) {
dictionary.put(ChefConstants.CLIENT_NAME, clientNameValue);
}
if (clientKeyFileValue != null) {
dictionary.put(ChefConstants.CLIENT_KEY_FILE, clientKeyFileValue);
}
if (validatorNameValue != null) {
dictionary.put(ChefConstants.VALIDATOR_NAME, validatorNameValue);
}
if (validatorKeyFileValue != null) {
dictionary.put(ChefConstants.VALIDATOR_KEY_FILE, validatorKeyFileValue);
}
for (Map.Entry<String, String> entry : props.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
dictionary.put(key, value);
}
configuration.update(dictionary);
}
} catch (Exception ex) {
// noop
}
}