Statistics
| Branch: | Revision:

root / src / com / rackspacecloud / android / ViewLoadBalancerActivity.java @ 157f0be5

History | View | Annotate | Download (20 kB)

1
/**
2
 * 
3
 */
4
package com.rackspacecloud.android;
5

    
6
import java.util.ArrayList;
7
import java.util.Collections;
8

    
9
import org.apache.http.HttpResponse;
10

    
11
import android.app.Activity;
12
import android.app.AlertDialog;
13
import android.app.Dialog;
14
import android.content.DialogInterface;
15
import android.content.Intent;
16
import android.graphics.Color;
17
import android.os.AsyncTask;
18
import android.os.Bundle;
19
import android.util.Log;
20
import android.util.TypedValue;
21
import android.view.Menu;
22
import android.view.MenuInflater;
23
import android.view.MenuItem;
24
import android.view.View;
25
import android.view.View.OnClickListener;
26
import android.widget.Button;
27
import android.widget.LinearLayout;
28
import android.widget.TextView;
29

    
30
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer;
31
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancerManager;
32
import com.rackspace.cloud.loadbalancer.api.client.Node;
33
import com.rackspace.cloud.loadbalancer.api.client.VirtualIp;
34
import com.rackspace.cloud.loadbalancer.api.client.http.LoadBalancersException;
35
import com.rackspace.cloud.servers.api.client.CloudServersException;
36
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
37

    
38
public class ViewLoadBalancerActivity extends CloudActivity {
39

    
40
        private static final int EDIT_LOAD_BALANCER_CODE = 184;
41
        private static final int EDIT_NODES_CODE = 185;
42

    
43
        private LoadBalancer loadBalancer;
44
        private PollLoadBalancerTask pollLoadBalancerTask;
45

    
46
        @Override
47
        public void onCreate(Bundle savedInstanceState) {
48
                super.onCreate(savedInstanceState);
49
                loadBalancer = (LoadBalancer) this.getIntent().getExtras().get("loadBalancer");
50
                setContentView(R.layout.view_loadbalancer);
51
                restoreState(savedInstanceState);
52
        }
53

    
54
        @Override
55
        protected void onSaveInstanceState(Bundle outState) {
56
                super.onSaveInstanceState(outState);
57
                outState.putSerializable("loadBalancer", loadBalancer);
58
        }
59

    
60
        protected void restoreState(Bundle state) {
61
                super.restoreState(state);
62

    
63
                if (state != null && state.containsKey("loadBalancer") && state.getSerializable("loadBalancer") != null) {
64
                        loadBalancer = (LoadBalancer) state.getSerializable("loadBalancer");
65
                        loadLoadBalancerData();
66
                        setUpButtons();
67
                }
68
                else{
69
                        new LoadLoadBalancerTask().execute((Void[]) null);
70
                }
71
        }
72

    
73
        @Override
74
        protected void onDestroy(){
75
                super.onDestroy();
76

    
77
                //need to cancel pollLoadBalancerTask so it 
78
                //does not keep polling in a new activity
79
                if(pollLoadBalancerTask != null){
80
                        pollLoadBalancerTask.cancel(true);
81
                }
82
        }
83

    
84
        private void setupButton(int resourceId, OnClickListener onClickListener) {
85
                Button button = (Button) findViewById(resourceId);
86
                button.setOnClickListener(onClickListener);
87
        }
88

    
89
        //change the text on the button depending
90
        //on the state of Connection Logging
91
        private void setLogButtonText(){
92
                Button logs = (Button)findViewById(R.id.connection_log_button);
93
                String loggingEnabled = loadBalancer.getIsConnectionLoggingEnabled();
94
                if(loggingEnabled != null && loggingEnabled.equals("true")){
95
                        logs.setText("Disable Logs");
96
                } else {
97
                        logs.setText("Enable Logs");
98
                }
99
        }
100

    
101
        //change the text on the button depending
102
        //on the state of Session Persistence
103
        private void setSessionButtonText(){
104
                Button sessionPersistence = (Button)findViewById(R.id.session_persistence_button);
105
                //session persistence is null if it is off
106
                if(loadBalancer.getSessionPersistence() != null){
107
                        sessionPersistence.setText("Disable Session Persistence");
108
                } else {
109
                        sessionPersistence.setText("Enable Session Persistence");
110
                }
111
        }
112

    
113
        //if the load balancer state contains DELETE
114
        //then parts of it may be null, so use a different
115
        //onClick in that condition
116
        private void setUpButtons(){
117
                setupButton(R.id.edit_loadbalancer_button, new OnClickListener() {
118
                        @Override
119
                        public void onClick(View v) {
120
                                if(!loadBalancer.getStatus().contains("DELETE")){
121
                                        Intent editLoadBalancerIntent = new Intent(getContext(), EditLoadBalancerActivity.class);
122
                                        editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
123
                                        startActivityForResult(editLoadBalancerIntent, EDIT_LOAD_BALANCER_CODE);
124
                                } else {
125
                                        showAlert(loadBalancer.getStatus(), "The load balancer cannot be updated.");
126
                                }
127
                        }
128
                });
129

    
130

    
131
                setupButton(R.id.delete_loadbalancer_button, new OnClickListener() {
132
                        @Override
133
                        public void onClick(View v) {
134
                                if(!loadBalancer.getStatus().contains("DELETE")){
135
                                        showDialog(R.id.view_server_delete_button);
136
                                } else {
137
                                        showAlert(loadBalancer.getStatus(), "The load balancer cannot be deleted.");
138
                                }
139
                        }
140

    
141
                });
142

    
143
                setupButton(R.id.edit_nodes_button, new OnClickListener() {
144
                        @Override
145
                        public void onClick(View v) {
146
                                if(!loadBalancer.getStatus().contains("DELETE")){
147
                                        Intent editLoadBalancerIntent = new Intent(getContext(), EditNodesActivity.class);
148
                                        editLoadBalancerIntent.putExtra("nodes", loadBalancer.getNodes());
149
                                        editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
150
                                        startActivityForResult(editLoadBalancerIntent, EDIT_NODES_CODE);
151
                                } else {
152
                                        showAlert(loadBalancer.getStatus(), "The nodes cannot be edited.");
153
                                }
154
                        }
155
                });
156

    
157
                setupButton(R.id.connection_log_button, new OnClickListener() {
158
                        @Override
159
                        public void onClick(View v) {
160
                                if(!loadBalancer.getStatus().contains("DELETE")){
161
                                        showDialog(R.id.connection_log_button);        
162
                                } else {
163
                                        showAlert(loadBalancer.getStatus(), "Log settings cannot be edited.");        
164
                                }
165
                        }
166
                });
167
                setLogButtonText();
168

    
169
                setupButton(R.id.session_persistence_button, new OnClickListener() {
170
                        @Override
171
                        public void onClick(View v) {
172
                                if(!loadBalancer.getStatus().contains("DELETE")){
173
                                        if(!loadBalancer.getProtocol().equals("HTTP")){
174
                                                showAlert("Error", "Session Persistence cannot be enabled for protocols other than HTTP.");
175
                                        } else {
176
                                                showDialog(R.id.session_persistence_button);
177
                                        }
178
                                } else {
179
                                        showAlert(loadBalancer.getStatus(), "Session Persistence cannot be edited.");        
180
                                }
181
                        }
182
                });
183
                setSessionButtonText();
184
        }
185

    
186
        @Override
187
        protected Dialog onCreateDialog(int id) {
188
                switch (id) {
189
                case R.id.view_server_delete_button:
190
                        return new AlertDialog.Builder(ViewLoadBalancerActivity.this)
191
                        .setIcon(R.drawable.alert_dialog_icon)
192
                        .setTitle("Delete Load Balancer")
193
                        .setMessage("Are you sure you want to delete the load balancer?")
194
                        .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
195
                                public void onClick(DialogInterface dialog, int whichButton) {
196
                                        new DeleteLoadBalancerTask().execute((Void[]) null);
197
                                }
198
                        })
199
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
200
                                public void onClick(DialogInterface dialog, int whichButton) {
201
                                        // do nothing
202
                                }
203
                        })
