}
protected boolean bindServiceToCaldecottApp(String serviceName, CloudFoundryOperations client, SubMonitor monitor)
throws CoreException {
CloudApplication caldecottApp = getCaldecottApp(client);
List<String> updateCaldecottServices = new ArrayList<String>();
List<String> existingServices = caldecottApp.getServices();
if (existingServices != null) {
// Must iterate to filter out possible null service names
for (String existing : existingServices) {
if (existing != null) {
updateCaldecottServices.add(existing);
}
}
}
IModule caldecottModule = getCaldecottModule(monitor.newChild(1));
if (!updateCaldecottServices.contains(serviceName)) {
monitor.setTaskName("Binding service " + serviceName + " to tunnel application"); //$NON-NLS-1$ //$NON-NLS-2$
updateCaldecottServices.add(serviceName);
CloudFoundryServerBehaviour behaviour = cloudServer.getBehaviour();
behaviour.stopModule(new IModule[] { caldecottModule }, monitor.newChild(1));
behaviour.updateServices(TunnelHelper.getTunnelAppName(), updateCaldecottServices, monitor.newChild(1));
setDeploymentServices(serviceName, monitor.newChild(1));
return caldecottApp.getServices().contains(serviceName);
}
else {
return true;
}