Bug 422047 - Add Cloud Foundry integration to Orion (cf info)
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
index bc68174..5211ceb 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
@@ -68,14 +68,14 @@
 			if (args.url) {

 				return cFService.setTarget(args.url).then(function(result) {

 					if (result) {

-						return "target: " + result.target;

+						return "target: " + result.Url;

 					} else {

 						return "Target not set";

 					}

 				});

 			} else {

 				return cFService.getTarget().then(function(result) {

-					return "target: " + result.target;

+					return "target: " + result.Url;

 				});

 			}

 		}

@@ -104,6 +104,31 @@
 			}]

 		}

 	);

+	

+	/** Add cf info command **/

+	var infoImpl = {

+		callback: function(args) {

+			return cFService.getInfo().then(function(result) {

+				var value = result.description + 

+					"\nversion: " + result.version +

+					"\nsupport: " + result.support;

+				

+				if (result.user) {

+					value += "\n\nuser: " + result.user;

+				}

+				

+				return value;

+			});

+		}

+	};

+	

+	provider.registerServiceProvider(

+		"orion.shell.command",

+		infoImpl, {

+			name: "cfo info",

+			description: "Display information on the current target, user, etc."

+		}

+	);

 

 	provider.connect();

 });
\ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
index 8492c98..cf20436 100644
--- a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
+++ b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
@@ -81,15 +81,17 @@
 				return clientDeferred;

 			},

 		

-			getTarget: function(targetName) {

-				var targetLocation = require.toUrl("cfapi/Target");

-				return this._xhrV1("GET", targetLocation + (targetName ? "/" + targetName : ""));

+			getTarget: function() {

+				return this._xhrV1("GET", require.toUrl("cfapi/Target"));

 			},

 			

-//			setTarget: function(url, token) {

-//				var self = this;

-//				return self._xhr("POST", require.toUrl("cf/target"), {URL: url, 'token': token}, 240000);

-//			}

+			setTarget: function(url) {

+				return this._xhrV1("POST", require.toUrl("cfapi/Target"), {Url: url});

+			},

+

+			getInfo: function() {

+				return this._xhrV1("GET", require.toUrl("cfapi/Info"));

+			}

 		};

 		

 		return CFService;