Revision c25e8fa0

b/AndroidManifest.xml
140 140
		<activity android:name=".AddExternalNodeActivity"></activity>
141 141
		<activity android:name=".SharedVipActivity"></activity>
142 142
		<activity android:name=".ConnectionThrottleActivity"></activity>
143
		<activity android:name=".AccessControlActivity"></activity>
144
		<activity android:name=".AddAccessRuleActivity"></activity>
143 145

  
144 146

  
145 147

  
b/res/layout/accesscontrol.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
	android:orientation="vertical" android:layout_width="fill_parent"
4
	android:layout_height="fill_parent">
5
	<RelativeLayout android:layout_width="fill_parent"
6
		android:id="@+id/nodes_relative" android:layout_height="fill_parent">
7
		<LinearLayout android:layout_height="fill_parent"
8
			android:layout_width="fill_parent" android:id="@+id/nodes_linear_layout"
9
			android:layout_above="@+id/linearLayout1">
10
			<ListView android:layout_width="fill_parent"
11
				android:layout_weight="1" android:id="@android:id/list"
12
				android:cacheColorHint="@android:color/transparent"
13
				android:layout_height="fill_parent"></ListView>
14
		</LinearLayout>
15
		<LinearLayout android:id="@+id/linearLayout1"
16
			android:layout_width="wrap_content" android:layout_height="wrap_content"
17
			android:layout_alignParentRight="true"
18
			android:layout_alignParentLeft="true" android:layout_below="@+id/node_scroll"
19
			android:gravity="center_horizontal" android:layout_alignParentBottom="true">
20
			<Button android:layout_height="wrap_content" android:layout_marginTop="5dip"
21
				android:layout_marginBottom="5dip"
22
				android:layout_width="130dip" android:text="Add Rule" android:id="@+id/add_rule_button"></Button>
23
		</LinearLayout>
24
	</RelativeLayout>
25
</LinearLayout>
26

  
27
  
b/res/layout/accesscontrolcell.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
	android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
4
    <ImageView android:layout_width="wrap_content" android:src="@drawable/allow_rule" android:layout_marginLeft="5dip" android:id="@+id/rule_type_image" android:layout_height="45dip"></ImageView>
5
	<LinearLayout android:layout_height="wrap_content"
6
		android:layout_marginLeft="10dip" android:id="@+id/linearLayout1"
7
		android:layout_width="wrap_content" android:orientation="vertical" android:layout_marginRight="2.5dip" android:layout_marginTop="6.5dip" android:layout_marginBottom="6.5dip">
8
		<LinearLayout android:id="@+id/ip_address_layout"
9
			android:layout_height="wrap_content" android:layout_width="fill_parent">
10
			<TextView android:id="@+id/textView1" android:layout_width="wrap_content"
11
				android:layout_height="wrap_content" android:text="IP Address: "></TextView>
12
			<TextView android:id="@+id/ip_address_text"
13
				android:layout_height="wrap_content" android:layout_width="wrap_content" android:lines="1"></TextView>
14
		</LinearLayout>
15
		<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/status_layout">
16
			<TextView android:id="@+id/TextView03" android:layout_width="wrap_content"
17
				android:layout_height="wrap_content" android:text="Status: "></TextView>
18
			<TextView android:layout_width="wrap_content"
19
				android:layout_height="wrap_content" android:id="@+id/status_text"></TextView>
20
		</LinearLayout>
21
	</LinearLayout>
22

  
23

  
24
</LinearLayout>
b/res/layout/addaccessrule.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3
	android:orientation="vertical" android:layout_width="fill_parent"
4
	android:layout_height="fill_parent">
5
	<LinearLayout android:layout_height="wrap_content"
6
		android:layout_width="fill_parent" android:id="@+id/linearLayout1"
7
		android:orientation="vertical">
8
		<TextView android:layout_height="wrap_content" android:id="@+id/textView1"
9
			android:layout_marginTop="5dip" android:text="Action"
10
			android:layout_width="wrap_content" android:layout_marginLeft="5dip"></TextView>
11
		<Spinner android:layout_height="wrap_content"
12
			android:layout_width="fill_parent" android:layout_marginLeft="22dip"
13
			android:layout_marginRight="30dip" android:id="@+id/rule_action_spinner"></Spinner>
14
		<TextView android:layout_height="wrap_content" android:id="@+id/textView2"
15
			android:layout_marginTop="10dip" android:layout_width="wrap_content"
16
			android:layout_marginLeft="5dip" android:text="IP Addresses / Networks"></TextView>
17
		<EditText android:layout_width="fill_parent" android:layout_above="@+id/add_text_file_buttons"
18
			android:layout_below="@+id/file_contents_view"
19
			android:layout_marginLeft="22dip" android:layout_marginRight="30dip"
20
			android:gravity="top" android:id="@+id/rule_address" android:layout_height="100dip"></EditText>
21
		<TextView android:layout_height="wrap_content" android:id="@+id/textView3"
22
			android:layout_marginRight="30dip" android:textSize="11dip"
23
			android:layout_width="wrap_content" android:layout_marginLeft="22dip" android:text="Enter IP addresses or networks in CIDR notation; separate multiple entries with commas. The network 0.0.0.0/0 can be used to create a rule for all traffic."></TextView>
24
		<Button android:layout_height="wrap_content"
25
			android:layout_gravity="center" android:layout_marginTop="10dip"
26
			android:text="Add Rule" android:layout_width="120dip" android:id="@+id/add_rule_button"></Button>
27
	</LinearLayout>
28

  
29
</ScrollView>
b/res/layout/addtextfile.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2

  
3
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout" android:layout_height="fill_parent" android:layout_width="fill_parent">
4
    <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Filename" android:id="@+id/filename_textview" android:layout_marginLeft="22dip"></TextView>
5
    <EditText android:id="@+id/file_name_text" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_below="@+id/filename_textview" android:layout_marginLeft="22dip" android:layout_marginRight="30dip" android:lines="1" android:scrollHorizontally="true"></EditText>