204
                        .create();
205
                case R.id.connection_log_button:
206
                        return new AlertDialog.Builder(ViewLoadBalancerActivity.this)
207
                        .setIcon(R.drawable.alert_dialog_icon)
208
                        .setTitle("Disable Logs")
209
                        .setMessage("Are you sure you want to disable logs for this Load Balancer?")
210
                        .setPositiveButton("Enable", new DialogInterface.OnClickListener() {
211
                                public void onClick(DialogInterface dialog, int whichButton) {
212
                                        new SetLoggingTask().execute();        
213
                                }
214
                        })
215
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
216
                                public void onClick(DialogInterface dialog, int whichButton) {
217
                                        // do nothing
218
                                }
219
                        })
220
                        .create();
221
                case R.id.session_persistence_button:
222
                        return new AlertDialog.Builder(ViewLoadBalancerActivity.this)
223
                        .setIcon(R.drawable.alert_dialog_icon)
224
                        .setTitle("Session Persistence")
225
                        .setMessage("Are you sure you want to disable session persistence for this Load Balancer?")
226
                        .setPositiveButton("Enable", new DialogInterface.OnClickListener() {
227
                                public void onClick(DialogInterface dialog, int whichButton) {
228
                                        new SessionPersistenceTask().execute();
229
                                }
230
                        })
