Revision 006434d8

b/src/com/rackspace/cloud/files/api/client/ContainerManager.java
2 2

  
3 3
import java.io.IOException;
4 4
import java.io.StringReader;
5
import java.net.MalformedURLException;
6
import java.net.URI;
7
import java.net.URISyntaxException;
5 8
import java.util.ArrayList;
6 9

  
7 10
import javax.xml.parsers.FactoryConfigurationError;
......
46 49
	public HttpBundle create(Editable editable) throws CloudServersException {
47 50
		HttpResponse resp = null;
48 51
		CustomHttpClient httpclient = new CustomHttpClient(context);
49
		HttpPut put = new HttpPut(Account.getAccount().getStorageUrl() + "/" + editable);
50

  
52
		
53
		String url = getSafeURL(Account.getAccount().getStorageUrl(), editable.toString());
54
		HttpPut put = new HttpPut(url);
55
		Log.d("info", "captin the url create " + url);
56
		
51 57
		put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
52 58
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
53 59

  
......
134 140
			throws CloudServersException {
135 141
		HttpResponse resp = null;
136 142
		CustomHttpClient httpclient = new CustomHttpClient(context);
137
		HttpPut put = new HttpPut(Account.getAccount().getCdnManagementUrl() + "/"
138
				+ container);
143
		String url = getSafeURL(Account.getAccount().getCdnManagementUrl(), container);
144
		HttpPut put = new HttpPut(url);
145
		Log.d("info", "captin the url enable " + url);
139 146

  
140 147
		put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
141 148
		put.addHeader("X-TTL", ttl);
......
168 175
	throws CloudServersException {
169 176
       HttpResponse resp = null;
170 177
 	    CustomHttpClient httpclient = new CustomHttpClient(context);
171
       	HttpPost post = new HttpPost(Account.getAccount().getCdnManagementUrl() + "/"
172
		+ container);
173

  
178
 	   String url = getSafeURL(Account.getAccount().getCdnManagementUrl(), container);
179
       	HttpPost post = new HttpPost(url);
180
       	Log.d("info", "captin the url disable " + url);
181
       	
174 182
       	post.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
175 183
       		post.addHeader("X-TTL", ttl);
176 184
       		post.addHeader("X-Log-Retention", logRet);
......
202 210
	public HttpBundle delete(String string) throws CloudServersException {
203 211
		HttpResponse resp = null;
204 212
		CustomHttpClient httpclient = new CustomHttpClient(context);
205
		HttpDelete put = new HttpDelete(Account.getAccount().getStorageUrl() + "/" + string);
206

  
213
		String url = getSafeURL(Account.getAccount().getStorageUrl(), string);
214
		HttpDelete put = new HttpDelete(url);
215
		Log.d("info", "captin the url delete " + url);
216
		
207 217
		put.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
208 218
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
209 219

  
......
288 298

  
289 299
		return containers;
290 300
	}
301
	
302
	private String getSafeURL(String badURL, String name){
303
		URI uri = null;
304
		try {
305
			uri = new URI("https", badURL.substring(8), "/" + name.toString()+"/", "");
306
		} catch (URISyntaxException e1) {
307
			// TODO Auto-generated catch block
308
			e1.printStackTrace();
309
		}
310
		String url = null;
311
		try {
312
			url = uri.toURL().toString();
313
		} catch (MalformedURLException e1) {
314
			// TODO Auto-generated catch block
315
			e1.printStackTrace();
316
		}
317
		return url.substring(0, url.length()-1);
318
	}
291 319

  
292 320
}
b/src/com/rackspace/cloud/files/api/client/ContainerObjectManager.java
2 2

  
3 3
import java.io.IOException;
4 4
import java.io.StringReader;
5
import java.io.UnsupportedEncodingException;
6
import java.net.MalformedURLException;
7
import java.net.URI;
8
import java.net.URISyntaxException;
5 9
import java.util.ArrayList;
6 10

  
7 11
import javax.xml.parsers.FactoryConfigurationError;
......
14 18
import org.apache.http.client.methods.HttpDelete;
15 19
import org.apache.http.client.methods.HttpGet;
16 20
import org.apache.http.client.methods.HttpPut;
21
import org.apache.http.entity.StringEntity;
17 22
import org.apache.http.impl.client.BasicResponseHandler;
18 23
import org.apache.http.protocol.RequestExpectContinue;
19 24
import org.xml.sax.InputSource;
......
21 26
import org.xml.sax.XMLReader;
22 27

  
23 28
import android.content.Context;
29
import android.util.Log;
24 30

  
25 31
import com.rackspace.cloud.files.api.client.parsers.ContainerObjectXMLparser;
26 32
import com.rackspace.cloud.servers.api.client.Account;
......
47 53
	public ArrayList<ContainerObjects> createList(boolean detail, String passName) throws CloudServersException {
48 54
		
49 55
		CustomHttpClient httpclient = new CustomHttpClient(context);
50
		HttpGet get = new HttpGet(Account.getAccount().getStorageUrl()+"/"+passName + "?format=xml");
56
		String url = getSafeURL(Account.getAccount().getStorageUrl(), passName) + "?format=xml";
57
		Log.d("info", "captin the url creatlist: " + url);
58
		HttpGet get = new HttpGet(url);
51 59
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
52 60
		
53 61
		
......
107 115
	public HttpBundle deleteObject(String Container, String Object) throws CloudServersException {
108 116
		HttpResponse resp = null;
109 117
		CustomHttpClient httpclient = new CustomHttpClient(context);
110
		HttpDelete deleteObject = new HttpDelete(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Object);
118
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container + "/" + Object);
119
		HttpDelete deleteObject = new HttpDelete(url);
120
		Log.d("info", "captin the url deleteobject: " + url);
111 121
				
112 122
		deleteObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
113 123
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
......
137 147
	public HttpBundle getObject(String Container, String Object) throws CloudServersException {
138 148
		HttpResponse resp = null;
139 149
		CustomHttpClient httpclient = new CustomHttpClient(context);
140
		HttpGet getObject = new HttpGet(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Object);
141
				
150
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container + "/" + Object);
151
		HttpGet getObject = new HttpGet(url);
152
		Log.d("info", "captin the url getobject: " + url);		
142 153
		getObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
143 154
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
144 155

  
......
167 178
	public HttpBundle addObject(String Container, String Path, String Object, String type) throws CloudServersException {
168 179
		HttpResponse resp = null;
169 180
		CustomHttpClient httpclient = new CustomHttpClient(context);
170
		HttpPut addObject = new HttpPut(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Path + Object);
171
				
181
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container + "/" + Path + Object);
182
		HttpPut addObject = new HttpPut(url);
183
		Log.d("info", "captin the url addobject: " + url);
184
		
172 185
		addObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
173 186
		addObject.addHeader("Content-Type", type);
174 187
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
......
202 215
	public HttpBundle addObject(String Container, String Path, String Object, String type, String data) throws CloudServersException {
203 216
		HttpResponse resp = null;
204 217
		CustomHttpClient httpclient = new CustomHttpClient(context);
205
		HttpPut addObject = new HttpPut(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Path + Object);
218
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container + "/" + Path + Object);
219
		HttpPut addObject = new HttpPut(url);
220
		Log.d("info", "captin the url addobject2: " + url);
206 221
				
207 222
		addObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
208 223
		addObject.addHeader("Content-Type", type);
209 224
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
210 225

  
226
		StringEntity tmp = null;
227
		try {
228
			tmp = new StringEntity(data);
229
		} catch (UnsupportedEncodingException e) {
230
			CloudServersException cse = new CloudServersException();
231
			cse.setMessage(e.getLocalizedMessage());
232
			throw cse;
233
		}
234
		addObject.setEntity(tmp);
235
		
211 236
		HttpBundle bundle = new HttpBundle();
212 237
		bundle.setCurlRequest(addObject);
213 238
		
......
229 254
		}	
230 255
		return bundle;
231 256
	}
257
	
258
	private String getSafeURL(String badURL, String name){
259
		URI uri = null;
260
		try {
261
			uri = new URI("https", badURL.substring(8), "/" + name + "/", "");
262
		} catch (URISyntaxException e1) {
263
			// TODO Auto-generated catch block
264
			e1.printStackTrace();
265
		}
266
		String url = null;
267
		try {
268
			url = uri.toURL().toString();
269
		} catch (MalformedURLException e1) {
270
			// TODO Auto-generated catch block
271
			e1.printStackTrace();
272
		}
273
		return url.substring(0, url.length()-2);
274
	}
232 275

  
233 276
}
b/src/com/rackspace/cloud/servers/api/client/ServerManager.java
27 27
import org.xml.sax.XMLReader;
28 28

  
29 29
import android.content.Context;
30
import android.util.Log;
30 31

  
31 32
import com.rackspace.cloud.files.api.client.CustomHttpClient;
32 33
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
......
264 265

  
265 266
		StringEntity tmp = null;