6
    <TextView android:layout_below="@+id/file_name_text" android:layout_height="wrap_content" android:id="@+id/file_contents_view" android:layout_width="wrap_content" android:text="File Content" android:layout_marginLeft="22dip"></TextView>
7
    <EditText android:layout_width="fill_parent" android:id="@+id/new_file_text" android:layout_above="@+id/add_text_file_buttons" android:layout_height="fill_parent" android:layout_below="@+id/file_contents_view" android:layout_marginLeft="22dip" android:layout_marginRight="30dip" android:gravity="top"></EditText>
8
    <LinearLayout android:layout_height="wrap_content" android:id="@+id/add_text_file_buttons" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_alignParentBottom="true">
9
        <Button android:layout_height="wrap_content" android:text="Submit" android:id="@+id/new_file_button" android:layout_gravity="left" android:layout_width="100dip" android:layout_marginLeft="22dip" android:layout_marginTop="10dip"></Button>
10
    </LinearLayout>
3
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
	android:id="@+id/RelativeLayout" android:layout_height="fill_parent"
5
	android:layout_width="fill_parent">
6
	<TextView android:layout_height="wrap_content"
7
		android:layout_width="wrap_content" android:text="Filename"
8
		android:id="@+id/filename_textview" android:layout_marginLeft="22dip"></TextView>
9
	<EditText android:id="@+id/file_name_text"
10
		android:layout_height="wrap_content" android:layout_width="fill_parent"
11
		android:layout_below="@+id/filename_textview"
12
		android:layout_marginLeft="22dip" android:layout_marginRight="30dip"
13
		android:lines="1" android:scrollHorizontally="true"></EditText>
14
	<TextView android:layout_below="@+id/file_name_text"
15
		android:layout_height="wrap_content" android:id="@+id/file_contents_view"
16
		android:layout_width="wrap_content" android:text="File Content"
17
		android:layout_marginLeft="22dip"></TextView>
18
	<EditText android:layout_width="fill_parent" android:id="@+id/new_file_text"
19
		android:layout_above="@+id/add_text_file_buttons"
20
		android:layout_height="fill_parent" android:layout_below="@+id/file_contents_view"
21
		android:layout_marginLeft="22dip" android:layout_marginRight="30dip"
22
		android:gravity="top"></EditText>
23
	<LinearLayout android:layout_height="wrap_content"
24
		android:id="@+id/add_text_file_buttons" android:orientation="horizontal"
25
		android:layout_width="fill_parent" android:layout_alignParentBottom="true">
26
		<Button android:layout_height="wrap_content" android:text="Submit"
27
			android:id="@+id/new_file_button" android:layout_gravity="left"
28
			android:layout_width="100dip" android:layout_marginLeft="22dip"
29
			android:layout_marginTop="10dip"></Button>
30
	</LinearLayout>
11 31

  
12 32

  
13 33
</RelativeLayout>
b/res/layout/norulescell.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
3
    android:orientation="vertical"
4
    android:layout_width="fill_parent"
5
    android:layout_height="264dip"
6
    >
7
    
8
    <TextView android:layout_width="fill_parent"
9
        android:layout_height="wrap_content"
10
        android:layout_marginTop="125px"
11
        android:textColor="#FFFFFF"
12
        android:gravity="center"
13
        
14
        android:textSize="24sp" android:id="@+id/no_rules_label" android:text="No Rules"/>
15

  
16
    <TextView android:layout_width="fill_parent"
17
        android:layout_height="wrap_content"
18
        android:layout_marginTop="10px"
19
        android:textColor="#FFFFFF"
20
        android:gravity="center"
21
        android:textSize="12sp" android:id="@+id/no_rules_sublabel" android:text="Press the button below to create a new rule."/>
22
        
23
</LinearLayout>
b/res/layout/view_loadbalancer.xml
136 136
				<Button android:layout_gravity="left" android:layout_width="130dip" android:layout_marginLeft="20dip" android:layout_height="wrap_content" android:id="@+id/edit_nodes_button" android:text="Edit Nodes" android:layout_marginTop="10dip"></Button>
137 137
				<Button android:layout_height="wrap_content" android:layout_marginTop="10dip" android:layout_marginLeft="10dip" android:layout_width="130dip" android:layout_gravity="left" android:text="Log Connections" android:id="@+id/connection_log_button"></Button>
138 138
			</LinearLayout>
139
			<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/load_balancer_button3">
139
			<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/load_balancer_buttons3">
140 140
				<Button android:layout_height="wrap_content" android:layout_marginLeft="20dip" android:layout_marginTop="10dip" android:layout_gravity="left" android:layout_width="130dip" android:id="@+id/session_persistence_button" android:text="Disable Session Persistence"></Button>
141 141
				<Button android:layout_marginTop="10dip" android:layout_marginLeft="10dip" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_width="130dip" android:text="Connection Throttle" android:id="@+id/connection_throttle_button"></Button>
142 142
			</LinearLayout>
143
			<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/load_balancer_buttons4">
144
				<Button android:layout_marginLeft="20dip" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_width="130dip" android:layout_marginTop="10dip" android:id="@+id/access_control_button" android:text="Access Control"></Button>
145
			</LinearLayout>
143 146
		</LinearLayout>
144 147
	</ScrollView>