231
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
232
                                public void onClick(DialogInterface dialog, int whichButton) {
233
                                        // do nothing
234
                                }
235
                        })
236
                        .create();
237
                }
238
                return null;
239
        }
240

    
241
        @Override
242
        //Need to show different message depending on the state
243
        //of connection_logs/session_persistence
244
        protected void onPrepareDialog(int id, Dialog dialog){
245
                switch (id) {
246
                case R.id.connection_log_button:
247
                        String logTitle;
248
                        String logMessage;
249
                        String logButton;
250
                        if(loadBalancer.getIsConnectionLoggingEnabled().equals("true")){
251
                                logTitle = "Disable Logs";
252
                                logMessage = "Are you sure you want to disable logs for this Load Balancer?";
253
                                logButton = "Disable";
254
                        } else {
255
                                logTitle = "Enable Logs";
256
                                logMessage = "Log files will be processed every hour and stored in your Cloud Files account. " +
257
                                "Standard Cloud Files storage and transfer fees will be accessed for the use of this feature." +
258
                                "\n\nAre you sure you want to enable logs for this Load Balancer?";
259
                                logButton = "Enable";
260
                        }
261
                        ((AlertDialog)dialog).setTitle(logTitle);
262
                        ((AlertDialog)dialog).setMessage(logMessage);
263
                        Button sessionLogButton = ((AlertDialog)dialog).getButton(AlertDialog.BUTTON1);
264
                        sessionLogButton.setText(logButton);
265
                        sessionLogButton.invalidate();
266
                        break;
267
                case R.id.session_persistence_button:
268
                        String sessionMessage;
269
                        String sessionButton;
270
                        if(loadBalancer.getSessionPersistence() != null){
271
                                Log.d("info", "in sessionpersistence != null");
272
                                sessionMessage = "Are you sure you want to disable session persistence for this Load Balancer?";
273
                                sessionButton = "Disable";
274
                        } else {
275
                                Log.d("info", "in sessionpersistence == null");
276
                                sessionMessage = "Are you sure you want to enable session persistence for this Load Balancer?";
277
                                sessionButton = "Enable";
278
                        }
279
                        ((AlertDialog)dialog).setMessage(sessionMessage);
280
                        Button sessionPersistButton = ((AlertDialog)dialog).getButton(AlertDialog.BUTTON1);
281
                        sessionPersistButton.setText(sessionButton);
282
                        sessionPersistButton.invalidate();
283
                        break;
284
                }
285
        }
286

    
287
        //Displays all the load balancer data