266 267
		try {
268
			Log.d("info", "captin the flavor id is " + flavorId);
267 269
			tmp = new StringEntity("<resize xmlns=\"http://docs.rackspacecloud.com/servers/api/v1.0\" flavorId=\"" + flavorId + "\"/>");
268 270
		} catch (UnsupportedEncodingException e) {
269 271
			CloudServersException cse = new CloudServersException();
b/src/com/rackspacecloud/android/AddFileActivity.java
145 145
				} else {
146 146
					CloudServersException cse = parseCloudServersException(response);
147 147
					if ("".equals(cse.getMessage())) {
148
						startFileError("There was a problem creating your container.", bundle);
148
						startFileError("There was a problem creating your file.", bundle);
149 149
					} else {
150
						startFileError("There was a problem creating your container: " + cse.getMessage() + " Check container name and try again", bundle);
150
						startFileError("There was a problem creating your file: " + cse.getMessage() + " Check file name and try again", bundle);
151 151
					}
152 152
				}
153 153
			} else if (exception != null) {
154
				startFileError("There was a problem creating your container: " + exception.getMessage()+" Check container name and try again", bundle);				
154
				startFileError("There was a problem creating your file: " + exception.getMessage()+" Check file name and try again", bundle);				
155 155
			}			
156 156
		}
