Revision 3d6041e8
b/AndroidManifest.xml | ||
---|---|---|
32 | 32 |
<category android:name="android.intent.category.APPLICATION"/> |
33 | 33 |
</intent-filter> |
34 | 34 |
</activity> |
35 |
<activity android:name=".AddContainerActivity" android:label="@string/app_name"> |
|
36 |
<intent-filter> |
|
37 |
<action android:name="android.intent.action.MAIN"/> |
|
38 |
<category android:name="android.intent.category.APPLICATION"/> |
|
39 |
</intent-filter> |
|
40 |
</activity> |
|
35 | 41 |
|
36 | 42 |
<activity android:name=".ViewServerActivity" android:label="@string/app_name"> |
37 | 43 |
<intent-filter> |
... | ... | |
39 | 45 |
<category android:name="android.intent.category.APPLICATION"/> |
40 | 46 |
</intent-filter> |
41 | 47 |
</activity> |
42 |
|
|
48 |
<activity android:name=".ViewServerActivity" android:label="@string/app_name"> |
|
49 |
<intent-filter> |
|
50 |
<action android:name="android.intent.action.MAIN"/> |
|
51 |
<category android:name="android.intent.category.APPLICATION"/> |
|
52 |
</intent-filter> |
|
53 |
</activity> |
|
54 |
<activity android:name=".ContainerObjectsActivity" android:label="@string/app_name"> |
|
55 |
<intent-filter> |
|
56 |
<action android:name="android.intent.action.MAIN"/> |
|
57 |
<category android:name="android.intent.category.APPLICATION"/> |
|
58 |
</intent-filter> |
|
59 |
</activity> |
|
60 |
<activity android:name=".ListContainerActivity" android:label="@string/app_name"> |
|
61 |
<intent-filter> |
|
62 |
<action android:name="android.intent.action.MAIN"/> |
|
63 |
<category android:name="android.intent.category.APPLICATION"/> |
|
64 |
</intent-filter> |
|
65 |
</activity> |
|
66 |
<activity android:name=".ContainerObjectDetails" android:label="@string/app_name"> |
|
67 |
<intent-filter> |
|
68 |
<action android:name="android.intent.action.MAIN"/> |
|
69 |
<category android:name="android.intent.category.APPLICATION"/> |
|
70 |
</intent-filter> |
|
71 |
</activity> |
|
72 |
|
|
73 |
<activity android:name=".EnableCDNActivity" android:label="@string/app_name"> |
|
74 |
<intent-filter> |
|
75 |
<action android:name="android.intent.action.MAIN"/> |
|
76 |
<category android:name="android.intent.category.APPLICATION"/> |
|
77 |
</intent-filter> |
|
78 |
</activity> |
|
79 |
|
|
43 | 80 |
|
44 | 81 |
</application> |
45 |
<uses-sdk android:minSdkVersion="4" />
|
|
82 |
<uses-sdk android:minSdkVersion="2" />
|
|
46 | 83 |
|
47 | 84 |
<uses-permission android:name="android.permission.INTERNET"></uses-permission> |
48 | 85 |
</manifest> |
b/gen/com/rackspacecloud/android/R.java | ||
---|---|---|
8 | 8 |
package com.rackspacecloud.android; |
9 | 9 |
|
10 | 10 |
public final class R { |
11 |
public static final class array { |
|
12 |
public static final int cdn=0x7f040002; |
|
13 |
public static final int logRet=0x7f040001; |
|
14 |
public static final int ttl=0x7f040000; |
|
15 |
} |
|
11 | 16 |
public static final class attr { |
12 | 17 |
} |
13 | 18 |
public static final class drawable { |
... | ... | |
15 | 20 |
public static final int alert_dialog_icon=0x7f020001; |
16 | 21 |
public static final int arch_icon=0x7f020002; |
17 | 22 |
public static final int arch_large=0x7f020003; |
18 |
public static final int centos_icon=0x7f020004; |
|
19 |
public static final int centos_large=0x7f020005; |
|
20 |
public static final int cloudfiles=0x7f020006; |
|
21 |
public static final int cloudservers_icon=0x7f020007; |
|
22 |
public static final int cloudservers_large=0x7f020008; |
|
23 |
public static final int debian_icon=0x7f020009; |
|
24 |
public static final int debian_large=0x7f02000a; |
|
25 |
public static final int fedora_icon=0x7f02000b; |
|
26 |
public static final int fedora_large=0x7f02000c; |
|
27 |
public static final int gentoo_icon=0x7f02000d; |
|
28 |
public static final int gentoo_large=0x7f02000e; |
|
29 |
public static final int icon=0x7f02000f; |
|
30 |
public static final int rackspace60=0x7f020010; |
|
31 |
public static final int rackspacecloud=0x7f020011; |
|
32 |
public static final int redhat_icon=0x7f020012; |
|
33 |
public static final int redhat_large=0x7f020013; |
|
34 |
public static final int refresh_button=0x7f020014; |
|
35 |
public static final int settings_button=0x7f020015; |
|
36 |
public static final int ubuntu_icon=0x7f020016; |
|
37 |
public static final int ubuntu_large=0x7f020017; |
|
38 |
public static final int ukflag=0x7f020018; |
|
39 |
public static final int usflag=0x7f020019; |
|
40 |
public static final int windows_icon=0x7f02001a; |
|
41 |
public static final int windows_large=0x7f02001b; |
|
23 |
public static final int cdncontainer=0x7f020004; |
|
24 |
public static final int centos_icon=0x7f020005; |
|
25 |
public static final int centos_large=0x7f020006; |
|
26 |
public static final int cloudfiles=0x7f020007; |
|
27 |
public static final int cloudservers_icon=0x7f020008; |
|
28 |
public static final int cloudservers_large=0x7f020009; |
|
29 |
public static final int container=0x7f02000a; |
|
30 |
public static final int debian_icon=0x7f02000b; |
|
31 |
public static final int debian_large=0x7f02000c; |
|
32 |
public static final int fedora_icon=0x7f02000d; |
|
33 |
public static final int fedora_large=0x7f02000e; |
|
34 |
public static final int gentoo_icon=0x7f02000f; |
|
35 |
public static final int gentoo_large=0x7f020010; |
|
36 |
public static final int icon=0x7f020011; |
|
37 |
public static final int rackspace60=0x7f020012; |
|
38 |
public static final int rackspacecloud=0x7f020013; |
|
39 |
public static final int redhat_icon=0x7f020014; |
|
40 |
public static final int redhat_large=0x7f020015; |
|
41 |
public static final int refresh_button=0x7f020016; |
|
42 |
public static final int settings_button=0x7f020017; |
|
43 |
public static final int ubuntu_icon=0x7f020018; |
|
44 |
public static final int ubuntu_large=0x7f020019; |
|
45 |
public static final int ukflag=0x7f02001a; |
|
46 |
public static final int usflag=0x7f02001b; |
|
47 |
public static final int windows_icon=0x7f02001c; |
|
48 |
public static final int windows_large=0x7f02001d; |
|
42 | 49 |
} |
43 | 50 |
public static final class id { |
44 |
public static final int add_server=0x7f060021; |
|
45 |
public static final int button=0x7f06000e; |
|
46 |
public static final int flavor_spinner=0x7f060002; |
|
47 |
public static final int icon=0x7f060006; |
|
48 |
public static final int image_spinner=0x7f060001; |
|
49 |
public static final int label=0x7f060007; |
|
50 |
public static final int list=0x7f060009; |
|
51 |
public static final int loading_label=0x7f06000b; |
|
52 |
public static final int loading_progress_bar=0x7f06000a; |
|
53 |
public static final int login_apikey=0x7f06000d; |
|
54 |
public static final int login_authenticating_label=0x7f060010; |
|
55 |
public static final int login_progress_bar=0x7f06000f; |
|
56 |
public static final int login_username=0x7f06000c; |
|
57 |
public static final int no_servers_label=0x7f060011; |
|
58 |
public static final int no_servers_sublabel=0x7f060012; |
|
59 |
public static final int refresh=0x7f060022; |
|
60 |
public static final int save_button=0x7f060003; |
|
61 |
public static final int save_server_progress_bar=0x7f060004; |
|
62 |
public static final int saving_server_label=0x7f060005; |
|
63 |
public static final int server_name=0x7f060000; |
|
64 |
public static final int sublabel=0x7f060008; |
|
65 |
public static final int tab1=0x7f060014; |
|
66 |
public static final int tab2=0x7f060015; |
|
67 |
public static final int tabhost=0x7f060013; |
|
68 |
public static final int view_server_delete_button=0x7f060020; |
|
69 |
public static final int view_server_disk=0x7f06001b; |
|
70 |
public static final int view_server_hard_reboot_button=0x7f06001e; |
|
71 |
public static final int view_server_layout=0x7f060016; |
|
72 |
public static final int view_server_memory=0x7f06001a; |
|
73 |
public static final int view_server_name=0x7f060018; |
|
74 |
public static final int view_server_os=0x7f060019; |
|
75 |
public static final int view_server_os_logo=0x7f060017; |
|
76 |
public static final int view_server_resize_button=0x7f06001f; |
|
77 |
public static final int view_server_soft_reboot_button=0x7f06001d; |
|
78 |
public static final int view_server_status=0x7f06001c; |
|
51 |
public static final int add_container=0x7f070035; |
|
52 |
public static final int add_server=0x7f070037; |
|
53 |
public static final int button=0x7f070018; |
|
54 |
public static final int cdn_spinner=0x7f070009; |
|
55 |
public static final int container_name=0x7f070000; |
|
56 |
public static final int delete_container=0x7f070039; |
|
57 |
public static final int delete_object=0x7f070036; |
|
58 |
public static final int disable_button=0x7f07000d; |
|
59 |
public static final int enable_button=0x7f07000c; |
|
60 |
public static final int enable_cdn=0x7f070038; |
|
61 |
public static final int flavor_spinner=0x7f070006; |
|
62 |
public static final int icon=0x7f07000e; |
|
63 |
public static final int image_spinner=0x7f070005; |
|
64 |
public static final int label=0x7f07000f; |
|
65 |
public static final int list=0x7f070013; |
|
66 |
public static final int loading_label=0x7f070015; |
|
67 |
public static final int loading_progress_bar=0x7f070014; |
|
68 |
public static final int log_retention_spinner=0x7f07000b; |
|
69 |
public static final int login_apikey=0x7f070017; |
|
70 |
public static final int login_authenticating_label=0x7f07001a; |
|
71 |
public static final int login_progress_bar=0x7f070019; |
|
72 |
public static final int login_username=0x7f070016; |
|
73 |
public static final int no_files_label=0x7f07001b; |
|
74 |
public static final int no_files_sublabel=0x7f07001c; |
|
75 |
public static final int no_servers_label=0x7f07001d; |
|
76 |
public static final int no_servers_sublabel=0x7f07001e; |
|
77 |
public static final int refresh=0x7f070034; |
|
78 |
public static final int save_button=0x7f070001; |
|
79 |
public static final int save_container_progress_bar=0x7f070002; |
|
80 |
public static final int save_server_progress_bar=0x7f070007; |
|
81 |
public static final int saving_container_label=0x7f070003; |
|
82 |
public static final int saving_server_label=0x7f070008; |
|
83 |
public static final int server_name=0x7f070004; |
|
84 |
public static final int sublabel=0x7f070010; |
|
85 |
public static final int sublabel1=0x7f070011; |
|
86 |
public static final int sublabel2=0x7f070012; |
|
87 |
public static final int tab1=0x7f070020; |
|
88 |
public static final int tab2=0x7f070021; |
|
89 |
public static final int tabhost=0x7f07001f; |
|
90 |
public static final int ttl_spinner=0x7f07000a; |
|
91 |
public static final int view_container_name=0x7f070024; |
|
92 |
public static final int view_content_type=0x7f070027; |
|
93 |
public static final int view_file_bytes=0x7f070025; |
|
94 |
public static final int view_file_cdnurl=0x7f070029; |
|
95 |
public static final int view_file_hash=0x7f070026; |
|
96 |
public static final int view_file_modification=0x7f070028; |
|
97 |
public static final int view_object_os_logo=0x7f070023; |
|
98 |
public static final int view_server_delete_button=0x7f070033; |
|
99 |
public static final int view_server_disk=0x7f07002e; |
|
100 |
public static final int view_server_hard_reboot_button=0x7f070031; |
|
101 |
public static final int view_server_layout=0x7f070022; |
|
102 |
public static final int view_server_memory=0x7f07002d; |
|
103 |
public static final int view_server_name=0x7f07002b; |
|
104 |
public static final int view_server_os=0x7f07002c; |
|
105 |
public static final int view_server_os_logo=0x7f07002a; |
|
106 |
public static final int view_server_resize_button=0x7f070032; |
|
107 |
public static final int view_server_soft_reboot_button=0x7f070030; |
|
108 |
public static final int view_server_status=0x7f07002f; |
|
79 | 109 |
} |
80 | 110 |
public static final class layout { |
81 |
public static final int createserver=0x7f030000; |
|
82 |
public static final int listservercell=0x7f030001; |
|
83 |
public static final int listservers=0x7f030002; |
|
84 |
public static final int loadingcell=0x7f030003; |
|
85 |
public static final int main=0x7f030004; |
|
86 |
public static final int noserverscell=0x7f030005; |
|
87 |
public static final int tabview=0x7f030006; |
|
88 |
public static final int viewserver=0x7f030007; |
|
111 |
public static final int createcontainer=0x7f030000; |
|
112 |
public static final int createserver=0x7f030001; |
|
113 |
public static final int enable_cdn_container=0x7f030002; |
|
114 |
public static final int listcontainerobjectcell=0x7f030003; |
|
115 |
public static final int listcontainerscell=0x7f030004; |
|
116 |
public static final int listservercell=0x7f030005; |
|
117 |
public static final int listservers=0x7f030006; |
|
118 |
public static final int loadingcell=0x7f030007; |
|
119 |
public static final int main=0x7f030008; |
|
120 |
public static final int nofilescell=0x7f030009; |
|
121 |
public static final int noserverscell=0x7f03000a; |
|
122 |
public static final int noviewfilescell=0x7f03000b; |
|
123 |
public static final int tabview=0x7f03000c; |
|
124 |
public static final int viewobject=0x7f03000d; |
|
125 |
public static final int viewserver=0x7f03000e; |
|
89 | 126 |
} |
90 | 127 |
public static final class menu { |
91 |
public static final int servers_list_menu=0x7f050000; |
|
128 |
public static final int cdn_container_list_menu=0x7f060000; |
|
129 |
public static final int container_list_menu=0x7f060001; |
|
130 |
public static final int container_object_list_menu=0x7f060002; |
|
131 |
public static final int servers_list_menu=0x7f060003; |
|
132 |
public static final int view_cdn_object_list_menu=0x7f060004; |
|
133 |
public static final int view_container_object_list_menu=0x7f060005; |
|
92 | 134 |
} |
93 | 135 |
public static final class string { |
94 |
public static final int apikey=0x7f040003;
|
|
95 |
public static final int app_name=0x7f040001;
|
|
96 |
public static final int authenticating=0x7f040005;
|
|
97 |
public static final int fields_missing=0x7f040006;
|
|
98 |
public static final int hello=0x7f040000;
|
|
99 |
public static final int login=0x7f040004;
|
|
100 |
public static final int ok=0x7f040008;
|
|
101 |
public static final int username=0x7f040002;
|
|
102 |
public static final int username_and_apikey_required=0x7f040007;
|
|
136 |
public static final int apikey=0x7f050003;
|
|
137 |
public static final int app_name=0x7f050001;
|
|
138 |
public static final int authenticating=0x7f050005;
|
|
139 |
public static final int fields_missing=0x7f050006;
|
|
140 |
public static final int hello=0x7f050000;
|
|
141 |
public static final int login=0x7f050004;
|
|
142 |
public static final int ok=0x7f050008;
|
|
143 |
public static final int username=0x7f050002;
|
|
144 |
public static final int username_and_apikey_required=0x7f050007;
|
|
103 | 145 |
} |
104 | 146 |
} |
b/res/layout/createcontainer.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="fill_parent" |
|
6 |
> |
|
7 |
|
|
8 |
<TextView |
|
9 |
android:layout_width="fill_parent" |
|
10 |
android:layout_height="wrap_content" |
|
11 |
android:layout_marginLeft="22dip" |
|
12 |
android:text="Container Name" |
|
13 |
/> |
|
14 |
<EditText android:id="@+id/container_name" |
|
15 |
android:layout_height="wrap_content" |
|
16 |
android:layout_width="fill_parent" |
|
17 |
android:layout_marginLeft="22dip" |
|
18 |
android:layout_marginRight="30dip" |
|
19 |
android:scrollHorizontally="true" |
|
20 |
android:autoText="false" |
|
21 |
android:capitalize="none" |
|
22 |
android:gravity="fill_horizontal" |
|
23 |
android:singleLine="true" |
|
24 |
android:inputType="textNoSuggestions" |
|
25 |
android:imeOptions="actionNext" |
|
26 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
27 |
/> |
|
28 |
<Button xmlns:android="http://schemas.android.com/apk/res/android" |
|
29 |
android:id="@+id/save_button" |
|
30 |
android:text="Save" |
|
31 |
android:layout_width="100dip" |
|
32 |
android:layout_height="wrap_content" |
|
33 |
android:layout_gravity="left" |
|
34 |
android:layout_marginLeft="20dip" |
|
35 |
android:layout_marginTop="10dip" |
|
36 |
/> |
|
37 |
|
|
38 |
<ProgressBar android:id="@+id/save_container_progress_bar" |
|
39 |
android:layout_width="30dip" |
|
40 |
android:layout_height="30dip" |
|
41 |
android:layout_marginLeft="130dip" |
|
42 |
android:layout_marginTop="-42dip" |
|
43 |
android:visibility="invisible" |
|
44 |
/> |
|
45 |
|
|
46 |
<TextView android:id="@+id/saving_container_label" |
|
47 |
android:layout_width="fill_parent" |
|
48 |
android:layout_height="wrap_content" |
|
49 |
android:layout_marginLeft="172dip" |
|
50 |
android:layout_marginTop="-28dip" |
|
51 |
android:visibility="invisible" |
|
52 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
53 |
android:text="Saving..." |
|
54 |
/> |
|
55 |
</LinearLayout> |
b/res/layout/enable_cdn_container.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent"> |
|
5 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
6 |
android:orientation="vertical" |
|
7 |
android:layout_width="fill_parent" |
|
8 |
android:layout_height="fill_parent" |
|
9 |
> |
|
10 |
<TextView |
|
11 |
android:layout_width="fill_parent" |
|
12 |
android:layout_height="wrap_content" |
|
13 |
android:layout_marginLeft="22dip" |
|
14 |
android:text="CDN: leave true if this is the initial set-up " |
|
15 |
/> |
|
16 |
<Spinner xmlns:android="http://schemas.android.com/apk/res/android" |
|
17 |
android:id="@+id/cdn_spinner" |
|
18 |
android:layout_height="wrap_content" |
|
19 |
android:layout_width="fill_parent" |
|
20 |
android:drawSelectorOnTop="true" |
|
21 |
android:layout_marginLeft="26dip" |
|
22 |
android:layout_marginRight="30dip"/> |
|
23 |
|
|
24 |
<TextView |
|
25 |
android:layout_width="fill_parent" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_marginLeft="22dip" |
|
28 |
android:text="TTL Expiration" |
|
29 |
/> |
|
30 |
<Spinner xmlns:android="http://schemas.android.com/apk/res/android" |
|
31 |
android:id="@+id/ttl_spinner" |
|
32 |
android:layout_height="wrap_content" |
|
33 |
android:layout_width="fill_parent" |
|
34 |
android:drawSelectorOnTop="true" |
|
35 |
android:layout_marginLeft="26dip" |
|
36 |
android:layout_marginRight="30dip" |
|
37 |
/> |
|
38 |
<TextView |
|
39 |
android:layout_width="fill_parent" |
|
40 |
android:layout_height="wrap_content" |
|
41 |
android:layout_marginLeft="22dip" |
|
42 |
android:text="Log Retention" |
|
43 |
/> |
|
44 |
<Spinner xmlns:android="http://schemas.android.com/apk/res/android" |
|
45 |
android:id="@+id/log_retention_spinner" |
|
46 |
android:layout_height="wrap_content" |
|
47 |
android:layout_width="fill_parent" |
|
48 |
android:drawSelectorOnTop="true" |
|
49 |
android:layout_marginLeft="26dip" |
|
50 |
android:layout_marginRight="30dip" |
|
51 |
/> |
|
52 |
<Button xmlns:android="http://schemas.android.com/apk/res/android" |
|
53 |
android:id="@+id/enable_button" |
|
54 |
android:text="Enable" |
|
55 |
android:layout_width="100dip" |
|
56 |
android:layout_height="wrap_content" |
|
57 |
android:layout_gravity="left" |
|
58 |
android:layout_marginLeft="20dip" |
|
59 |
android:layout_marginTop="10dip" |
|
60 |
/> |
|
61 |
<TextView |
|
62 |
android:layout_width="fill_parent" |
|
63 |
android:layout_height="wrap_content" |
|
64 |
android:layout_marginLeft="22dip" |
|
65 |
android:text="Click here to disable, change attributes, or enable a previously enabled CDN container. |
|
66 |
If you wish to disable a container choose false from the CDN spinner." |
|
67 |
/> |
|
68 |
|
|
69 |
<Button xmlns:android="http://schemas.android.com/apk/res/android" |
|
70 |
android:id="@+id/disable_button" |
|
71 |
android:text="Change Attributes" |
|
72 |
android:layout_width="100dip" |
|
73 |
android:layout_height="wrap_content" |
|
74 |
android:layout_gravity="left" |
|
75 |
android:layout_marginLeft="20dip" |
|
76 |
android:layout_marginTop="10dip" |
|
77 |
/> |
|
78 |
<ProgressBar android:id="@+id/save_container_progress_bar" |
|
79 |
android:layout_width="30dip" |
|
80 |
android:layout_height="30dip" |
|
81 |
android:layout_marginLeft="130dip" |
|
82 |
android:layout_marginTop="-42dip" |
|
83 |
android:visibility="invisible" |
|
84 |
/> |
|
85 |
|
|
86 |
<TextView android:id="@+id/saving_container_label" |
|
87 |
android:layout_width="fill_parent" |
|
88 |
android:layout_height="wrap_content" |
|
89 |
android:layout_marginLeft="172dip" |
|
90 |
android:layout_marginTop="-28dip" |
|
91 |
android:visibility="invisible" |
|
92 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
93 |
android:text="Saving..." |
|
94 |
/> |
|
95 |
</LinearLayout> |
|
96 |
</ScrollView> |
b/res/layout/listcontainerobjectcell.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="horizontal" |
|
4 |
android:layout_width="fill_parent" |
|
5 |
android:layout_height="64dip" |
|
6 |
> |
|
7 |
<ImageView android:id="@+id/icon" |
|
8 |
android:layout_width="37px" |
|
9 |
android:paddingLeft="0px" |
|
10 |
android:paddingRight="0px" |
|
11 |
android:paddingTop="0px" |
|
12 |
android:layout_marginRight="10px" |
|
13 |
android:layout_marginLeft="10px" |
|
14 |
android:layout_marginTop="13px" |
|
15 |
android:layout_height="37px" |
|
16 |
android:src="@drawable/cloudfiles" /> |
|
17 |
|
|
18 |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
19 |
android:orientation="vertical" |
|
20 |
android:layout_width="fill_parent" |
|
21 |
android:layout_height="fill_parent"> |
|
22 |
|
|
23 |
<TableRow> |
|
24 |
<TextView android:id="@+id/label" |
|
25 |
android:layout_width="wrap_content" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_marginTop="5px" |
|
28 |
android:textColor="#FFFFFF" |
|
29 |
android:textSize="24sp" /> |
|
30 |
</TableRow> |
|
31 |
|
|
32 |
<TableRow> |
|
33 |
<TextView android:id="@+id/sublabel" |
|
34 |
android:layout_width="wrap_content" |
|
35 |
android:layout_height="wrap_content" |
|
36 |
android:layout_marginTop="0px" |
|
37 |
android:textColor="#FFFFFF" |
|
38 |
android:text="256 server - CentOS 5.3" |
|
39 |
android:textSize="12sp" /> |
|
40 |
</TableRow> |
|
41 |
</TableLayout> |
|
42 |
|
|
43 |
|
|
44 |
</LinearLayout> |
b/res/layout/listcontainerscell.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="horizontal" |
|
4 |
android:layout_width="fill_parent" |
|
5 |
android:layout_height="64dip" |
|
6 |
> |
|
7 |
<ImageView android:id="@+id/icon" |
|
8 |
android:layout_width="37px" |
|
9 |
android:paddingLeft="0px" |
|
10 |
android:paddingRight="0px" |
|
11 |
android:paddingTop="0px" |
|
12 |
android:layout_marginRight="10px" |
|
13 |
android:layout_marginLeft="10px" |
|
14 |
android:layout_marginTop="13px" |
|
15 |
android:layout_height="37px" |
|
16 |
android:src="@drawable/cdncontainer" /> |
|
17 |
|
|
18 |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
19 |
android:orientation="vertical" |
|
20 |
android:layout_width="fill_parent" |
|
21 |
android:layout_height="fill_parent"> |
|
22 |
|
|
23 |
<TableRow> |
|
24 |
<TextView android:id="@+id/label" |
|
25 |
android:layout_width="wrap_content" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_marginTop="5px" |
|
28 |
android:textColor="#FFFFFF" |
|
29 |
android:textSize="24sp" /> |
|
30 |
</TableRow> |
|
31 |
|
|
32 |
<TableRow> |
|
33 |
<TextView android:id="@+id/sublabel" |
|
34 |
android:layout_width="wrap_content" |
|
35 |
android:layout_height="wrap_content" |
|
36 |
android:layout_marginTop="0px" |
|
37 |
android:textColor="#FFFFFF" |
|
38 |
android:text="256 server - CentOS 5.3" |
|
39 |
android:textSize="12sp" /> |
|
40 |
|
|
41 |
<TextView android:id="@+id/sublabel1" |
|
42 |
android:layout_width="wrap_content" |
|
43 |
android:layout_height="wrap_content" |
|
44 |
android:layout_marginTop="0px" |
|
45 |
android:textColor="#FFFFFF" |
|
46 |
android:text="256 container" |
|
47 |
android:textSize="10sp" /> |
|
48 |
|
|
49 |
<TextView android:id="@+id/sublabel2" |
|
50 |
android:layout_width="wrap_content" |
|
51 |
android:layout_height="wrap_content" |
|
52 |
android:layout_marginTop="0px" |
|
53 |
android:textColor="#FFFFFF" |
|
54 |
android:text="256 container" |
|
55 |
android:textSize="10sp" |
|
56 |
android:layout_marginLeft="20px" /> |
|
57 |
</TableRow> |
|
58 |
</TableLayout> |
|
59 |
|
|
60 |
|
|
61 |
</LinearLayout> |
b/res/layout/nofilescell.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:id="@+id/no_files_label" |
|
9 |
android:layout_width="fill_parent" |
|
10 |
android:layout_height="wrap_content" |
|
11 |
android:layout_marginTop="125px" |
|
12 |
android:textColor="#FFFFFF" |
|
13 |
android:text="No Containers" |
|
14 |
android:gravity="center" |
|
15 |
|
|
16 |
android:textSize="24sp" /> |
|
17 |
|
|
18 |
<TextView android:id="@+id/no_files_sublabel" |
|
19 |
android:layout_width="fill_parent" |
|
20 |
android:layout_height="wrap_content" |
|
21 |
android:layout_marginTop="10px" |
|
22 |
android:textColor="#FFFFFF" |
|
23 |
android:text="Press menu to refresh list and more options" |
|
24 |
android:gravity="center" |
|
25 |
android:textSize="12sp" /> |
|
26 |
|
|
27 |
</LinearLayout> |
b/res/layout/noviewfilescell.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:id="@+id/no_files_label" |
|
9 |
android:layout_width="fill_parent" |
|
10 |
android:layout_height="wrap_content" |
|
11 |
android:layout_marginTop="125px" |
|
12 |
android:textColor="#FFFFFF" |
|
13 |
android:text="No Files In Current Container" |
|
14 |
android:gravity="center" |
|
15 |
|
|
16 |
android:textSize="24sp" /> |
|
17 |
|
|
18 |
<TextView android:id="@+id/no_files_sublabel" |
|
19 |
android:layout_width="fill_parent" |
|
20 |
android:layout_height="wrap_content" |
|
21 |
android:layout_marginTop="10px" |
|
22 |
android:textColor="#FFFFFF" |
|
23 |
android:text="Press menu to delete an empty container" |
|
24 |
android:gravity="center" |
|
25 |
android:textSize="12sp" /> |
|
26 |
|
|
27 |
</LinearLayout> |
b/res/layout/viewobject.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent"> |
|
5 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
6 |
android:id="@+id/view_server_layout" |
|
7 |
android:orientation="vertical" |
|
8 |
android:layout_width="fill_parent" |
|
9 |
android:layout_height="fill_parent" |
|
10 |
> |
|
11 |
<ImageView |
|
12 |
android:id="@+id/view_object_os_logo" |
|
13 |
android:layout_width="700dip" |
|
14 |
android:layout_height="700dip" |
|
15 |
android:adjustViewBounds="true" |
|
16 |
android:layout_gravity="left" |
|
17 |
/> |
|
18 |
|
|
19 |
|
|
20 |
<!-- Container Name - Setting top margin to -700 so it will sit over the OS logo image --> |
|
21 |
<TextView |
|
22 |
android:layout_width="fill_parent" |
|
23 |
android:layout_height="wrap_content" |
|
24 |
android:layout_marginLeft="22dip" |
|
25 |
android:layout_marginTop="-700dip" |
|
26 |
android:text="Container Name" |
|
27 |
android:singleLine="false" |
|
28 |
/> |
|
29 |
<TextView android:id="@+id/view_container_name" |
|
30 |
android:layout_height="wrap_content" |
|
31 |
android:layout_width="fill_parent" |
|
32 |
android:layout_marginLeft="22dip" |
|
33 |
android:layout_marginRight="30dip" |
|
34 |
android:scrollHorizontally="true" |
|
35 |
android:gravity="fill_horizontal" |
|
36 |
android:textStyle="bold" |
|
37 |
android:textSize="20.0sp" |
|
38 |
android:textColor="#fff" |
|
39 |
/> |
|
40 |
|
|
41 |
<!-- File Size in Bytes --> |
|
42 |
<TextView |
|
43 |
android:layout_width="fill_parent" |
|
44 |
android:layout_height="wrap_content" |
|
45 |
android:layout_marginLeft="22dip" |
|
46 |
android:text="File Size in Bytes" |
|
47 |
android:singleLine="false" |
|
48 |
/> |
|
49 |
<TextView android:id="@+id/view_file_bytes" |
|
50 |
android:layout_height="wrap_content" |
|
51 |
android:layout_width="fill_parent" |
|
52 |
android:layout_marginLeft="22dip" |
|
53 |
android:layout_marginRight="30dip" |
|
54 |
android:scrollHorizontally="true" |
|
55 |
android:gravity="fill_horizontal" |
|
56 |
android:textStyle="bold" |
|
57 |
android:textSize="20.0sp" |
|
58 |
android:textColor="#fff" |
|
59 |
/> |
|
60 |
|
|
61 |
<!-- Hash Code --> |
|
62 |
<TextView |
|
63 |
android:layout_width="fill_parent" |
|
64 |
android:layout_height="wrap_content" |
|
65 |
android:layout_marginLeft="22dip" |
|
66 |
android:text="Hash" |
|
67 |
android:singleLine="false" |
|
68 |
/> |
|
69 |
<TextView android:id="@+id/view_file_hash" |
|
70 |
android:layout_height="wrap_content" |
|
71 |
android:layout_width="fill_parent" |
|
72 |
android:layout_marginLeft="22dip" |
|
73 |
android:layout_marginRight="30dip" |
|
74 |
android:scrollHorizontally="true" |
|
75 |
android:gravity="fill_horizontal" |
|
76 |
android:textStyle="bold" |
|
77 |
android:textSize="20.0sp" |
|
78 |
android:textColor="#fff" |
|
79 |
/> |
|
80 |
|
|
81 |
<!-- Content Type --> |
|
82 |
<TextView |
|
83 |
android:layout_width="fill_parent" |
|
84 |
android:layout_height="wrap_content" |
|
85 |
android:layout_marginLeft="22dip" |
|
86 |
android:text="Content Type" |
|
87 |
android:singleLine="false" |
|
88 |
/> |
|
89 |
<TextView android:id="@+id/view_content_type" |
|
90 |
android:layout_height="wrap_content" |
|
91 |
android:layout_width="fill_parent" |
|
92 |
android:layout_marginLeft="22dip" |
|
93 |
android:layout_marginRight="30dip" |
|
94 |
android:scrollHorizontally="true" |
|
95 |
android:gravity="fill_horizontal" |
|
96 |
android:textStyle="bold" |
|
97 |
android:textSize="20.0sp" |
|
98 |
android:textColor="#fff" |
|
99 |
/> |
|
100 |
|
|
101 |
<!-- Last Modification --> |
|
102 |
<TextView |
|
103 |
android:layout_width="fill_parent" |
|
104 |
android:layout_height="wrap_content" |
|
105 |
android:layout_marginLeft="22dip" |
|
106 |
android:text="Last Modification" |
|
107 |
android:singleLine="false" |
|
108 |
/> |
|
109 |
<TextView android:id="@+id/view_file_modification" |
|
110 |
android:layout_height="wrap_content" |
|
111 |
android:layout_width="fill_parent" |
|
112 |
android:layout_marginLeft="22dip" |
|
113 |
android:layout_marginRight="30dip" |
|
114 |
android:scrollHorizontally="true" |
|
115 |
android:gravity="fill_horizontal" |
|
116 |
android:textStyle="bold" |
|
117 |
android:textSize="20.0sp" |
|
118 |
android:textColor="#fff" |
|
119 |
/> |
|
120 |
|
|
121 |
|
|
122 |
<!-- CDN URL --> |
|
123 |
<TextView |
|
124 |
android:layout_width="fill_parent" |
|
125 |
android:layout_height="wrap_content" |
|
126 |
android:layout_marginLeft="22dip" |
|
127 |
android:text="CDN Download Link" |
|
128 |
android:singleLine="false" |
|
129 |
/> |
|
130 |
<TextView android:id="@+id/view_file_cdnurl" |
|
131 |
android:layout_height="wrap_content" |
|
132 |
android:layout_width="fill_parent" |
|
133 |
android:layout_marginLeft="22dip" |
|
134 |
android:layout_marginRight="30dip" |
|
135 |
android:scrollHorizontally="true" |
|
136 |
android:gravity="fill_horizontal" |
|
137 |
android:textStyle="bold" |
|
138 |
android:textSize="20.0sp" |
|
139 |
android:textColor="#fff" |
|
140 |
android:autoLink="all" |
|
141 |
/> |
|
142 |
</LinearLayout> |
|
143 |
|
|
144 |
</ScrollView> |
b/res/menu/cdn_container_list_menu.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
<item android:id="@+id/refresh" android:title="Refresh" android:icon="@drawable/refresh_button" /> |
|
4 |
</menu> |
b/res/menu/container_list_menu.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
<item android:id="@+id/add_container" android:title="New Container" android:icon="@drawable/add_button" /> |
|
4 |
<item android:id="@+id/refresh" android:title="Refresh" android:icon="@drawable/refresh_button" /> |
|
5 |
</menu> |
b/res/menu/container_object_list_menu.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
<item android:id="@+id/delete_object" android:title="Delete File" android:icon="@drawable/add_button" /> |
|
4 |
<item android:id="@+id/refresh" android:title="Refresh" android:icon="@drawable/refresh_button" /> |
|
5 |
</menu> |
b/res/menu/view_cdn_object_list_menu.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
<item android:id="@+id/enable_cdn" android:title="Enable CDN" android:icon="@drawable/add_button" /> |
|
4 |
<item android:id="@+id/refresh" android:title="Refresh" android:icon="@drawable/refresh_button" /> |
|
5 |
</menu> |
b/res/menu/view_container_object_list_menu.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
<item android:id="@+id/delete_container" android:title="Delete Container" android:icon="@drawable/add_button" /> |
|
4 |
<item android:id="@+id/enable_cdn" android:title="Enable CDN" android:icon="@drawable/add_button" /> |
|
5 |
<item android:id="@+id/refresh" android:title="Refresh" android:icon="@drawable/refresh_button" /> |
|
6 |
</menu> |
b/res/values/arrays.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
|
|
3 |
<resources> |
|
4 |
<string-array name="ttl"> |
|
5 |
<item>3600</item> |
|
6 |
<item>18000</item> |
|
7 |
<item>36000</item> |
|
8 |
<item>86400</item> |
|
9 |
<item>129600</item> |
|
10 |
<item>172800</item> |
|
11 |
<item>201600</item> |
|
12 |
<item>259200</item> |
|
13 |
</string-array> |
|
14 |
|
|
15 |
<string-array name="logRet"> |
|
16 |
<item> true</item> |
|
17 |
<item> false</item> |
|
18 |
</string-array> |
|
19 |
|
|
20 |
<string-array name="cdn"> |
|
21 |
<item> true</item> |
|
22 |
<item> false</item> |
|
23 |
</string-array> |
|
24 |
</resources> |
b/src/com/rackspace/cloud/files/api/client/ContainerManager.java | ||
---|---|---|
1 |
package com.rackspace.cloud.files.api.client; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
|
|
7 |
import javax.xml.parsers.FactoryConfigurationError; |
|
8 |
import javax.xml.parsers.ParserConfigurationException; |
|
9 |
import javax.xml.parsers.SAXParser; |
|
10 |
import javax.xml.parsers.SAXParserFactory; |
|
11 |
|
|
12 |
import org.apache.http.HttpResponse; |
|
13 |
import org.apache.http.client.ClientProtocolException; |
|
14 |
import org.apache.http.client.methods.HttpDelete; |
|
15 |
import org.apache.http.client.methods.HttpGet; |
|
16 |
import org.apache.http.client.methods.HttpPost; |
|
17 |
import org.apache.http.client.methods.HttpPut; |
|
18 |
import org.apache.http.impl.client.BasicResponseHandler; |
|
19 |
import org.apache.http.impl.client.DefaultHttpClient; |
|
20 |
import org.apache.http.protocol.RequestExpectContinue; |
|
21 |
import org.xml.sax.InputSource; |
|
22 |
import org.xml.sax.SAXException; |
|
23 |
import org.xml.sax.XMLReader; |
|
24 |
|
|
25 |
import android.text.Editable; |
|
26 |
import android.util.Log; |
|
27 |
|
|
28 |
import com.rackspace.cloud.files.api.client.parsers.ContainerXMLParser; |
|
29 |
import com.rackspace.cloud.servers.api.client.Account; |
|
30 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
31 |
import com.rackspace.cloud.servers.api.client.EntityManager; |
|
32 |
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author Phillip Toohill |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class ContainerManager extends EntityManager { |
|
39 |
|
|
40 |
public HttpResponse create(Editable editable) throws CloudServersException { |
|
41 |
HttpResponse resp = null; |
|
42 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
43 |
HttpPut put = new HttpPut(Account.getStorageUrl() + "/" + editable); |
|
44 |
|
|
45 |
put.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
46 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
47 |
|
|
48 |
try { |
|
49 |
resp = httpclient.execute(put); |
|
50 |
} catch (ClientProtocolException e) { |
|
51 |
CloudServersException cse = new CloudServersException(); |
|
52 |
cse.setMessage(e.getLocalizedMessage()); |
|
53 |
throw cse; |
|
54 |
} catch (IOException e) { |
|
55 |
CloudServersException cse = new CloudServersException(); |
|
56 |
cse.setMessage(e.getLocalizedMessage()); |
|
57 |
throw cse; |
|
58 |
} catch (FactoryConfigurationError e) { |
|
59 |
CloudServersException cse = new CloudServersException(); |
|
60 |
cse.setMessage(e.getLocalizedMessage()); |
|
61 |
throw cse; |
|
62 |
} |
|
63 |
return resp; |
|
64 |
} |
|
65 |
|
|
66 |
public ArrayList<Container> createCDNList(boolean detail) throws CloudServersException { |
|
67 |
|
|
68 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
69 |
HttpGet get = new HttpGet(Account.getCdnManagementUrl()+"?format=xml"); |
|
70 |
ArrayList<Container> cdnContainers = new ArrayList<Container>(); |
|
71 |
|
|
72 |
get.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
73 |
|
|
74 |
try { |
|
75 |
HttpResponse resp = httpclient.execute(get); |
|
76 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
77 |
String body = responseHandler.handleResponse(resp); |
|
78 |
|
|
79 |
if (resp.getStatusLine().getStatusCode() == 200) { |
|
80 |
ContainerXMLParser cdnContainerXMLParser = new ContainerXMLParser(); |
|
81 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
82 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
83 |
xmlReader.setContentHandler(cdnContainerXMLParser); |
|
84 |
|
|
85 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
86 |
cdnContainers = cdnContainerXMLParser.getContainers(); |
|
87 |
} else { |
|
88 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
89 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
90 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
91 |
xmlReader.setContentHandler(parser); |
|
92 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
93 |
CloudServersException cse = parser.getException(); |
|
94 |
throw cse; |
|
95 |
} |
|
96 |
} catch (ClientProtocolException e) { |
|
97 |
CloudServersException cse = new CloudServersException(); |
|
98 |
cse.setMessage(e.getLocalizedMessage()); |
|
99 |
throw cse; |
|
100 |
} catch (IOException e) { |
|
101 |
CloudServersException cse = new CloudServersException(); |
|
102 |
cse.setMessage(e.getLocalizedMessage()); |
|
103 |
throw cse; |
|
104 |
} catch (ParserConfigurationException e) { |
|
105 |
CloudServersException cse = new CloudServersException(); |
|
106 |
cse.setMessage(e.getLocalizedMessage()); |
|
107 |
throw cse; |
|
108 |
} catch (SAXException e) { |
|
109 |
CloudServersException cse = new CloudServersException(); |
|
110 |
cse.setMessage(e.getLocalizedMessage()); |
|
111 |
throw cse; |
|
112 |
} catch (FactoryConfigurationError e) { |
|
113 |
CloudServersException cse = new CloudServersException(); |
|
114 |
cse.setMessage(e.getLocalizedMessage()); |
|
115 |
throw cse; |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
return cdnContainers; |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
public HttpResponse enable(String container, String ttl, String logRet) |
|
124 |
throws CloudServersException { |
|
125 |
HttpResponse resp = null; |
|
126 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
127 |
HttpPut put = new HttpPut(Account.getCdnManagementUrl() + "/" |
|
128 |
+ container); |
|
129 |
|
|
130 |
put.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
131 |
put.addHeader("X-TTL", ttl); |
|
132 |
put.addHeader("X-Log-Retention", logRet); |
|
133 |
Log.v("cdn manager", ttl + container + logRet); |
|
134 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
135 |
|
|
136 |
try { |
|
137 |
resp = httpclient.execute(put); |
|
138 |
} catch (ClientProtocolException e) { |
|
139 |
CloudServersException cse = new CloudServersException(); |
|
140 |
cse.setMessage(e.getLocalizedMessage()); |
|
141 |
throw cse; |
|
142 |
} catch (IOException e) { |
|
143 |
CloudServersException cse = new CloudServersException(); |
|
144 |
cse.setMessage(e.getLocalizedMessage()); |
|
145 |
throw cse; |
|
146 |
} catch (FactoryConfigurationError e) { |
|
147 |
CloudServersException cse = new CloudServersException(); |
|
148 |
cse.setMessage(e.getLocalizedMessage()); |
|
149 |
throw cse; |
|
150 |
} |
|
151 |
return resp; |
|
152 |
} |
|
153 |
public HttpResponse disable(String container, String cdn, String ttl, String logRet) |
|
154 |
throws CloudServersException { |
|
155 |
HttpResponse resp = null; |
|
156 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
157 |
HttpPost post = new HttpPost(Account.getCdnManagementUrl() + "/" |
|
158 |
+ container); |
|
159 |
|
|
160 |
post.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
161 |
post.addHeader("X-TTL", ttl); |
|
162 |
post.addHeader("X-Log-Retention", logRet); |
|
163 |
post.addHeader("X-CDN-Enabled", cdn); |
|
164 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
165 |
|
|
166 |
try { |
|
167 |
resp = httpclient.execute(post); |
|
168 |
} catch (ClientProtocolException e) { |
|
169 |
CloudServersException cse = new CloudServersException(); |
|
170 |
cse.setMessage(e.getLocalizedMessage()); |
|
171 |
throw cse; |
|
172 |
} catch (IOException e) { |
|
173 |
CloudServersException cse = new CloudServersException(); |
|
174 |
cse.setMessage(e.getLocalizedMessage()); |
|
175 |
throw cse; |
|
176 |
} catch (FactoryConfigurationError e) { |
|
177 |
CloudServersException cse = new CloudServersException(); |
|
178 |
cse.setMessage(e.getLocalizedMessage()); |
|
179 |
throw cse; |
|
180 |
} |
|
181 |
return resp; |
|
182 |
} |
|
183 |
|
|
184 |
public HttpResponse delete(String string) throws CloudServersException { |
|
185 |
HttpResponse resp = null; |
|
186 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
187 |
HttpDelete put = new HttpDelete(Account.getStorageUrl() + "/" + string); |
|
188 |
|
|
189 |
put.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
190 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
191 |
|
|
192 |
try { |
|
193 |
resp = httpclient.execute(put); |
|
194 |
} catch (ClientProtocolException e) { |
|
195 |
CloudServersException cse = new CloudServersException(); |
|
196 |
cse.setMessage(e.getLocalizedMessage()); |
|
197 |
throw cse; |
|
198 |
} catch (IOException e) { |
|
199 |
CloudServersException cse = new CloudServersException(); |
|
200 |
cse.setMessage(e.getLocalizedMessage()); |
|
201 |
throw cse; |
|
202 |
} catch (FactoryConfigurationError e) { |
|
203 |
CloudServersException cse = new CloudServersException(); |
|
204 |
cse.setMessage(e.getLocalizedMessage()); |
|
205 |
throw cse; |
|
206 |
} |
|
207 |
return resp; |
|
208 |
} |
|
209 |
|
|
210 |
public ArrayList<Container> createList(boolean detail) |
|
211 |
throws CloudServersException { |
|
212 |
|
|
213 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
214 |
HttpGet get = new HttpGet(Account.getStorageUrl() + "?format=xml"); |
|
215 |
ArrayList<Container> containers = new ArrayList<Container>(); |
|
216 |
|
|
217 |
get.addHeader("X-Storage-Token", Account.getStorageToken()); |
|
218 |
get.addHeader("Content-Type", "application/xml"); |
|
219 |
|
|
220 |
try { |
|
221 |
HttpResponse resp = httpclient.execute(get); |
|
222 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
223 |
String body = responseHandler.handleResponse(resp); |
|
224 |
|
|
225 |
if (resp.getStatusLine().getStatusCode() == 200 |
|
226 |
|| resp.getStatusLine().getStatusCode() == 203) { |
|
227 |
ContainerXMLParser containerXMLParser = new ContainerXMLParser(); |
|
228 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
229 |
.newSAXParser(); |
|
230 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
231 |
xmlReader.setContentHandler(containerXMLParser); |
|
232 |
|
|
233 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
234 |
containers = containerXMLParser.getContainers(); |
|
235 |
} else { |
|
236 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
237 |
SAXParser saxParser = SAXParserFactory.newInstance() |
|
238 |
.newSAXParser(); |
|
239 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
240 |
xmlReader.setContentHandler(parser); |
|
241 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
242 |
CloudServersException cse = parser.getException(); |
|
243 |
throw cse; |
|
244 |
} |
|
245 |
} catch (ClientProtocolException e) { |
|
246 |
CloudServersException cse = new CloudServersException(); |
|
247 |
cse.setMessage(e.getLocalizedMessage()); |
|
248 |
throw cse; |
|
249 |
} catch (IOException e) { |
|
250 |
CloudServersException cse = new CloudServersException(); |
|
251 |
cse.setMessage(e.getLocalizedMessage()); |
|
252 |
throw cse; |
|
253 |
} catch (ParserConfigurationException e) { |
|
254 |
CloudServersException cse = new CloudServersException(); |
|
255 |
cse.setMessage(e.getLocalizedMessage()); |
|
256 |
throw cse; |
|
257 |
} catch (SAXException e) { |
|
258 |
CloudServersException cse = new CloudServersException(); |
|
259 |
cse.setMessage(e.getLocalizedMessage()); |
|
260 |
throw cse; |
|
261 |
} catch (FactoryConfigurationError e) { |
|
262 |
CloudServersException cse = new CloudServersException(); |
|
263 |
cse.setMessage(e.getLocalizedMessage()); |
|
264 |
throw cse; |
|
265 |
} |
|
266 |
|
|
267 |
return containers; |
|
268 |
} |
|
269 |
|
|
270 |
} |
b/src/com/rackspace/cloud/files/api/client/ContainerObjectManager.java | ||
---|---|---|
1 |
package com.rackspace.cloud.files.api.client; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
|
|
7 |
import javax.xml.parsers.FactoryConfigurationError; |
|
8 |
import javax.xml.parsers.ParserConfigurationException; |
|
9 |
import javax.xml.parsers.SAXParser; |
|
10 |
import javax.xml.parsers.SAXParserFactory; |
|
11 |
|
|
12 |
import org.apache.http.HttpResponse; |
|
13 |
import org.apache.http.client.ClientProtocolException; |
|
14 |
import org.apache.http.client.methods.HttpDelete; |
|
15 |
import org.apache.http.client.methods.HttpGet; |
|
16 |
import org.apache.http.impl.client.BasicResponseHandler; |
|
17 |
import org.apache.http.impl.client.DefaultHttpClient; |
|
18 |
import org.apache.http.protocol.RequestExpectContinue; |
|
19 |
import org.xml.sax.InputSource; |
|
20 |
import org.xml.sax.SAXException; |
|
21 |
import org.xml.sax.XMLReader; |
|
22 |
|
|
23 |
import android.util.Log; |
|
24 |
|
|
25 |
import com.rackspace.cloud.files.api.client.parsers.ContainerObjectXMLparser; |
|
26 |
import com.rackspace.cloud.servers.api.client.Account; |
|
27 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
28 |
import com.rackspace.cloud.servers.api.client.EntityManager; |
|
29 |
import com.rackspace.cloud.servers.api.client.Server; |
|
30 |
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser; |
|
31 |
import com.rackspacecloud.android.ContainerObjectsActivity; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author Phillip Toohill |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class ContainerObjectManager extends EntityManager { |
|
39 |
|
|
40 |
public String LOG = "ContainerObjectManager"; |
|
41 |
public static final String storageToken = Account.getStorageToken(); |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
public ArrayList<ContainerObjects> createList(boolean detail, String passName) throws CloudServersException { |
|
46 |
|
|
47 |
|
|
48 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
49 |
HttpGet get = new HttpGet(Account.getStorageUrl()+"/"+passName+"?format=xml"); |
|
50 |
ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>(); |
|
51 |
|
|
52 |
|
|
53 |
get.addHeader("Content-Type", "application/xml"); |
|
54 |
get.addHeader("X-Storage-Token", storageToken); |
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
try { |
|
59 |
HttpResponse resp = httpclient.execute(get); |
|
60 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
61 |
String body = responseHandler.handleResponse(resp); |
|
62 |
|
|
63 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 203) { |
|
64 |
ContainerObjectXMLparser filesXMLParser = new ContainerObjectXMLparser(); |
|
65 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
66 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
67 |
xmlReader.setContentHandler(filesXMLParser); |
|
68 |
|
|
69 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
70 |
files = filesXMLParser.getViewFiles(); |
|
71 |
|
|
72 |
} else { |
|
73 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
74 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
75 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
76 |
xmlReader.setContentHandler(parser); |
|
77 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
78 |
CloudServersException cse = parser.getException(); |
|
79 |
throw cse; |
|
80 |
} |
|
81 |
} catch (ClientProtocolException e) { |
|
82 |
CloudServersException cse = new CloudServersException(); |
|
83 |
cse.setMessage(e.getLocalizedMessage()); |
|
84 |
throw cse; |
|
85 |
} catch (IOException e) { |
|
86 |
CloudServersException cse = new CloudServersException(); |
|
87 |
cse.setMessage(e.getLocalizedMessage()); |
|
88 |
throw cse; |
|
89 |
} catch (ParserConfigurationException e) { |
|
90 |
CloudServersException cse = new CloudServersException(); |
|
91 |
cse.setMessage(e.getLocalizedMessage()); |
|
92 |
throw cse; |
|
93 |
} catch (SAXException e) { |
|
94 |
CloudServersException cse = new CloudServersException(); |
|
95 |
cse.setMessage(e.getLocalizedMessage()); |
|
96 |
throw cse; |
|
97 |
} catch (FactoryConfigurationError e) { |
|
98 |
CloudServersException cse = new CloudServersException(); |
|
99 |
cse.setMessage(e.getLocalizedMessage()); |
|
100 |
throw cse; |
|
101 |
} |
|
102 |
return files; |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
public HttpResponse deleteObject(String Container, String Object) throws CloudServersException { |
|
107 |
HttpResponse resp = null; |
|
108 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
|
109 |
HttpDelete deleteObject = new HttpDelete(Account.getStorageUrl() + "/" + Container + "/" + Object); |
|
110 |
Log.v(LOG, "the container (deleteObject) vairble "+Container+" "+Object); |
|
111 |
|
|
112 |
deleteObject.addHeader("X-Auth-Token", Account.getAuthToken()); |
|
113 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
114 |
|
|
115 |
try { |
|
116 |
resp = httpclient.execute(deleteObject); |
|
117 |
} catch (ClientProtocolException e) { |
|
118 |
CloudServersException cse = new CloudServersException(); |
|
119 |
cse.setMessage(e.getLocalizedMessage()); |
|
120 |
throw cse; |
|
121 |
} catch (IOException e) { |
|
122 |
CloudServersException cse = new CloudServersException(); |
|
123 |
cse.setMessage(e.getLocalizedMessage()); |
|
124 |
throw cse; |
|
125 |
} catch (FactoryConfigurationError e) { |
|
126 |
CloudServersException cse = new CloudServersException(); |
|
127 |
cse.setMessage(e.getLocalizedMessage()); |
|
128 |
throw cse; |
|
129 |
} |
|
130 |
return resp; |
|
131 |
} |
|
132 |
|
|
133 |
|
|
134 |
} |
b/src/com/rackspace/cloud/files/api/client/ContainerObjects.java | ||
---|---|---|
1 |
package com.rackspace.cloud.files.api.client; |
|
2 |
|
|
3 |
import com.rackspace.cloud.servers.api.client.Entity; |
|
4 |
|
|
5 |
/** |
|
6 |
* @author Phillip Toohill dead2hill@gmail.com |
|
7 |
* |
|
8 |
*/ |
|
9 |
public class ContainerObjects extends Entity { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 5994739895998309675L; |
|
12 |
private String object; |
|
13 |
private String hash; |
|
14 |
private String lastMod; |
|
15 |
private String bytes; |
|
16 |
private String cname; |
|
17 |
private String cName; |
|
18 |
private String contentType; |
|
19 |
|
|
20 |
/** |
|
21 |
* |
|
22 |
* @return the object |
|
23 |
*/ |
|
24 |
public String getObject() { |
|
25 |
return object; |
|
26 |
} |
|
27 |
/** |
|
28 |
* |
|
29 |
* @param object from container |
|
30 |
*/ |
|
31 |
public void setObject(String object) { |
|
32 |
this.object = object; |
|
33 |
} |
|
34 |
/** |
|
35 |
* @return the hash |
|
36 |
*/ |
|
37 |
public String getHash() { |
|
38 |
return hash; |
|
39 |
} |
|
40 |
/** |
|
41 |
* @param hash hash of object |
|
42 |
*/ |
|
43 |
public void setHash(String hash) { |
|
44 |
this.hash = hash; |
|
45 |
} |
|
46 |
/** |
|
47 |
* |
|
48 |
* @return the LastMod ification of file |
|
49 |
*/ |
|
50 |
public String getLastMod() { |
|
51 |
return lastMod; |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* |
|
56 |
* @param lastMod that LastMod is set to |
|
57 |
*/ |
|
58 |
public void setLastMod(String lastMod) { |
|
59 |
this.lastMod = lastMod; |
|
60 |
} |
|
61 |
/** |
|
62 |
* |
|
63 |
* @return the object's name |
|
64 |
*/ |
|
65 |
public String getCName() { |
|
66 |
return cname; |
|
67 |
} |
|
68 |
/** |
|
69 |
* |
|
70 |
* @param name the object is set to |
|
71 |
*/ |
|
72 |
public void setCName(String cname) { |
|
73 |
this.cname = cname; |
|
74 |
} |
|
75 |
public String getBytes() { |
|
76 |
return bytes; |
|
77 |
} |
|
78 |
/** |
|
79 |
* |
|
80 |
* @param bytes |
|
81 |
*/ |
|
82 |
public void setBytes(String bytes) { |
|
83 |
this.bytes = bytes; |
|
84 |
} |
|
85 |
public void setCname(String cName) { |
|
86 |
this.cName = cName; |
|
87 |
|
|
88 |
} |
|
89 |
public String getCname(){ |
|
90 |
return cName; |
|
91 |
} |
|
92 |
public void setContentType(String contentType) { |
|
93 |
this.contentType = contentType; |
|
94 |
|
|
95 |
} |
|
96 |
public String getContentType(){ |
|
97 |
return contentType; |
|
98 |
} |
|
99 |
} |
|
100 |
|
b/src/com/rackspace/cloud/files/api/client/parsers/ContainerObjectXMLparser.java | ||
---|---|---|
1 |
package com.rackspace.cloud.files.api.client.parsers; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import com.rackspace.cloud.files.api.client.ContainerObjects; |
|
7 |
|
|
8 |
import org.xml.sax.Attributes; |
|
9 |
import org.xml.sax.helpers.DefaultHandler; |
|
10 |
|
|
11 |
import android.util.Log; |
|
12 |
/** |
|
13 |
* |
|
14 |
* @author Phillip Toohill |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class ContainerObjectXMLparser extends DefaultHandler { |
|
18 |
|
|
19 |
private ContainerObjects object; |
|
20 |
private ArrayList<ContainerObjects> files; |
|
21 |
|
|
22 |
private StringBuffer currentData; |
|
23 |
private boolean find_Title = false; |
|
24 |
private boolean find_Hash = false; |
|
25 |
private boolean find_Bytes = false; |
|
26 |
private boolean find_lastMod = false; |
|
27 |
public String LOG = "ViewFilesXMLparser"; |
|
28 |
private boolean find_contentType = false; |
|
29 |
|
|
30 |
public void startDocument() { |
|
31 |
Log.v(LOG, "startDocument"); |
|
32 |
} |
|
33 |
|
|
34 |
public void endDocument() { |
|
35 |
Log.v(LOG, "endDocument = true"); |
|
36 |
} |
|
37 |
|
|
38 |
public void startElement(String uri, String name, String qName, Attributes atts) { |
|
39 |
|
|
40 |
currentData = new StringBuffer(); |
|
41 |
if ("container".equals(name)) { |
|
42 |
files = new ArrayList<ContainerObjects>(); |
|
43 |
|
|
44 |
|
|
45 |
} else if ("object".equals(name)) { |
|
46 |
object = new ContainerObjects(); |
|
47 |
}else if ("name".equals(name)){ |
|
48 |
this.find_Title = true; |
|
49 |
}else if ("content_type".equals(name)){ |
|
50 |
this.find_contentType = true; |
|
51 |
}else if ("hash".equals(name)){ |
|
52 |
this.find_Hash = true; |
|
53 |
}else if ("bytes".equals(name)){ |
|
54 |
this.find_Bytes = true; |
|
55 |
}else if ("last_modified".equals(name)) { |
|
56 |
this.find_lastMod=true; |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
} |
|
61 |
|
|
62 |
public void endElement(String uri, String name, String qName) { |
|
63 |
if ("container".equals(name)) { |
|
64 |
|
|
65 |
} else if ("object".equals(name)) { |
|
66 |
if (files != null) { |
|
67 |
files.add(object); |
|
68 |
} |
|
69 |
}else if ("name".equals(name)){ |
|
70 |
this.find_Title = false; |
|
71 |
}else if ("content_type".equals(name)){ |
|
72 |
this.find_contentType = false; |
|
73 |
}else if ("hash".equals(name)){ |
|
74 |
this.find_Hash = false; |
|
75 |
}else if ("bytes".equals(name)){ |
|
76 |
this.find_Bytes = false; |
|
77 |
}else if ("last_modified".equals(name)){ |
|
78 |
this.find_lastMod = false; |
|
79 |
|
|
80 |
|
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
public void characters(char ch[], int start, int length) { |
|
85 |
|
|
86 |
if(this.find_Title){ |
|
87 |
object.setCName(new String(ch, start, length)); |
Also available in: Unified diff