Search in sources :

Example 36 with CamelExchangeException

use of org.apache.camel.CamelExchangeException in project camel by apache.

the class OpenShiftProducer method doRestart.

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

Example 37 with CamelExchangeException

use of org.apache.camel.CamelExchangeException 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 38 with CamelExchangeException

use of org.apache.camel.CamelExchangeException 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 39 with CamelExchangeException

use of org.apache.camel.CamelExchangeException 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 40 with CamelExchangeException

use of org.apache.camel.CamelExchangeException 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)

Aggregations

CamelExchangeException (org.apache.camel.CamelExchangeException)82 IApplication (com.openshift.client.IApplication)23 Exchange (org.apache.camel.Exchange)17 IOException (java.io.IOException)10 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)8 IEnvironmentVariable (com.openshift.client.IEnvironmentVariable)5 InputStream (java.io.InputStream)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 AsyncCallback (org.apache.camel.AsyncCallback)5 CamelExecutionException (org.apache.camel.CamelExecutionException)5 Message (org.apache.camel.Message)5 File (java.io.File)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Processor (org.apache.camel.Processor)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 IEmbeddedCartridge (com.openshift.client.cartridge.IEmbeddedCartridge)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Serializable (java.io.Serializable)3 URI (java.net.URI)3 List (java.util.List)3