145 148
</LinearLayout>
b/src/com/rackspace/cloud/loadbalancer/api/client/NetworkItem.java
1
package com.rackspace.cloud.loadbalancer.api.client;
2

  
3
import java.util.ArrayList;
4

  
5
public class NetworkItem extends Entity{
6

  
7
	/**
8
	 * 
9
	 */
10
	private static final long serialVersionUID = 8134384955296218387L;
11
	
12
	private static ArrayList<NetworkItem> networkItems;
13
	private String address;
14
	private String type;
15

  
16
	/**
17
	 * @param address the address to set
18
	 */
19
	public void setAddress(String address) {
20
		this.address = address;
21
	}
22
	/**
23
	 * @return the address
24
	 */
25
	public String getAddress() {
26
		return address;
27
	}
28
	
29
	/**
30
	 * @param type the type to set
31
	 */
32
	public void setType(String type) {
33
		this.type = type.toUpperCase();
34
	}
35
	/**
36
	 * @return the type
37
	 */
38
	public String getType() {
39
		return type;
40
	}
41
	
42
	/**
43
	 * @return the networkItems
44
	 */
45
	public static ArrayList<NetworkItem> getNetworkItems() {
46
		return networkItems;
47
	}
48
	/**
49
	 * @param networkItems the etworkItems to set
50
	 */
51
	public static void setNetworkItems(ArrayList<NetworkItem> networkItems) {
52
		NetworkItem.networkItems = networkItems;
53
	}
54
	
55

  
56
}
b/src/com/rackspace/cloud/loadbalancer/api/client/NetworkItemManager.java
1
/**
2
 * 
3
 */
4
package com.rackspace.cloud.loadbalancer.api.client;
5

  
6
import java.io.IOException;
7
import java.io.StringReader;
8
import java.io.UnsupportedEncodingException;
9
import java.util.ArrayList;
10

  
11
import javax.xml.parsers.FactoryConfigurationError;
12
import javax.xml.parsers.ParserConfigurationException;
13
import javax.xml.parsers.SAXParser;
14
import javax.xml.parsers.SAXParserFactory;
15

  
16
import org.apache.http.HttpResponse;
17
import org.apache.http.client.ClientProtocolException;
18
import org.apache.http.client.methods.HttpDelete;
19
import org.apache.http.client.methods.HttpGet;
20
import org.apache.http.client.methods.HttpPost;
21
import org.apache.http.entity.StringEntity;
22
import org.apache.http.impl.client.BasicResponseHandler;
23
import org.apache.http.protocol.RequestExpectContinue;
24
import org.xml.sax.InputSource;
25
import org.xml.sax.SAXException;
26
import org.xml.sax.XMLReader;
27

  
28
import android.content.Context;
29

  
30
import com.rackspace.cloud.files.api.client.CustomHttpClient;
31
import com.rackspace.cloud.loadbalancer.api.client.http.LoadBalancersException;
32
import com.rackspace.cloud.loadbalancer.api.parsers.CloudLoadBalancersFaultXMLParser;
33
import com.rackspace.cloud.loadbalancer.api.parsers.NetworkItemXMLParser;
34
import com.rackspace.cloud.servers.api.client.Account;
35
import com.rackspace.cloud.servers.api.client.CloudServersException;
36
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
37

  
38
public class NetworkItemManager extends EntityManager {
39
	private Context context;
40

  
41
	public NetworkItemManager(Context context) {
42
		this.context = context;
43
	}
44

  
45
	public ArrayList<NetworkItem> createList(LoadBalancer loadBalancer) throws LoadBalancersException {
46
		CustomHttpClient httpclient = new CustomHttpClient(context);
47
		HttpGet get = new HttpGet(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) 
48
				+ Account.getAccount().getAccountId() + "/loadbalancers/" + loadBalancer.getId() + "/accesslist");
49
		
50
		ArrayList<NetworkItem> networkItems = new ArrayList<NetworkItem>();
51

  
52
		get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
53
		get.addHeader("Accept", "application/xml");
54

  
55
		try {			
56
			HttpResponse resp = httpclient.execute(get);		    
57
			BasicResponseHandler responseHandler = new BasicResponseHandler();
58
			String body = responseHandler.handleResponse(resp);
59
			if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) {		    	
60
				NetworkItemXMLParser networkItemXMLParser = new NetworkItemXMLParser();
61
				SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
62
				XMLReader xmlReader = saxParser.getXMLReader();
63
				xmlReader.setContentHandler(networkItemXMLParser);
64
				xmlReader.parse(new InputSource(new StringReader(body)));		    	
65
				networkItems = networkItemXMLParser.getNetworkItems();		    	
66
			} else {
67
				CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser();
68
				SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
69
				XMLReader xmlReader = saxParser.getXMLReader();
70
				xmlReader.setContentHandler(parser);
71
				xmlReader.parse(new InputSource(new StringReader(body)));		    	
72
				LoadBalancersException cse = parser.getException();		    	
73
				throw cse;
74
			}
75
		} catch (ClientProtocolException e) {
76
			LoadBalancersException cse = new LoadBalancersException();
77
			cse.setMessage(e.getLocalizedMessage());
78
			throw cse;
79
		} catch (IOException e) {
80
			LoadBalancersException cse = new LoadBalancersException();
81
			cse.setMessage(e.getLocalizedMessage());
82
			throw cse;
83
		} catch (ParserConfigurationException e) {
84
			LoadBalancersException cse = new LoadBalancersException();
85
			cse.setMessage(e.getLocalizedMessage());
86
			throw cse;
87
		} catch (SAXException e) {
88
			LoadBalancersException cse = new LoadBalancersException();
89
			cse.setMessage(e.getLocalizedMessage());
90
			throw cse;
91
		} catch (FactoryConfigurationError e) {
92
			LoadBalancersException cse = new LoadBalancersException();
93
			cse.setMessage(e.getLocalizedMessage());
94
			throw cse;
95
		}
96
		return networkItems;
97
	}
98
	
99
	public HttpBundle create(LoadBalancer loadBalancer, ArrayList<NetworkItem> entity) throws CloudServersException {
100
		HttpResponse resp = null;
101
		CustomHttpClient httpclient = new CustomHttpClient(context);
102
		HttpPost post = new HttpPost(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) 
103
				+ Account.getAccount().getAccountId() + "/loadbalancers/" + loadBalancer.getId() + "/accesslist");
104
		
105
		post.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
106
		post.addHeader("Content-Type", "application/xml");
107

  
108
		String xml = "<accessList xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\"> ";
109
					for(NetworkItem networkItem : entity){
110
					xml += "<networkItem " +
111
						   "address=\"" + networkItem.getAddress() + "\" " + 
112
						   "type=\"" + networkItem.getType() + "\" /> ";
113
					}
