Revision 7b27f0dc

b/AndroidManifest.xml
100 100
		<activity android:name=".PithosLoginActivity"></activity>
101 101
		<activity android:name=".ContactActivity"></activity>
102 102
		
103
		<activity android:name=".AddFileActivity"></activity>
103
		
104 104
		<activity android:name=".ErrorDetailsActivity"></activity>
105 105
		<activity android:name=".ConfirmResizeActivity"
106 106
			android:theme="@android:style/Theme.Dialog"></activity>
/dev/null
1
package com.rackspace.cloud.android;
2

  
3
import org.apache.http.HttpResponse;
4

  
5
import android.app.Activity;
6
import android.os.AsyncTask;
7
import android.os.Bundle;
8
import android.view.View;
9
import android.view.View.OnClickListener;
10
import android.widget.Button;
11
import android.widget.EditText;
12

  
13
import com.rackspace.cloud.android.R;
14
import com.rackspace.cloud.files.api.client.ContainerObjectManager;
15
import com.rackspace.cloud.servers.api.client.CloudServersException;
16
import com.rackspace.cloud.servers.api.client.http.HttpBundle;
17

  
18
public class AddFileActivity extends CloudActivity implements OnClickListener{
19

  
20
	private EditText fileName;
21
	private EditText contents;
22
	private String containerName;
23
	private String path;
24

  
25
	/** Called when the activity is first created. */
26
	@Override
27
	public void onCreate(Bundle savedInstanceState) {
28
		super.onCreate(savedInstanceState);
29
		trackPageView(GoogleAnalytics.PAGE_ADD_OBJECT);
30
		setContentView(R.layout.addtextfile);
31
		restoreState(savedInstanceState);
32
	}
33

  
34
	protected void restoreState(Bundle state){
35
		super.restoreState(state);
36
		containerName = (String) this.getIntent().getExtras().get("Cname");
37
		path = (String) this.getIntent().getExtras().get("curPath");
38
		setUpInputs();
39
	}
40

  
41
	@Override
42
	protected void onSaveInstanceState(Bundle outState) {
43
		super.onSaveInstanceState(outState);
44
	}
45

  
46
	private void setUpInputs(){
47
		((Button) findViewById(R.id.new_file_button)).setOnClickListener(this);
48
		fileName = ((EditText)findViewById(R.id.file_name_text));
49
		fileName.append(".txt");
50
		contents = ((EditText)findViewById(R.id.new_file_text));
51
	}
52

  
53
	public void onClick(View arg0) {
54
		if ("".equals(fileName.getText().toString())) {
55
			showAlert("Required Fields Missing", " File name is required.");
56
		} else {
57
			trackEvent(GoogleAnalytics.CATEGORY_FILE, GoogleAnalytics.EVENT_CREATE, "", -1);
58
			new SaveFileTask().execute((Void[]) null);
59
		}
60
	}
61

  
62
	private class SaveFileTask extends AsyncTask<Void, Void, HttpBundle> {
63
		private CloudServersException exception;
64

  
65
		protected void onPreExecute(){
66
			showDialog();
67
		}
68

  
69
		@Override
70
		protected HttpBundle doInBackground(Void... arg0) {
71
			HttpBundle bundle = null;
72
			try {
73
				bundle = (new ContainerObjectManager(getContext())).addObject(containerName, path, fileName.getText().toString(), "text/plain", contents.getText().toString());
74
			} catch (CloudServersException e) {
75
				exception = e;
76
			}
77
			return bundle;
78
		}
79

  
80
		@Override
81
		protected void onPostExecute(HttpBundle bundle) {
82
			hideDialog();
83
			HttpResponse response = bundle.getResponse();
84
			if (response != null) {
85
				int statusCode = response.getStatusLine().getStatusCode();
86
				if (statusCode == 201) {
87
					setResult(Activity.RESULT_OK);
88
					finish();
89
				} else {
90
					CloudServersException cse = parseCloudServersException(response);
91
					if ("".equals(cse.getMessage())) {
92
						showError("There was a problem creating your file.", bundle);
93
					} else {
94
						showError("There was a problem creating your file: " + cse.getMessage() +  " See details for more information", bundle);
95
					}
96
				}
97
			} else if (exception != null) {
98
				showError("There was a problem creating your file: " + exception.getMessage()+ " See details for more information", bundle);				
99
			}			
100
		}
101
	}
102
}
b/src/com/rackspace/cloud/android/ContainerObjectDetails.java
82 82
	private DownloadObjectListenerTask downloadObjTask;
83 83
	private List<ObjectVersion> versions = new ArrayList<ObjectVersion>();
84 84
	private boolean isReadOnly = false;
85
	private final List<String> metadataRemoved = new ArrayList<String>();
86
	private final Map<String,String> metadataAdded = new HashMap<String, String>();
87
	
85 88
	/** Called when the activity is first created. */
86 89
	@Override
87 90
	public void onCreate(Bundle savedInstanceState) {
......
94 97
				.get("containerNames");
95 98
		cdnURL = (String) this.getIntent().getExtras().get("cdnUrl");
96 99
		cdnEnabled = (String) this.getIntent().getExtras().get("isCdnEnabled");
97

  
100
		
98 101
		setContentView(R.layout.viewobject);
99 102
		TabHost tabs = (TabHost) findViewById(R.id.tabhost2);
100 103

  
......
197 200
	}
198 201

  
199 202
	private void loadObjectData() {
203
		setTitle("Details: " +objects.getCName());
204
		metadataRemoved.clear();
205
		metadataAdded.clear();
200 206
		if(Container.MYSHARED.equals(objects.getContainerName())||Container.MYSHARED.equals(containerNames)){
201 207
			isReadOnly = true;
202 208
			
......
306 312
	private void addMetatadata(String key, String value){
307 313
		if(objects.getMetadata()==null)
308 314
			objects.setMetadata(new HashMap<String, String>());
315
		metadataAdded.put(key,value);
309 316
		objects.getMetadata().put(key, value);
310 317
		rebuildMetadataList();
311 318
	}
......
324 331
			@Override
325 332
			public void onClick(View v1) {
326 333
				properties.removeView(v);
334
				metadataRemoved.add(metadata.getKey());
327 335
				objects.getMetadata().remove(metadata.getKey());
336
				
328 337

  
329 338
			}
330 339
		});
......
371 380
			((CheckBox) v.findViewById(R.id.read)).setEnabled(false);
372 381
			((CheckBox) v.findViewById(R.id.write)).setEnabled(false);
373 382
		}
