camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1234247 - in /camel/branches/camel-2.9.x: ./ components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
Date Sat, 21 Jan 2012 02:42:36 GMT
Author: hadrian
Date: Sat Jan 21 02:42:35 2012
New Revision: 1234247

URL: http://svn.apache.org/viewvc?rev=1234247&view=rev
Log:
Merged revisions 1234099 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1234099 | bvahdat | 2012-01-20 14:50:55 -0500 (Fri, 20 Jan 2012) | 1 line
  
  Polished
........

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java?rev=1234247&r1=1234246&r2=1234247&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
Sat Jan 21 02:42:35 2012
@@ -31,12 +31,12 @@ import org.jclouds.compute.domain.NodeSt
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.compute.domain.internal.NodeMetadataImpl;
 import org.jclouds.compute.options.RunScriptOptions;
-import org.jclouds.domain.Credentials;
+import org.jclouds.domain.LoginCredentials;
 
 
 public class JcloudsComputeProducer extends JcloudsProducer {
 
-    private ComputeService computeService;
+    private final ComputeService computeService;
 
     public JcloudsComputeProducer(JcloudsEndpoint endpoint, ComputeService computeService)
{
         super(endpoint);
@@ -44,6 +44,11 @@ public class JcloudsComputeProducer exte
     }
 
     @Override
+    public JcloudsComputeEndpoint getEndpoint() {
+        return (JcloudsComputeEndpoint)super.getEndpoint();
+    }
+
+    @Override
     public void process(Exchange exchange) throws Exception {
         String operation = getOperation(exchange);
 
@@ -53,23 +58,16 @@ public class JcloudsComputeProducer exte
 
         if (JcloudsConstants.LIST_NODES.equals(operation)) {
             listNodes(exchange);
-
         } else if (JcloudsConstants.LIST_IMAGES.equals(operation)) {
             listImages(exchange);
-
         } else if (JcloudsConstants.LIST_HARDWARE.equals(operation)) {
             listHardware(exchange);
-
         } else if (JcloudsConstants.RUN_SCRIPT.equals(operation)) {
             runScriptOnNode(exchange);
-
         } else if (JcloudsConstants.CREATE_NODE.equals(operation)) {
             createNode(exchange);
-
         } else if (JcloudsConstants.DESTROY_NODE.equals(operation)) {
             destroyNode(exchange);
-        } else {
-
         }
     }
 
@@ -121,17 +119,17 @@ public class JcloudsComputeProducer exte
         String nodeId = getNodeId(exchange);
         String user = getUser(exchange);
 
-        Credentials credentials = null;
+        LoginCredentials credentials = null;
 
         if (user != null) {
-            credentials = new Credentials(user, null);
+            credentials = LoginCredentials.builder().user(user).build();
         }
         ExecResponse execResponse = null;
 
         if (credentials == null) {
             execResponse = computeService.runScriptOnNode(nodeId, script);
         } else {
-            execResponse = computeService.runScriptOnNode(nodeId, script, RunScriptOptions.Builder.overrideCredentialsWith(credentials).runAsRoot(false));
+            execResponse = computeService.runScriptOnNode(nodeId, script, RunScriptOptions.Builder.overrideLoginCredentials(credentials).runAsRoot(false));
         }
 
         if (execResponse == null) {
@@ -140,9 +138,7 @@ public class JcloudsComputeProducer exte
 
         exchange.setProperty(JcloudsConstants.RUN_SCRIPT_ERROR, execResponse.getError());
         exchange.setProperty(JcloudsConstants.RUN_SCRIPT_EXIT_CODE, execResponse.getExitCode());
-        if (execResponse != null) {
-            exchange.getOut().setBody(execResponse.getOutput());
-        }
+        exchange.getOut().setBody(execResponse.getOutput());
     }
 
     /**
@@ -264,7 +260,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     public String getOperation(Exchange exchange) {
-        String operation = ((JcloudsComputeEndpoint) getEndpoint()).getOperation();
+        String operation = getEndpoint().getOperation();
 
         if (exchange.getIn().getHeader(JcloudsConstants.OPERATION) != null) {
             operation = (String) exchange.getIn().getHeader(JcloudsConstants.OPERATION);
@@ -280,7 +276,7 @@ public class JcloudsComputeProducer exte
      */
     public NodeState getNodeState(Exchange exchange) {
         NodeState nodeState = null;
-        String state = ((JcloudsComputeEndpoint) getEndpoint()).getNodeState();
+        String state = getEndpoint().getNodeState();
         if (state != null) {
             nodeState = NodeState.valueOf(state);
         }
@@ -306,7 +302,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getImageId(Exchange exchange) {
-        String imageId = ((JcloudsComputeEndpoint) getEndpoint()).getImageId();
+        String imageId = getEndpoint().getImageId();
 
         if (exchange.getIn().getHeader(JcloudsConstants.IMAGE_ID) != null) {
             imageId = (String) exchange.getIn().getHeader(JcloudsConstants.IMAGE_ID);
@@ -321,7 +317,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getHardwareId(Exchange exchange) {
-        String hardwareId = ((JcloudsComputeEndpoint) getEndpoint()).getHardwareId();
+        String hardwareId = getEndpoint().getHardwareId();
 
         if (exchange.getIn().getHeader(JcloudsConstants.HARDWARE_ID) != null) {
             hardwareId = (String) exchange.getIn().getHeader(JcloudsConstants.HARDWARE_ID);
@@ -336,7 +332,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getLocationId(Exchange exchange) {
-        String locationId = ((JcloudsComputeEndpoint) getEndpoint()).getLocationId();
+        String locationId = getEndpoint().getLocationId();
 
         if (exchange.getIn().getHeader(JcloudsConstants.LOCATION_ID) != null) {
             locationId = (String) exchange.getIn().getHeader(JcloudsConstants.LOCATION_ID);
@@ -351,7 +347,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getNodeId(Exchange exchange) {
-        String nodeId = ((JcloudsComputeEndpoint) getEndpoint()).getNodeId();
+        String nodeId = getEndpoint().getNodeId();
 
         if (exchange.getIn().getHeader(JcloudsConstants.NODE_ID) != null) {
             nodeId = (String) exchange.getIn().getHeader(JcloudsConstants.NODE_ID);
@@ -366,7 +362,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getGroup(Exchange exchange) {
-        String group = ((JcloudsComputeEndpoint) getEndpoint()).getGroup();
+        String group = getEndpoint().getGroup();
 
         if (exchange.getIn().getHeader(JcloudsConstants.GROUP) != null) {
             group = (String) exchange.getIn().getHeader(JcloudsConstants.GROUP);
@@ -381,7 +377,7 @@ public class JcloudsComputeProducer exte
      * @return
      */
     protected String getUser(Exchange exchange) {
-        String user = ((JcloudsComputeEndpoint) getEndpoint()).getUser();
+        String user = getEndpoint().getUser();
 
         if (exchange.getIn().getHeader(JcloudsConstants.USER) != null) {
             user = (String) exchange.getIn().getHeader(JcloudsConstants.USER);



Mime
View raw message