114
					xml += "</accessList>";
115

  
116
		StringEntity tmp = null;
117
		try {
118
			tmp = new StringEntity(xml);
119
		} catch (UnsupportedEncodingException e) {
120
			CloudServersException cse = new CloudServersException();
121
			cse.setMessage(e.getLocalizedMessage());
122
			throw cse;
123
		}
124
		post.setEntity(tmp);
125
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
126

  
127
		HttpBundle bundle = new HttpBundle();
128
		bundle.setCurlRequest(post);
129
		
130
		try {			
131
			resp = httpclient.execute(post);
132
			bundle.setHttpResponse(resp);
133
		} catch (ClientProtocolException e) {
134
			CloudServersException cse = new CloudServersException();
135
			cse.setMessage(e.getLocalizedMessage());
136
			throw cse;
137
		} catch (IOException e) {
138
			CloudServersException cse = new CloudServersException();
139
			cse.setMessage(e.getLocalizedMessage());
140
			throw cse;
141
		} catch (FactoryConfigurationError e) {
142
			CloudServersException cse = new CloudServersException();
143
			cse.setMessage(e.getLocalizedMessage());
144
			throw cse;
145
		}	
146
		return bundle;
147
	}
148

  
149
	public HttpBundle delete(LoadBalancer loadBalancer, NetworkItem networkItem) throws CloudServersException {
150
		HttpResponse resp = null;
151
		CustomHttpClient httpclient = new CustomHttpClient(context);
152

  
153
		HttpDelete delete = new HttpDelete(LoadBalancer.getRegionUrl(loadBalancer.getRegion()) + Account.getAccount().getAccountId() 
154
				+ "/loadbalancers/" + loadBalancer.getId() + "/accesslist/" + networkItem.getId());				
155
		delete.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
156
		delete.addHeader("Content-Type", "application/xml");
157
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
158

  
159
		HttpBundle bundle = new HttpBundle();
160
		bundle.setCurlRequest(delete);
161

  
162
		try {			
163
			resp = httpclient.execute(delete);
164
			bundle.setHttpResponse(resp);
165
		} catch (ClientProtocolException e) {
166
			CloudServersException cse = new CloudServersException();
167
			cse.setMessage(e.getLocalizedMessage());
168
			throw cse;
169
		} catch (IOException e) {
170
			CloudServersException cse = new CloudServersException();
171
			cse.setMessage(e.getLocalizedMessage());
172
			throw cse;
173
		} catch (FactoryConfigurationError e) {
174
			CloudServersException cse = new CloudServersException();
175
			cse.setMessage(e.getLocalizedMessage());
176
			throw cse;
177
		}	
178
		return bundle;
179
	}
180

  
181
}
b/src/com/rackspace/cloud/loadbalancer/api/parsers/NetworkItemXMLParser.java
1
/**
2
 * 
3
 */
