You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2015/05/01 10:31:30 UTC
[1/3] camel git commit: CAMEL-8726 Camel-Openshift: Add multiple
environment variables to application
Repository: camel
Updated Branches:
refs/heads/master 4fac6a0bc -> c8c60933e
CAMEL-8726 Camel-Openshift: Add multiple environment variables to application
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/35827b46
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35827b46
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35827b46
Branch: refs/heads/master
Commit: 35827b4601b404b12b64d985bbd7ce76360da171
Parents: 4fac6a0
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri May 1 10:15:47 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri May 1 10:25:34 2015 +0200
----------------------------------------------------------------------
.../component/openshift/OpenShiftConstants.java | 1 +
.../component/openshift/OpenShiftOperation.java | 1 +
.../component/openshift/OpenShiftProducer.java | 26 +++++++++
...hiftAddMultipleEnvironmentVariablesTest.java | 60 ++++++++++++++++++++
4 files changed, 88 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/35827b46/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java
index e390fe0..049e113 100644
--- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java
+++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java
@@ -27,6 +27,7 @@ public final class OpenShiftConstants {
public static final String DEPLOYMENT_TYPE = "CamelOpenShiftDeploymentType";
public static final String ENVIRONMENT_VARIABLE_NAME = "CamelOpenShiftEnvironmentVariableName";
public static final String ENVIRONMENT_VARIABLE_VALUE = "CamelOpenShiftEnvironmentVariableValue";
+ public static final String ENVIRONMENT_VARIABLE_MAP = "CamelOpenShiftEnvironmentVariableMap";
private OpenShiftConstants() {
}
http://git-wip-us.apache.org/repos/asf/camel/blob/35827b46/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java
index 3295565..c1610ca 100644
--- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java
+++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java
@@ -34,6 +34,7 @@ public enum OpenShiftOperation {
setDeploymentType,
getAllEnvironmentVariables,
addEnvironmentVariable,
+ addMultipleEnvironmentVariables,
updateEnvironmentVariable,
getEnvironmentVariableValue,
removeEnvironmentVariable,
http://git-wip-us.apache.org/repos/asf/camel/blob/35827b46/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
index cb52efc..23026c7 100644
--- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
+++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
@@ -107,6 +107,9 @@ public class OpenShiftProducer extends DefaultProducer {
case addEnvironmentVariable:
doAddEnvironmentVariable(exchange, domain);
break;
+ case addMultipleEnvironmentVariables:
+ doAddMultipleEnvironmentVariables(exchange, domain);
+ break;
case updateEnvironmentVariable:
doUpdateEnvironmentVariable(exchange, domain);
break;
@@ -459,6 +462,29 @@ public class OpenShiftProducer extends DefaultProducer {
}
}
+ protected void doAddMultipleEnvironmentVariables(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 environmentVariables = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_MAP, getEndpoint().getApplication(), Map.class);
+ if (!app.canUpdateEnvironmentVariables()) {
+ throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange);
+ }
+ if ((!ObjectHelper.isEmpty(environmentVariables) && environmentVariables != null)) {
+ Map<String, IEnvironmentVariable> result = app.addEnvironmentVariables(environmentVariables);
+ exchange.getIn().setBody(result);
+ } else {
+ throw new CamelExchangeException("Environment variables not correctly specified", exchange);
+ }
+ }
+ }
+
protected void doUpdateEnvironmentVariable(Exchange exchange, IDomain domain) throws CamelExchangeException {
String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class);
if (name == null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/35827b46/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddMultipleEnvironmentVariablesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddMultipleEnvironmentVariablesTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddMultipleEnvironmentVariablesTest.java
new file mode 100644
index 0000000..51f4388
--- /dev/null
+++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddMultipleEnvironmentVariablesTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openshift;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class OpenShiftAddMultipleEnvironmentVariablesTest extends CamelTestSupport {
+
+ private String username;
+ private String password;
+
+ @Override
+ public void setUp() throws Exception {
+ // INSERT credentials here
+ username = null;
+ password = null;
+ super.setUp();
+ }
+
+ @Test
+ public void testAddEnvironmentVariable() throws Exception {
+ if (username == null) {
+ return;
+ }
+
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .toF("openshift:myApp?operation=addMultipleEnvironmentVariables&mode=json&username=%s&password=%s", username, password)
+ .to("mock:result");
+ }
+ };
+ }
+}
[2/3] camel git commit: Fixed CS related to CAMEL-8726
Posted by ac...@apache.org.
Fixed CS related to CAMEL-8726
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/25ec134d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/25ec134d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/25ec134d
Branch: refs/heads/master
Commit: 25ec134d2521992d7edc55ec5c2edea1b76bd56b
Parents: 35827b4
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri May 1 10:27:08 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri May 1 10:27:08 2015 +0200
----------------------------------------------------------------------
.../org/apache/camel/component/openshift/OpenShiftProducer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/25ec134d/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
index 23026c7..1e01c4e 100644
--- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
+++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java
@@ -476,7 +476,7 @@ public class OpenShiftProducer extends DefaultProducer {
if (!app.canUpdateEnvironmentVariables()) {
throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange);
}
- if ((!ObjectHelper.isEmpty(environmentVariables) && environmentVariables != null)) {
+ if (!ObjectHelper.isEmpty(environmentVariables) && environmentVariables != null) {
Map<String, IEnvironmentVariable> result = app.addEnvironmentVariables(environmentVariables);
exchange.getIn().setBody(result);
} else {
[3/3] camel git commit: Camel-Openshift components docs
Posted by ac...@apache.org.
Camel-Openshift components docs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c8c60933
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c8c60933
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c8c60933
Branch: refs/heads/master
Commit: c8c60933e6f483ec74f66c785f431421fe8c165a
Parents: 25ec134
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri May 1 10:30:33 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri May 1 10:30:33 2015 +0200
----------------------------------------------------------------------
.../org/apache/camel/component/openshift/OpenShiftEndpoint.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c8c60933/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftEndpoint.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftEndpoint.java
index ad2be5c..6cfb4fa 100644
--- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftEndpoint.java
+++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftEndpoint.java
@@ -44,8 +44,8 @@ public class OpenShiftEndpoint extends ScheduledPollEndpoint {
@UriParam
private String server;
@UriParam(label = "producer", enums = "list,start,stop,restart,state,getStandaloneCartridge,getEmbeddedCartridges,addEmbeddedCartridge,removeEmbeddedCartridge,"
- + "scaleUp,scaleDown,getGitUrl,getDeploymentType,setDeploymentType,getAllEnvironmentVariables,addEnvironmentVariable,updateEnvironmentVariable,"
- + "getEnvironmentVariableValue,removeEnvironmentVariable,getGearProfile")
+ + "scaleUp,scaleDown,getGitUrl,getDeploymentType,setDeploymentType,getAllEnvironmentVariables,addEnvironmentVariable,addMultipleEnvironmentVariables,"
+ + "updateEnvironmentVariable,getEnvironmentVariableValue,removeEnvironmentVariable,getGearProfile")
private String operation;
@UriParam(label = "producer")
private String application;