288
        private void loadLoadBalancerData() {
289
                if(loadBalancer != null){
290
                        /*
291
                         * need to update the text on button if 
292
                         * it has changed
293
                         */
294
                        setLogButtonText();
295
                        setSessionButtonText();
296

    
297

    
298
                        TextView name = (TextView) findViewById(R.id.view_name);
299
                        name.setText(loadBalancer.getName());
300

    
301
                        TextView id = (TextView) findViewById(R.id.view_lb_id);
302
                        id.setText(loadBalancer.getId());
303

    
304
                        TextView protocol = (TextView) findViewById(R.id.view_protocol);
305
                        protocol.setText(loadBalancer.getProtocol());
306

    
307
                        TextView port = (TextView) findViewById(R.id.view_port);
308
                        port.setText(loadBalancer.getPort());
309

    
310
                        TextView algorithm = (TextView) findViewById(R.id.view_algorithm);
311
                        algorithm.setText(getPrettyAlgoName(loadBalancer.getAlgorithm()));
312

    
313
                        TextView status = (TextView) findViewById(R.id.view_status);
314
                        if (!"ACTIVE".equals(loadBalancer.getStatus())) {
315
                                status.setText(loadBalancer.getStatus());
316
                                pollLoadBalancerTask = new PollLoadBalancerTask();
317
                                pollLoadBalancerTask.execute((Void[]) null);
318
                        } else {
319
                                status.setText(loadBalancer.getStatus());
320
                        }
321

    
322
                        status.setText(loadBalancer.getStatus());
323

    
324
                        TextView connectionLogging = (TextView) findViewById(R.id.view_islogging);
325
                        String isConnectionLogging = loadBalancer.getIsConnectionLoggingEnabled();
326
                        if(isConnectionLogging != null && isConnectionLogging.equals("true")){
327
                                connectionLogging.setText("Enabled");
328
                        } else {
329
                                connectionLogging.setText("Disabled");
330
                        }
331

    
332
                        loadVirutalIpData();
333
                }
334
        }
335
        
336
        private String getPrettyAlgoName(String name){
337
                if(name == null || name.length() == 0){
338
                        return "";
339
                } else {
340
                        String result = name.charAt(0) + "";
341
                        boolean previousWasSpace = false;;
342
                        for(int i = 1; i < name.length(); i++){
343
                                char curLetter = name.charAt(i);
344
                                if(curLetter == '_'){
345
                                        result += " ";
346
                                        previousWasSpace = true;
347
                                } else {
348
                                        if(previousWasSpace){
349
                                                result += Character.toUpperCase(curLetter);
350
                                        } else {
351
                                                result += Character.toLowerCase(curLetter);
352
                                        }
353
                                        previousWasSpace = false;
354
                                }
355
                        }
356
                        return result;
357
                }
358
        }
359

    
360
        private void loadVirutalIpData() {
361
                int layoutIndex = 0;
362
                LinearLayout layout = (LinearLayout) this.findViewById(R.id.vip_addresses);    
363
                layout.removeAllViews();
364
                ArrayList<VirtualIp> virtualIps = loadBalancer.getVirtualIps();
365
                //maybe null if the lb has been deleted
366
                if(virtualIps != null){
367
                        for (int i = 0; i < virtualIps.size(); i++) {
368
                                TextView tv = new TextView(this.getBaseContext());
369
                                tv.setLayoutParams(((TextView)findViewById(R.id.view_port)).getLayoutParams()); // easy quick styling! :)
370
                                tv.setTypeface(tv.getTypeface(), 1); // 1 == bold
371
                                tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
372
                                tv.setTextColor(Color.WHITE);
373
                                tv.setText(virtualIps.get(i).getAddress());
374
                                layout.addView(tv, layoutIndex++);
375
                        }
376
                }
377

    
378
                loadNodeData();
379
        }
380

    
381
        private void loadNodeData() {
382
                int layoutIndex = 0; // public IPs start here
383
                LinearLayout layout = (LinearLayout) this.findViewById(R.id.node_addresses);   
384
                layout.removeAllViews();
385
                ArrayList<Node> nodeIps = loadBalancer.getNodes();
386
                if(nodeIps == null){
387
                        nodeIps = new ArrayList<Node>();
388
                }
389

    
390
                /*
391
                 * need to sort the addresses because during polling
392
                 * their order can change and the display becomes
393
                 * jumpy
394
                 */
395
                ArrayList<String> addresses = new ArrayList<String>();
396
                for(Node n : nodeIps){
397
                        addresses.add(n.getAddress());
398
                }
399

    
400
                Collections.sort(addresses);
401

    
402
                //may be null if lb has been deleted
403
                if(nodeIps != null){
404
                        for (int i = 0; i < nodeIps.size(); i++) {
405
                                TextView tv = new TextView(this.getBaseContext());
406
                                tv.setLayoutParams(((TextView)findViewById(R.id.view_port)).getLayoutParams()); // easy quick styling! :)
407
                                tv.setTypeface(tv.getTypeface(), 1); // 1 == bold
408
                                tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
409
                                tv.setTextColor(Color.WHITE);
410
                                tv.setText(addresses.get(i));
411
                                layout.addView(tv, layoutIndex++);
412
                        }
413
                }
414
        }