4
package com.rackspace.cloud.loadbalancer.api.parsers;
5

  
6
import java.util.ArrayList;
7

  
8
import org.xml.sax.Attributes;
9
import org.xml.sax.helpers.DefaultHandler;
10

  
11
import android.util.Log;
12

  
13
import com.rackspace.cloud.loadbalancer.api.client.NetworkItem;
14

  
15
public class NetworkItemXMLParser extends DefaultHandler {
16
	private NetworkItem networkItem;
17
	private ArrayList<NetworkItem> networkItems;
18
	private StringBuffer currentData;
19

  
20
	public void startDocument() {
21
	}
22

  
23
	public void endDocument() {
24
	}
25

  
26
	public void startElement(String uri, String name, String qName, Attributes atts) {
27

  
28
		currentData = new StringBuffer();
29
		if ("accessList".equals(name)) {
30
			networkItems = new ArrayList<NetworkItem>();
31
		} else if ("networkItem".equals(name)) {
32
			networkItem = new NetworkItem();
33
			networkItem.setId(atts.getValue("id"));
34
			networkItem.setAddress(atts.getValue("address"));
35
			networkItem.setType(atts.getValue("type"));
36
		}
37
	}
38

  
39
	public void endElement(String uri, String name, String qName) {
40
		if ("networkItem".equals(name)) {
41
			if (networkItem != null) {
42
				networkItems.add(networkItem);
43
			}
44
		}		
45
	}
46

  
47
	public void characters(char ch[], int start, int length) {
48
		Log.d("Rackspace-Cloud", "Characters:    \"");
49
		for (int i = start; i < start + length; i++) {
50
			switch (ch[i]) {
51
			case '\\':
52
				Log.d("Rackspace-Cloud", "\\\\");
53
				break;
54
			case '"':
55
				Log.d("Rackspace-Cloud", "\\\"");
56
				break;
57
			case '\n':
58
				Log.d("Rackspace-Cloud", "\\n");
59
				break;
60
			case '\r':
61
				Log.d("Rackspace-Cloud", "\\r");
62
				break;
63
			case '\t':
64
				Log.d("Rackspace-Cloud", "\\t");
65
				break;
66
			default:
67
				Log.d("Rackspace-Cloud", String.valueOf(ch[i]));
68
				break;
69
			}
70
		}
71
		Log.d("Rackspace-Cloud", "\"\n");
72

  
73

  
74
		for (int i = start; i < (start + length); i++) {
75
			currentData.append(ch[i]);
76
		}
77
	}
78

  
79
	/**
80
	 * @return the networkItem
81
	 */
82
	public NetworkItem getNetworkItem() {
83
		return networkItem;
84
	}
85

  
86
	/**
87
	 * @param networkItem the networkItem to set
88
	 */
89
	public void setBetworkItem(NetworkItem networkItem) {
90
		this.networkItem = networkItem;
91
	}
92

  
93
	/**
94
	 * @return the networkItems
95
	 */
96
	public ArrayList<NetworkItem> getNetworkItems() {
97
		return networkItems;
98
	}
99

  
100
	/**
101
	 * @param networkItems the networkItems to set
102
	 */
103
	public void setNetworkItems(ArrayList<NetworkItem> networkItems) {
104
		this.networkItems = networkItems;
105
	}
106

  
107
}
b/src/com/rackspacecloud/android/AccessControlActivity.java
1
package com.rackspacecloud.android;
2

  
3
import java.util.ArrayList;
4

  
5
import org.apache.http.HttpResponse;
6

  
7
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer;
8
import com.rackspace.cloud.loadbalancer.api.client.NetworkItem;
9
import com.rackspace.cloud.loadbalancer.api.client.NetworkItemManager;
10
import com.rackspace.cloud.loadbalancer.api.client.http.LoadBalancersException;
11
import com.rackspace.cloud.servers.api.client.CloudServersException;
12
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
13

  
14
import android.app.Activity;
15
import android.app.AlertDialog;
16
import android.app.Dialog;
17
import android.content.DialogInterface;
18
import android.content.Intent;
19
import android.os.AsyncTask;
20
import android.os.Bundle;
21
import android.view.LayoutInflater;
22
import android.view.View;
23
import android.view.View.OnClickListener;
24
import android.view.ViewGroup;
25
import android.widget.ArrayAdapter;
26
import android.widget.Button;
27
import android.widget.ImageView;
28
import android.widget.ListView;
29
import android.widget.TextView;
30

  
31
public class AccessControlActivity extends CloudListActivity {
32

  
33
	private final int REMOVE_RULE = 199;
34
	private final int ADD_RULE = 219;
35
	
36
	private LoadBalancer loadBalancer;
37
	private ArrayList<NetworkItem> networkItems;
38
	private int lastSelectedRulePosition;
39

  
40
	@Override
41
	public void onCreate(Bundle savedInstanceState) {
42
		super.onCreate(savedInstanceState);
43
		loadBalancer = (LoadBalancer) this.getIntent().getExtras().get("loadBalancer");
44
		setContentView(R.layout.accesscontrol);
45
		restoreState(savedInstanceState);
46
	}
47

  
48
	@Override
49
	protected void onSaveInstanceState(Bundle outState) {
50
		super.onSaveInstanceState(outState);
51
		outState.putSerializable("networkItems", networkItems);
52
	}
53

  
54
	@SuppressWarnings("unchecked")
55
	protected void restoreState(Bundle state) {
56
		super.restoreState(state);
57

  
58
		setupButton();
59
		
60
		if (state != null && state.containsKey("networkItems") && state.getSerializable("networkItems") != null) {
61
			networkItems = (ArrayList<NetworkItem>) state.getSerializable("networkItems");
62
			if (networkItems.size() == 0) {
63
				displayNoRulesCell();
64
			} else {
65
				getListView().setDividerHeight(1); // restore divider lines
66
				setListAdapter(new NetworkItemAdapter());
67
			}
68
		} else {
69
			loadNetworkItems();
70
		}
71
	}
72
	
73
	private void setupButton(){
74
		Button addRule = (Button)findViewById(R.id.add_rule_button);
75
		addRule.setOnClickListener(new OnClickListener() {
76
			
77
			@Override
78
			public void onClick(View v) {
79
				Intent viewIntent = new Intent(getContext(), AddAccessRuleActivity.class);
80
				viewIntent.putExtra("loadBalancer", loadBalancer);
81
				startActivityForResult(viewIntent, ADD_RULE);
82
			}
83
		});
84
	}
85

  
86
	protected void onListItemClick(ListView l, View v, int position, long id) {
87
		if (networkItems != null && networkItems.size() > 0) {
88
			lastSelectedRulePosition = position;
89
			showDialog(REMOVE_RULE);
90
		}
91
	}
92

  
93
	@Override
94
	protected Dialog onCreateDialog(int id) {
95
		switch (id) {
96
		case REMOVE_RULE: 
97
			return new AlertDialog.Builder(AccessControlActivity.this)
98
			.setIcon(R.drawable.alert_dialog_icon)
99
			.setTitle("Remove Rule")
100
			.setMessage("Would you like to remove this rule?")
101
			.setPositiveButton("Remove", new DialogInterface.OnClickListener() {
102
				public void onClick(DialogInterface dialog, int whichButton) {
103
					//trackEvent(CATEGORY_SERVER, EVENT_DELETE, "", -1);
104
					new DeleteNetworkItemTask().execute((Void[]) null);
105
				}
106
			})
107
			.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
108
				public void onClick(DialogInterface dialog, int whichButton) {
109
					// User clicked Cancel so do some stuff
110
				}
111
			})
112
			.create();          
113
		}
114
		return null;
115
	}
116
	
117
	private void setNetworkItemList(ArrayList<NetworkItem> networkItems) {
118
		if (networkItems == null) {
119
			networkItems = new ArrayList<NetworkItem>();
120
		}
121
		this.networkItems = new ArrayList<NetworkItem>();
122
		String[] networkItemNames = new String[networkItems.size()];
123

  
124
		if (networkItems != null) {
125
			for (int i = 0; i < networkItems.size(); i++) {
126
				NetworkItem networkItem = networkItems.get(i);
127
				this.networkItems.add(i, networkItem);
128
				networkItemNames[i] = networkItem.getName();
129
			}
130
		}
131

  
132
		if (networkItemNames.length == 0) {
133
			displayNoRulesCell();
134
		} else {
135
			getListView().setDividerHeight(1); // restore divider lines 
136
			setListAdapter(new NetworkItemAdapter());
137
		}
138
	}
139

  
140
	private void displayNoRulesCell() {
141
		String a[] = new String[1];
142
		a[0] = "No Rules";
143
		setListAdapter(new ArrayAdapter<String>(this, R.layout.norulescell, R.id.no_rules_label, a));
144
		getListView().setTextFilterEnabled(true);
145
		getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row
146
		getListView().setItemsCanFocus(false);
147
	}