374
		((TextView) v.findViewById(R.id.ownerName)).setText(perm.getUser());
383
		
384
		((TextView) v.findViewById(R.id.ownerName)).setText(perm.getUser()==null?perm.getGroup()+":":perm.getUser());
375 385
		((CheckBox) v.findViewById(R.id.read)).setChecked(perm.isRead());
376 386
		((CheckBox) v.findViewById(R.id.write)).setChecked(perm.isWrite());
377 387

  
......
597 607
		super.onCreateOptionsMenu(menu);
598 608
		MenuInflater inflater = getMenuInflater();
599 609
		inflater.inflate(R.menu.container_object_list_menu, menu);
600
		menu.findItem(R.id.delete_object).setVisible(isReadOnly);
601
		menu.findItem(R.id.save).setVisible(isReadOnly);
610
		menu.findItem(R.id.delete_object).setVisible(!isReadOnly);
611
		menu.findItem(R.id.save).setVisible(!isReadOnly);
602 612
		return true;
603 613
	}
604 614

  
......
982 992
	
983 993
	public void saveObject(){
984 994
		Map<String,String> headers = new HashMap<String,String>();
985
		for(Entry<String,String> entry : objects.getMetadata().entrySet()){
986
			headers.put("X-Object-Meta-"+entry.getKey(), entry.getValue());
995
		if(objects.getMetadata()!=null)
996
			for(Entry<String,String> entry : objects.getMetadata().entrySet()){
997
				headers.put("X-Object-Meta-"+entry.getKey(), entry.getValue());
998
			}
999
		for(String s : metadataRemoved){
1000
			headers.put("X-Object-Meta-"+s, "~");
1001
		}
1002
		String read ="";
1003
		String write="";
1004
		for(Permission p : objects.getPermissions()){
1005
			if(p.isWrite()){
1006
				if(!write.equals("")){
1007
					write = write+",";
1008
				}
1009
				write = write + (p.getGroup()==null?p.getUser():p.getGroup());
1010
			}
1011
			else if(p.isRead()){
1012
				if(!read.equals("")){
1013
					read = read+",";
1014
				}
1015
				read = read + (p.getGroup()==null?p.getUser():p.getGroup());
1016
			}
1017
			
1018
			
987 1019
		}
1020
		Log.d(LOG,"read:"+read);
1021
		Log.d(LOG,"write:"+write);
1022
		read = "read="+read;
1023
		write = "write="+write;
1024
		headers.put("X-Object-Sharing", read+";"+write);
988 1025
		try {
989 1026
			HttpBundle b = new ContainerObjectManager(getApplicationContext()).updateObject(objects.getContainerName(), objects.getCName(), "", null, headers);
990 1027
			Log.i(LOG,"response:"+b.getResponse().getStatusLine().getStatusCode());
b/src/com/rackspace/cloud/android/ContainerObjectsActivity.java
55 55

  
56 56
	private static final int deleteContainer = 0;
57 57
	private static final int deleteFolder = 1;
58

  
58
	private static final int deleteContext = 2;
59
	private static final int toTrashContext = 3;
60
	private static final int fromTrashContext = 4;
61
	private String currentSelectedPath=null;
59 62
	private ContainerObjects[] files;
60 63
	private static Container container;
61 64
	public String LOG = "viewFilesActivity";
......
104 107

  
105 108
	protected void restoreState(Bundle state) {
106 109
		super.restoreState(state);
107

  
110
		
108 111
		/*
109 112
		 * need reference to the app so you can access curDirFiles as well as
110 113
		 * processing status
......
200 203
	 * go to the current directory's parent and display that data
201 204
	 */
202 205
	private void goUpDirectory() {
206
		if(currentSelectedPath != null){
207
			currentSelectedPath=null;
208
			loadFiles();
209
			return;
210
		}
203 211
		currentPath = currentPath.substring(
204 212
				0,
205 213
				currentPath.substring(0, currentPath.length() - 2).lastIndexOf(
206 214
						"/") + 1);
207
		if(container.getName().equalsIgnoreCase(Container.MYSHARED)){
208
			loadCurrentDirectoryFiles();
209
			displayCurrentFiles();
210
		}
211
		else if(previousFiles!=null&&previousFiles.size()>0){
215
		if(previousFiles!=null&&previousFiles.size()>0){
212 216
			files = previousFiles.toArray(new ContainerObjects[]{});
213 217
			previousFiles=null;
214 218
			loadCurrentDirectoryFiles();
......
250 254
	 * determines if a file should be displayed in current directory
251 255
	 */
252 256
	protected Boolean fileBelongsInDir(ContainerObjects obj) {
253
		String objPath = obj.getCName();
257
		/*String objPath = obj.getCName();
254 258

  
255 259
		if (!objPath.startsWith(currentPath)) {
256 260
			Log.i(LOG, "Path is:" + currentPath + " " + objPath + " " + false);
......
260 264
			Log.i(LOG, "Path is:" + currentPath + " " + objPath + " "
261 265
					+ !objPath.contains("/"));
262 266
			return !objPath.contains("/");
263
		}
267
		}*/
268
		return true;
264 269
	}
265 270

  
266 271
	/*
267 272
	 * loads all the files that are in the container into one array
268 273
	 */
269
	private void setFileList(ArrayList<ContainerObjects> files) {
274
	private void setFileList(List<ContainerObjects> files) {
270 275
		if (files == null) {
271 276
			files = new ArrayList<ContainerObjects>();
272 277
		}
......
284 289
	}
285 290

  
286 291
	protected void displayCurrentFiles() {
292
		setTitle(container.getName()+": /"+currentPath);
287 293
		if (app.getCurFiles().size() == 0) {
288 294
			displayNoFilesCell();
289 295
		} else {
......
356 362
	protected void onListItemClick(ListView l, View v, int position, long id) {
357 363
		if (app.getCurFiles() != null && app.getCurFiles().size() > 0) {
358 364
			Intent viewIntent;
359
			if (app.getCurFiles().get(position).getContentType()
360
					.startsWith("application/directory")) {
365
			if (app.getCurFiles().get(position).isFolder()) {
361 366
				currentPath = app.getCurFiles().get(position).getCName() + "/";
362
				if(container.getName().equalsIgnoreCase(Container.MYSHARED)){
367
				/*if(container.getName().equalsIgnoreCase(Container.MYSHARED)){
363 368
					loadCurrentDirectoryFiles();
364 369
					displayCurrentFiles();
365 370
				}
366
				else{
371
				else{*/
367 372
					previousFiles = Arrays.asList(files);
368 373
					loadFiles();
369
				}
374
				//}
370 375
				//loadCurrentDirectoryFiles();
371 376
				//displayCurrentFiles();
372 377
			}
......
432 437
		}
433 438
		long id = getListAdapter().getItemId(info.position);
434 439
		final ContainerObjects obj = (ContainerObjects) getListAdapter().getItem(info.position);
435
		
440
		currentSelectedPath = obj.getCName() + "/";
436 441
		switch (item.getItemId()) {
437 442
			case R.id.delete_contextmenu:
438
				/*if (currentPath.equals("")) {
439
					showDialog(deleteContainer);
440
				} else {
441
					showDialog(deleteFolder);
442
				}*///TODO
443
				showDialog(deleteContext);
443 444
				return true;
444 445
			case R.id.totrash_contextmenu:
445
				/*if (currentPath.equals("")) {
446
					showDialog(deleteContainer);
447
				} else {
448
					showDialog(deleteFolder);
449
				}*///TODO
446
				showDialog(toTrashContext);
450 447
				return true;
451 448
			case R.id.fromtrash_contextmenu:
452
				/*if (currentPath.equals("")) {
453
					showDialog(deleteContainer);
454
				} else {
455
					showDialog(deleteFolder);
456
				}*///TODO
449
				showDialog(fromTrashContext);
457 450
				return true;
458 451
			case R.id.properties_contextmenu:
459 452
				Intent viewIntent;
......
466 459
				return true;
467 460
			
468 461
		}
462
		currentSelectedPath=null;
469 463
		return false;
470 464
		
471 465
	}
......
585 579
										// User clicked Cancel so do some stuff
586 580
									}
587 581
								}).create();
588
			} else {
589
				return new AlertDialog.Builder(ContainerObjectsActivity.this)
590
						.setIcon(R.drawable.alert_dialog_icon)
591
						.setTitle("Delete Folder")
592
						.setMessage("Folder must be empty to delete")
593
						.setNegativeButton("OK",
594
								new DialogInterface.OnClickListener() {
595
									public void onClick(DialogInterface dialog,
596
											int whichButton) {
597
										// User clicked Cancel so do some stuff
598
									}
599
								}).create();
600 582
			}
583
		case deleteContext:
584
			return new AlertDialog.Builder(ContainerObjectsActivity.this)
585
				.setIcon(R.drawable.alert_dialog_icon)
586
				.setTitle("Delete Object")
587
				.setMessage(
588
						"Are you sure you want to delete this Object?")
589
							.setPositiveButton("Delete Object",
590
									new DialogInterface.OnClickListener() {
591
										public void onClick(DialogInterface dialog,
592
												int whichButton) {
593
											// 	User clicked OK so do some stuff
594
											new DeleteObjectTask().execute(container.getName(), currentSelectedPath);
595
										}
596
									})
597
									.setNegativeButton("Cancel",
598
											new DialogInterface.OnClickListener() {
599
										public void onClick(DialogInterface dialog,
600
												int whichButton) {
601
											currentSelectedPath=null;
602
											// User clicked Cancel so do some stuff
603
										}
604
									}).create();
601 605
		case R.id.add_folder:
602 606
			final EditText input = new EditText(this);
603 607
			return new AlertDialog.Builder(ContainerObjectsActivity.this)
......
669 673

  
670 674
			ImageView objectImage = (ImageView) row
671 675
					.findViewById(R.id.file_type_image);
672
			if (file.getContentType().startsWith("application/directory")||file.getContentType().startsWith("application/folder")) {
676
			if (file.isFolder()) {
673 677
				objectImage.setImageResource(R.drawable.folder);
674 678
			} else {
675 679
				objectImage.setImageResource(R.drawable.file);
......
693 697
	}
694 698

  
695 699
	private class LoadFilesTask extends
696
			AsyncTask<String, Void, ArrayList<ContainerObjects>> {
700
			AsyncTask<String, Void, List<ContainerObjects>> {
697 701

  
698 702
		private CloudServersException exception;
699 703

  
......
703 707
		}
704 708

  
705 709
		@Override
706
		protected ArrayList<ContainerObjects> doInBackground(String... path) {
707
			ArrayList<ContainerObjects> files = null;
710
		protected List<ContainerObjects> doInBackground(String... path) {
711
			List<ContainerObjects> files = null;
708 712
			try {
709 713
				if (container.getName().equals(Container.MYSHARED)) {
710 714
					files = (new ContainerObjectManager(getContext()))
711
							.createListMyShared(true, container.getName(),
715
							.createListMyShared( container.getName(),
712 716
									new ContainerManager(getContext())
713
											.createList(true));
717
											.createList(true),path[0]);
714 718
				} else if (container.getName().equals(Container.OTHERS)) {
715 719

  
716 720
				} else {
717 721
					if (container.getOtherUser() == null)
718 722
						files = (new ContainerObjectManager(getContext()))
719
								.createList(true, container.getName(),path[0]);
723
								.createList(container.getName(), path[0]);
720 724
					else
721 725
						files = (new ContainerObjectManager(getContext()))
722
								.createOtherList(true, container.getName(),
723
										container.getOtherUser());
726
								.createOtherList(container.getName(), container.getOtherUser());
724 727
				}
725 728
			} catch (CloudServersException e) {
726 729
				exception = e;
......
730 733
		}
731 734

  
732 735
		@Override
733
		protected void onPostExecute(ArrayList<ContainerObjects> result) {
736
		protected void onPostExecute(List<ContainerObjects> result) {
734 737
			loadingFiles = false;
735 738
			hideDialog();
736 739
			if (exception != null) {
......
850 853
	private class DeleteObjectTask extends AsyncTask<String, Void, HttpBundle> {
851 854

  
852 855
		private CloudServersException exception;
853

  
856
		public boolean isInFile=false;
854 857
		@Override
855 858
		protected void onPreExecute() {
856 859
			showDialog();
......
1014 1017
		@Override
1015 1018
		protected void onPostExecute(Void arg1) {
1016 1019
			hideDialog();
1017
			removeFromList(currentPath);
1020
			if(currentSelectedPath==null)
1021
				removeFromList(currentPath);
1018 1022
			previousFiles=null;
1019 1023
			goUpDirectory();
1020 1024
		}
b/src/com/rackspace/cloud/android/PithosLoginActivity.java
55 55
	private void doLogin(){
56 56
		CookieSyncManager.createInstance(this);
57 57
		CookieSyncManager.getInstance().startSync();
58
		CookieSyncManager.getInstance().sync();
59
		String loginUrl ="https://plus.pithos.grnet.gr/im/login/";//invitation?code=3219662435709009446");
60
		/*
61
		CookieManager.getInstance().setCookie(loginUrl, "_pithos2_a='';expires=Mon, 17 Oct 2010 10:47:11 UTC;");
62
		CookieManager.getInstance().removeExpiredCookie();
63
		CookieManager.getInstance().removeSessionCookie();*/
64
		CookieManager.getInstance().removeAllCookie();
58 65
		final WebView webview = (WebView) findViewById(R.id.browser);//new WebView(this);
59 66
		webview.getSettings().setJavaScriptEnabled(true);
60 67
		// webview.setHttpAuthUsernamePassword("vho.grnet.gr", "VHO login",
......
64 71
		webview.clearFormData();
65 72
		webview.clearHistory();
66 73
		
67

  
74
		
68 75
		webview.getSettings().setBuiltInZoomControls(true);
69 76
		//webview.getSettings().setDefaultZoom(ZoomDensity.);
70 77
		if(Build.VERSION.SDK_INT!=7)
......
81 88
				  view.loadUrl(url); return true;
82 89
			  }
83 90
			 
84
			@Override
91
			@Override//?code=321 966 243 570 900 944 6 c: _pithos2_a=chstath%40ebs.gr%7CEL6igBZTXMyaemdV64OXPg%3D%3D
92

  
85 93
			public void onPageFinished(WebView view, String url) {
86 94
				super.onPageFinished(view, url);
87 95
				//webview.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
88
				CookieSyncManager.getInstance().sync();
96
				//CookieSyncManager.getInstance().sync();
97
				
89 98
				String cookie = CookieManager.getInstance().getCookie(url);
90
				Log.i("LOGIN COOKIE","c: "+cookie);
99
				Log.i("LOGIN COOKIE",url+" c: "+cookie);
91 100
				
92 101
				if(null!=cookie && cookie.startsWith("_pithos2_a")){
93 102
					try {
......
166 175
		//setContentView(webview);
167 176
		webview.clearSslPreferences();
168 177
		//webview.loadUrl("https://pithos.dev.grnet.gr/im/login/invitation?code=6879429392467020041");
169
		webview.loadUrl("https://plus.pithos.grnet.gr/im/login/invitation?code=3219662435709009446");
178
		
179
		
180
		webview.loadUrl(loginUrl);//invitation?code=3219662435709009446");
170 181
		//webview.loadUrl("http://www.google.gr");
171 182
	}
172 183
	void exit(String username,String token){
b/src/com/rackspace/cloud/android/PithosMySharedActivity.java
19 19
	}
20 20
	
21 21

  
22
	/* load only the files that should display for the 
23
	 * current directory in the curDirFiles[]
24
	 */
25
	protected void loadCurrentDirectoryFiles(){
26
		ArrayList<ContainerObjects> curFiles = new ArrayList<ContainerObjects>();
27
		Log.i(LOG,"loading files");
28
		ContainerObjects[] files = getFiles();
29
		if(files != null){
30
			for(int i = 0 ; i < files.length; i ++){
31
				Log.i(LOG,"loading files"+i);
32
				if(fileBelongsInDir(files[i])){
33
					curFiles.add(files[i]);
34
				}
35
			}
36
			AndroidCloudApplication app = (AndroidCloudApplication)this.getApplication();
37
			app.setCurFiles(curFiles);
38
		}
39
	}
40
	List<String> dirPaths=new ArrayList<String>();
41
	/*
42
	 * determines if a file should be displayed in current 
43
	 * directory
44
	 */
45
	protected Boolean fileBelongsInDir(ContainerObjects obj){
46
		String objPath = obj.getCName();
47
		String currentPath = getCurrentPath();
48
		
49
		if(!objPath.startsWith(currentPath)){
50
			Log.i(LOG,"Path is:"+currentPath+" "+objPath+" "+false);
51
			return false;
52
		}
53
		else if(objPath.endsWith("/")){
54
			return true;
55
		}
56
		else{
57
			objPath = objPath.substring(currentPath.length());
58
			Log.i(LOG,"Path is:"+currentPath+" "+objPath+" "+!objPath.contains("/"));
59
			return !objPath.contains("/");
60
		}
61
	}
62 22
	
63
	protected void displayCurrentFiles(){
64
		AndroidCloudApplication app = (AndroidCloudApplication)this.getApplication();
65
		if (app.getCurFiles().size() == 0) {
66
			displayNoFilesCell();
67
		} else {
68
			ArrayList<ContainerObjects> tempList = new ArrayList<ContainerObjects>();
69
			for(int i = 0; i < app.getCurFiles().size(); i++){
70
				tempList.add(app.getCurFiles().get(i));
71
			}
72
			getListView().setDividerHeight(1); // restore divider lines
73
			setListAdapter(new FileAdapter());
74
		}
75
	}
76

  
77 23

  
78 24
}
b/src/com/rackspace/cloud/files/api/client/ContainerObjectManager.java
3 3
import java.io.File;
4 4
import java.io.IOException;
5 5
import java.io.StringReader;
6
import java.io.UnsupportedEncodingException;
7 6
import java.net.MalformedURLException;
8 7
import java.net.URI;
9 8
import java.net.URISyntaxException;
......
23 22
import org.apache.http.client.methods.HttpGet;
24 23
import org.apache.http.client.methods.HttpPost;
25 24
import org.apache.http.client.methods.HttpPut;
25
import org.apache.http.client.methods.HttpRequestBase;
26 26
import org.apache.http.entity.FileEntity;
27
import org.apache.http.entity.StringEntity;
28 27
import org.apache.http.impl.client.BasicResponseHandler;
29 28
import org.apache.http.protocol.RequestExpectContinue;
30 29
import org.xml.sax.InputSource;
......
48 47
 * 
49 48
 */
50 49
public class ContainerObjectManager extends EntityManager {
51

  
50
	public final static int GET=0;
51
	public final static int PUT=1;
52
	public final static int POST=2;
53
	public final static int DELETE=3;
52 54
	public String LOG = "ContainerObjectManager";
53 55
	private Context context;
54 56
	public static final String storageToken = Account.getAccount()
......
57 59
	public ContainerObjectManager(Context context) {
58 60
		this.context = context;
59 61
	}
60

  
61
	public ArrayList<ContainerObjects> createList(boolean detail,
62
			String passName) throws CloudServersException {
63
		Log.i(LOG,"Create List:"+passName);
64
		CustomHttpClient httpclient = new CustomHttpClient(context);
65
		String url = getSafeURL(Account.getAccount().getStorageUrl(), passName)
66
				+ "?format=xml";
67
		HttpGet get = new HttpGet(url);
68
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
69

  
70
		get.addHeader("Content-Type", "application/xml");
71
		get.addHeader(CustomHttpClient.X_STORAGE_TOKEN, storageToken);
72

  
73
		try {
74
			HttpResponse resp = httpclient.execute(get);
75
			BasicResponseHandler responseHandler = new BasicResponseHandler();
76
			String body = responseHandler.handleResponse(resp);
77

  
78
			if (resp.getStatusLine().getStatusCode() == 200
79
					|| resp.getStatusLine().getStatusCode() == 203) {
80
				ContainerObjectXMLparser filesXMLParser = new ContainerObjectXMLparser();
81
				SAXParser saxParser = SAXParserFactory.newInstance()
82
						.newSAXParser();
83
				XMLReader xmlReader = saxParser.getXMLReader();
84
				xmlReader.setContentHandler(filesXMLParser);
85

  
86
				xmlReader.parse(new InputSource(new StringReader(body)));
87
				files = filesXMLParser.getViewFiles();
88
				for(ContainerObjects o :files)
89
					o.setContainerName(passName);
90

  
91
			} else {
92
				CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
93
				SAXParser saxParser = SAXParserFactory.newInstance()
94
						.newSAXParser();
95
				XMLReader xmlReader = saxParser.getXMLReader();
96
				xmlReader.setContentHandler(parser);
97
				xmlReader.parse(new InputSource(new StringReader(body)));
98
				CloudServersException cse = parser.getException();
99
				throw cse;
100
			}
101
		} catch (ClientProtocolException e) {
102
			CloudServersException cse = new CloudServersException();
103
			cse.setMessage(e.getLocalizedMessage());
104
			throw cse;
105
		} catch (IOException e) {
106
			CloudServersException cse = new CloudServersException();
107
			cse.setMessage(e.getLocalizedMessage());
108
			throw cse;
109
		} catch (ParserConfigurationException e) {
110
			CloudServersException cse = new CloudServersException();
111
			cse.setMessage(e.getLocalizedMessage());
112
			throw cse;
113
		} catch (SAXException e) {
114
			CloudServersException cse = new CloudServersException();
115
			cse.setMessage(e.getLocalizedMessage());
116
			throw cse;
117
		} catch (FactoryConfigurationError e) {
118
			CloudServersException cse = new CloudServersException();
119
			cse.setMessage(e.getLocalizedMessage());
120
			throw cse;
121
		}
122
		return files;
123

  
124
	}
125 62
	
126 63
	
127
	public ArrayList<ContainerObjects> createList(boolean detail,
128
			String passName, boolean shared) throws CloudServersException {
129
		Log.i(LOG,"Create List:"+passName);
64
	private List<ContainerObjects> executeGet(String containerName, String url) throws CloudServersException{
130 65
		CustomHttpClient httpclient = new CustomHttpClient(context);
131
		String url = getSafeURL(Account.getAccount().getStorageUrl(), passName)
132
				+ "?format=xml&shared="+shared;
133 66
		HttpGet get = new HttpGet(url);
134 67
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
135 68

  
......
152 85
				xmlReader.parse(new InputSource(new StringReader(body)));
153 86
				files = filesXMLParser.getViewFiles();
154 87
				for(ContainerObjects o :files)
155
					o.setContainerName(passName);
156

  
88
					o.setContainerName(containerName);
157 89
			} else {
158 90
				CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
159 91
				SAXParser saxParser = SAXParserFactory.newInstance()
......
186 118
			throw cse;
187 119
		}
188 120
		return files;
121
	}
122
		
123
	public List<ContainerObjects> createList(String containerName,
124
			boolean shared, String prefix) throws CloudServersException {
125
		Log.i(LOG,"Create List:"+containerName+ " prefix "+prefix);
126
		while(prefix.endsWith("/"))
127
			prefix = prefix.substring(0,prefix.length()-1);
128
		String url = getSafeURL(Account.getAccount().getStorageUrl(), containerName)
129
				+ "?format=xml&shared="+shared+"&prefix="+prefix+"&delimiter=/";
130
		Log.i(LOG," Getting "+containerName+":"+shared+" "+prefix);
131
		Log.i(LOG," URL:"+url);
132
		return executeGet(containerName, url);
189 133

  
190 134
	}
191 135
	
192
	public ArrayList<ContainerObjects> createOtherList(boolean detail,
193
			String passName, String user) throws CloudServersException {
194
		Log.i(LOG,"Create List:"+passName);
195
		CustomHttpClient httpclient = new CustomHttpClient(context);
196
		String url = getSafeURL(Account.getAccount().getStorageUrl().replaceAll(Account.getAccount().getUsername(), user), passName)
136
	public List<ContainerObjects> createOtherList(String containerName,
137
			String user) throws CloudServersException {
138
		Log.i(LOG,"Create List:"+containerName);		
139
		String url = getSafeURL(Account.getAccount().getStorageUrl().replaceAll(Account.getAccount().getUsername(), user), containerName)
197 140
				+ "?format=xml";
198
		HttpGet get = new HttpGet(url);
199
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
200

  
201
		get.addHeader("Content-Type", "application/xml");
202
		get.addHeader(CustomHttpClient.X_STORAGE_TOKEN, storageToken);
203

  
204
		try {
205
			HttpResponse resp = httpclient.execute(get);
206
			BasicResponseHandler responseHandler = new BasicResponseHandler();
207
			String body = responseHandler.handleResponse(resp);
208

  
209
			if (resp.getStatusLine().getStatusCode() == 200
210
					|| resp.getStatusLine().getStatusCode() == 203) {
211
				ContainerObjectXMLparser filesXMLParser = new ContainerObjectXMLparser();
212
				SAXParser saxParser = SAXParserFactory.newInstance()
213
						.newSAXParser();
214
				XMLReader xmlReader = saxParser.getXMLReader();
215
				xmlReader.setContentHandler(filesXMLParser);
216

  
217
				xmlReader.parse(new InputSource(new StringReader(body)));
218
				files = filesXMLParser.getViewFiles();
219
				for(ContainerObjects o :files)
220
					o.setContainerName(passName);
221

  
222
			} else {
223
				CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
224
				SAXParser saxParser = SAXParserFactory.newInstance()
225
						.newSAXParser();
226
				XMLReader xmlReader = saxParser.getXMLReader();
227
				xmlReader.setContentHandler(parser);
228
				xmlReader.parse(new InputSource(new StringReader(body)));
229
				CloudServersException cse = parser.getException();
230
				throw cse;
231
			}
232
		} catch (ClientProtocolException e) {
233
			CloudServersException cse = new CloudServersException();
234
			cse.setMessage(e.getLocalizedMessage());
235
			throw cse;
236
		} catch (IOException e) {
237
			CloudServersException cse = new CloudServersException();
238
			cse.setMessage(e.getLocalizedMessage());
239
			throw cse;
240
		} catch (ParserConfigurationException e) {
241
			CloudServersException cse = new CloudServersException();
242
			cse.setMessage(e.getLocalizedMessage());
243
			throw cse;
244
		} catch (SAXException e) {
245
			CloudServersException cse = new CloudServersException();
246
			cse.setMessage(e.getLocalizedMessage());
247
			throw cse;
248
		} catch (FactoryConfigurationError e) {
249
			CloudServersException cse = new CloudServersException();
250
			cse.setMessage(e.getLocalizedMessage());
251
			throw cse;
252
		}
253
		return files;
141
		return executeGet(containerName, url);
254 142

  
255 143
	}
256 144
	
257
	public ArrayList<ContainerObjects> createList(boolean detail,
258
			String passName, String prefix) throws CloudServersException {
259
		if(prefix.endsWith("/"))
145
	public List<ContainerObjects> createList(String containerName,
146
			String prefix) throws CloudServersException {
147
		while(prefix.endsWith("/"))
260 148
			prefix = prefix.substring(0,prefix.length()-1);
261
		CustomHttpClient httpclient = new CustomHttpClient(context);
262
		String url = getSafeURL(Account.getAccount().getStorageUrl(), passName)
149
		String url = getSafeURL(Account.getAccount().getStorageUrl(), containerName)
263 150
				+ "?format=xml&prefix="+prefix+"&delimiter=/";
264 151
		Log.i(LOG,url);
265
		HttpGet get = new HttpGet(url);
266
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
267

  
268
		get.addHeader("Content-Type", "application/xml");
269
		get.addHeader(CustomHttpClient.X_STORAGE_TOKEN, storageToken);
270

  
271
		try {
272
			HttpResponse resp = httpclient.execute(get);
273
			BasicResponseHandler responseHandler = new BasicResponseHandler();
274
			String body = responseHandler.handleResponse(resp);
275

  
276
			if (resp.getStatusLine().getStatusCode() == 200
277
					|| resp.getStatusLine().getStatusCode() == 203) {
278
				ContainerObjectXMLparser filesXMLParser = new ContainerObjectXMLparser();
279
				SAXParser saxParser = SAXParserFactory.newInstance()
280
						.newSAXParser();
281
				XMLReader xmlReader = saxParser.getXMLReader();
282
				xmlReader.setContentHandler(filesXMLParser);
283

  
284
				xmlReader.parse(new InputSource(new StringReader(body)));
285
				files = filesXMLParser.getViewFiles();
286
				for(ContainerObjects o :files)
287
					o.setContainerName(passName);
288

  
289
			} else {
290
				CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser();
291
				SAXParser saxParser = SAXParserFactory.newInstance()
292
						.newSAXParser();
293
				XMLReader xmlReader = saxParser.getXMLReader();
294
				xmlReader.setContentHandler(parser);
295
				xmlReader.parse(new InputSource(new StringReader(body)));
296
				CloudServersException cse = parser.getException();
297
				throw cse;
298
			}
299
		} catch (ClientProtocolException e) {
300
			CloudServersException cse = new CloudServersException();
301
			cse.setMessage(e.getLocalizedMessage());
302
			throw cse;
303
		} catch (IOException e) {
304
			CloudServersException cse = new CloudServersException();
305
			cse.setMessage(e.getLocalizedMessage());
306
			throw cse;
307
		} catch (ParserConfigurationException e) {
308
			CloudServersException cse = new CloudServersException();
309
			cse.setMessage(e.getLocalizedMessage());
310
			throw cse;
311
		} catch (SAXException e) {
312
			CloudServersException cse = new CloudServersException();
313
			cse.setMessage(e.getLocalizedMessage());
314
			throw cse;
315
		} catch (FactoryConfigurationError e) {
316
			CloudServersException cse = new CloudServersException();
317
			cse.setMessage(e.getLocalizedMessage());
318
			throw cse;
319
		}
320
		return files;
152
		return executeGet(containerName, url);
321 153

  
322 154
	}
323 155
	
......
326 158
		CustomHttpClient httpclient = new CustomHttpClient(context);
327 159
		String url = Account.getAccount().getStorageUrl()+"/"+ Container
328 160
				+ "/" + Object+"?format=xml&version=list";
329
		Log.i("papala",url);
161
		Log.i(LOG,url);
330 162
		HttpGet get = new HttpGet(url);
331 163
		List<ObjectVersion> versions =null;
332 164
		get.addHeader("Content-Type", "application/xml");
......
383 215
		return versions;
384 216
	}
385 217
	
386
	public ArrayList<ContainerObjects> createListMyShared(boolean detail,
387
			String passName, List<Container> containers) throws CloudServersException {
218
	public List<ContainerObjects> createListMyShared(
219
			String passName, List<Container> containers, String prefix) throws CloudServersException {
388 220

  
389 221
		ArrayList<ContainerObjects> files = new ArrayList<ContainerObjects>();
390 222
		for(Container con :containers ){
......
392 224
			if(con.getName().equalsIgnoreCase("trash")||con.getName().equals(Container.MYSHARED)||con.getName().equals(Container.OTHERS)){}
393 225
			else
394 226
			try{
395
				ArrayList<ContainerObjects> temp = createList(detail, con.getName(), true);
227
				List<ContainerObjects> temp = createList(con.getName(), true, prefix);
396 228
				for(ContainerObjects o : temp){
397 229
					Log.i(LOG,o.getCName()+" "+o.isShared());
398
					if(o.isShared()){
230
					if(o.isShared()||o.isSubDir()){
399 231
						o.setContainerName(Container.MYSHARED);
400 232
						files.add(o);
401 233
					}
......
408 240
		return files;
409 241

  
410 242
	}
411

  
412
	public HttpBundle deleteObject(String Container, String Object)
413
			throws CloudServersException {
243
	private HttpBundle executeMethod(int methodName ,String url) throws CloudServersException{
244
		return executeMethod(methodName, url, null, null);
245
	}
246
	
247
	private HttpBundle executeMethod(int methodName ,String url,String contentType) throws CloudServersException{
248
		return executeMethod(methodName, url, contentType, null);
249
	}
250
	
251
	private HttpBundle executeMethod(int methodName ,String url, String contentType, Map<String,String> headers) throws CloudServersException{
414 252
		HttpResponse resp = null;
415 253
		CustomHttpClient httpclient = new CustomHttpClient(context);
416
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container
417
				+ "/" + Object);
418
		HttpDelete deleteObject = new HttpDelete(url);
254
		Log.d(LOG, url);
255
		HttpRequestBase addObject = null;
256
		switch (methodName) {
257
		case GET:
258
			addObject = new HttpGet(url);
259
			break;
260
		case PUT:
261
			addObject = new HttpPut(url);
262
			break;
263
		case POST:
264
			addObject = new HttpPost(url);
265
			break;
266
		case DELETE:
267
			addObject = new HttpDelete(url);
268
			break;
269

  
270
		default:
271
			CloudServersException cse = new CloudServersException();
272
			cse.setMessage("Invalid method");
273
			throw cse;
274
		}
419 275

  
420
		deleteObject.addHeader("X-Auth-Token", Account.getAccount()
421
				.getAuthToken());
276
		addObject
277
				.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
278
		if(contentType!=null)
279
			addObject.addHeader("Content-Type", contentType);
280
		//addObject.addHeader("Content-Type",t);
281
		if(headers!=null)
282
			for(Entry<String,String> entry : headers.entrySet()){
283
				addObject.addHeader(entry.getKey(),entry.getValue());
284
			}
422 285
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
423 286

  
424 287
		HttpBundle bundle = new HttpBundle();
425
		bundle.setCurlRequest(deleteObject);
288
		bundle.setCurlRequest(addObject);
426 289

  
427 290
		try {
428
			resp = httpclient.execute(deleteObject);
291
			resp = httpclient.execute(addObject);
429 292
			bundle.setHttpResponse(resp);
430 293
		} catch (ClientProtocolException e) {
431 294
			CloudServersException cse = new CloudServersException();
......
443 306
		return bundle;
444 307
	}
445 308

  
446
	public HttpBundle getObject(String Container, String Object)
309
	public HttpBundle deleteObject(String Container, String Object)
447 310
			throws CloudServersException {
448
		HttpResponse resp = null;
449
		CustomHttpClient httpclient = new CustomHttpClient(context);
311
		
450 312
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container
451 313
				+ "/" + Object);
452
		HttpGet getObject = new HttpGet(url);
453
		getObject
454
				.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
455
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
456

  
457
		HttpBundle bundle = new HttpBundle();
458
		bundle.setCurlRequest(getObject);
314
		return executeMethod(DELETE, url);
315
	}
459 316

  
460
		try {
461
			resp = httpclient.execute(getObject);
462
			bundle.setHttpResponse(resp);
463
		} catch (ClientProtocolException e) {
464
			CloudServersException cse = new CloudServersException();
465
			cse.setMessage(e.getLocalizedMessage());
466
			throw cse;
467
		} catch (IOException e) {
468
			CloudServersException cse = new CloudServersException();
469
			cse.setMessage(e.getLocalizedMessage());
470
			throw cse;
471
		} catch (FactoryConfigurationError e) {
472
			CloudServersException cse = new CloudServersException();
473
			cse.setMessage(e.getLocalizedMessage());
474
			throw cse;
475
		}
476
		return bundle;
317
	public HttpBundle getObject(String Container, String Object)
318
			throws CloudServersException {
319
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container
320
				+ "/" + Object);
321
		return executeMethod(GET, url);
477 322
	}
478 323
	
479 324
	
480 325

  
481 326
	public HttpBundle addObject(String Container, String Path, String Object,
482 327
			String type) throws CloudServersException {
483
		HttpResponse resp = null;
484
		CustomHttpClient httpclient = new CustomHttpClient(context);
485 328
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container
486 329
				+ "/" + Path + Object);
487
		HttpPut addObject = new HttpPut(url);
488

  
489
		addObject
490
				.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
491
		addObject.addHeader("Content-Type", type);
492
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
493

  
494
		HttpBundle bundle = new HttpBundle();
495
		bundle.setCurlRequest(addObject);
496

  
497
		try {
498
			resp = httpclient.execute(addObject);
499
			bundle.setHttpResponse(resp);
500
		} catch (ClientProtocolException e) {
501
			CloudServersException cse = new CloudServersException();
502
			cse.setMessage(e.getLocalizedMessage());
503
			throw cse;
504
		} catch (IOException e) {
505
			CloudServersException cse = new CloudServersException();
506
			cse.setMessage(e.getLocalizedMessage());
507
			throw cse;
508
		} catch (FactoryConfigurationError e) {
509
			CloudServersException cse = new CloudServersException();
510
			cse.setMessage(e.getLocalizedMessage());
511
			throw cse;
512
		}
513
		return bundle;
330
		return executeMethod(DELETE, url,type);
514 331
	}
515 332
	
333
	
334
	
516 335
	public HttpBundle updateObject(String Container, String Path, String Object,
517 336
			String type, Map<String,String> headers) throws CloudServersException {
518
		HttpResponse resp = null;
519
		CustomHttpClient httpclient = new CustomHttpClient(context);
520 337
		String url;
521 338
		if(Container !=null)
522 339
			url = getSafeURL(Account.getAccount().getStorageUrl(), Container
......
527 344
				url = url.substring(0, url.length()-1);
528 345
		}
529 346
		url =url+"?update=";
530
		Log.d("papala", url);
531
		HttpPost addObject = new HttpPost(url);
532

  
533
		addObject
534
				.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
535
		addObject.addHeader("Content-Type", "	text/plain; charset=UTF-8");
536
		//addObject.addHeader("Content-Type",t);
537
		for(Entry<String,String> entry : headers.entrySet()){
538
			addObject.addHeader(entry.getKey(),entry.getValue());
539
		}
540
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
541

  
542
		HttpBundle bundle = new HttpBundle();
543
		bundle.setCurlRequest(addObject);
544

  
545
		try {
546
			resp = httpclient.execute(addObject);
547
			bundle.setHttpResponse(resp);
548
		} catch (ClientProtocolException e) {
549
			CloudServersException cse = new CloudServersException();
550
			cse.setMessage(e.getLocalizedMessage());
551
			throw cse;
552
		} catch (IOException e) {
553
			CloudServersException cse = new CloudServersException();
554
			cse.setMessage(e.getLocalizedMessage());
555
			throw cse;
556
		} catch (FactoryConfigurationError e) {
557
			CloudServersException cse = new CloudServersException();
558
			cse.setMessage(e.getLocalizedMessage());
559
			throw cse;
560
		}
561
		return bundle;
347
		Log.d(LOG, url);
348
		return executeMethod(DELETE, url,  "	text/plain; charset=UTF-8", headers);
562 349
	}
563 350

  
564
	/*
565
	 * used for adding text files, requires an extra parameter to store the data
566
	 * for the file
567
	 */
568
	public HttpBundle addObject(String Container, String Path, String Object,
569
			String type, String data) throws CloudServersException {
570
		HttpResponse resp = null;
571
		CustomHttpClient httpclient = new CustomHttpClient(context);
572
		String url = getSafeURL(Account.getAccount().getStorageUrl(), Container
573
				+ "/" + Path + Object);
574
		HttpPut addObject = new HttpPut(url);
575

  
576
		addObject
577
				.addHeader("X-Auth-Token", Account.getAccount().getAuthToken());
578
		addObject.addHeader("Content-Type", type);
579
		httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class);
580

  
581
		StringEntity tmp = null;
582
		try {
583
			tmp = new StringEntity(data);
584
		} catch (UnsupportedEncodingException e) {
585
			CloudServersException cse = new CloudServersException();
586
			cse.setMessage(e.getLocalizedMessage());
587
			throw cse;
588
		}
589
		addObject.setEntity(tmp);
590

  
591
		HttpBundle bundle = new HttpBundle();
592
		bundle.setCurlRequest(addObject);
593

  
594
		try {
595
			resp = httpclient.execute(addObject);
596
			bundle.setHttpResponse(resp);
597
		} catch (ClientProtocolException e) {
598
			CloudServersException cse = new CloudServersException();
599
			cse.setMessage(e.getLocalizedMessage());
600
			throw cse;
601
		} catch (IOException e) {
602
			CloudServersException cse = new CloudServersException();
603
			cse.setMessage(e.getLocalizedMessage());
604
			throw cse;
605
		} catch (FactoryConfigurationError e) {
606
			CloudServersException cse = new CloudServersException();
607
			cse.setMessage(e.getLocalizedMessage());
608
			throw cse;
609
		}
610
		return bundle;
611
	}
351
	
612 352
	
613 353
	/*
614
	 * used for adding text files, requires an extra parameter to store the data
354
	 * used for adding sdcard files, requires an extra parameter to store the data
615 355
	 * for the file
616 356
	 */
617 357
	public HttpBundle addFileObject(String Container, String Path, String Object,
b/src/com/rackspace/cloud/files/api/client/ContainerObjects.java
2 2

  
3 3
import java.util.Map;
4 4

  
5
import com.rackspace.cloud.servers.api.client.Account;
5 6
import com.rackspace.cloud.servers.api.client.Entity;
6 7

  
7 8
/**
......
14 15
	private String object;
15 16
	private String hash;
16 17
	private String lastMod;
17
	private int bytes;
18
	private int bytes=0;
18 19
	private String cname;
19 20
	private String contentType;
20 21
	private String containerName;
22
	private boolean subDir = false;
21 23
	
22
	private boolean isFolder() {
23
		return contentType.startsWith("application/folder;");
24
	public boolean isSubDir() {
25
		return subDir;
26
	}
27
	
28
	public void setSubDir(boolean subDir) {
29
		this.subDir = subDir;
30
	}
31
	
32
	public boolean isFolder() {
33
		return isSubDir()||getContentType().startsWith("application/directory")||getContentType().startsWith("application/folder");
24 34
	}
25 35
	
26 36
	public boolean isShared(){
......
28 38
			return true;
29 39
		}
30 40
		if(getObjectSharing()!=null){
31
			if(getObjectSharing().split(":").length>1)
32
				return true;
41
			if(getPermissions().size()>0){
42
				for(Permission p : getPermissions()){
43
					if(p.getGroup()!=null ||(p.getUser()!=null && !p.getUser().equals(Account.getAccount().getUsername()))){
44
						if(p.isRead()||p.isWrite())
45
							return true;
46
					}
47
				}
48
			}
49
			
33 50
		}
34 51
		return false;
35 52
	}
b/src/com/rackspace/cloud/files/api/client/Permission.java
25 25
            for (String u : users) {
26 26
            	Permission p = new Permission();
27 27
                String user = u.trim();
28
                p.setUser(user);
28
                if(u.indexOf(':')==-1)
29
                	p.setUser(user);
30
                else{
31
                	String group = user.substring(u.lastIndexOf(':')+1,u.length());
32
                	for(Permission pp : permissions){
33
                		if(group.equals(pp.getGroup())){
34
                			p=pp;
35
                			break;
36
                		}
37
                	}
38
                	p.setGroup(group);
39
                }
40
                	
29 41
                if (perm.equals("read")) {
30 42
                    p.read = Boolean.TRUE;
31 43
                }
b/src/com/rackspace/cloud/files/api/client/parsers/ContainerObjectXMLparser.java
4 4
import java.util.HashMap;
5 5
import java.util.Map;
6 6

  
7
import javax.security.auth.Subject;
8

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

  
......
31 33
	}
32 34

  
33 35
	public void endDocument() {
34
		Log.v(LOG, "endDocument = true");
36
		Log.v(LOG, "endDocument = true "+files);
35 37
	}
36 38

  
37 39
	public void startElement(String uri, String name, String qName,
......
45 47
		} else if ("x_object_meta".equals(name)) {
46 48
			metadata = new HashMap<String, String>();
47 49
		}
50
		 else if ("subdir".equals(name)) {
51
			 Log.i(LOG, "inside:"+name+" "+atts.getValue(0));
52
				object = new ContainerObjects();
53
				object.setSubDir(true);
54
				Log.i(LOG,true+" "+atts.getLength());
55
				for(int i=0;i<atts.getLength();i++){
56
					Log.i(LOG,true+" "+atts.getQName(i)+" "+atts.getLocalName(i)+" "+atts.getValue(i));
57
					if(atts.getLocalName(i).equals("name")){
58
						object.setName(atts.getValue(i));
59
						break;
60
					}
61
				}
62
				object.setCName(object.getName());
63
				files.add(object);
64
				Log.i(LOG,"set name:"+object.getName());
65
				object=null;
66
			}
48 67
	}
49 68

  
50 69
	public void endElement(String uri, String name, String qName) {

Also available in: Unified diff