use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetGitUrl.
protected void doGetGitUrl(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 gitUrl = app.getGitUrl();
exchange.getIn().setBody(gitUrl);
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doRemoveAlias.
protected void doRemoveAlias(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.removeAlias(alias);
exchange.getIn().setBody(alias);
} else {
throw new CamelExchangeException("Application Alias not specified", exchange);
}
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doSetDeploymentType.
protected void doSetDeploymentType(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 deploymentType = exchange.getIn().getHeader(OpenShiftConstants.DEPLOYMENT_TYPE, getEndpoint().getApplication(), String.class);
if (ObjectHelper.isNotEmpty(deploymentType)) {
String result = app.setDeploymentType(deploymentType);
exchange.getIn().setBody(result);
} else {
throw new CamelExchangeException("Deployment Type not specified", exchange);
}
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doGetGearProfile.
protected void doGetGearProfile(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 {
IGearProfile result = app.getGearProfile();
exchange.getIn().setBody(result.getName());
}
}
use of com.openshift.client.IApplication in project camel by apache.
the class OpenShiftProducer method doRemoveEmbeddedCartridge.
protected void doRemoveEmbeddedCartridge(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)) {
IEmbeddableCartridge removingCartridge = (new LatestEmbeddableCartridge(embeddedCartridgeName)).get(app);
for (IEmbeddedCartridge cartridge : app.getEmbeddedCartridges()) {
if (cartridge.equals(removingCartridge)) {
cartridge.destroy();
exchange.getIn().setBody(cartridge.getDisplayName());
}
}
} else {
throw new CamelExchangeException("Cartridge not specified", exchange);
}
}
}
Aggregations