148

  
149
	private void loadNetworkItems() {
150
		new LoadNetworkItemsTask().execute((Void[]) null);
151
	}
152

  
153
	// * Adapter/
154
	class NetworkItemAdapter extends ArrayAdapter<NetworkItem> {
155
		NetworkItemAdapter() {
156
			super(AccessControlActivity.this, R.layout.accesscontrolcell, networkItems);
157
		}
158

  
159
		public View getView(int position, View convertView, ViewGroup parent) {
160

  
161
			NetworkItem networkItem = networkItems.get(position);
162
			LayoutInflater inflater = getLayoutInflater();
163
			View row = inflater.inflate(R.layout.accesscontrolcell, parent, false);
164

  
165
			TextView label = (TextView) row.findViewById(R.id.ip_address_text);
166
			label.setText(networkItem.getAddress());
167

  
168
			TextView sublabel = (TextView) row.findViewById(R.id.status_text);
169
			sublabel.setText(networkItem.getType());
170
			
171
			ImageView typeImage = (ImageView) row.findViewById(R.id.rule_type_image);
172
			int image;
173
			if(networkItem.getType().equals("ALLOW")){
174
				image = R.drawable.allow_rule;
175
			} else {
176
				image = R.drawable.deny_rule;
177
			}
178
			typeImage.setImageResource(image);
179

  
180

  
181
			return(row);
182
		}
183
	}
184

  
185
	private class LoadNetworkItemsTask extends AsyncTask<Void, Void, ArrayList<NetworkItem>> {
186
		private LoadBalancersException exception;
187

  
188
		@Override
189
		protected void onPreExecute(){
190
			showDialog();
191
		}
192

  
193
		@Override
194
		protected ArrayList<NetworkItem> doInBackground(Void... arg0) {
195
			ArrayList<NetworkItem> networkItems = null;
196
			try {
197
				networkItems = new NetworkItemManager(getContext()).createList(loadBalancer);
198
			} catch (LoadBalancersException e) {
199
				exception = e;				
200
			}
201
			return networkItems;
202
		}
203

  
204
		@Override
205
		protected void onPostExecute(ArrayList<NetworkItem> result) {
206
			hideDialog();
207
			if (exception != null) {
208
				showAlert("Error", exception.getMessage());
209
			}
210
			setNetworkItemList(result);
211
		}
212
	}
213
	
214
	private class DeleteNetworkItemTask extends AsyncTask<Void, Void, HttpBundle> {
215

  
216
			private CloudServersException exception;
217

  
218
			@Override
219
			//let user know their process has started
220
			protected void onPreExecute(){
221
				showDialog();
222
			}
223
			@Override
224
			protected HttpBundle doInBackground(Void... arg0) {
225
				HttpBundle bundle = null;
226
				try {
227
					bundle = new NetworkItemManager(getContext()).delete(loadBalancer, networkItems.get(lastSelectedRulePosition));
228
				} catch (CloudServersException e) {
229
					exception = e;
230
				}
231
				return bundle;
232
			}
233

  
234
			@Override
235
			protected void onPostExecute(HttpBundle bundle) {
236
				hideDialog();
237
				HttpResponse response = bundle.getResponse();
238
				if (response != null) {
239
					int statusCode = response.getStatusLine().getStatusCode();
240
					if (statusCode == 202 || statusCode == 200) {
241
						setResult(Activity.RESULT_OK);
242
						loadNetworkItems();
243
					} else {
244
						CloudServersException cse = parseCloudServersException(response);
245
						if ("".equals(cse.getMessage())) {
246
							showError("There was a problem deleting your rule.", bundle);
247
						} else {
248
							showError("There was a problem deleting your rule: " + cse.getMessage(), bundle);
249
						}
250
					}
251
				} else if (exception != null) {
252
					showError("There was a problem deleting your rule: " + exception.getMessage(), bundle);				
253
				}			
254
			}
255
		}
256

  
257

  
258

  
259
	protected void onActivityResult(int requestCode, int resultCode, Intent data){	
260
		if(requestCode == ADD_RULE && resultCode == RESULT_OK){
261
			loadNetworkItems();
262
		}
263
	}
264
}
b/src/com/rackspacecloud/android/AddAccessRuleActivity.java
1
package com.rackspacecloud.android;
2

  
3
import java.util.ArrayList;
4
import java.util.regex.Matcher;
5
import java.util.regex.Pattern;
6

  
7
import org.apache.http.HttpResponse;
8

  
9
import android.app.Activity;
10
import android.os.AsyncTask;
11
import android.os.Bundle;
12
import android.text.Editable;
13
import android.text.TextWatcher;
14
import android.view.View;
15
import android.view.View.OnClickListener;
16
import android.widget.AdapterView;
17
import android.widget.ArrayAdapter;
18
import android.widget.Button;
19
import android.widget.EditText;
20
import android.widget.Spinner;
21
import android.widget.AdapterView.OnItemSelectedListener;
22

  
23
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer;
24
import com.rackspace.cloud.loadbalancer.api.client.NetworkItem;
25
import com.rackspace.cloud.loadbalancer.api.client.NetworkItemManager;
26
import com.rackspace.cloud.servers.api.client.CloudServersException;
27
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
28

  
29
public class AddAccessRuleActivity extends CloudActivity{
30

  
31
	private final String[] ACTIONS = {"Deny", "Allow"};
32
	
33
	private LoadBalancer loadBalancer;
34
	private String selectedAction;
35
	private String selectedAddresses;
36
	private NetworkItem networkItem;
37
	
38
	@Override
39
	public void onCreate(Bundle savedInstanceState) {
40
		super.onCreate(savedInstanceState);
41
		loadBalancer = (LoadBalancer) this.getIntent().getExtras().get("loadBalancer");
42
		setContentView(R.layout.addaccessrule);
43
		restoreState(savedInstanceState);
44
	}
45

  
46
	@Override
47
	protected void onSaveInstanceState(Bundle outState) {
48
		super.onSaveInstanceState(outState);
49
	}
50

  
51
	protected void restoreState(Bundle state) {
52
		super.restoreState(state);
53
		setupInputs();
54
	}
55
	
56
	private void setupInputs(){
57
		Spinner actionSpinner = (Spinner)findViewById(R.id.rule_action_spinner);
58
		
59
		ArrayAdapter<String> actionAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ACTIONS);
60
		actionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
61
		actionSpinner.setAdapter(actionAdapter);
62

  
63
		actionSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
64

  
65
			@Override
66
			public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
67
				selectedAction = ACTIONS[pos];	
68
			}