415

    
416
        //setup menu for when menu button is pressed
417
        public boolean onCreateOptionsMenu(Menu menu) {
418
                super.onCreateOptionsMenu(menu);
419
                MenuInflater inflater = getMenuInflater();
420
                inflater.inflate(R.menu.view_loadbalancer_menu, menu);
421
                return true;
422
        } 
423

    
424
        @Override 
425
        public boolean onOptionsItemSelected(MenuItem item) {
426
                switch (item.getItemId()) {
427
                case R.id.refresh_loadbalancer:
428
                        new LoadLoadBalancerTask().execute((Void[]) null);   
429
                        return true;
430
                }        
431
                return false;
432
        } 
433

    
434
        @Override
435
        //have been kicked back from another activity,
436
        //so refresh the load balancer data
437
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
438
                super.onActivityResult(requestCode, resultCode, data);
439
                if (resultCode == RESULT_OK) {
440
                        new LoadLoadBalancerTask().execute((Void[]) null);   
441
                }
442
        }
443

    
444
        // HTTP request tasks
445
        private class PollLoadBalancerTask extends AsyncTask<Void, Void, LoadBalancer> {
446

    
447
                @Override
448
                protected LoadBalancer doInBackground(Void... arg0) {
449
                        if(pollLoadBalancerTask.isCancelled()){
450
                                return null;
451
                        }
452
                        try {
453
                                loadBalancer = (new LoadBalancerManager(getContext())).getLoadBalancerById(Integer.parseInt(loadBalancer.getId()));
454
                        } catch (NumberFormatException e) {
455
                                // we're polling, so need to show exceptions
456
                        } catch (LoadBalancersException e) {
457
                                // we're polling, so need to show exceptions
458
                        }
459
                        return loadBalancer;
460
                }
461

    
462
                @Override
463
                protected void onPostExecute(LoadBalancer result) {
464
                        loadBalancer = result;
465
                        loadLoadBalancerData();
466
                }
467
        }
468

    
469
        private class LoadLoadBalancerTask extends AsyncTask<Void, Void, LoadBalancer> {
470

    
471
                private LoadBalancersException exception;
472
                private String loadBalancerId;
473

    
474
                protected void onPreExecute() {
475
                        loadBalancerId = loadBalancer.getId();
476
                        /*
477
                         * set to null, so if config change occurs
478
                         * it will be reloaded in onCreate()
479
                         */
480
                        loadBalancer = null;
481
                        showDialog();
482
                }
483

    
484
                @Override
485
                protected LoadBalancer doInBackground(Void... arg0) {
486
                        LoadBalancer result = null;
487
                        try {
488
                                result = (new LoadBalancerManager(getContext())).getLoadBalancerById(Integer.parseInt(loadBalancerId));
489
                        } catch (LoadBalancersException e) {
490
                                exception = e;
491
                        }
492
                        return result;
493
                }
494

    
495
                @Override
496
                protected void onPostExecute(LoadBalancer result) {
497
                        hideDialog();
498
                        if (exception != null) {
499
                                showAlert("Error", exception.getMessage());
500
                        }
501
                        loadBalancer = result;
502

    
503
                        setUpButtons();
504
                        loadLoadBalancerData();
505
                }
506
        } 
507

    
508
        public class DeleteLoadBalancerTask extends AsyncTask<Void, Void, HttpBundle> {
509

    
510
                private CloudServersException exception;
511

    
512
                @Override
513
                protected void onPreExecute(){
514
                        showDialog();
515
                }
516

    
517
                @Override
518
                protected HttpBundle doInBackground(Void... arg0) {
519
                        HttpBundle bundle = null;
520
                        try {
521
                                bundle = (new LoadBalancerManager(getContext())).delete(loadBalancer);
522
                        } catch (CloudServersException e) {
523
                                exception = e;
524
                        }
525
                        return bundle;
526
                }
527

    
528
                @Override
529
                protected void onPostExecute(HttpBundle bundle) {
530
                        hideDialog();
531
                        HttpResponse response = bundle.getResponse();
532
                        if (response != null) {
533
                                int statusCode = response.getStatusLine().getStatusCode();
534
                                if (statusCode == 202) {
535
                                        setResult(Activity.RESULT_OK);
536
                                        finish();
537
                                } else {
538
                                        CloudServersException cse = parseCloudServersException(response);
539
                                        if ("".equals(cse.getMessage())) {
540
                                                showError("There was a problem deleting your load balancer.", bundle);
541
                                        } else {
542
                                                showError("There was a problem deleting your load balancer: " + cse.getMessage(), bundle);
543
                                        }
544
                                }
545
                        } else if (exception != null) {
546
                                showError("There was a problem deleting your load balancer: " + exception.getMessage(), bundle);                                
547
                        }                        
548
                }
549
        }
