use of com.openshift.client.IApplication 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();
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetAliases.
protected void doGetAliases(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 {
List<String> aliases = app.getAliases();
exchange.getIn().setBody(aliases);
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doState.
protected void doState(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 state = OpenShiftHelper.getStateForApplication(app);
exchange.getIn().setBody(state);
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doUpdateEnvironmentVariable.
protected void doUpdateEnvironmentVariable(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 variableName = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_NAME, getEndpoint().getApplication(), String.class);
String variableValue = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_VALUE, getEndpoint().getApplication(), String.class);
if (!app.canUpdateEnvironmentVariables()) {
throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange);
}
if (ObjectHelper.isNotEmpty(variableName) && ObjectHelper.isNotEmpty(variableValue)) {
IEnvironmentVariable result = app.updateEnvironmentVariable(variableName, variableValue);
exchange.getIn().setBody(result.getName());
} else {
throw new CamelExchangeException("Environment variable not correctly specified", exchange);
}
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetAllEnvironmentVariables.
protected void doGetAllEnvironmentVariables(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 {
Map<String, IEnvironmentVariable> result = app.getEnvironmentVariables();
exchange.getIn().setBody(result);
}
}
Aggregations