Revision c8f8690d
b/src/gr/grnet/pithos/web/client/AddUserDialog.java | ||
---|---|---|
45 | 45 |
import com.google.gwt.http.client.URL; |
46 | 46 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
47 | 47 |
import com.google.gwt.user.client.ui.*; |
48 |
import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs; |
|
49 |
import gr.grnet.pithos.web.client.catalog.UserCatalogs; |
|
48 | 50 |
import gr.grnet.pithos.web.client.grouptree.Group; |
49 | 51 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
50 | 52 |
import gr.grnet.pithos.web.client.rest.RestException; |
51 | 53 |
|
54 |
import java.util.Arrays; |
|
55 |
|
|
52 | 56 |
/** |
53 | 57 |
* The 'Folder properties' dialog box implementation. |
54 | 58 |
*/ |
... | ... | |
60 | 64 |
/** |
61 | 65 |
* The widget that holds the folderName of the folder. |
62 | 66 |
*/ |
63 |
TextBox userName = new TextBox(); |
|
67 |
TextBox userNameInput = new TextBox();
|
|
64 | 68 |
|
65 | 69 |
final VerticalPanel inner; |
66 | 70 |
|
... | ... | |
101 | 105 |
FlexTable generalTable = new FlexTable(); |
102 | 106 |
generalTable.setText(0, 0, "Username"); |
103 | 107 |
|
104 |
generalTable.setWidget(0, 1, userName); |
|
108 |
generalTable.setWidget(0, 1, userNameInput);
|
|
105 | 109 |
|
106 | 110 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
107 | 111 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
... | ... | |
131 | 135 |
@Override |
132 | 136 |
public void center() { |
133 | 137 |
super.center(); |
134 |
userName.setFocus(true); |
|
138 |
userNameInput.setFocus(true);
|
|
135 | 139 |
} |
136 | 140 |
|
137 | 141 |
@Override |
... | ... | |
165 | 169 |
hide(); |
166 | 170 |
} |
167 | 171 |
|
168 |
/** |
|
169 |
* Generate an RPC request to create a new folder. |
|
170 |
*/ |
|
171 |
void addUser() { |
|
172 |
String name = userName.getText().trim(); |
|
173 |
if(name.length() == 0) { |
|
174 |
return; |
|
175 |
} |
|
176 |
if(!Const.EMAIL_REGEX.test(name)) { |
|
177 |
app.displayWarning("Username must be a valid email address"); |
|
178 |
return; |
|
179 |
} |
|
180 |
|
|
181 |
group.addMember(name); |
|
172 |
private void doAddUser(final String userID) { |
|
173 |
group.addMember(userID); |
|
182 | 174 |
String path = "?update="; |
183 | 175 |
PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUserID(), path) { |
184 | 176 |
|
... | ... | |
212 | 204 |
updateGroup.setHeader(Const.X_ACCOUNT_GROUP_ + URL.encodePathSegment(group.getName()), groupMembers); |
213 | 205 |
Scheduler.get().scheduleDeferred(updateGroup); |
214 | 206 |
} |
207 |
/** |
|
208 |
* Generate an RPC request to create a new folder. |
|
209 |
*/ |
|
210 |
void addUser() { |
|
211 |
final String userDisplayName = userNameInput.getText().trim(); |
|
212 |
if(userDisplayName.length() == 0) { |
|
213 |
return; |
|
214 |
} |
|
215 |
if(!Const.EMAIL_REGEX.test(userDisplayName)) { |
|
216 |
app.displayWarning("Username must be a valid email address"); |
|
217 |
return; |
|
218 |
} |
|
219 |
|
|
220 |
if(app.hasIDForUserDisplayName(userDisplayName)) { |
|
221 |
final String userID = app.getIDForUserDisplayName(userDisplayName); |
|
222 |
doAddUser(userID); |
|
223 |
} |
|
224 |
else { |
|
225 |
new UpdateUserCatalogs(app, null, Arrays.asList(userDisplayName)) { |
|
226 |
@Override |
|
227 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
|
228 |
final String userID = app.getIDForUserDisplayName(userDisplayName); |
|
229 |
doAddUser(userID); |
|
230 |
} |
|
231 |
}.scheduleDeferred(); |
|
232 |
} |
|
233 |
|
|
234 |
|
|
235 |
} |
|
215 | 236 |
} |
b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java | ||
---|---|---|
141 | 141 |
} |
142 | 142 |
|
143 | 143 |
final String ownerID = file.getOwnerID(); |
144 |
final String displayName = app.getUserDisplayNameForID(ownerID);
|
|
144 |
final String displayName = app.getDisplayNameForUserID(ownerID);
|
|
145 | 145 |
final String ownerDisplayName; |
146 | 146 |
if(displayName == null) { |
147 | 147 |
// FIXME: Get the actual display name and do not use the id |
b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java | ||
---|---|---|
136 | 136 |
} |
137 | 137 |
else { |
138 | 138 |
final String ownerID = folder.getOwnerID(); |
139 |
final String displayName = app.getUserDisplayNameForID(ownerID);
|
|
139 |
final String displayName = app.getDisplayNameForUserID(ownerID);
|
|
140 | 140 |
final String ownerDisplayName; |
141 | 141 |
if(displayName == null) { |
142 | 142 |
// FIXME: Get the actual display name and do not use the id |
b/src/gr/grnet/pithos/web/client/PermissionsAddDialog.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import com.google.gwt.http.client.Request; |
|
38 |
import com.google.gwt.http.client.Response; |
|
39 |
import com.google.gwt.json.client.JSONObject; |
|
40 |
import gr.grnet.pithos.web.client.catalog.GetUserCatalogs; |
|
41 | 37 |
import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs; |
42 | 38 |
import gr.grnet.pithos.web.client.catalog.UserCatalogs; |
43 | 39 |
import gr.grnet.pithos.web.client.grouptree.Group; |
... | ... | |
179 | 175 |
} |
180 | 176 |
|
181 | 177 |
// Now get the userID |
182 |
final String userID = app.getUserIDForDisplayName(userDisplayName);
|
|
178 |
final String userID = app.getIDForUserDisplayName(userDisplayName);
|
|
183 | 179 |
if(userID != null) { |
184 | 180 |
// Check if already have the permission |
185 | 181 |
if(!alreadyHasPermission(userID)) { |
... | ... | |
191 | 187 |
new UpdateUserCatalogs(app, null, Helpers.toList(userDisplayName)) { |
192 | 188 |
@Override |
193 | 189 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
194 |
final String userID = updatedUserCatalogs.getUserID(userDisplayName);
|
|
190 |
final String userID = updatedUserCatalogs.getID(userDisplayName); |
|
195 | 191 |
if(userID == null) { |
196 | 192 |
app.displayWarning("Unknown user " + userDisplayName); |
197 | 193 |
} |
b/src/gr/grnet/pithos/web/client/PermissionsList.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import com.google.gwt.http.client.Request; |
|
38 |
import com.google.gwt.http.client.Response; |
|
39 |
import com.google.gwt.json.client.JSONObject; |
|
40 | 37 |
import gr.grnet.pithos.web.client.FilePermissionsDialog.Images; |
41 | 38 |
|
42 | 39 |
import java.util.HashMap; |
... | ... | |
49 | 46 |
import com.google.gwt.user.client.Command; |
50 | 47 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
51 | 48 |
import com.google.gwt.user.client.ui.Anchor; |
52 |
import com.google.gwt.user.client.ui.CheckBox; |
|
53 | 49 |
import com.google.gwt.user.client.ui.Composite; |
54 | 50 |
import com.google.gwt.user.client.ui.FlexTable; |
55 | 51 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
56 |
import com.google.gwt.user.client.ui.PushButton; |
|
57 | 52 |
import com.google.gwt.user.client.ui.RadioButton; |
58 | 53 |
import com.google.gwt.user.client.ui.VerticalPanel; |
59 |
import gr.grnet.pithos.web.client.catalog.GetUserCatalogs; |
|
60 | 54 |
import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs; |
61 | 55 |
import gr.grnet.pithos.web.client.catalog.UserCatalogs; |
62 | 56 |
|
... | ... | |
134 | 128 |
for(final String userID : permissions.keySet()) { |
135 | 129 |
if (!userID.contains(":")) { |
136 | 130 |
//not a group |
137 |
final String displayName = app.getUserDisplayNameForID(userID);
|
|
131 |
final String displayName = app.getDisplayNameForUserID(userID);
|
|
138 | 132 |
if(displayName != null) { |
139 | 133 |
permTable.setHTML( |
140 | 134 |
i, |
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
129 | 129 |
return displayName == null ? getUserID() : displayName; |
130 | 130 |
} |
131 | 131 |
|
132 |
public boolean hasUserDisplayNameForID(String userID) {
|
|
132 |
public boolean hasDisplayNameForUserID(String userID) {
|
|
133 | 133 |
return userCatalogs.getDisplayName(userID) != null; |
134 | 134 |
} |
135 | 135 |
|
136 |
public String getUserDisplayNameForID(String userID) { |
|
136 |
public boolean hasIDForUserDisplayName(String userDisplayName) { |
|
137 |
return userCatalogs.getID(userDisplayName) != null; |
|
138 |
} |
|
139 |
|
|
140 |
public String getDisplayNameForUserID(String userID) { |
|
137 | 141 |
return userCatalogs.getDisplayName(userID); |
138 | 142 |
} |
139 | 143 |
|
140 |
public String getUserIDForDisplayName(String displayName) {
|
|
141 |
return userCatalogs.getUserID(displayName);
|
|
144 |
public String getIDForUserDisplayName(String userDisplayName) {
|
|
145 |
return userCatalogs.getID(userDisplayName);
|
|
142 | 146 |
} |
143 | 147 |
|
144 |
public List<String> getUserDisplayNamesForIDs(List<String> userIDs) {
|
|
148 |
public List<String> getDisplayNamesForUserIDs(List<String> userIDs) {
|
|
145 | 149 |
if(userIDs == null) { |
146 | 150 |
userIDs = new ArrayList<String>(); |
147 | 151 |
} |
148 | 152 |
final List<String> userDisplayNames = new ArrayList<String>(); |
149 | 153 |
for(String userID : userIDs) { |
150 |
final String displayName = getUserDisplayNameForID(userID);
|
|
154 |
final String displayName = getDisplayNameForUserID(userID);
|
|
151 | 155 |
userDisplayNames.add(displayName); |
152 | 156 |
} |
153 | 157 |
|
... | ... | |
332 | 336 |
} |
333 | 337 |
}-*/; |
334 | 338 |
|
335 |
public static void LOG(String ...args) {
|
|
339 |
public static void LOG(Object ...args) {
|
|
336 | 340 |
final StringBuilder sb = new StringBuilder(); |
337 |
for(String arg : args) {
|
|
341 |
for(Object arg : args) {
|
|
338 | 342 |
sb.append(arg); |
339 | 343 |
} |
340 | 344 |
if(sb.length() > 0) { |
... | ... | |
710 | 714 |
|
711 | 715 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, getApiPath(), userID, path) { |
712 | 716 |
@Override |
713 |
public void onSuccess(AccountResource _result) {
|
|
714 |
account = _result;
|
|
717 |
public void onSuccess(AccountResource accountResource) {
|
|
718 |
account = accountResource;
|
|
715 | 719 |
if(callback != null) { |
716 | 720 |
callback.execute(); |
717 | 721 |
} |
722 |
|
|
723 |
final List<String> memberIDs = new ArrayList<String>(); |
|
724 |
final List<Group> groups = account.getGroups(); |
|
725 |
for(Group group : groups) { |
|
726 |
LOG("Group ", group); |
|
727 |
for(String member: group.getMembers()) { |
|
728 |
LOG(" ", member); |
|
729 |
memberIDs.add(member); |
|
730 |
} |
|
731 |
} |
|
732 |
|
|
733 |
final List<String> theUnknown = Pithos.this.filterUserIDsWithUnknownDisplayName(memberIDs); |
|
718 | 734 |
// Initialize the user catalog |
719 |
new UpdateUserCatalogs(Pithos.this, Pithos.this.getUserID()).scheduleDeferred(); |
|
735 |
new UpdateUserCatalogs(Pithos.this, theUnknown).scheduleEntry(); |
|
736 |
LOG("Called new UpdateUserCatalogs(Pithos.this, theUnknown).scheduleDeferred();"); |
|
720 | 737 |
} |
721 | 738 |
|
722 | 739 |
@Override |
b/src/gr/grnet/pithos/web/client/catalog/UpdateUserCatalogs.java | ||
---|---|---|
7 | 7 |
import gr.grnet.pithos.web.client.Helpers; |
8 | 8 |
import gr.grnet.pithos.web.client.Pithos; |
9 | 9 |
|
10 |
import java.util.Iterator; |
|
10 | 11 |
import java.util.List; |
12 |
import java.util.Map; |
|
11 | 13 |
|
12 | 14 |
/** |
13 | 15 |
* This is a wrapper around GetUserCatalogs that takes care of updating |
... | ... | |
30 | 32 |
} |
31 | 33 |
|
32 | 34 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
35 |
for(Map.Entry<String, String> uc : requestedUserCatalogs) { |
|
36 |
app.LOG("New displayName ", uc.getValue()); |
|
37 |
} |
|
33 | 38 |
} |
34 | 39 |
|
35 | 40 |
public void onError(Request request, Throwable t) { |
... | ... | |
60 | 65 |
public void scheduleDeferred() { |
61 | 66 |
Scheduler.get().scheduleDeferred(this); |
62 | 67 |
} |
68 |
|
|
69 |
public void scheduleEntry() { |
|
70 |
Scheduler.get().scheduleEntry(this); |
|
71 |
} |
|
63 | 72 |
} |
b/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java | ||
---|---|---|
45 | 45 |
); |
46 | 46 |
} |
47 | 47 |
|
48 |
public boolean hasID(String id) {
|
|
49 |
return id2name.containsKey(id);
|
|
48 |
public boolean hasID(String userID) {
|
|
49 |
return id2name.containsKey(userID);
|
|
50 | 50 |
} |
51 | 51 |
|
52 |
public boolean hasName(String name) {
|
|
53 |
return name2id.containsKey(name);
|
|
52 |
public boolean hasDisplayName(String displayName) {
|
|
53 |
return name2id.containsKey(displayName);
|
|
54 | 54 |
} |
55 | 55 |
|
56 |
public String getDisplayName(String id) {
|
|
57 |
return id2name.get(id);
|
|
56 |
public String getDisplayName(String userID) {
|
|
57 |
return id2name.get(userID);
|
|
58 | 58 |
} |
59 | 59 |
|
60 |
public String getUserID(String name) {
|
|
61 |
return name2id.get(name);
|
|
60 |
public String getID(String displayName) {
|
|
61 |
return name2id.get(displayName);
|
|
62 | 62 |
} |
63 | 63 |
|
64 |
/** |
|
65 |
* Returns an iterator of <code>(UUID, DisplayName)</code> pairs. |
|
66 |
*/ |
|
64 | 67 |
@Override |
65 | 68 |
public Iterator<Map.Entry<String, String>> iterator() { |
66 | 69 |
return id2name.entrySet().iterator(); |
b/src/gr/grnet/pithos/web/client/commands/RemoveUserCommand.java | ||
---|---|---|
76 | 76 |
final Group group = app.getAccount().getGroup(groupName); |
77 | 77 |
if (group == null) |
78 | 78 |
return; |
79 |
group.removeMember(user.getName());
|
|
79 |
group.removeMember(user.getUserID());
|
|
80 | 80 |
String path = "?update="; |
81 | 81 |
PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUserID(), path) { |
82 | 82 |
|
b/src/gr/grnet/pithos/web/client/grouptree/Group.java | ||
---|---|---|
62 | 62 |
public void removeMember(String username) { |
63 | 63 |
members.remove(username); |
64 | 64 |
} |
65 |
|
|
66 |
@Override |
|
67 |
public String toString() { |
|
68 |
return "Group(" + name + ", " + members.size() + " members)"; |
|
69 |
} |
|
65 | 70 |
} |
b/src/gr/grnet/pithos/web/client/grouptree/GroupTreeViewModel.java | ||
---|---|---|
86 | 86 |
public void render(Context context, User value, SafeHtmlBuilder sb) { |
87 | 87 |
String html = AbstractImagePrototype.create(GroupTreeView.images.user()).getHTML(); |
88 | 88 |
sb.appendHtmlConstant(html).appendHtmlConstant(" "); |
89 |
sb.append(Templates.INSTANCE.nameSpan(value.getName()));
|
|
89 |
sb.append(Templates.INSTANCE.nameSpan(value.getUserID()));
|
|
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
@Override |
b/src/gr/grnet/pithos/web/client/grouptree/User.java | ||
---|---|---|
36 | 36 |
package gr.grnet.pithos.web.client.grouptree; |
37 | 37 |
|
38 | 38 |
|
39 |
public class User { |
|
40 |
private String name; |
|
41 |
|
|
42 |
private String group; |
|
43 |
|
|
44 |
public User(String _name, String _group) { |
|
45 |
name = _name; |
|
46 |
group = _group; |
|
39 |
public final class User { |
|
40 |
private final String userID; |
|
41 |
|
|
42 |
private final String group; |
|
43 |
|
|
44 |
public User(String name, String group) { |
|
45 |
this.userID = name; |
|
46 |
this.group = group; |
|
47 |
} |
|
48 |
|
|
49 |
public String getUserID() { |
|
50 |
return this.userID; |
|
51 |
} |
|
52 |
|
|
53 |
public String getGroup() { |
|
54 |
return this.group; |
|
47 | 55 |
} |
48 | 56 |
|
49 |
public String getName() { |
|
50 |
return name; |
|
57 |
@Override |
|
58 |
public boolean equals(Object o) { |
|
59 |
if(this == o) { |
|
60 |
return true; |
|
61 |
} |
|
62 |
if(o == null || getClass() != o.getClass()) { |
|
63 |
return false; |
|
64 |
} |
|
65 |
|
|
66 |
User user = (User) o; |
|
67 |
|
|
68 |
if(group != null ? !group.equals(user.group) : user.group != null) { |
|
69 |
return false; |
|
70 |
} |
|
71 |
if(userID != null ? !userID.equals(user.userID) : user.userID != null) { |
|
72 |
return false; |
|
73 |
} |
|
74 |
|
|
75 |
return true; |
|
51 | 76 |
} |
52 | 77 |
|
53 |
public String getGroup() { |
|
54 |
return group; |
|
55 |
} |
|
78 |
@Override |
|
79 |
public int hashCode() { |
|
80 |
int result = userID != null ? userID.hashCode() : 0; |
|
81 |
result = 31 * result + (group != null ? group.hashCode() : 0); |
|
82 |
return result; |
|
83 |
} |
|
56 | 84 |
} |
b/src/gr/grnet/pithos/web/client/othersharedtree/OtherSharedTreeViewModel.java | ||
---|---|---|
45 | 45 |
import com.google.gwt.http.client.Request; |
46 | 46 |
import com.google.gwt.http.client.Response; |
47 | 47 |
import com.google.gwt.http.client.URL; |
48 |
import com.google.gwt.json.client.JSONObject; |
|
49 | 48 |
import com.google.gwt.safehtml.shared.SafeHtml; |
50 | 49 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
51 | 50 |
import com.google.gwt.text.shared.SafeHtmlRenderer; |
... | ... | |
57 | 56 |
import gr.grnet.pithos.web.client.FolderContextMenu; |
58 | 57 |
import gr.grnet.pithos.web.client.Pithos; |
59 | 58 |
import gr.grnet.pithos.web.client.SharingUsers; |
60 |
import gr.grnet.pithos.web.client.catalog.GetUserCatalogs; |
|
61 | 59 |
import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs; |
62 | 60 |
import gr.grnet.pithos.web.client.catalog.UserCatalogs; |
63 | 61 |
import gr.grnet.pithos.web.client.foldertree.AccountResource; |
... | ... | |
127 | 125 |
return new DefaultNodeInfo<String>(userLevelDataProviderForIDs, new TextCell(new SafeHtmlRenderer<String>() { |
128 | 126 |
@Override |
129 | 127 |
public SafeHtml render(String object) { |
130 |
final String displayName = app.getUserDisplayNameForID(object);
|
|
128 |
final String displayName = app.getDisplayNameForUserID(object);
|
|
131 | 129 |
// LOG("render(userID = "+object+"), displayName = " + displayName); |
132 | 130 |
SafeHtmlBuilder builder = new SafeHtmlBuilder(); |
133 | 131 |
render(displayName, builder); |
... | ... | |
141 | 139 |
String html = AbstractImagePrototype.create(OtherSharedTreeView.images.myShared()).getHTML(); |
142 | 140 |
builder.appendHtmlConstant(html).appendHtmlConstant(" "); |
143 | 141 |
} |
144 |
final String displayName = app.getUserDisplayNameForID(object);
|
|
142 |
final String displayName = app.getDisplayNameForUserID(object);
|
|
145 | 143 |
builder.append(OtherSharedTreeView.Templates.INSTANCE.nameSpan(object)); |
146 | 144 |
} |
147 | 145 |
}), null, null); |
Also available in: Unified diff