550

    
551

    
552
        private class SetLoggingTask extends AsyncTask<Void, Void, HttpBundle> {
553

    
554
                private CloudServersException exception;
555

    
556
                @Override
557
                protected void onPreExecute(){
558
                        showDialog();
559
                }
560

    
561
                @Override
562
                protected HttpBundle doInBackground(Void... arg0) {
563
                        HttpBundle bundle = null;        
564
                        try {
565
                                bundle = (new LoadBalancerManager(context)).setLogging(loadBalancer, !Boolean.valueOf(loadBalancer.getIsConnectionLoggingEnabled()));
566
                        } catch (CloudServersException e) {
567
                                exception = e;
568
                        }
569
                        return bundle;
570
                }
571

    
572
                @Override
573
                protected void onPostExecute(HttpBundle bundle) {
574
                        hideDialog();
575
                        HttpResponse response = bundle.getResponse();
576
                        if (response != null) {
577
                                int statusCode = response.getStatusLine().getStatusCode();                        
578
                                if (statusCode == 202 || statusCode == 204) {
579
                                        pollLoadBalancerTask = new PollLoadBalancerTask();
580
                                        pollLoadBalancerTask.execute((Void[]) null);
581
                                } else {                                        
582
                                        CloudServersException cse = parseCloudServersException(response);
583
                                        if ("".equals(cse.getMessage())) {
584
                                                showError("There was a problem changing your log settings.", bundle);
585
                                        } else {
586
                                                showError("There was a problem changing your log settings: " + cse.getMessage(), bundle);
587
                                        }                                        
588
                                }
589
                        } else if (exception != null) {
590
                                showError("There was a problem changing your log settings: " + exception.getMessage(), bundle);
591

    
592
                        }
593

    
594
                }
595
        }
596

    
597
        private class SessionPersistenceTask extends AsyncTask<Void, Void, HttpBundle> {
598

    
599
                private CloudServersException exception;
600

    
601
                @Override
602
                protected void onPreExecute(){
603
                        showDialog();
604
                }
605

    
606
                @Override
607
                protected HttpBundle doInBackground(Void... arg0) {
608
                        HttpBundle bundle = null;        
609
                        try {
610
                                String currentSetting = loadBalancer.getSessionPersistence();
611
                                if(currentSetting == null){
612
                                        bundle = (new LoadBalancerManager(context)).setSessionPersistence(loadBalancer, "HTTP_COOKIE");
613
                                } else {
614
                                        bundle = (new LoadBalancerManager(context)).disableSessionPersistence(loadBalancer);
615
                                }
616
                        } catch (CloudServersException e) {
617
                                exception = e;
618
                        }
619
                        return bundle;
620
                }
621

    
622
                @Override
623
                protected void onPostExecute(HttpBundle bundle) {
624
                        hideDialog();
625
                        HttpResponse response = bundle.getResponse();
626
                        if (response != null) {
627
                                int statusCode = response.getStatusLine().getStatusCode();                        
628
                                if (statusCode == 202 || statusCode == 200) {
629
                                        pollLoadBalancerTask = new PollLoadBalancerTask();
630
                                        pollLoadBalancerTask.execute((Void[]) null);
631
                                } else {                                        
632
                                        CloudServersException cse = parseCloudServersException(response);
633
                                        if ("".equals(cse.getMessage())) {
634
                                                showError("There was a problem changing your session persistence settings.", bundle);
635
                                        } else {
636
                                                showError("There was a problem changing your session persistence settings: " + cse.getMessage(), bundle);
637
                                        }                                        
638
                                }
639
                        } else if (exception != null) {
640
                                showError("There was a problem changing your session persistence settings: " + exception.getMessage(), bundle);
641

    
642
                        }
643

    
644
                }
645
        }
646

    
647

    
648
}