Search in sources :

Example 21 with IApplication

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

Example 22 with IApplication

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

Example 23 with IApplication

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

Example 24 with IApplication

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

Example 25 with IApplication

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

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