if (log.isDebugEnabled()) {
log.debug("API update from file : " + fileName + " has started");
}
try {
API api = APIFactory.createAPI(artifactConfig);
if (api == null) {
handleSynapseArtifactDeploymentError("API update failed. The artifact " +
"defined in the file: " + fileName + " is not a valid API.");
return null;
}
api.setFileName(new File(fileName).getName());
if (log.isDebugEnabled()) {
log.debug("API: " + api.getName() + " has been built from the file: " + fileName);
}
api.init(getSynapseEnvironment());
API existingAPI = getSynapseConfiguration().getAPI(existingArtifactName);
if (existingArtifactName.equals(api.getName())) {
getSynapseConfiguration().updateAPI(existingArtifactName, api);
} else {
// The user has changed the name of the API
// We should add the updated API as a new API and remove the old one
getSynapseConfiguration().addAPI(api.getName(), api);
getSynapseConfiguration().removeAPI(existingArtifactName);
log.info("API: " + existingArtifactName + " has been undeployed");
}
log.info("API: " + api.getName() + " has been updated from the file: " + fileName);
waitForCompletion();
existingAPI.destroy();
return api.getName();
} catch (DeploymentException e) {
handleSynapseArtifactDeploymentError("Error while updating the API from the " +
"file: " + fileName);