api.setTdr(new TdrData());
}
}
protected void deployApi(Api api, ExchangeData exchange) throws RollbackException, ProvisionException {
ApiJar oldApiJar = null;
try {
oldApiJar = dataManager.getApiJar(api.getId());
byte[] apiNewJarBytes = apiBuilder.build(api, exchange);
if (apiNewJarBytes != null) {
deploymentManager.deployApi(exchange, apiNewJarBytes);
} else {
LOG.error("No Jar data created for for Api ID: " + api.getId());
}
} catch (DeploymentException e) {
LOG.error("Deployment failed for Api ID: " + api.getId(), e);
deploymentManager.undeployApi(exchange, api.getId());
// Roll back old API
if (oldApiJar != null) {
try {
// Deploy N-1 jar
deploymentManager.deployApi(exchange, oldApiJar.getData());
// throw this status for error mgmt
throw new RollbackException(ApplicationCodeConstants.ROUTE_CREATION_FAILED_ROLLBACK_OK, "Route edition failed, rollback ok.");
} catch (DeploymentException e1) {
throw new RollbackException(ApplicationCodeConstants.ROLLBACK_FAILED, "Second try deployment, give up", e1);