69

  
70
			@Override
71
			public void onNothingSelected(AdapterView<?> arg0) {
72

  
73
			}
74

  
75
		});
76
		
77
		EditText address = (EditText)findViewById(R.id.rule_address);
78
		address.addTextChangedListener(new TextWatcher() {
79
			
80
			@Override
81
			public void onTextChanged(CharSequence s, int start, int before, int count) {
82
				selectedAddresses = s.toString();
83
			}
84
			
85
			@Override
86
			public void beforeTextChanged(CharSequence s, int start, int count,
87
					int after) {
88
				//do nothing
89
			}
90
			
91
			@Override
92
			public void afterTextChanged(Editable s) {
93
				//do nothing
94
			}
95
		});
96
		
97
		Button addRule = (Button)findViewById(R.id.add_rule_button);
98
		addRule.setOnClickListener(new OnClickListener() {
99
			
100
			@Override
101
			public void onClick(View v) {
102
				if(!validAddress(selectedAddresses)){
103
					showAlert("Error", "Please enter a valid IP address.");
104
				} else if(!validAction(selectedAction)) {
105
					showAlert("Error", "Please select an action type.");
106
				} else{
107
					ArrayList<NetworkItem> networkItems = new ArrayList<NetworkItem>();
108
					String[] networkAddresses = selectedAddresses.split(",");
109
					for(int i = 0; i < networkAddresses.length; i++){
110
						NetworkItem networkItem = new NetworkItem();
111
						networkItem.setAddress(networkAddresses[i].trim());
112
						networkItem.setType(selectedAction);
113
						networkItems.add(networkItem);
114
					}
115
					new AddNetworkItemTask().execute(networkItems);
116
				}
117
			}
118
		});
119
	}
120
	
121
	//basic ip validation just checks that the string
122
	//is only composed of letters, numbers, ., :
123
	private static boolean validAddress(String address){
124
		//Enter regex
125
		if(address != null){
126
			Pattern pattern = Pattern.compile("[a-zA-Z0-9.:/, ]+");
127
			Matcher match = pattern.matcher(address);
128
			return match.matches();
129
		} else {
130
			return false;
131
		}
132
	}
133
	
134
	private Boolean validAction(String action){
135
		return action != null;
136
	}
137
	
138
	private class AddNetworkItemTask extends AsyncTask<ArrayList<NetworkItem>, Void, HttpBundle> {
139

  
140
		private CloudServersException exception;
141

  
142
		@Override
143
		protected void onPreExecute(){
144
			showDialog();
145
		}
146
		@Override
147
		protected HttpBundle doInBackground(ArrayList<NetworkItem>... networkItems) {
148
			HttpBundle bundle = null;
149
			try {
150
				bundle = new NetworkItemManager(getContext()).create(loadBalancer, networkItems[0]);
151
			} catch (CloudServersException e) {
152
				exception = e;
153
			}
154
			return bundle;
155
		}
156

  
157
		@Override
158
		protected void onPostExecute(HttpBundle bundle) {
159
			hideDialog();
160
			HttpResponse response = bundle.getResponse();
161
			if (response != null) {
162
				int statusCode = response.getStatusLine().getStatusCode();
163
				if (statusCode == 202 || statusCode == 200) {
164
					setResult(Activity.RESULT_OK);
165
					finish();
166
				} else {
167
					CloudServersException cse = parseCloudServersException(response);
168
					if ("".equals(cse.getMessage())) {
169
						showError("There was a problem creating your rule.", bundle);
170
					} else {
171
						showError("There was a problem creating your rule: " + cse.getMessage(), bundle);
172
					}
173
				}
174
			} else if (exception != null) {
175
				showError("There was a problem creating your rule: " + exception.getMessage(), bundle);				
176
			}			
177
		}
178
	}
179
}
b/src/com/rackspacecloud/android/AddExternalNodeActivity.java
136 136
	//is only composed of letters, numbers, ., :
137 137
	private static boolean validIp(String ip){
138 138
		//Enter regex
139
		Pattern pattern = Pattern.compile("[a-zA-Z0-9.:]+");
140
		Matcher match = pattern.matcher(ip);
141
		return match.matches();
139
		if(ip != null){
140
			Pattern pattern = Pattern.compile("[a-zA-Z0-9.:]+");
141
			Matcher match = pattern.matcher(ip);
142
			return match.matches();
143
		} else {
144
			return false;
145
		}
142 146
	}
