/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
*/
package gr.grnet.pithos.web.client.commands;
+import gr.grnet.pithos.web.client.AddUserDialog;
import gr.grnet.pithos.web.client.Pithos;
-import gr.grnet.pithos.web.client.foldertree.Resource;
import gr.grnet.pithos.web.client.grouptree.Group;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.PopupPanel;
/**
public void execute() {
if (containerPanel != null)
containerPanel.hide();
- String username = Window.prompt("Enter username:", "");
- if (username != null && username.length() > 0) {
- group.addMember(username);
- String path = "?update=";
- PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUsername(), path) {
-
- @Override
- public void onSuccess(@SuppressWarnings("unused") Resource result) {
- app.updateGroupNode(group);
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to update group:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error updating group:" + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- app.sessionExpired();
- }
- };
- updateGroup.setHeader("X-Auth-Token", app.getToken());
- String groupMembers = "";
- for (String u : group.getMembers())
- groupMembers += (u + ",");
- updateGroup.setHeader("X-Account-Group-" + group.getName(), groupMembers);
- Scheduler.get().scheduleDeferred(updateGroup);
- }
+ AddUserDialog dlg = new AddUserDialog(app, group);
+ dlg.center();
}
}