Revision d8be1aef
b/.classpath | ||
---|---|---|
3 | 3 |
<classpathentry kind="src" path="gen"/> |
4 | 4 |
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> |
5 | 5 |
<classpathentry kind="src" path="src"/> |
6 |
<classpathentry kind="lib" path="lib/droid-fu-1.0-SNAPSHOT.jar"/> |
|
7 | 6 |
<classpathentry kind="output" path="bin"/> |
8 | 7 |
</classpath> |
b/.project | ||
---|---|---|
25 | 25 |
<arguments> |
26 | 26 |
</arguments> |
27 | 27 |
</buildCommand> |
28 |
<buildCommand> |
|
29 |
<name>net.sourceforge.metrics.builder</name> |
|
30 |
<arguments> |
|
31 |
</arguments> |
|
32 |
</buildCommand> |
|
28 | 33 |
</buildSpec> |
29 | 34 |
<natures> |
30 | 35 |
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> |
31 | 36 |
<nature>org.eclipse.jdt.core.javanature</nature> |
37 |
<nature>net.sourceforge.metrics.nature</nature> |
|
32 | 38 |
</natures> |
33 | 39 |
<filteredResources> |
34 | 40 |
<filter> |
b/res/layout/activity_choser.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/rack_bg_main"> |
|
3 |
<ImageView android:id="@+id/headerimage" android:layout_width="wrap_content" android:layout_height="75dip"></ImageView> |
|
4 |
<LinearLayout android:layout_weight="1" android:layout_height="300dip" android:layout_width="fill_parent"> |
|
5 |
<LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
6 |
<ImageButton android:layout_height="fill_parent" android:src="@drawable/serverbuttonmed" android:id="@+id/serverbutton" android:background="@android:color/transparent" android:layout_width="fill_parent"></ImageButton> |
|
7 |
</LinearLayout> |
|
8 |
<LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
9 |
<ImageButton android:layout_height="fill_parent" android:src="@drawable/filebuttonmed" android:id="@+id/filesbutton" android:background="@android:color/transparent" android:layout_width="fill_parent"></ImageButton> |
|
10 |
</LinearLayout> |
|
11 |
<LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
12 |
<ImageButton android:layout_height="fill_parent" android:src="@drawable/lbbuttonmed" android:id="@+id/loadbalancersbutton" android:background="@android:color/transparent" android:layout_width="fill_parent"></ImageButton> |
|
13 |
</LinearLayout> |
|
14 |
</LinearLayout> |
|
15 |
<LinearLayout android:layout_weight="1" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> |
|
16 |
<TextView android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="TextView" android:layout_width="wrap_content" android:id="@+id/textView1"></TextView> |
|
17 |
</LinearLayout> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="vertical" android:layout_height="fill_parent" |
|
4 |
android:layout_width="fill_parent" android:background="@drawable/rack_bg_main"> |
|
5 |
<ImageView android:id="@+id/headerimage" |
|
6 |
android:layout_width="wrap_content" android:layout_height="75dip"></ImageView> |
|
7 |
<LinearLayout android:layout_weight="1" |
|
8 |
android:layout_height="300dip" android:layout_width="fill_parent"> |
|
9 |
<LinearLayout android:layout_weight="1" |
|
10 |
android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
11 |
<ImageButton android:layout_height="fill_parent" |
|
12 |
android:src="@drawable/serverbuttonmed" android:id="@+id/serverbutton" |
|
13 |
android:background="@android:color/transparent" |
|
14 |
android:layout_width="fill_parent"></ImageButton> |
|
15 |
</LinearLayout> |
|
16 |
<LinearLayout android:layout_weight="1" |
|
17 |
android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
18 |
<ImageButton android:layout_height="fill_parent" |
|
19 |
android:src="@drawable/filebuttonmed" android:id="@+id/filesbutton" |
|
20 |
android:background="@android:color/transparent" |
|
21 |
android:layout_width="fill_parent"></ImageButton> |
|
22 |
</LinearLayout> |
|
23 |
<LinearLayout android:layout_weight="1" |
|
24 |
android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
25 |
<ImageButton android:layout_height="fill_parent" |
|
26 |
android:src="@drawable/lbbuttonmed" android:id="@+id/loadbalancersbutton" |
|
27 |
android:background="@android:color/transparent" |
|
28 |
android:layout_width="fill_parent"></ImageButton> |
|
29 |
</LinearLayout> |
|
30 |
</LinearLayout> |
|
31 |
<LinearLayout android:layout_weight="1" |
|
32 |
android:orientation="vertical" android:layout_height="fill_parent" |
|
33 |
android:layout_width="fill_parent"> |
|
34 |
<TextView android:layout_height="wrap_content" |
|
35 |
android:layout_gravity="center_horizontal" android:text="TextView" |
|
36 |
android:layout_width="wrap_content" android:id="@+id/textView1"></TextView> |
|
37 |
</LinearLayout> |
|
18 | 38 |
</LinearLayout> |
b/res/layout/list_servers.xml | ||
---|---|---|
4 | 4 |
android:layout_height="fill_parent" android:background="@drawable/rack_bg_transparent"> |
5 | 5 |
<ImageView android:id="@+id/headerimage" |
6 | 6 |
android:layout_width="wrap_content" android:layout_height="80dip"></ImageView> |
7 |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
7 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
8 | 8 |
android:layout_width="fill_parent" android:layout_height="fill_parent"> |
9 | 9 |
<ListView android:id="@+id/android:list" |
10 |
android:layout_width="fill_parent" android:layout_height="fill_parent" |
|
11 |
android:cacheColorHint="@android:color/transparent" /> |
|
12 |
</ScrollView> |
|
10 |
android:layout_width="fill_parent" android:cacheColorHint="@android:color/transparent" android:layout_height="417dp"/> |
|
11 |
</LinearLayout> |
|
13 | 12 |
<ImageView android:id="@+id/headerimage" |
14 | 13 |
android:layout_width="wrap_content" android:layout_height="25dip"></ImageView> |
15 | 14 |
</LinearLayout> |
b/src/com/rackspace/cloud/loadbalancer/api/client/LoadBalancerManager.java | ||
---|---|---|
16 | 16 |
import org.apache.http.client.ClientProtocolException; |
17 | 17 |
import org.apache.http.client.methods.HttpGet; |
18 | 18 |
import org.apache.http.impl.client.BasicResponseHandler; |
19 |
import org.apache.http.impl.client.DefaultHttpClient; |
|
20 | 19 |
import org.xml.sax.InputSource; |
21 | 20 |
import org.xml.sax.SAXException; |
22 | 21 |
import org.xml.sax.XMLReader; |
23 | 22 |
|
23 |
import android.content.Context; |
|
24 | 24 |
import android.util.Log; |
25 | 25 |
|
26 |
import com.rackspace.cloud.files.api.client.CustomHttpClient; |
|
26 | 27 |
import com.rackspace.cloud.loadbalancer.api.parsers.CloudLoadBalancersFaultXMLParser; |
27 | 28 |
import com.rackspace.cloud.loadbalancer.api.parsers.LoadBalancersXmlParser; |
28 | 29 |
import com.rackspace.cloud.loadbalancers.api.client.http.LoadBalancersException; |
29 | 30 |
import com.rackspace.cloud.servers.api.client.Account; |
30 | 31 |
|
31 | 32 |
public class LoadBalancerManager extends EntityManager { |
32 |
|
|
33 |
public LoadBalancer getLoadBalncerById(long id) throws LoadBalancersException { |
|
33 |
private Context context; |
|
34 |
|
|
35 |
public LoadBalancerManager(Context context) { |
|
36 |
this.context = context; |
|
37 |
} |
|
38 |
|
|
39 |
public LoadBalancer getLoadBalancerById(long id) throws LoadBalancersException { |
|
34 | 40 |
//TODO:grab from ord and combine list |
35 |
DefaultHttpClient httpclient = new DefaultHttpClient();
|
|
41 |
CustomHttpClient httpclient = new CustomHttpClient(context);
|
|
36 | 42 |
//TODO: check for uk or us |
37 | 43 |
HttpGet get = new HttpGet(Account.getAccount().getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers/" + id); |
38 | 44 |
LoadBalancer loadBalancer = new LoadBalancer(); |
39 |
|
|
45 |
|
|
40 | 46 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
41 | 47 |
get.addHeader("Accept", "application/xml"); |
42 |
|
|
48 |
|
|
43 | 49 |
try { |
44 | 50 |
HttpResponse resp = httpclient.execute(get); |
45 |
BasicResponseHandler responseHandler = new BasicResponseHandler();
|
|
46 |
String body = responseHandler.handleResponse(resp);
|
|
47 |
Log.i("LB PARSE", body);
|
|
48 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) {
|
|
49 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser();
|
|
50 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
51 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
52 |
xmlReader.setContentHandler(loadBalancersXMLParser);
|
|
53 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
54 |
loadBalancer = loadBalancersXMLParser.getLoadBalancer();
|
|
55 |
} else {
|
|
56 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser();
|
|
57 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
58 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
59 |
xmlReader.setContentHandler(parser);
|
|
60 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
61 |
LoadBalancersException cse = parser.getException();
|
|
62 |
throw cse;
|
|
63 |
}
|
|
51 |
BasicResponseHandler responseHandler = new BasicResponseHandler();
|
|
52 |
String body = responseHandler.handleResponse(resp);
|
|
53 |
Log.i("LB PARSE", body);
|
|
54 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) {
|
|
55 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser();
|
|
56 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
57 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
58 |
xmlReader.setContentHandler(loadBalancersXMLParser);
|
|
59 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
60 |
loadBalancer = loadBalancersXMLParser.getLoadBalancer();
|
|
61 |
} else {
|
|
62 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser();
|
|
63 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
64 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
65 |
xmlReader.setContentHandler(parser);
|
|
66 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
67 |
LoadBalancersException cse = parser.getException();
|
|
68 |
throw cse;
|
|
69 |
}
|
|
64 | 70 |
} catch (ClientProtocolException e) { |
65 | 71 |
LoadBalancersException cse = new LoadBalancersException(); |
66 | 72 |
cse.setMessage(e.getLocalizedMessage()); |
... | ... | |
82 | 88 |
cse.setMessage(e.getLocalizedMessage()); |
83 | 89 |
throw cse; |
84 | 90 |
} |
85 |
|
|
91 |
|
|
86 | 92 |
return loadBalancer; |
87 | 93 |
} |
88 | 94 |
|
89 |
public ArrayList<LoadBalancer> createList() throws LoadBalancersException { |
|
95 |
public ArrayList<LoadBalancer> createList() throws LoadBalancersException{ |
|
96 |
ArrayList<LoadBalancer> loadBalancers = createSublist(Account.getAccount().getLoadBalancerORDUrl()); |
|
97 |
loadBalancers.addAll(createSublist(Account.getAccount().getLoadBalancerDFWUrl())); |
|
98 |
return loadBalancers; |
|
99 |
} |
|
100 |
|
|
101 |
public ArrayList<LoadBalancer> createSublist(String regionUrl) throws LoadBalancersException { |
|
90 | 102 |
//TODO:grab from ord and combine list |
91 |
DefaultHttpClient httpclient = new DefaultHttpClient();
|
|
103 |
CustomHttpClient httpclient = new CustomHttpClient(context);
|
|
92 | 104 |
//TODO:check for uk or us |
93 |
HttpGet get = new HttpGet(Account.getAccount().getLoadBalancerDFWUrl() + Account.getAccount().getAccountId() + "/loadbalancers");
|
|
105 |
HttpGet get = new HttpGet(regionUrl + Account.getAccount().getAccountId() + "/loadbalancers");
|
|
94 | 106 |
ArrayList<LoadBalancer> loadBalancers = new ArrayList<LoadBalancer>(); |
95 |
|
|
107 |
|
|
96 | 108 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
97 | 109 |
get.addHeader("Accept", "application/xml"); |
98 |
|
|
110 |
|
|
99 | 111 |
try { |
100 | 112 |
HttpResponse resp = httpclient.execute(get); |
101 |
BasicResponseHandler responseHandler = new BasicResponseHandler();
|
|
102 |
String body = responseHandler.handleResponse(resp);
|
|
103 |
Log.i("LB PARSE", body);
|
|
104 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) {
|
|
105 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser();
|
|
106 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
107 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
108 |
xmlReader.setContentHandler(loadBalancersXMLParser);
|
|
109 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
110 |
loadBalancers = loadBalancersXMLParser.getLoadBalancers();
|
|
111 |
} else {
|
|
112 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser();
|
|
113 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
114 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
115 |
xmlReader.setContentHandler(parser);
|
|
116 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
117 |
LoadBalancersException cse = parser.getException();
|
|
118 |
throw cse;
|
|
119 |
}
|
|
113 |
BasicResponseHandler responseHandler = new BasicResponseHandler();
|
|
114 |
String body = responseHandler.handleResponse(resp);
|
|
115 |
Log.i("LB PARSE", body);
|
|
116 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 202) {
|
|
117 |
LoadBalancersXmlParser loadBalancersXMLParser = new LoadBalancersXmlParser();
|
|
118 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
119 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
120 |
xmlReader.setContentHandler(loadBalancersXMLParser);
|
|
121 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
122 |
loadBalancers = loadBalancersXMLParser.getLoadBalancers();
|
|
123 |
} else {
|
|
124 |
CloudLoadBalancersFaultXMLParser parser = new CloudLoadBalancersFaultXMLParser();
|
|
125 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
|
126 |
XMLReader xmlReader = saxParser.getXMLReader();
|
|
127 |
xmlReader.setContentHandler(parser);
|
|
128 |
xmlReader.parse(new InputSource(new StringReader(body)));
|
|
129 |
LoadBalancersException cse = parser.getException();
|
|
130 |
throw cse;
|
|
131 |
}
|
|
120 | 132 |
} catch (ClientProtocolException e) { |
121 | 133 |
LoadBalancersException cse = new LoadBalancersException(); |
122 | 134 |
cse.setMessage(e.getLocalizedMessage()); |
b/src/com/rackspacecloud/android/ListLoadBalancersActivity.java | ||
---|---|---|
5 | 5 |
import android.app.AlertDialog; |
6 | 6 |
import android.app.ListActivity; |
7 | 7 |
import android.app.ProgressDialog; |
8 |
import android.content.Context; |
|
8 | 9 |
import android.content.DialogInterface; |
9 | 10 |
import android.content.Intent; |
10 | 11 |
import android.os.AsyncTask; |
... | ... | |
25 | 26 |
import com.rackspace.cloud.loadbalancers.api.client.http.LoadBalancersException; |
26 | 27 |
|
27 | 28 |
public class ListLoadBalancersActivity extends ListActivity { |
29 |
|
|
28 | 30 |
private LoadBalancer[] loadBalancers; |
31 |
private Context context; |
|
29 | 32 |
ProgressDialog pDialog; |
30 | 33 |
|
31 | 34 |
@Override |
... | ... | |
42 | 45 |
} |
43 | 46 |
|
44 | 47 |
private void restoreState(Bundle state) { |
48 |
context = getApplicationContext(); |
|
45 | 49 |
if (state != null && state.containsKey("loadBalancers")) { |
46 | 50 |
loadBalancers = (LoadBalancer[]) state |
47 | 51 |
.getSerializable("loadBalancers"); |
... | ... | |
137 | 141 |
protected ArrayList<LoadBalancer> doInBackground(Void... arg0) { |
138 | 142 |
ArrayList<LoadBalancer> loadBalancers = null; |
139 | 143 |
try { |
140 |
loadBalancers = (new LoadBalancerManager()).createList(); |
|
144 |
loadBalancers = (new LoadBalancerManager(context)).createList();
|
|
141 | 145 |
} catch (LoadBalancersException e) { |
142 | 146 |
exception = e; |
143 | 147 |
} |
b/src/com/rackspacecloud/android/ViewLoadBalancerActivity.java | ||
---|---|---|
8 | 8 |
import android.app.Activity; |
9 | 9 |
import android.app.AlertDialog; |
10 | 10 |
import android.app.ProgressDialog; |
11 |
import android.content.Context; |
|
11 | 12 |
import android.content.DialogInterface; |
12 | 13 |
import android.os.AsyncTask; |
13 | 14 |
import android.os.Bundle; |
... | ... | |
20 | 21 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer; |
21 | 22 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancerManager; |
22 | 23 |
import com.rackspace.cloud.loadbalancers.api.client.http.LoadBalancersException; |
24 |
import com.rackspace.cloud.servers.api.client.Account; |
|
23 | 25 |
|
24 | 26 |
public class ViewLoadBalancerActivity extends Activity { |
25 | 27 |
private LoadBalancer loadBalancer; |
26 | 28 |
private LoadBalancer returnLoadBalancer; |
29 |
private Context context; |
|
27 | 30 |
ProgressDialog pDialog; |
28 | 31 |
|
29 | 32 |
@Override |
... | ... | |
43 | 46 |
} |
44 | 47 |
|
45 | 48 |
private void restoreState(Bundle state) { |
49 |
context = getApplicationContext(); |
|
46 | 50 |
if (state != null && state.containsKey("loadBalancer")) { |
47 | 51 |
loadBalancer = (LoadBalancer) state.getSerializable("loadBalancer"); |
48 | 52 |
} |
... | ... | |
114 | 118 |
@Override |
115 | 119 |
protected LoadBalancer doInBackground(Void... arg0) { |
116 | 120 |
try { |
117 |
returnLoadBalancer = (new LoadBalancerManager()).getLoadBalncerById(Integer.parseInt(loadBalancer.getId()));
|
|
121 |
returnLoadBalancer = (new LoadBalancerManager(context)).getLoadBalancerById(Integer.parseInt(loadBalancer.getId()));
|
|
118 | 122 |
} catch (NumberFormatException e) { |
119 | 123 |
// we're polling, so need to show exceptions |
120 | 124 |
} catch (LoadBalancersException e) { |
... | ... | |
141 | 145 |
@Override |
142 | 146 |
protected LoadBalancer doInBackground(Void... arg0) { |
143 | 147 |
try { |
144 |
returnLoadBalancer = (new LoadBalancerManager()).getLoadBalncerById(Integer.parseInt(loadBalancer.getId()));
|
|
148 |
returnLoadBalancer = (new LoadBalancerManager(context)).getLoadBalancerById(Integer.parseInt(loadBalancer.getId()));
|
|
145 | 149 |
} catch (LoadBalancersException e) { |
146 | 150 |
exception = e; |
147 | 151 |
} |
Also available in: Unified diff