Search in sources :

Example 11 with IApplication

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);
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication)

Example 12 with IApplication

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);
        }
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication)

Example 13 with IApplication

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);
        }
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication)

Example 14 with IApplication

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());
    }
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) IApplication(com.openshift.client.IApplication) IGearProfile(com.openshift.client.IGearProfile)

Example 15 with IApplication

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);
        }
    }
}
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)25 CamelExchangeException (org.apache.camel.CamelExchangeException)23 IEnvironmentVariable (com.openshift.client.IEnvironmentVariable)5 IEmbeddedCartridge (com.openshift.client.cartridge.IEmbeddedCartridge)4 ApplicationScale (com.openshift.client.ApplicationScale)2 LatestEmbeddableCartridge (com.openshift.client.cartridge.query.LatestEmbeddableCartridge)2 IGear (com.openshift.client.IGear)1 IGearGroup (com.openshift.client.IGearGroup)1 IGearProfile (com.openshift.client.IGearProfile)1 OpenShiftException (com.openshift.client.OpenShiftException)1 IDeployedStandaloneCartridge (com.openshift.client.cartridge.IDeployedStandaloneCartridge)1 IEmbeddableCartridge (com.openshift.client.cartridge.IEmbeddableCartridge)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Endpoint (org.apache.camel.Endpoint)1 Exchange (org.apache.camel.Exchange)1