log.error("Error while chaining run to call", e);
}
}
public ConfigurationUpdateResponse call() throws Exception {
ConfigurationUpdateResponse response;
int requestId = request.getConfigurationUpdateId();
try {
response = new ConfigurationUpdateResponse(requestId, request.getConfiguration(), SUCCESS, null);
try {
configMgmt.executeUpdate(request.getResourceId(), request.getConfiguration());
} catch (UpdateInProgressException e) {
response.setStatus(INPROGRESS);
response.setErrorMessage("Configuration facet did not indicate success or failure - assuming failure.");
} catch (ConfigurationUpdateException e) {
response.setStatus(FAILURE);
response.setErrorMessage(e.getMessage());
}
ConfigurationDefinition configurationDefinition = resourceType.getResourceConfigurationDefinition();
// Normalize and validate the config.
configUtilService.normalizeConfiguration(response.getConfiguration(), configurationDefinition);
List<String> errorMessages = configUtilService.validateConfiguration(response.getConfiguration(),
configurationDefinition);
for (String errorMessage : errorMessages) {
log.warn("Plugin Error: Invalid " + resourceType.getName() + " Resource configuration returned by "
+ resourceType.getPlugin() + " plugin - " + errorMessage);
}
// If it was successful, there is no need to waste bandwidth and send back the entire configuration again.
// Just set it to null - the remote client will see it was a success and assume the configuration that was
// saved is the same configuration that was passed in via the request.
if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) {
response.setConfiguration(null);
}
} catch (Throwable t) {
log.error("Plugin Error: Exception thrown while updating Resource configuration for "
+ resourceType.getName() + " Resource with id [" + request.getResourceId() + "].", t);
response = new ConfigurationUpdateResponse(requestId, request.getConfiguration(), t);
}
if (this.configurationServerService != null) {
this.configurationServerService.completeConfigurationUpdate(response);
}