use of com.openshift.client.cartridge.query.LatestEmbeddableCartridge 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);
}
}
}
use of com.openshift.client.cartridge.query.LatestEmbeddableCartridge 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);
}
}
}
Aggregations