143 147

  
144 148
	private boolean validPort(String port){
b/src/com/rackspacecloud/android/ConnectionThrottleActivity.java
187 187
			HttpResponse response = bundle.getResponse();
188 188
			if (response != null) {
189 189
				int statusCode = response.getStatusLine().getStatusCode();
190
				if (statusCode == 202) {
190
				if (statusCode == 202 || statusCode == 200) {
191 191
					setResult(Activity.RESULT_OK);
192 192
					finish();
193 193
				} else {
......
230 230
			HttpResponse response = bundle.getResponse();
231 231
			if (response != null) {
232 232
				int statusCode = response.getStatusLine().getStatusCode();
233
				if (statusCode == 202) {
233
				if (statusCode == 202 || statusCode == 200) {
234 234
					setResult(Activity.RESULT_OK);
235 235
					finish();
236 236
				} else {
b/src/com/rackspacecloud/android/ViewLoadBalancerActivity.java
41 41
	private final int EDIT_LOAD_BALANCER_CODE = 184;
42 42
	private final int EDIT_NODES_CODE = 185;
43 43
	private final int EDIT_THROTTLE_CODE = 186;
44
	
44
	private final int EDIT_ACCESS_CONTROL_CODE = 187;
45

  
45 46
	private final String DELETED = "DELETED";
46 47

  
47 48
	private LoadBalancer loadBalancer;
......
118 119
	//then parts of it may be null, so use a different
119 120
	//onClick in that condition
120 121
	private void setUpButtons(){
121
		setupButton(R.id.edit_loadbalancer_button, new OnClickListener() {
122
			@Override
123
			public void onClick(View v) {
124
				if(!loadBalancer.getStatus().contains(DELETED)){
125
					Intent editLoadBalancerIntent = new Intent(getContext(), EditLoadBalancerActivity.class);
126
					editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
127
					startActivityForResult(editLoadBalancerIntent, EDIT_LOAD_BALANCER_CODE);
128
				} else {
129
					showAlert(loadBalancer.getStatus(), "The load balancer cannot be updated.");
122
		if(loadBalancer != null){
123
			setupButton(R.id.edit_loadbalancer_button, new OnClickListener() {
124
				@Override
125
				public void onClick(View v) {
126
					if(!loadBalancer.getStatus().contains(DELETED)){
127
						Intent editLoadBalancerIntent = new Intent(getContext(), EditLoadBalancerActivity.class);
128
						editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
129
						startActivityForResult(editLoadBalancerIntent, EDIT_LOAD_BALANCER_CODE);
130
					} else {
131
						showAlert(loadBalancer.getStatus(), "The load balancer cannot be updated.");
132
					}
130 133
				}
131
			}
132
		});
134
			});
133 135

  
134 136

  
135
		setupButton(R.id.delete_loadbalancer_button, new OnClickListener() {
136
			@Override
137
			public void onClick(View v) {
138
				if(!loadBalancer.getStatus().contains(DELETED)){
139
					showDialog(R.id.view_server_delete_button);
140
				} else {
141
					showAlert(loadBalancer.getStatus(), "The load balancer cannot be deleted.");
137
			setupButton(R.id.delete_loadbalancer_button, new OnClickListener() {
138
				@Override
139
				public void onClick(View v) {
140
					if(!loadBalancer.getStatus().contains(DELETED)){
141
						showDialog(R.id.view_server_delete_button);
142
					} else {
143
						showAlert(loadBalancer.getStatus(), "The load balancer cannot be deleted.");
144
					}
142 145
				}
143
			}
144 146

  
145
		});
147
			});
146 148

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

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

  
173
		setupButton(R.id.session_persistence_button, new OnClickListener() {
174
			@Override
175
			public void onClick(View v) {
176
				if(!loadBalancer.getStatus().contains(DELETED)){
177
					if(!loadBalancer.getProtocol().equals("HTTP")){
178
						showAlert("Error", "Session Persistence cannot be enabled for protocols other than HTTP.");
172
			});
173
			setLogButtonText();
174

  
175
			setupButton(R.id.session_persistence_button, new OnClickListener() {
176
				@Override
177
				public void onClick(View v) {
178
					if(!loadBalancer.getStatus().contains(DELETED)){
179
						if(!loadBalancer.getProtocol().equals("HTTP")){
180
							showAlert("Error", "Session Persistence cannot be enabled for protocols other than HTTP.");
181
						} else {
182
							showDialog(R.id.session_persistence_button);
183
						}
179 184
					} else {
180
						showDialog(R.id.session_persistence_button);
185
						showAlert(loadBalancer.getStatus(), "Session Persistence cannot be edited.");	
181 186
					}
182
				} else {
183
					showAlert(loadBalancer.getStatus(), "Session Persistence cannot be edited.");	
184 187
				}
185
			}
186
		});
187
		setSessionButtonText();
188
		
189
		setupButton(R.id.connection_throttle_button, new OnClickListener() {
190
			@Override
191
			public void onClick(View v) {
192
				if(!loadBalancer.getStatus().contains(DELETED)){
193
					Intent editLoadBalancerIntent = new Intent(getContext(), ConnectionThrottleActivity.class);
194
					editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
195
					startActivityForResult(editLoadBalancerIntent, EDIT_THROTTLE_CODE);
196
				} else {
197
					showAlert(loadBalancer.getStatus(), "Connection Throttle cannot be edited.");
188
			});
189
			setSessionButtonText();
190

  
191
			setupButton(R.id.connection_throttle_button, new OnClickListener() {
192
				@Override
193
				public void onClick(View v) {
194
					if(!loadBalancer.getStatus().contains(DELETED)){
195
						Intent editLoadBalancerIntent = new Intent(getContext(), ConnectionThrottleActivity.class);
196
						editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
197
						startActivityForResult(editLoadBalancerIntent, EDIT_THROTTLE_CODE);
198
					} else {
199
						showAlert(loadBalancer.getStatus(), "Connection Throttle cannot be edited.");
200
					}
198 201
				}
199
			}
200
		});
202
			});
203

  
204
			setupButton(R.id.access_control_button, new OnClickListener() {
205
				@Override
206
				public void onClick(View v) {
207
					if(!loadBalancer.getStatus().contains(DELETED)){
208
						Intent editLoadBalancerIntent = new Intent(getContext(), AccessControlActivity.class);
209
						editLoadBalancerIntent.putExtra("loadBalancer", loadBalancer);
210
						startActivityForResult(editLoadBalancerIntent, EDIT_ACCESS_CONTROL_CODE);
211
					} else {
212
						showAlert(loadBalancer.getStatus(), "Access Control cannot be edited.");
213
					}
214
				}
215
			});
216
		}
201 217
	}
202 218

  
203 219
	@Override
......
349 365
			loadVirutalIpData();
350 366
		}
351 367
	}
352
	
368

  
353 369
	private String getPrettyAlgoName(String name){
354 370
		if(name == null || name.length() == 0){
355 371
			return "";

Also available in: Unified diff