//read the password, without echoing the output
if (vcap_passwd == null) {
vcap_passwd = new String(console.readPassword("Password? "));
}
CloudFoundryClient client = clientInit();
String version = client.getCloudInfo().getVersion();
if (Float.valueOf(version) >= 2.0) {
//read org, using java.util.Formatter syntax :
if (vcap_org == null) {
vcap_org = console.readLine("Org to use? ");
}
//read space, using java.util.Formatter syntax :
if (vcap_space == null) {
vcap_space = console.readLine("Space to use? ");
}
client = clientOrgSpace(client);
}
CloudApplication serverApp = null;
try {
serverApp = client.getApplication(TunnelHelper.getTunnelAppName());
}
catch (CloudFoundryException e) {}
if (serverApp == null) {
System.out.println("Deploying Caldecott server app");
TunnelHelper.deployTunnelApp(client);
}
try {
serverApp = client.getApplication(TunnelHelper.getTunnelAppName());
}
catch (CloudFoundryException e) {
System.err.println("Unable to deploy Caldecott server app: " + e.getMessage());
throw e;
}
if (!serverApp.getState().equals(CloudApplication.AppState.STARTED)) {
System.out.println("Starting Caldecott server app");
client.startApplication(serverApp.getName());
}
while (vcap_service == null) {
System.out.println("You have the following services defined:");
List<CloudService> services = client.getServices();
int i = 0;
for (CloudService svc : services) {
i++;
System.out.println(i + ": " + svc.getName());
}