Search in sources :

Example 1 with IEmbeddableCartridge

use of com.openshift.client.cartridge.IEmbeddableCartridge 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);
        }
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) LatestEmbeddableCartridge(com.openshift.client.cartridge.query.LatestEmbeddableCartridge) IEmbeddedCartridge(com.openshift.client.cartridge.IEmbeddedCartridge) IEmbeddableCartridge(com.openshift.client.cartridge.IEmbeddableCartridge)

Aggregations

IApplication (com.openshift.client.IApplication)1 IEmbeddableCartridge (com.openshift.client.cartridge.IEmbeddableCartridge)1 IEmbeddedCartridge (com.openshift.client.cartridge.IEmbeddedCartridge)1 LatestEmbeddableCartridge (com.openshift.client.cartridge.query.LatestEmbeddableCartridge)1 CamelExchangeException (org.apache.camel.CamelExchangeException)1