Revision ee77dbf1
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; |
51 |
import gr.grnet.pithos.web.client.grouptree.User; |
|
49 | 52 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
50 | 53 |
import gr.grnet.pithos.web.client.rest.RestException; |
51 | 54 |
|
... | ... | |
60 | 63 |
/** |
61 | 64 |
* The widget that holds the folderName of the folder. |
62 | 65 |
*/ |
63 |
TextBox userName = new TextBox();
|
|
66 |
TextBox userDisplayNameTextBox = new TextBox();
|
|
64 | 67 |
|
65 | 68 |
final VerticalPanel inner; |
66 | 69 |
|
... | ... | |
101 | 104 |
FlexTable generalTable = new FlexTable(); |
102 | 105 |
generalTable.setText(0, 0, "Username"); |
103 | 106 |
|
104 |
generalTable.setWidget(0, 1, userName);
|
|
107 |
generalTable.setWidget(0, 1, userDisplayNameTextBox);
|
|
105 | 108 |
|
106 | 109 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
107 | 110 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
... | ... | |
131 | 134 |
@Override |
132 | 135 |
public void center() { |
133 | 136 |
super.center(); |
134 |
userName.setFocus(true);
|
|
137 |
userDisplayNameTextBox.setFocus(true);
|
|
135 | 138 |
} |
136 | 139 |
|
137 | 140 |
@Override |
... | ... | |
169 | 172 |
* Generate an RPC request to create a new folder. |
170 | 173 |
*/ |
171 | 174 |
void addUser() { |
172 |
String name = userName.getText().trim();
|
|
173 |
if(name.length() == 0) {
|
|
175 |
final String userDisplayName = userDisplayNameTextBox.getText().trim();
|
|
176 |
if(userDisplayName.length() == 0) {
|
|
174 | 177 |
return; |
175 | 178 |
} |
176 |
if(!Const.EMAIL_REGEX.test(name)) {
|
|
179 |
if(!Const.EMAIL_REGEX.test(userDisplayName)) {
|
|
177 | 180 |
app.displayWarning("Username must be a valid email address"); |
178 | 181 |
return; |
179 | 182 |
} |
180 | 183 |
|
181 |
group.addMember(name); |
|
182 |
String path = "?update="; |
|
183 |
PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUserID(), path) { |
|
184 |
// Now get the userID |
|
185 |
final String userID = app.getUserIDForDisplayName(userDisplayName); |
|
186 |
if(userID != null) { |
|
187 |
doAddUser(userID, userDisplayName); |
|
188 |
} |
|
189 |
else { |
|
190 |
// Must call server to obtain userID |
|
191 |
new UpdateUserCatalogs(app, null, Helpers.toList(userDisplayName)) { |
|
192 |
@Override |
|
193 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
|
194 |
final String userID = updatedUserCatalogs.getUserID(userDisplayName); |
|
195 |
if(userID != null) { |
|
196 |
doAddUser(userID, userDisplayName); |
|
197 |
} |
|
198 |
else { |
|
199 |
app.displayError("Unknown user " + userDisplayName); |
|
200 |
} |
|
201 |
} |
|
202 |
}.scheduleDeferred(); |
|
203 |
} |
|
204 |
} |
|
184 | 205 |
|
206 |
private void doAddUser(String userID, String userDisplayName) { |
|
207 |
final User newUser = new User(userID, userDisplayName, group.getName()); |
|
208 |
app.LOG("doAddUser() ", newUser); |
|
209 |
group.addUser(newUser); |
|
210 |
final String path = "?update="; |
|
211 |
PostRequest updateGroup = new PostRequest(app, app.getApiPath(), app.getUserID(), path) { |
|
185 | 212 |
@Override |
186 | 213 |
public void onSuccess(Resource result) { |
187 | 214 |
app.updateGroupNode(group); |
... | ... | |
205 | 232 |
} |
206 | 233 |
}; |
207 | 234 |
updateGroup.setHeader(Const.X_AUTH_TOKEN, app.getUserToken()); |
208 |
String groupMembers = ""; |
|
209 |
for(String u : group.getMembers()) { |
|
210 |
groupMembers += (URL.encodePathSegment(u) + ","); |
|
211 |
} |
|
235 |
final String groupMembers = group.encodeUserIDsForXAccountGroup(); |
|
212 | 236 |
updateGroup.setHeader(Const.X_ACCOUNT_GROUP_ + URL.encodePathSegment(group.getName()), groupMembers); |
213 | 237 |
Scheduler.get().scheduleDeferred(updateGroup); |
214 | 238 |
} |
b/src/gr/grnet/pithos/web/client/Const.java | ||
---|---|---|
23 | 23 |
public static final String TRASH_CONTAINER = "trash"; |
24 | 24 |
public static final RegExp EMAIL_REGEX = RegExp.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+[.][A-Z]{2,4}$", "i"); |
25 | 25 |
public static final String X_ACCOUNT_GROUP_ = "X-Account-Group-"; |
26 |
public static final String X_ACCOUNT_CONTAINER_COUNT = "X-Account-Container-Count"; |
|
27 |
public static final String X_ACCOUNT_OBJECT_COUNT = "X-Account-Object-Count"; |
|
28 |
public static final String X_ACCOUNT_BYTES_USED = "X-Account-Bytes-Used"; |
|
29 |
public static final String X_ACCOUNT_POLICY_QUOTA = "X-Account-Policy-Quota"; |
|
30 |
public static final String X_ACCOUNT_LAST_LOGIN = "X-Account-Last-Login"; |
|
31 |
public static final String LAST_MODIFIED = "Last-Modified"; |
|
32 |
public static final String NUMBER_FORMAT_1 = "######.#"; |
|
26 | 33 |
|
27 | 34 |
private Const() {} |
28 | 35 |
|
b/src/gr/grnet/pithos/web/client/DeleteFileDialog.java | ||
---|---|---|
135 | 135 |
if (iter.hasNext()) { |
136 | 136 |
File f = iter.next(); |
137 | 137 |
String path = f.getUri(); |
138 |
DeleteRequest deleteFile = new DeleteRequest(app.getApiPath(), f.getOwnerID(), URL.encode(path)) { |
|
138 |
DeleteRequest deleteFile = new DeleteRequest(app, app.getApiPath(), f.getOwnerID(), URL.encode(path)) {
|
|
139 | 139 |
@Override |
140 | 140 |
public void onSuccess(Resource result) { |
141 | 141 |
deleteFile(iter); |
b/src/gr/grnet/pithos/web/client/FeedbackDialog.java | ||
---|---|---|
140 | 140 |
*/ |
141 | 141 |
void sendFeedback() { |
142 | 142 |
final String feedbackURL = otherProperties.get("feedbackUrl"); |
143 |
PostRequest sendFeedback = new PostRequest("", "", feedbackURL, "feedback_msg=" + msg.getText() + "&feedback_data=" + appData + "&auth=" + app.getUserToken()) { |
|
143 |
PostRequest sendFeedback = new PostRequest(app, "", "", feedbackURL, "feedback_msg=" + msg.getText() + "&feedback_data=" + appData + "&auth=" + app.getUserToken()) {
|
|
144 | 144 |
|
145 | 145 |
@Override |
146 | 146 |
protected void onUnauthorized(Response response) { |
b/src/gr/grnet/pithos/web/client/FilePermissionsDialog.java | ||
---|---|---|
262 | 262 |
|
263 | 263 |
protected void updateMetaData(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) { |
264 | 264 |
if (newPermissions != null) { |
265 |
PostRequest updateFile = new PostRequest(api, owner, path) { |
|
265 |
PostRequest updateFile = new PostRequest(app, api, owner, path) {
|
|
266 | 266 |
@Override |
267 | 267 |
public void onSuccess(Resource result) { |
268 |
HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) { |
|
268 |
HeadRequest<File> headFile = new HeadRequest<File>(app, File.class, app.getApiPath(), file.getOwnerID(), path, file) {
|
|
269 | 269 |
|
270 | 270 |
@Override |
271 | 271 |
public void onSuccess(File _result) { |
b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java | ||
---|---|---|
261 | 261 |
|
262 | 262 |
if (newFilename != null) { |
263 | 263 |
final String path = file.getParent().getUri() + "/" + newFilename; |
264 |
PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUserID(), path) { |
|
264 |
PutRequest updateFile = new PutRequest(app, app.getApiPath(), app.getUserID(), path) {
|
|
265 | 265 |
@Override |
266 | 266 |
public void onSuccess(Resource result) { |
267 | 267 |
updateMetaData(app.getApiPath(), file.getOwnerID(), path, newMeta); |
... | ... | |
319 | 319 |
|
320 | 320 |
protected void updateMetaData(final String api, final String owner, final String path, Map<String, String> newMeta) { |
321 | 321 |
if (newMeta != null) { |
322 |
PostRequest updateFile = new PostRequest(api, owner, path + "?update=") { |
|
322 |
PostRequest updateFile = new PostRequest(app, api, owner, path + "?update=") {
|
|
323 | 323 |
@Override |
324 | 324 |
public void onSuccess(Resource result) { |
325 | 325 |
if (!app.isMySharedSelected()) |
b/src/gr/grnet/pithos/web/client/FilePublishDialog.java | ||
---|---|---|
230 | 230 |
|
231 | 231 |
protected void updateMetaData(String api, String owner, final String path, final Boolean published) { |
232 | 232 |
if (published != null) { |
233 |
PostRequest updateFile = new PostRequest(api, owner, path) { |
|
233 |
PostRequest updateFile = new PostRequest(app, api, owner, path) {
|
|
234 | 234 |
@Override |
235 | 235 |
public void onSuccess(Resource result) { |
236 |
HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) { |
|
236 |
HeadRequest<File> headFile = new HeadRequest<File>(app, File.class, app.getApiPath(), file.getOwnerID(), path, file) {
|
|
237 | 237 |
|
238 | 238 |
@Override |
239 | 239 |
public void onSuccess(File _result) { |
b/src/gr/grnet/pithos/web/client/FileVersionsDialog.java | ||
---|---|---|
146 | 146 |
|
147 | 147 |
protected void fetchVersions() { |
148 | 148 |
String path = file.getUri() + "?format=json&version=list"; |
149 |
GetRequest<FileVersions> getVersions = new GetRequest<FileVersions>(FileVersions.class, app.getApiPath(), file.getOwnerID(), path) { |
|
149 |
GetRequest<FileVersions> getVersions = new GetRequest<FileVersions>(app, FileVersions.class, app.getApiPath(), file.getOwnerID(), path) {
|
|
150 | 150 |
|
151 | 151 |
@Override |
152 | 152 |
public void onSuccess(FileVersions _result) { |
b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java | ||
---|---|---|
215 | 215 |
|
216 | 216 |
protected void updateMetadata(final String path, final Map<String, Boolean[]> newPermissions) { |
217 | 217 |
if (newPermissions != null) { |
218 |
PostRequest updateFolder = new PostRequest(app.getApiPath(), folder.getOwnerID(), path) { |
|
218 |
PostRequest updateFolder = new PostRequest(app, app.getApiPath(), folder.getOwnerID(), path) {
|
|
219 | 219 |
@Override |
220 | 220 |
public void onSuccess(Resource result) { |
221 | 221 |
app.updateFolder(folder.getParent(), false, new Command() { |
... | ... | |
234 | 234 |
if (t instanceof RestException) { |
235 | 235 |
if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { //Probably a virtual folder |
236 | 236 |
final String path1 = folder.getUri(); |
237 |
PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getOwnerID(), path1) { |
|
237 |
PutRequest newFolder = new PutRequest(app, app.getApiPath(), folder.getOwnerID(), path1) {
|
|
238 | 238 |
@Override |
239 | 239 |
public void onSuccess(Resource result) { |
240 | 240 |
updateMetadata(path, newPermissions); |
b/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java | ||
---|---|---|
249 | 249 |
return; |
250 | 250 |
} |
251 | 251 |
String path = folder.getUri() + "/" + name; |
252 |
PutRequest createFolder = new PutRequest(app.getApiPath(), folder.getOwnerID(), path) { |
|
252 |
PutRequest createFolder = new PutRequest(app, app.getApiPath(), folder.getOwnerID(), path) {
|
|
253 | 253 |
@Override |
254 | 254 |
public void onSuccess(Resource result) { |
255 | 255 |
app.updateFolder(folder, true, new Command() { |
b/src/gr/grnet/pithos/web/client/GroupCreateDialog.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.commands.AddUserCommand; |
|
38 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
39 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
40 |
|
|
41 | 37 |
import com.google.gwt.dom.client.NativeEvent; |
42 | 38 |
import com.google.gwt.event.dom.client.ClickEvent; |
43 | 39 |
import com.google.gwt.event.dom.client.ClickHandler; |
... | ... | |
45 | 41 |
import com.google.gwt.event.dom.client.KeyDownEvent; |
46 | 42 |
import com.google.gwt.user.client.Command; |
47 | 43 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
48 |
import com.google.gwt.user.client.ui.Anchor; |
|
49 |
import com.google.gwt.user.client.ui.Button; |
|
50 |
import com.google.gwt.user.client.ui.DialogBox; |
|
51 |
import com.google.gwt.user.client.ui.FlexTable; |
|
52 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
|
53 |
import com.google.gwt.user.client.ui.TextBox; |
|
54 |
import com.google.gwt.user.client.ui.VerticalPanel; |
|
44 |
import com.google.gwt.user.client.ui.*; |
|
45 |
import gr.grnet.pithos.web.client.commands.AddUserCommand; |
|
46 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
55 | 47 |
|
56 | 48 |
/** |
57 | 49 |
* The 'Folder properties' dialog box implementation. |
... | ... | |
61 | 53 |
protected Pithos app; |
62 | 54 |
|
63 | 55 |
private Command callback; |
64 |
|
|
65 |
/**
|
|
66 |
* The widget that holds the folderName of the folder.
|
|
67 |
*/
|
|
68 |
TextBox groupName = new TextBox();
|
|
69 |
|
|
70 |
final VerticalPanel inner;
|
|
71 |
|
|
72 |
public GroupCreateDialog(final Pithos app) {
|
|
73 |
this(app, null);
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* The widget's constructor.
|
|
78 |
*/
|
|
79 |
public GroupCreateDialog(final Pithos app, Command callback) {
|
|
56 |
|
|
57 |
/**
|
|
58 |
* The widget that holds the folderName of the folder.
|
|
59 |
*/
|
|
60 |
TextBox groupNameTextBox = new TextBox();
|
|
61 |
|
|
62 |
final VerticalPanel inner;
|
|
63 |
|
|
64 |
public GroupCreateDialog(final Pithos app) {
|
|
65 |
this(app, null);
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* The widget's constructor.
|
|
70 |
*/
|
|
71 |
public GroupCreateDialog(final Pithos app, Command callback) {
|
|
80 | 72 |
this.app = app; |
81 | 73 |
this.callback = callback; |
82 |
|
|
83 |
Anchor close = new Anchor("close");
|
|
84 |
close.addStyleName("close");
|
|
85 |
close.addClickHandler(new ClickHandler() {
|
|
86 |
|
|
87 |
@Override
|
|
88 |
public void onClick(ClickEvent event) {
|
|
89 |
hide();
|
|
90 |
}
|
|
91 |
});
|
|
92 |
|
|
93 |
setGlassEnabled(true);
|
|
94 |
setStyleName("pithos-DialogBox");
|
|
95 |
|
|
96 |
// Enable IE selection for the dialog (must disable it upon closing it)
|
|
97 |
Pithos.enableIESelection();
|
|
98 |
|
|
99 |
// Use this opportunity to set the dialog's caption.
|
|
100 |
setText("Create group");
|
|
101 |
|
|
102 |
// Outer contains inner and buttons
|
|
103 |
VerticalPanel outer = new VerticalPanel();
|
|
104 |
outer.add(close);
|
|
105 |
// Inner contains generalPanel and permPanel
|
|
106 |
inner = new VerticalPanel();
|
|
107 |
inner.addStyleName("inner");
|
|
108 |
|
|
109 |
VerticalPanel generalPanel = new VerticalPanel();
|
|
74 |
|
|
75 |
Anchor close = new Anchor("close");
|
|
76 |
close.addStyleName("close");
|
|
77 |
close.addClickHandler(new ClickHandler() {
|
|
78 |
|
|
79 |
@Override
|
|
80 |
public void onClick(ClickEvent event) {
|
|
81 |
hide();
|
|
82 |
}
|
|
83 |
});
|
|
84 |
|
|
85 |
setGlassEnabled(true);
|
|
86 |
setStyleName("pithos-DialogBox");
|
|
87 |
|
|
88 |
// Enable IE selection for the dialog (must disable it upon closing it)
|
|
89 |
Pithos.enableIESelection();
|
|
90 |
|
|
91 |
// Use this opportunity to set the dialog's caption.
|
|
92 |
setText("Create group");
|
|
93 |
|
|
94 |
// Outer contains inner and buttons
|
|
95 |
VerticalPanel outer = new VerticalPanel();
|
|
96 |
outer.add(close);
|
|
97 |
// Inner contains generalPanel and permPanel
|
|
98 |
inner = new VerticalPanel();
|
|
99 |
inner.addStyleName("inner");
|
|
100 |
|
|
101 |
VerticalPanel generalPanel = new VerticalPanel();
|
|
110 | 102 |
FlexTable generalTable = new FlexTable(); |
111 | 103 |
generalTable.setText(0, 0, "Name"); |
112 | 104 |
|
113 |
generalTable.setWidget(0, 1, groupName); |
|
105 |
generalTable.setWidget(0, 1, groupNameTextBox);
|
|
114 | 106 |
|
115 | 107 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
116 | 108 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
... | ... | |
120 | 112 |
|
121 | 113 |
outer.add(inner); |
122 | 114 |
|
123 |
// Create the 'Create/Update' button, along with a listener that hides the dialog
|
|
124 |
// when the button is clicked and quits the application.
|
|
125 |
String okLabel = "Create";
|
|
126 |
final Button ok = new Button(okLabel, new ClickHandler() {
|
|
127 |
@Override
|
|
128 |
public void onClick(ClickEvent event) {
|
|
129 |
createGroup();
|
|
130 |
closeDialog();
|
|
131 |
}
|
|
132 |
});
|
|
133 |
ok.addStyleName("button");
|
|
134 |
outer.add(ok);
|
|
115 |
// Create the 'Create/Update' button, along with a listener that hides the dialog
|
|
116 |
// when the button is clicked and quits the application.
|
|
117 |
String okLabel = "Create";
|
|
118 |
final Button ok = new Button(okLabel, new ClickHandler() {
|
|
119 |
@Override
|
|
120 |
public void onClick(ClickEvent event) {
|
|
121 |
createGroup();
|
|
122 |
closeDialog();
|
|
123 |
}
|
|
124 |
});
|
|
125 |
ok.addStyleName("button");
|
|
126 |
outer.add(ok);
|
|
135 | 127 |
outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
136 | 128 |
|
137 | 129 |
setWidget(outer); |
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public void center() { |
|
142 |
super.center(); |
|
143 |
groupName.setFocus(true); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
|
148 |
super.onPreviewNativeEvent(preview); |
|
149 |
|
|
150 |
NativeEvent evt = preview.getNativeEvent(); |
|
151 |
if (evt.getType().equals(KeyDownEvent.getType().getName())) |
|
152 |
// Use the popup's key preview hooks to close the dialog when either |
|
153 |
// enter or escape is pressed. |
|
154 |
switch (evt.getKeyCode()) { |
|
155 |
case KeyCodes.KEY_ENTER: |
|
156 |
createGroup(); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void center() { |
|
134 |
super.center(); |
|
135 |
groupNameTextBox.setFocus(true); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
|
140 |
super.onPreviewNativeEvent(preview); |
|
141 |
|
|
142 |
NativeEvent evt = preview.getNativeEvent(); |
|
143 |
if(evt.getType().equals(KeyDownEvent.getType().getName())) |
|
144 |
// Use the popup's key preview hooks to close the dialog when either |
|
145 |
// enter or escape is pressed. |
|
146 |
{ |
|
147 |
switch(evt.getKeyCode()) { |
|
148 |
case KeyCodes.KEY_ENTER: |
|
149 |
createGroup(); |
|
150 |
closeDialog(); |
|
151 |
break; |
|
152 |
case KeyCodes.KEY_ESCAPE: |
|
157 | 153 |
closeDialog(); |
158 |
break;
|
|
159 |
case KeyCodes.KEY_ESCAPE:
|
|
160 |
closeDialog();
|
|
161 |
break;
|
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Enables IE selection prevention and hides the dialog
|
|
168 |
* (we disable the prevention on creation of the dialog)
|
|
169 |
*/
|
|
170 |
public void closeDialog() {
|
|
171 |
Pithos.preventIESelection();
|
|
172 |
hide();
|
|
173 |
if (callback != null)
|
|
174 |
callback.execute();
|
|
175 |
} |
|
176 |
|
|
177 |
/**
|
|
178 |
* Generate an RPC request to create a new folder.
|
|
179 |
*/
|
|
180 |
void createGroup() {
|
|
181 |
String name = groupName.getText().trim();
|
|
182 |
if (name.length() == 0)
|
|
183 |
return;
|
|
184 |
Group group = app.addGroup(name);
|
|
185 |
|
|
186 |
new AddUserCommand(app, null, group).execute();
|
|
187 |
}
|
|
154 |
break;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
|
|
160 |
/** |
|
161 |
* Enables IE selection prevention and hides the dialog |
|
162 |
* (we disable the prevention on creation of the dialog)
|
|
163 |
*/
|
|
164 |
public void closeDialog() {
|
|
165 |
Pithos.preventIESelection();
|
|
166 |
hide();
|
|
167 |
if(callback != null) {
|
|
168 |
callback.execute();
|
|
169 |
}
|
|
170 |
}
|
|
171 |
|
|
172 |
/** |
|
173 |
* Generate an RPC request to create a new folder.
|
|
174 |
*/
|
|
175 |
void createGroup() {
|
|
176 |
final String groupName = groupNameTextBox.getText().trim();
|
|
177 |
if(groupName.length() == 0) {
|
|
178 |
return;
|
|
179 |
}
|
|
180 |
Group group = app.addGroup(groupName);
|
|
181 |
|
|
182 |
new AddUserCommand(app, null, group).execute();
|
|
183 |
}
|
|
188 | 184 |
} |
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 |
|
... | ... | |
146 | 140 |
new UpdateUserCatalogs(app, userID) { |
147 | 141 |
@Override |
148 | 142 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
149 |
final String displayName = updatedUserCatalogs.getDisplayName(userID); |
|
143 |
final String displayName = updatedUserCatalogs.getUserDisplayName(userID);
|
|
150 | 144 |
permTable.setHTML( |
151 | 145 |
ii, |
152 | 146 |
0, |
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
public String getCurrentUserDisplayNameOrID() { |
128 |
final String displayName = userCatalogs.getDisplayName(getUserID()); |
|
128 |
final String displayName = userCatalogs.getUserDisplayName(getUserID());
|
|
129 | 129 |
return displayName == null ? getUserID() : displayName; |
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
public boolean hasUserDisplayNameForID(String userID) { |
133 |
return userCatalogs.getDisplayName(userID) != null; |
|
133 |
return userCatalogs.getUserDisplayName(userID) != null; |
|
134 |
} |
|
135 |
|
|
136 |
public boolean hasUserIDForDisplayName(String displayName) { |
|
137 |
return userCatalogs.getUserID(displayName) != null; |
|
134 | 138 |
} |
135 | 139 |
|
136 | 140 |
public String getUserDisplayNameForID(String userID) { |
137 |
return userCatalogs.getDisplayName(userID); |
|
141 |
return userCatalogs.getUserDisplayName(userID);
|
|
138 | 142 |
} |
139 | 143 |
|
140 | 144 |
public String getUserIDForDisplayName(String displayName) { |
... | ... | |
160 | 164 |
} |
161 | 165 |
final List<String> filtered = new ArrayList<String>(); |
162 | 166 |
for(String userID : userIDs) { |
163 |
if(!this.userCatalogs.hasID(userID)) { |
|
167 |
if(!this.userCatalogs.hasUserID(userID)) {
|
|
164 | 168 |
filtered.add(userID); |
165 | 169 |
} |
166 | 170 |
} |
... | ... | |
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) { |
... | ... | |
549 | 553 |
return true; |
550 | 554 |
} |
551 | 555 |
|
552 |
HeadRequest<Folder> head = new HeadRequest<Folder>(Folder.class, getApiPath(), f.getOwnerID(), "/" + f.getContainer()) { |
|
556 |
HeadRequest<Folder> head = new HeadRequest<Folder>(Pithos.this, Folder.class, getApiPath(), f.getOwnerID(), "/" + f.getContainer()) {
|
|
553 | 557 |
|
554 | 558 |
@Override |
555 | 559 |
public void onSuccess(Folder _result) { |
... | ... | |
706 | 710 |
} |
707 | 711 |
|
708 | 712 |
public void fetchAccount(final Command callback) { |
713 |
LOG("Pithos::fetchAccount(), callback = ", callback); |
|
709 | 714 |
String path = "?format=json"; |
710 | 715 |
|
711 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, getApiPath(), userID, path) { |
|
716 |
GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(this, AccountResource.class, getApiPath(), userID, path) {
|
|
712 | 717 |
@Override |
713 | 718 |
public void onSuccess(AccountResource _result) { |
714 | 719 |
account = _result; |
... | ... | |
741 | 746 |
} |
742 | 747 |
|
743 | 748 |
public void updateStatistics() { |
744 |
HeadRequest<AccountResource> headAccount = new HeadRequest<AccountResource>(AccountResource.class, getApiPath(), userID, "", account) { |
|
749 |
HeadRequest<AccountResource> headAccount = new HeadRequest<AccountResource>(this, AccountResource.class, getApiPath(), userID, "", account) {
|
|
745 | 750 |
|
746 | 751 |
@Override |
747 | 752 |
public void onSuccess(AccountResource _result) { |
... | ... | |
771 | 776 |
|
772 | 777 |
protected void createHomeContainer(final AccountResource _account, final Command callback) { |
773 | 778 |
String path = "/" + Const.HOME_CONTAINER; |
774 |
PutRequest createPithos = new PutRequest(getApiPath(), getUserID(), path) { |
|
779 |
PutRequest createPithos = new PutRequest(this, getApiPath(), getUserID(), path) {
|
|
775 | 780 |
@Override |
776 | 781 |
public void onSuccess(Resource result) { |
777 | 782 |
if(!_account.hasTrashContainer()) { |
... | ... | |
805 | 810 |
|
806 | 811 |
protected void createTrashContainer(final Command callback) { |
807 | 812 |
String path = "/" + Const.TRASH_CONTAINER; |
808 |
PutRequest createPithos = new PutRequest(getApiPath(), getUserID(), path) { |
|
813 |
PutRequest createPithos = new PutRequest(this, getApiPath(), getUserID(), path) {
|
|
809 | 814 |
@Override |
810 | 815 |
public void onSuccess(Resource result) { |
811 | 816 |
fetchAccount(callback); |
... | ... | |
972 | 977 |
final PleaseWaitPopup pwp = new PleaseWaitPopup(); |
973 | 978 |
pwp.center(); |
974 | 979 |
String path = "/" + folder.getContainer() + "/" + folder.getPrefix() + "?delimiter=/" + "&t=" + System.currentTimeMillis(); |
975 |
DeleteRequest deleteFolder = new DeleteRequest(getApiPath(), folder.getOwnerID(), path) { |
|
980 |
DeleteRequest deleteFolder = new DeleteRequest(this, getApiPath(), folder.getOwnerID(), path) {
|
|
976 | 981 |
|
977 | 982 |
@Override |
978 | 983 |
protected void onUnauthorized(Response response) { |
... | ... | |
1026 | 1031 |
if(iter.hasNext()) { |
1027 | 1032 |
File file = iter.next(); |
1028 | 1033 |
String path = targetUri + "/" + file.getName(); |
1029 |
PutRequest copyFile = new PutRequest(getApiPath(), targetUsername, path) { |
|
1034 |
PutRequest copyFile = new PutRequest(this, getApiPath(), targetUsername, path) {
|
|
1030 | 1035 |
@Override |
1031 | 1036 |
public void onSuccess(Resource result) { |
1032 | 1037 |
copyFiles(iter, targetUsername, targetUri, callback); |
... | ... | |
1064 | 1069 |
|
1065 | 1070 |
public void copyFolder(final Folder f, final String targetUsername, final String targetUri, boolean move, final Command callback) { |
1066 | 1071 |
String path = targetUri + "?delimiter=/"; |
1067 |
PutRequest copyFolder = new PutRequest(getApiPath(), targetUsername, path) { |
|
1072 |
PutRequest copyFolder = new PutRequest(this, getApiPath(), targetUsername, path) {
|
|
1068 | 1073 |
@Override |
1069 | 1074 |
public void onSuccess(Resource result) { |
1070 | 1075 |
if(callback != null) { |
... | ... | |
1121 | 1126 |
groupTreeView.updateGroupNode(null); |
1122 | 1127 |
} |
1123 | 1128 |
|
1124 |
public Group addGroup(String groupname) {
|
|
1125 |
Group newGroup = new Group(groupname);
|
|
1126 |
account.addGroup(newGroup);
|
|
1129 |
public Group addGroup(String groupName) {
|
|
1130 |
final Group group = new Group(groupName);
|
|
1131 |
account.addGroup(group);
|
|
1127 | 1132 |
groupTreeView.updateGroupNode(null); |
1128 |
return newGroup;
|
|
1133 |
return group;
|
|
1129 | 1134 |
} |
1130 | 1135 |
|
1131 | 1136 |
public void removeGroup(Group group) { |
... | ... | |
1278 | 1283 |
} |
1279 | 1284 |
} |
1280 | 1285 |
else { |
1281 |
HeadRequest<Folder> headFolder = new HeadRequest<Folder>(Folder.class, getApiPath(), folder.getOwnerID(), folder.getUri(), folder) { |
|
1286 |
HeadRequest<Folder> headFolder = new HeadRequest<Folder>(this, Folder.class, getApiPath(), folder.getOwnerID(), folder.getUri(), folder) {
|
|
1282 | 1287 |
|
1283 | 1288 |
@Override |
1284 | 1289 |
public void onSuccess(Folder _result) { |
... | ... | |
1292 | 1297 |
if(t instanceof RestException) { |
1293 | 1298 |
if(((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { |
1294 | 1299 |
final String path = folder.getUri(); |
1295 |
PutRequest newFolder = new PutRequest(getApiPath(), folder.getOwnerID(), path) { |
|
1300 |
PutRequest newFolder = new PutRequest(Pithos.this, getApiPath(), folder.getOwnerID(), path) {
|
|
1296 | 1301 |
@Override |
1297 | 1302 |
public void onSuccess(Resource _result) { |
1298 | 1303 |
scheduleFolderHeadCommand(folder, callback); |
... | ... | |
1347 | 1352 |
} |
1348 | 1353 |
|
1349 | 1354 |
public void scheduleFileHeadCommand(File f, final Command callback) { |
1350 |
HeadRequest<File> headFile = new HeadRequest<File>(File.class, getApiPath(), f.getOwnerID(), f.getUri(), f) { |
|
1355 |
HeadRequest<File> headFile = new HeadRequest<File>(this, File.class, getApiPath(), f.getOwnerID(), f.getUri(), f) {
|
|
1351 | 1356 |
|
1352 | 1357 |
@Override |
1353 | 1358 |
public void onSuccess(File _result) { |
... | ... | |
1461 | 1466 |
|
1462 | 1467 |
public void emptyContainer(final Folder container) { |
1463 | 1468 |
String path = "/" + container.getName() + "?delimiter=/"; |
1464 |
DeleteRequest delete = new DeleteRequest(getApiPath(), getUserID(), path) { |
|
1469 |
DeleteRequest delete = new DeleteRequest(this, getApiPath(), getUserID(), path) {
|
|
1465 | 1470 |
|
1466 | 1471 |
@Override |
1467 | 1472 |
protected void onUnauthorized(Response response) { |
b/src/gr/grnet/pithos/web/client/Resource.java | ||
---|---|---|
116 | 116 |
}-*/; |
117 | 117 |
|
118 | 118 |
@SuppressWarnings("unchecked") |
119 |
public static <T> T createFromResponse(Class<T> aClass, String owner, Response response, T result) { |
|
119 |
public static <T> T createFromResponse(Pithos app, Class<T> aClass, String owner, Response response, T result) {
|
|
120 | 120 |
T result1 = null; |
121 | 121 |
if(aClass.equals(AccountResource.class)) { |
122 |
result1 = (T) AccountResource.createFromResponse(owner, response, (AccountResource) result); |
|
122 |
result1 = (T) AccountResource.createFromResponse(app, owner, response, (AccountResource) result);
|
|
123 | 123 |
} |
124 | 124 |
else if(aClass.equals(Folder.class)) { |
125 | 125 |
result1 = (T) Folder.createFromResponse(owner, response, (Folder) result); |
b/src/gr/grnet/pithos/web/client/VersionsList.java | ||
---|---|---|
132 | 132 |
|
133 | 133 |
void restoreVersion(int version) { |
134 | 134 |
String path = file.getUri() + "?update="; |
135 |
PostRequest restoreVersion = new PostRequest(app.getApiPath(), file.getOwnerID(), path) { |
|
135 |
PostRequest restoreVersion = new PostRequest(app, app.getApiPath(), file.getOwnerID(), path) {
|
|
136 | 136 |
|
137 | 137 |
@Override |
138 | 138 |
public void onSuccess(Resource result) { |
b/src/gr/grnet/pithos/web/client/catalog/UpdateUserCatalogs.java | ||
---|---|---|
60 | 60 |
public void scheduleDeferred() { |
61 | 61 |
Scheduler.get().scheduleDeferred(this); |
62 | 62 |
} |
63 |
|
|
64 |
public void scheduleEntry() { |
|
65 |
Scheduler.get().scheduleEntry(this); |
|
66 |
} |
|
63 | 67 |
} |
b/src/gr/grnet/pithos/web/client/catalog/UserCatalogs.java | ||
---|---|---|
45 | 45 |
); |
46 | 46 |
} |
47 | 47 |
|
48 |
public boolean hasID(String id) { |
|
48 |
public boolean hasUserID(String id) {
|
|
49 | 49 |
return id2name.containsKey(id); |
50 | 50 |
} |
51 | 51 |
|
52 |
public boolean hasName(String name) {
|
|
53 |
return name2id.containsKey(name);
|
|
52 |
public boolean hasUserDisplayName(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 getUserDisplayName(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 getUserID(String displayName) {
|
|
61 |
return name2id.get(displayName);
|
|
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
@Override |
b/src/gr/grnet/pithos/web/client/commands/DeleteGroupCommand.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client.commands; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.Const; |
|
37 | 38 |
import gr.grnet.pithos.web.client.Pithos; |
38 | 39 |
import gr.grnet.pithos.web.client.Resource; |
39 | 40 |
import gr.grnet.pithos.web.client.grouptree.Group; |
... | ... | |
75 | 76 |
containerPanel.hide(); |
76 | 77 |
if (Window.confirm("Are you sure you want to delete group " + group.getName())) { |
77 | 78 |
String path = "?update="; |
78 |
PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUserID(), path) { |
|
79 |
PostRequest updateGroup = new PostRequest(app, app.getApiPath(), app.getUserID(), path) {
|
|
79 | 80 |
|
80 | 81 |
@Override |
81 | 82 |
public void onSuccess(Resource result) { |
... | ... | |
98 | 99 |
app.sessionExpired(); |
99 | 100 |
} |
100 | 101 |
}; |
101 |
updateGroup.setHeader("X-Auth-Token", app.getUserToken());
|
|
102 |
updateGroup.setHeader("X-Account-Group-" + URL.encodePathSegment(group.getName()), "~");
|
|
102 |
updateGroup.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
|
|
103 |
updateGroup.setHeader(Const.X_ACCOUNT_GROUP_ + URL.encodePathSegment(group.getName()), "~");
|
|
103 | 104 |
Scheduler.get().scheduleDeferred(updateGroup); |
104 | 105 |
} |
105 | 106 |
} |
b/src/gr/grnet/pithos/web/client/commands/PasteCommand.java | ||
---|---|---|
137 | 137 |
if (iter.hasNext()) { |
138 | 138 |
File file = iter.next(); |
139 | 139 |
String path = folder.getUri() + "/" + file.getName(); |
140 |
PutRequest copyFile = new PutRequest(app.getApiPath(), folder.getOwnerID(), path) { |
|
140 |
PutRequest copyFile = new PutRequest(app, app.getApiPath(), folder.getOwnerID(), path) {
|
|
141 | 141 |
@Override |
142 | 142 |
public void onSuccess(Resource result) { |
143 | 143 |
moveFiles(iter, callback); |
b/src/gr/grnet/pithos/web/client/commands/RemoveUserCommand.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client.commands; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 |
import gr.grnet.pithos.web.client.Resource; |
|
39 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
40 |
import gr.grnet.pithos.web.client.grouptree.User; |
|
41 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
|
42 |
import gr.grnet.pithos.web.client.rest.RestException; |
|
43 |
|
|
44 | 37 |
import com.google.gwt.core.client.GWT; |
45 | 38 |
import com.google.gwt.core.client.Scheduler; |
46 | 39 |
import com.google.gwt.http.client.Response; |
47 | 40 |
import com.google.gwt.http.client.URL; |
48 | 41 |
import com.google.gwt.user.client.Command; |
49 | 42 |
import com.google.gwt.user.client.ui.PopupPanel; |
43 |
import gr.grnet.pithos.web.client.Const; |
|
44 |
import gr.grnet.pithos.web.client.Pithos; |
|
45 |
import gr.grnet.pithos.web.client.Resource; |
|
46 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
47 |
import gr.grnet.pithos.web.client.grouptree.User; |
|
48 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
|
49 |
import gr.grnet.pithos.web.client.rest.RestException; |
|
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* Display the 'new folder' dialog for creating a new folder. |
53 |
* |
|
54 | 53 |
*/ |
55 | 54 |
public class RemoveUserCommand implements Command { |
56 |
private PopupPanel containerPanel;
|
|
55 |
private PopupPanel containerPanel;
|
|
57 | 56 |
|
58 | 57 |
User user; |
59 | 58 |
|
60 | 59 |
Pithos app; |
61 | 60 |
|
62 |
/**
|
|
63 |
* @param aContainerPanel
|
|
64 |
*/
|
|
65 |
public RemoveUserCommand(Pithos _app, PopupPanel aContainerPanel, User _user){
|
|
61 |
/**
|
|
62 |
* @param aContainerPanel
|
|
63 |
*/
|
|
64 |
public RemoveUserCommand(Pithos _app, PopupPanel aContainerPanel, User _user) {
|
|
66 | 65 |
app = _app; |
67 |
containerPanel = aContainerPanel; |
|
68 |
user = _user; |
|
69 |
} |
|
66 |
containerPanel = aContainerPanel; |
|
67 |
user = _user; |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void execute() { |
|
72 |
if(containerPanel != null) { |
|
73 |
containerPanel.hide(); |
|
74 |
} |
|
75 |
final String groupName = user.getGroup(); |
|
76 |
final Group group = app.getAccount().getGroup(groupName); |
|
77 |
if(group == null) { |
|
78 |
return; |
|
79 |
} |
|
80 |
group.removeUser(user); |
|
81 |
String path = "?update="; |
|
82 |
PostRequest updateGroup = new PostRequest(app, app.getApiPath(), app.getUserID(), path) { |
|
83 |
|
|
84 |
@Override |
|
85 |
public void onSuccess(Resource result) { |
|
86 |
app.fetchAccount(new Command() { |
|
87 |
|
|
88 |
@Override |
|
89 |
public void execute() { |
|
90 |
Group updatedGroup2 = app.getAccount().getGroup(groupName); |
|
91 |
if(updatedGroup2 != null) { |
|
92 |
app.updateGroupNode(updatedGroup2); |
|
93 |
} |
|
94 |
else { |
|
95 |
app.updateGroupNode(null); |
|
96 |
} |
|
97 |
} |
|
98 |
}); |
|
99 |
} |
|
70 | 100 |
|
71 |
@Override |
|
72 |
public void execute() { |
|
73 |
if (containerPanel != null) |
|
74 |
containerPanel.hide(); |
|
75 |
final String groupName = user.getGroup(); |
|
76 |
final Group group = app.getAccount().getGroup(groupName); |
|
77 |
if (group == null) |
|
78 |
return; |
|
79 |
group.removeMember(user.getName()); |
|
80 |
String path = "?update="; |
|
81 |
PostRequest updateGroup = new PostRequest(app.getApiPath(), app.getUserID(), path) { |
|
82 |
|
|
83 |
@Override |
|
84 |
public void onSuccess(Resource result) { |
|
85 |
app.fetchAccount(new Command() { |
|
86 |
|
|
87 |
@Override |
|
88 |
public void execute() { |
|
89 |
Group updatedGroup2 = app.getAccount().getGroup(groupName); |
|
90 |
if (updatedGroup2 != null) |
|
91 |
app.updateGroupNode(updatedGroup2); |
|
92 |
else { |
|
93 |
app.updateGroupNode(null); |
|
94 |
} |
|
95 |
} |
|
96 |
}); |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void onError(Throwable t) { |
|
101 |
GWT.log("", t); |
|
102 |
app.setError(t); |
|
103 |
if (t instanceof RestException) { |
|
104 |
app.displayError("Unable to update group:" + ((RestException) t).getHttpStatusText()); |
|
105 |
} |
|
106 |
else |
|
107 |
app.displayError("System error updating group:" + t.getMessage()); |
|
108 |
} |
|
101 |
@Override |
|
102 |
public void onError(Throwable t) { |
|
103 |
GWT.log("", t); |
|
104 |
app.setError(t); |
|
105 |
if(t instanceof RestException) { |
|
106 |
app.displayError("Unable to update group:" + ((RestException) t).getHttpStatusText()); |
|
107 |
} |
|
108 |
else { |
|
109 |
app.displayError("System error updating group:" + t.getMessage()); |
|
110 |
} |
|
111 |
} |
|
109 | 112 |
|
110 |
@Override
|
|
111 |
protected void onUnauthorized(Response response) {
|
|
112 |
app.sessionExpired();
|
|
113 |
}
|
|
114 |
};
|
|
115 |
updateGroup.setHeader("X-Auth-Token", app.getUserToken());
|
|
116 |
String groupMembers = "";
|
|
117 |
if (!group.getMembers().isEmpty()) {
|
|
118 |
for (String u : group.getMembers())
|
|
119 |
groupMembers += (URL.encodePathSegment(u) + ",");
|
|
120 |
}
|
|
121 |
else
|
|
122 |
groupMembers = "~";
|
|
123 |
updateGroup.setHeader("X-Account-Group-" + URL.encodePathSegment(group.getName()), groupMembers);
|
|
124 |
Scheduler.get().scheduleDeferred(updateGroup);
|
|
125 |
}
|
|
113 |
@Override
|
|
114 |
protected void onUnauthorized(Response response) {
|
|
115 |
app.sessionExpired();
|
|
116 |
}
|
|
117 |
};
|
|
118 |
updateGroup.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
|
|
119 |
final String groupMembers;
|
|
120 |
if(!group.getUsers().isEmpty()) {
|
|
121 |
groupMembers = group.encodeUserIDsForXAccountGroup();
|
|
122 |
}
|
|
123 |
else {
|
|
124 |
groupMembers = "~";
|
|
125 |
}
|
|
126 |
updateGroup.setHeader(Const.X_ACCOUNT_GROUP_ + URL.encodePathSegment(group.getName()), groupMembers);
|
|
127 |
Scheduler.get().scheduleDeferred(updateGroup);
|
|
128 |
}
|
|
126 | 129 |
} |
b/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java | ||
---|---|---|
117 | 117 |
if (iter.hasNext()) { |
118 | 118 |
File file = iter.next(); |
119 | 119 |
String path = "/" + Const.HOME_CONTAINER + "/" + file.getPath(); |
120 |
PutRequest untrashFile = new PutRequest(app.getApiPath(), app.getUserID(), path) { |
|
120 |
PutRequest untrashFile = new PutRequest(app, app.getApiPath(), app.getUserID(), path) {
|
|
121 | 121 |
@Override |
122 | 122 |
public void onSuccess(Resource result) { |
123 | 123 |
untrashFiles(iter, callback); |
b/src/gr/grnet/pithos/web/client/commands/ToTrashCommand.java | ||
---|---|---|
127 | 127 |
if (iter.hasNext()) { |
128 | 128 |
File file = iter.next(); |
129 | 129 |
String path = "/" + Const.TRASH_CONTAINER + "/" + file.getPath(); |
130 |
PutRequest trashFile = new PutRequest(app.getApiPath(), app.getUserID(), path) { |
|
130 |
PutRequest trashFile = new PutRequest(app, app.getApiPath(), app.getUserID(), path) {
|
|
131 | 131 |
@Override |
132 | 132 |
public void onSuccess(Resource result) { |
133 | 133 |
trashFiles(iter, callback); |
b/src/gr/grnet/pithos/web/client/foldertree/AccountResource.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.foldertree; |
37 | 37 |
|
38 |
import gr.grnet.pithos.web.client.Const; |
|
39 |
import gr.grnet.pithos.web.client.Resource; |
|
40 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
41 |
|
|
42 |
import java.util.ArrayList; |
|
43 |
import java.util.Date; |
|
44 |
import java.util.List; |
|
45 |
|
|
46 | 38 |
import com.google.gwt.http.client.Header; |
47 | 39 |
import com.google.gwt.http.client.Response; |
48 | 40 |
import com.google.gwt.http.client.URL; |
... | ... | |
53 | 45 |
import com.google.gwt.json.client.JSONObject; |
54 | 46 |
import com.google.gwt.json.client.JSONParser; |
55 | 47 |
import com.google.gwt.json.client.JSONValue; |
48 |
import gr.grnet.pithos.web.client.Const; |
|
49 |
import gr.grnet.pithos.web.client.Pithos; |
|
50 |
import gr.grnet.pithos.web.client.Resource; |
|
51 |
import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs; |
|
52 |
import gr.grnet.pithos.web.client.catalog.UserCatalogs; |
|
53 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
54 |
import gr.grnet.pithos.web.client.grouptree.User; |
|
55 |
|
|
56 |
import java.util.*; |
|
56 | 57 |
|
57 | 58 |
/** |
58 | 59 |
* Created by IntelliJ IDEA. User: chstath Date: 5/19/11 Time: 2:55 PM To change this template use File | Settings | |
59 | 60 |
* File Templates. |
60 | 61 |
*/ |
61 | 62 |
public class AccountResource extends Resource { |
63 |
private final Pithos app; |
|
62 | 64 |
|
63 | 65 |
private long numberOfContainers = 0; |
64 | 66 |
|
... | ... | |
71 | 73 |
private Date lastLogin = null; |
72 | 74 |
|
73 | 75 |
private Date lastModified = null; |
74 |
|
|
76 |
|
|
75 | 77 |
private List<Folder> containers = new ArrayList<Folder>(); |
76 | 78 |
|
77 | 79 |
private Date currentLogin = null; |
78 | 80 |
|
79 | 81 |
private List<Group> groups = new ArrayList<Group>(); |
80 | 82 |
|
83 |
public AccountResource(Pithos app) { |
|
84 |
this.app = app; |
|
85 |
} |
|
86 |
|
|
81 | 87 |
public long getQuota() { |
82 | 88 |
return quota; |
83 | 89 |
} |
... | ... | |
103 | 109 |
} |
104 | 110 |
|
105 | 111 |
@Override |
106 |
public Date getLastModified() {
|
|
112 |
public Date getLastModified() {
|
|
107 | 113 |
return lastModified; |
108 | 114 |
} |
109 | 115 |
|
... | ... | |
139 | 145 |
this.currentLogin = currentLogin; |
140 | 146 |
} |
141 | 147 |
|
148 |
private void doAddUsersByIDs(final List<String> userIDs, final String groupName) { |
|
149 |
app.LOG("AccountResource::doAddUsersByIDs(), group = ", groupName); |
|
150 |
final Group group = new Group(groupName); |
|
151 |
for(String userID : userIDs) { |
|
152 |
final String userDisplayName = app.getUserDisplayNameForID(userID); |
|
153 |
final User user = new User(userID, userDisplayName, groupName); |
|
154 |
group.addUser(user); |
|
155 |
app.LOG("AccountResource::doAddUsersByIDs(), user = (", userID, ", ", userDisplayName, ")"); |
|
156 |
|
|
157 |
} |
|
158 |
groups.add(group); |
|
159 |
|
|
160 |
} |
|
161 |
|
|
142 | 162 |
public void populate(String owner, Response response) { |
143 | 163 |
DateTimeFormat df = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822); |
144 | 164 |
groups.clear(); |
145 |
for (Header h : response.getHeaders()) { |
|
146 |
if (h != null) { |
|
147 |
String name = h.getName(); |
|
148 |
if (name.startsWith("X-Account-Group-")) { |
|
149 |
String groupName = URL.decodePathSegment(name.substring("X-Account-Group-".length())); |
|
150 |
Group g = new Group(groupName); |
|
151 |
String[] members = h.getValue().split(","); |
|
152 |
for (String s : members) |
|
153 |
g.addMember(URL.decodePathSegment(s).trim()); |
|
154 |
groups.add(g); |
|
155 |
} |
|
156 |
else if (name.equals("X-Account-Container-Count")) { |
|
157 |
numberOfContainers = Long.valueOf(h.getValue()); |
|
158 |
} |
|
159 |
else if (name.equals("X-Account-Object-Count")) { |
|
160 |
numberOfObjects = Long.valueOf(h.getValue()); |
|
161 |
} |
|
162 |
else if (name.equals("X-Account-Bytes-Used")) { |
|
163 |
bytesUsed = Long.valueOf(h.getValue()); |
|
164 |
} |
|
165 |
else if (name.equals("X-Account-Policy-Quota")) { |
|
166 |
quota = Long.valueOf(h.getValue()); |
|
167 |
} |
|
168 |
else if (name.equals("X-Account-Last-Login")) { |
|
169 |
lastLogin = df.parse(h.getValue()); |
|
170 |
} |
|
171 |
else if (name.equals("Last-Modified")) { |
|
172 |
lastModified = df.parse(h.getValue()); |
|
173 |
} |
|
174 |
} |
|
165 |
|
|
166 |
final Map<String, List<String>> parsedGroups = new HashMap<String, List<String>>(); |
|
167 |
|
|
168 |
for(Header h : response.getHeaders()) { |
|
169 |
if(h != null) { |
|
170 |
String name = h.getName(); |
|
171 |
if(name.startsWith(Const.X_ACCOUNT_GROUP_)) { |
|
172 |
final String groupName = URL.decodePathSegment(name.substring(Const.X_ACCOUNT_GROUP_.length())); |
|
173 |
final String[] users = h.getValue().split(","); |
|
174 |
final List<String> userIDs = new ArrayList<String>(); |
|
175 |
for(String user : users) { |
|
176 |
final String userID = URL.decodePathSegment(user).trim(); |
|
177 |
userIDs.add(userID); |
|
178 |
} |
|
179 |
parsedGroups.put(groupName, userIDs); |
|
180 |
} |
|
181 |
else if(name.equals(Const.X_ACCOUNT_CONTAINER_COUNT)) { |
|
182 |
numberOfContainers = Long.valueOf(h.getValue()); |
|
183 |
} |
|
184 |
else if(name.equals(Const.X_ACCOUNT_OBJECT_COUNT)) { |
|
185 |
numberOfObjects = Long.valueOf(h.getValue()); |
|
186 |
} |
|
187 |
else if(name.equals(Const.X_ACCOUNT_BYTES_USED)) { |
|
188 |
bytesUsed = Long.valueOf(h.getValue()); |
|
189 |
} |
|
190 |
else if(name.equals(Const.X_ACCOUNT_POLICY_QUOTA)) { |
|
191 |
quota = Long.valueOf(h.getValue()); |
|
192 |
} |
|
193 |
else if(name.equals(Const.X_ACCOUNT_LAST_LOGIN)) { |
|
194 |
lastLogin = df.parse(h.getValue()); |
|
195 |
} |
|
196 |
else if(name.equals(Const.LAST_MODIFIED)) { |
|
197 |
lastModified = df.parse(h.getValue()); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
// Gather all unknown users for the groups |
|
203 |
final List<String> userIDsWithUnknownDisplayName = new ArrayList<String>(); |
|
204 |
for(Map.Entry<String, List<String>> parsedGroupEntry : parsedGroups.entrySet()) { |
|
205 |
final List<String> groupUserIDs = parsedGroupEntry.getValue(); |
|
206 |
userIDsWithUnknownDisplayName.addAll(app.filterUserIDsWithUnknownDisplayName(groupUserIDs)); |
|
207 |
} |
|
208 |
if(userIDsWithUnknownDisplayName.size() == 0) { |
|
209 |
for(Map.Entry<String, List<String>> parsedGroupEntry : parsedGroups.entrySet()) { |
|
210 |
final String groupName = parsedGroupEntry.getKey(); |
|
211 |
final List<String> groupUserIDs = parsedGroupEntry.getValue(); |
|
212 |
doAddUsersByIDs(groupUserIDs, groupName); |
|
213 |
} |
|
214 |
} |
|
215 |
else { |
|
216 |
new UpdateUserCatalogs(app, userIDsWithUnknownDisplayName) { |
|
217 |
@Override |
|
218 |
public void onSuccess(UserCatalogs requestedUserCatalogs, UserCatalogs updatedUserCatalogs) { |
|
219 |
for(Map.Entry<String, List<String>> parsedGroupEntry : parsedGroups.entrySet()) { |
|
220 |
final String groupName = parsedGroupEntry.getKey(); |
|
221 |
final List<String> groupUserIDs = parsedGroupEntry.getValue(); |
|
222 |
doAddUsersByIDs(groupUserIDs, groupName); |
|
223 |
} |
|
224 |
} |
|
225 |
}.scheduleEntry(); |
|
175 | 226 |
} |
176 | 227 |
|
177 |
if (response.getText() != null && response.getText().length() > 0) {
|
|
178 |
containers.clear();
|
|
179 |
JSONValue json = JSONParser.parseStrict(response.getText());
|
|
180 |
JSONArray array = json.isArray();
|
|
181 |
if (array != null) {
|
|
182 |
for (int i=0; i<array.size(); i++) {
|
|
183 |
JSONObject o = array.get(i).isObject();
|
|
184 |
if (o != null) {
|
|
185 |
Folder f = new Folder();
|
|
186 |
f.populate(null, o, owner, null);
|
|
187 |
containers.add(f);
|
|
188 |
}
|
|
189 |
}
|
|
190 |
}
|
|
228 |
if(response.getText() != null && response.getText().length() > 0) { |
|
229 |
containers.clear();
|
|
230 |
JSONValue json = JSONParser.parseStrict(response.getText());
|
|
231 |
JSONArray array = json.isArray();
|
|
232 |
if(array != null) {
|
|
233 |
for(int i = 0; i < array.size(); i++) {
|
|
234 |
JSONObject o = array.get(i).isObject();
|
|
235 |
if(o != null) {
|
|
236 |
Folder f = new Folder();
|
|
237 |
f.populate(null, o, owner, null);
|
|
238 |
containers.add(f);
|
|
239 |
}
|
|
240 |
}
|
|
241 |
}
|
|
191 | 242 |
} |
192 | 243 |
} |
193 | 244 |
|
194 |
public static AccountResource createFromResponse(String owner, Response response, AccountResource result) { |
|
195 |
AccountResource a; |
|
196 |
if (result == null) |
|
197 |
a = new AccountResource(); |
|
198 |
else |
|
199 |
a = result; |
|
245 |
public static AccountResource createFromResponse(Pithos app, String owner, Response response, AccountResource result) { |
|
246 |
AccountResource a; |
|
247 |
if(result == null) { |
|
248 |
a = new AccountResource(app); |
|
249 |
} |
|
250 |
else { |
|
251 |
a = result; |
|
252 |
} |
|
200 | 253 |
a.populate(owner, response); |
201 | 254 |
return a; |
202 | 255 |
} |
203 | 256 |
|
204 |
private String getSize(Long size, Double division){ |
|
205 |
Double res = Double.valueOf(size.toString())/division;
|
|
206 |
NumberFormat nf = NumberFormat.getFormat("######.#");
|
|
257 |
private String getSize(Long size, Double division) {
|
|
258 |
Double res = Double.valueOf(size.toString()) / division;
|
|
259 |
NumberFormat nf = NumberFormat.getFormat(Const.NUMBER_FORMAT_1);
|
|
207 | 260 |
return nf.format(res); |
208 | 261 |
} |
209 | 262 |
|
210 | 263 |
public String getFileSizeAsString() { |
211 |
if (bytesUsed < 1024)
|
|
264 |
if(bytesUsed < 1024) {
|
|
212 | 265 |
return String.valueOf(bytesUsed) + "B"; |
213 |
else if (bytesUsed < 1024*1024) |
|
266 |
} |
|
267 |
else if(bytesUsed < 1024 * 1024) { |
|
214 | 268 |
return getSize(bytesUsed, 1024D) + "KB"; |
215 |
else if (bytesUsed < 1024*1024*1024) |
|
216 |
return getSize(bytesUsed,(1024D*1024D)) + "MB"; |
|
217 |
return getSize(bytesUsed , (1024D*1024D*1024D)) + "GB"; |
|
269 |
} |
|
270 |
else if(bytesUsed < 1024 * 1024 * 1024) { |
|
271 |
return getSize(bytesUsed, (1024D * 1024D)) + "MB"; |
|
272 |
} |
|
273 |
return getSize(bytesUsed, (1024D * 1024D * 1024D)) + "GB"; |
|
218 | 274 |
} |
219 | 275 |
|
220 | 276 |
public String getQuotaAsString() { |
221 |
if (quota < 1024)
|
|
277 |
if(quota < 1024) {
|
|
222 | 278 |
return String.valueOf(quota) + "B"; |
223 |
else if (quota < 1024 * 1024) |
|
279 |
} |
|
280 |
else if(quota < 1024 * 1024) { |
|
224 | 281 |
return getSize(quota, 1024D) + "KB"; |
225 |
else if (quota < 1024 * 1024 * 1024) |
|
226 |
return getSize(quota,(1024D * 1024D)) + "MB"; |
|
227 |
return getSize(quota , (1024D * 1024D * 1024D)) + "GB"; |
|
282 |
} |
|
283 |
else if(quota < 1024 * 1024 * 1024) { |
|
284 |
return getSize(quota, (1024D * 1024D)) + "MB"; |
|
285 |
} |
|
286 |
return getSize(quota, (1024D * 1024D * 1024D)) + "GB"; |
|
228 | 287 |
} |
229 | 288 |
|
230 | 289 |
public List<Group> getGroups() { |
231 | 290 |
return groups; |
232 | 291 |
} |
233 |
|
|
292 |
|
|
234 | 293 |
public boolean hasHomeContainer() { |
235 |
for (Folder f : containers) |
|
236 |
if (f.getName().equals(Const.HOME_CONTAINER)) |
|
237 |
return true; |
|
238 |
return false; |
|
294 |
for(Folder f : containers) { |
|
295 |
if(f.getName().equals(Const.HOME_CONTAINER)) { |
|
296 |
return true; |
|
297 |
} |
|
298 |
} |
|
299 |
return false; |
|
239 | 300 |
} |
240 | 301 |
|
241 | 302 |
public boolean hasTrashContainer() { |
242 |
for (Folder f : containers) |
|
243 |
if (f.getName().equals(Const.TRASH_CONTAINER)) |
|
244 |
return true; |
|
245 |
return false; |
|
303 |
for(Folder f : containers) { |
|
304 |
if(f.getName().equals(Const.TRASH_CONTAINER)) { |
|
305 |
return true; |
|
306 |
} |
|
307 |
} |
|
308 |
return false; |
|
309 |
} |
|
310 |
|
|
311 |
public void addGroup(Group group) { |
|
312 |
groups.add(group); |
|
313 |
} |
|
314 |
|
|
315 |
public void removeGroup(Group group) { |
|
316 |
groups.remove(group); |
|
246 | 317 |
} |
247 | 318 |
|
248 |
public void addGroup(Group newGroup) { |
|
249 |
groups.add(newGroup); |
|
250 |
} |
|
251 |
|
|
252 |
public void removeGroup(Group group) { |
|
253 |
groups.remove(group); |
|
254 |
} |
|
255 |
|
|
256 |
public Folder getTrash() { |
|
257 |
for (Folder c : containers) { |
|
258 |
if (c.getName().equals(Const.TRASH_CONTAINER)) |
|
259 |
return c; |
|
260 |
} |
|
261 |
return null; |
|
262 |
} |
|
263 |
|
|
264 |
public double getUsedPercentage() { |
|
265 |
if (quota == 0) |
|
266 |
return 0; |
|
267 |
return ((double) bytesUsed) / quota; |
|
268 |
} |
|
269 |
|
|
270 |
public Folder getPithos() { |
|
271 |
for (Folder f : containers) |
|
272 |
if (f.getName().equals(Const.HOME_CONTAINER)) |
|
273 |
return f; |
|
274 |
return null; |
|
275 |
} |
|
276 |
|
|
277 |
public Group getGroup(String groupName) { |
|
278 |
for (Group g : groups) |
|
279 |
if (g.getName().equalsIgnoreCase(groupName)) |
|
280 |
return g; |
|
281 |
return null; |
|
282 |
} |
|
319 |
public Folder getTrash() { |
|
320 |
for(Folder c : containers) { |
|
321 |
if(c.getName().equals(Const.TRASH_CONTAINER)) { |
|
322 |
return c; |
|
323 |
} |
|
324 |
} |
|
325 |
return null; |
|
326 |
} |
|
327 |
|
|
328 |
public double getUsedPercentage() { |
|
329 |
if(quota == 0) { |
|
330 |
return 0; |
|
331 |
} |
|
332 |
return ((double) bytesUsed) / quota; |
|
333 |
} |
|
334 |
|
|
335 |
public Folder getPithos() { |
|
336 |
for(Folder f : containers) { |
|
337 |
if(f.getName().equals(Const.HOME_CONTAINER)) { |
|
338 |
return f; |
|
339 |
} |
|
340 |
} |
|
341 |
return null; |
|
342 |
} |
|
343 |
|
|
344 |
public Group getGroup(String groupName) { |
|
345 |
for(Group g : groups) { |
|
346 |
if(g.getName().equalsIgnoreCase(groupName)) { |
|
347 |
return g; |
|
348 |
} |
|
349 |
} |
|
350 |
return null; |
|
351 |
} |
|
283 | 352 |
} |
b/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java | ||
---|---|---|
152 | 152 |
final Folder f = iter.next(); |
153 | 153 |
|
154 | 154 |
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()); |
155 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwnerID(), path, f) { |
|
155 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(app, Folder.class, app.getApiPath(), f.getOwnerID(), path, f) {
|
|
156 | 156 |
@Override |
157 | 157 |
public void onSuccess(Folder _result) { |
158 | 158 |
fetchFolder(iter, callback); |
... | ... | |
236 | 236 |
|
237 | 237 |
public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles, final Command callback) { |
238 | 238 |
String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()); |
239 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwnerID(), path, f) { |
|
239 |
GetRequest<Folder> getFolder = new GetRequest<Folder>(app, Folder.class, app.getApiPath(), f.getOwnerID(), path, f) {
|
|
240 | 240 |
@Override |
241 | 241 |
public void onSuccess(final Folder _result) { |
242 | 242 |
if (showfiles) |
b/src/gr/grnet/pithos/web/client/grouptree/Group.java | ||
---|---|---|
36 | 36 |
package gr.grnet.pithos.web.client.grouptree; |
37 | 37 |
|
38 | 38 |
import java.util.ArrayList; |
39 |
import java.util.Collections; |
|
39 | 40 |
import java.util.List; |
40 | 41 |
|
41 |
public class Group { |
|
42 |
private String name; |
|
42 |
public final class Group {
|
|
43 |
private final String name;
|
|
43 | 44 |
|
44 |
private List<String> members = new ArrayList<String>();
|
|
45 |
private final List<User> users = new ArrayList<User>();
|
|
45 | 46 |
|
46 |
public Group(String _name) {
|
|
47 |
name = _name;
|
|
47 |
public Group(String name) { |
|
48 |
this.name = name;
|
|
48 | 49 |
} |
49 | 50 |
|
50 |
public List<String> getMembers() {
|
|
51 |
return members;
|
|
51 |
public List<User> getUsers() {
|
|
52 |
return Collections.unmodifiableList(users);
|
|
52 | 53 |
} |
53 | 54 |
|
54 | 55 |
public String getName() { |
55 | 56 |
return name; |
56 | 57 |
} |
57 | 58 |
|
Also available in: Unified diff