157 157
    }
b/src/com/rackspacecloud/android/ContainerObjectDetails.java
35 35
import android.os.AsyncTask;
36 36
import android.os.Bundle;
37 37
import android.os.Environment;
38
import android.util.Log;
38 39
import android.view.Menu;
39 40
import android.view.MenuInflater;
40 41
import android.view.MenuItem;
......
311 312
	    File file = new File(object.getAbsolutePath()); 
312 313
	    String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
313 314
	    String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
315
	    Log.d("info", "captin the file name is " + object.getName());
316
	    Log.d("info", "captin the uri is " + Uri.fromFile(object).toString());
314 317
	    myIntent.setDataAndType(Uri.fromFile(file),mimetype);
315 318
	    startActivity(myIntent);
316 319
	}
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java
235 235
				fileNames[i] = file.getName();
236 236
			}
237 237
		}
238
		
238
				
239 239
		displayCurrentFiles();
240 240
	}
241 241
	
......
612 612
			if (exception != null) {
613 613
				showAlert("Error", exception.getMessage());
614 614
			}
615
			Log.d("info", "captin the length of the fiels is " + result.size());
615 616
			setFileList(result);
616 617
			loadingFiles = false;
617 618
		}
b/src/com/rackspacecloud/android/ListAccountsActivity.java
46 46

  
47 47
public class ListAccountsActivity extends ListActivity{
48 48

  
49
	private ArrayList<Account> accounts;
49
	private final int PASSWORD_PROMPT = 123;
50 50
	private final String FILENAME = "accounts.data";
51
	private Intent tabViewIntent;
51
	
52 52
	private boolean authenticating;
53
	private ArrayList<Account> accounts;
54
	private Intent tabViewIntent;
53 55
	private ProgressDialog dialog;
54 56
	private Context context;
55
	private final int PASSWORD_PROMPT = 123;
57
	
58
	//need to store if the user has successfully logged in
59
	private boolean loggedIn;
56 60

  
57 61

  
58 62
	public void onCreate(Bundle savedInstanceState) {
......
69 73
	protected void onSaveInstanceState(Bundle outState) {
70 74
		super.onSaveInstanceState(outState);
71 75
		outState.putBoolean("authenticating", authenticating);
76
		outState.putBoolean("loggedIn", loggedIn);
72 77
		//need to set authenticating back to true because it is set to false
73 78
		//in hideDialog()
74 79
		if(authenticating){
......
80 85
	
81 86
	@Override
82 87
	protected void onRestoreInstanceState(Bundle state) {
88
		if (state != null && state.containsKey("loggedIn")){
89
			loggedIn = state.getBoolean("loggedIn");
90
		}
91
		else{
92
			loggedIn = false;
93
		}
83 94
		if (state != null && state.containsKey("authenticating") && state.getBoolean("authenticating")) {
84 95
    		showDialog();
85 96
    	} else {
......
123 134
	private void verifyPassword(){
124 135
		PasswordManager pwManager = new PasswordManager(getSharedPreferences(
125 136
				Preferences.SHARED_PREFERENCES_NAME, MODE_PRIVATE));
126
		if(pwManager.hasPassword()){
137
		if(pwManager.hasPassword() && !loggedIn){
127 138
			createCustomDialog(PASSWORD_PROMPT);
128 139
		}
129 140
	}
......
153 164
					if(!rightPassword(passwordText.getText().toString())){
154 165
						passwordText.setText("");
155 166
						showToast("Password was incorrect.");
167
						loggedIn = false;
156 168
					}
157 169
					else{
158 170
						dialog.dismiss();
171
						loggedIn = true;
159 172
					}
160 173
				}
161 174
				
b/src/com/rackspacecloud/android/ViewServerActivity.java
29 29
import android.graphics.Color;
30 30
import android.os.AsyncTask;
31 31
import android.os.Bundle;
32
import android.util.Log;
32 33
import android.view.View;
33 34
import android.view.View.OnClickListener;
34 35
import android.widget.Button;
......
338 339
		viewIntent.putExtra("request", bundle.getCurlRequest());
339 340
		startActivity(viewIntent);
340 341
	}
342
	
343
	private String prints(Object[] arr){
344
		String result = "";
345
		for(int i = 0; i < arr.length; i++){
346
			result += arr[i] + " ";
347
		}
348
		return result;
349
	}
341 350

  
342 351
	@Override
343 352
	protected Dialog onCreateDialog(int id) {
......
390 399
				})
391 400
				.create();
392 401
			case R.id.view_server_resize_button:
402
				Log.d("info", "the flavor names are " + prints(flavorNames));
393 403
				return new AlertDialog.Builder(ViewServerActivity.this)
394 404
				.setItems(flavorNames, new ResizeClickListener())
395 405
				.setIcon(R.drawable.alert_dialog_icon)
......
466 476
	private class ResizeClickListener implements android.content.DialogInterface.OnClickListener {
467 477

  
468 478
		public void onClick(DialogInterface dialog, int which) {
469
			selectedFlavorId = which + "";
479
			//need to add one because server flavors state at index 1
480
			selectedFlavorId = which + 1 + "";
470 481
			new ResizeServerTask().execute((Void[]) null);
471 482
		}
472 483

  

Also available in: Unified diff