use of org.apache.camel.CamelExchangeException in project camel by apache.
the class OpenShiftProducer method doScaleUp.
protected void doScaleUp(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
try {
app.scaleUp();
ApplicationScale result = app.getApplicationScale();
exchange.getIn().setBody(result.getValue());
} catch (OpenShiftException e) {
throw new CamelExchangeException("Application with id " + name + " is not scalable", exchange);
}
}
}
use of org.apache.camel.CamelExchangeException in project camel by apache.
the class OpenShiftProducer method doAddAlias.
protected void doAddAlias(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
String alias = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION_ALIAS, getEndpoint().getApplication(), String.class);
if (!app.canGetEnvironmentVariables()) {
throw new CamelExchangeException("The application with id " + name + " can't get Environment Variables", exchange);
}
if (ObjectHelper.isNotEmpty(alias)) {
app.addAlias(alias);
exchange.getIn().setBody(alias);
} else {
throw new CamelExchangeException("Application Alias name not specified", exchange);
}
}
}
use of org.apache.camel.CamelExchangeException in project camel by apache.
the class OpenShiftProducer method doAddEmbeddedCartridge.
protected void doAddEmbeddedCartridge(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
String embeddedCartridgeName = exchange.getIn().getHeader(OpenShiftConstants.EMBEDDED_CARTRIDGE_NAME, getEndpoint().getApplication(), String.class);
if (ObjectHelper.isNotEmpty(embeddedCartridgeName)) {
IEmbeddedCartridge p = app.addEmbeddableCartridge((new LatestEmbeddableCartridge(embeddedCartridgeName)).get(app));
exchange.getIn().setBody(p.getDisplayName());
} else {
throw new CamelExchangeException("Cartridge not specified", exchange);
}
}
}
use of org.apache.camel.CamelExchangeException in project camel by apache.
the class OpenShiftProducer method process.
@Override
public void process(Exchange exchange) throws Exception {
String openshiftServer = OpenShiftHelper.getOpenShiftServer(getEndpoint());
IDomain domain = OpenShiftHelper.loginAndGetDomain(getEndpoint(), openshiftServer);
if (domain == null) {
throw new CamelExchangeException("User has no domain with id " + getEndpoint().getDomain(), exchange);
}
OpenShiftOperation operation = exchange.getIn().getHeader(OpenShiftConstants.OPERATION, getEndpoint().getOperation(), OpenShiftOperation.class);
switch(operation) {
case start:
doStart(exchange, domain);
break;
case stop:
doStop(exchange, domain);
break;
case restart:
doRestart(exchange, domain);
break;
case state:
doState(exchange, domain);
break;
case getStandaloneCartridge:
doGetStandaloneCartridge(exchange, domain);
break;
case getEmbeddedCartridges:
doGetEmbeddedCartridges(exchange, domain);
break;
case getGitUrl:
doGetGitUrl(exchange, domain);
break;
case addEmbeddedCartridge:
doAddEmbeddedCartridge(exchange, domain);
break;
case removeEmbeddedCartridge:
doRemoveEmbeddedCartridge(exchange, domain);
break;
case scaleUp:
doScaleUp(exchange, domain);
break;
case scaleDown:
doScaleDown(exchange, domain);
break;
case getDeploymentType:
doGetDeploymentType(exchange, domain);
break;
case setDeploymentType:
doSetDeploymentType(exchange, domain);
break;
case addEnvironmentVariable:
doAddEnvironmentVariable(exchange, domain);
break;
case addMultipleEnvironmentVariables:
doAddMultipleEnvironmentVariables(exchange, domain);
break;
case updateEnvironmentVariable:
doUpdateEnvironmentVariable(exchange, domain);
break;
case getAllEnvironmentVariables:
doGetAllEnvironmentVariables(exchange, domain);
break;
case getEnvironmentVariableValue:
doGetEnvironmentVariableValue(exchange, domain);
break;
case removeEnvironmentVariable:
doRemoveEnvironmentVariable(exchange, domain);
break;
case getGearProfile:
doGetGearProfile(exchange, domain);
break;
case addAlias:
doAddAlias(exchange, domain);
break;
case removeAlias:
doRemoveAlias(exchange, domain);
break;
case getAliases:
doGetAliases(exchange, domain);
break;
case list:
default:
// and do list by default
if (getEndpoint().getMode().equals("json")) {
doListJson(exchange, domain);
} else {
doListPojo(exchange, domain);
}
break;
}
}
use of org.apache.camel.CamelExchangeException in project camel by apache.
the class OpenShiftProducer method doStop.
protected void doStop(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
throw new CamelExchangeException("Application not specified", exchange);
}
IApplication app = domain.getApplicationByName(name);
if (app == null) {
throw new CamelExchangeException("Application with id " + name + " not found.", exchange);
} else {
app.stop();
}
}
Aggregations