Revision 378fe36a src/com/rackspace/cloud/android/PithosGroupsActivity.java

b/src/com/rackspace/cloud/android/PithosGroupsActivity.java
134 134
			group = null;
135 135
			user = null;
136 136
		}
137
		Log.i("GROUPS", "****************************");
138
		Log.i("GROUPS", "group:" + groupPos + " child:" + childPos);
139
		Log.i("GROUPS", "****************************");
140 137

  
141 138
		AlertDialog alertDialog = null;
142 139
		switch (item.getItemId()) {
......
162 159
					Map<String, String> headers = new HashMap<String, String>();
163 160
					if (isUser) {
164 161
						group.getUsers().remove(user);
165
						new GroupOrUserTask().execute("X-Account-Group-" + group.getName(),
166
								group.getUserString());
162
						new GroupOrUserTask().execute("X-Account-Group-"
163
								+ group.getName(), group.getUserString());
167 164
					} else {
168
						new GroupOrUserTask().execute("X-Account-Group-" + group.getName(),
169
								"~");
165
						new GroupOrUserTask().execute("X-Account-Group-"
166
								+ group.getName(), "~");
170 167
					}
171 168
				}
172 169
			});
......
195 192
						public void onClick(DialogInterface dialog,
196 193
								int whichButton) {
197 194
							String value = input.getText().toString().trim();
198
							new GroupOrUserTask().execute("X-Account-Group-" + group.getName(),
199
									group.getUserString() + value);
195
							String uuid = Account.getAccount().getUUIDForDisplayName(value, PithosGroupsActivity.this);
196
							if(uuid == null){
197
								showAlert("User Does Not Exist", "The username you supplied is not valid");
198
							}
199
							else{
200
								new GroupOrUserTask().execute("X-Account-Group-"
201
										+ group.getName(), group.getUserString()
202
										+ value);
203
							}
200 204
						}
201 205
					});
202 206

  
......
213 217
			return super.onContextItemSelected(item);
214 218
		}
215 219
	}
216
	
217
	private HttpBundle updateObject( String header, String value) throws CloudServersException{
220

  
221
	private HttpBundle updateObject(String header, String value)
222
			throws CloudServersException {
218 223
		Map<String, String> headers = new HashMap<String, String>();
219 224

  
220
		headers.put(header,value);
221
		HttpBundle bundel  = new ContainerObjectManager(
222
					getApplicationContext()).updateObject(
223
					null, null, null, "application/json",
224
					headers, null);
225
		headers.put(header, value);
226
		HttpBundle bundel = new ContainerObjectManager(getApplicationContext())
227
				.updateObject(null, null, null, "application/json", headers,
228
						null);
225 229
		return bundel;
226 230
	}
227 231

  
228
	private class GroupOrUserTask extends
229
			AsyncTask<String, Void, HttpBundle> {
232
	private class GroupOrUserTask extends AsyncTask<String, Void, HttpBundle> {
230 233

  
231 234
		private CloudServersException exception;
232 235

  
......
241 244
			HttpBundle bundle = null;
242 245
			try {
243 246
				bundle = updateObject(arg0[0], arg0[1]);
247
				bundle.parseResponse();
244 248
			} catch (CloudServersException e) {
245 249
				exception = e;
246 250
			}
......
253 257
			HttpResponse response = bundle.getResponse();
254 258
			if (response != null) {
255 259
				int statusCode = response.getStatusLine().getStatusCode();
256
				Log.i("Groups","status:"+statusCode);
260
				Log.i("Groups", "status:" + statusCode);
257 261
				if (statusCode == 202) {
258 262
					setResult(Activity.RESULT_OK);
259 263
					refresh();
260 264
					((GroupsListView) findViewById(R.id.groupsListView))
261
					.getGroupsAdapter().notifyDataSetChanged();
262
					
265
							.getGroupsAdapter().notifyDataSetChanged();
266

  
263 267
				} else {
264 268
					CloudServersException cse = parseCloudServersException(response);
265 269
					cse.printStackTrace();
......
275 279
				showError("There was a problem updating your Groups. "
276 280
						+ exception.getMessage(), bundle);
277 281
			}
278
			
282

  
279 283
		}
280 284
	}
281 285

  
......
289 293
				new DialogInterface.OnClickListener() {
290 294
					public void onClick(DialogInterface dialog, int whichButton) {
291 295
						String value = input.getText().toString().trim();
292
						new GroupOrUserTask().execute("X-Account-Group-" + value, "placeholder,");
296
						new GroupOrUserTask().execute("X-Account-Group-"
297
								+ value, "placeholder,");
293 298

  
294 299
					}
295 300
				});
......
305 310
	}
306 311

  
307 312
	protected void refresh() {
308
		try {
309
			new ContainerManager(getApplicationContext()).createList(true);
310
		} catch (CloudServersException e) {
311
			// TODO Auto-generated catch block
312
			e.printStackTrace();
313
		}
314
		((GroupsListView) findViewById(R.id.groupsListView)).getGroupsAdapter()
315
				.notifyDataSetChanged();
313
		new AsyncTask<Void, Void, Void>() {
314

  
315
			@Override
316
			protected Void doInBackground(Void... params) {
317
				try {
318
					new ContainerManager(getApplicationContext())
319
							.createList(true);
320
				} catch (CloudServersException e) {
321
					// TODO Auto-generated catch block
322
					e.printStackTrace();
323
				}
324
				return null;
325
			}
326

  
327
			protected void onPostExecute(Void result) {
328
				((GroupsListView) findViewById(R.id.groupsListView))
329
						.getGroupsAdapter().notifyDataSetChanged();
330
			};
331

  
332
		}.execute();
333

  
316 334
	}
317 335

  
318 336
	protected Container getContainer() {

Also available in: Unified diff