root / src / gr / ebs / gss / client / FilePropertiesDialog.java @ d7cdcd53
History | View | Annotate | Download (18.8 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
6 |
* GSS is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* GSS is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
package gr.ebs.gss.client; |
20 |
|
21 |
import gr.ebs.gss.client.rest.PostCommand; |
22 |
import gr.ebs.gss.client.rest.RestException; |
23 |
import gr.ebs.gss.client.rest.resource.FileResource; |
24 |
import gr.ebs.gss.client.rest.resource.GroupResource; |
25 |
import gr.ebs.gss.client.rest.resource.PermissionHolder; |
26 |
|
27 |
import java.util.Iterator; |
28 |
import java.util.List; |
29 |
import java.util.Set; |
30 |
|
31 |
import com.google.gwt.core.client.GWT; |
32 |
import com.google.gwt.event.dom.client.ChangeEvent; |
33 |
import com.google.gwt.event.dom.client.ChangeHandler; |
34 |
import com.google.gwt.event.dom.client.ClickEvent; |
35 |
import com.google.gwt.event.dom.client.ClickHandler; |
36 |
import com.google.gwt.event.dom.client.KeyDownEvent; |
37 |
import com.google.gwt.event.dom.client.KeyDownHandler; |
38 |
import com.google.gwt.i18n.client.DateTimeFormat; |
39 |
import com.google.gwt.json.client.JSONArray; |
40 |
import com.google.gwt.json.client.JSONBoolean; |
41 |
import com.google.gwt.json.client.JSONObject; |
42 |
import com.google.gwt.json.client.JSONString; |
43 |
import com.google.gwt.resources.client.ClientBundle; |
44 |
import com.google.gwt.resources.client.ImageResource; |
45 |
import com.google.gwt.user.client.Command; |
46 |
import com.google.gwt.user.client.DeferredCommand; |
47 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
48 |
import com.google.gwt.user.client.ui.Button; |
49 |
import com.google.gwt.user.client.ui.CheckBox; |
50 |
import com.google.gwt.user.client.ui.DecoratedTabPanel; |
51 |
import com.google.gwt.user.client.ui.DisclosurePanel; |
52 |
import com.google.gwt.user.client.ui.FlexTable; |
53 |
import com.google.gwt.user.client.ui.FlowPanel; |
54 |
import com.google.gwt.user.client.ui.FocusPanel; |
55 |
import com.google.gwt.user.client.ui.HTML; |
56 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
57 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
58 |
import com.google.gwt.user.client.ui.Label; |
59 |
import com.google.gwt.user.client.ui.TextBox; |
60 |
import com.google.gwt.user.client.ui.VerticalPanel; |
61 |
|
62 |
/**
|
63 |
* The 'File properties' dialog box implementation.
|
64 |
*
|
65 |
* @author past
|
66 |
*/
|
67 |
public class FilePropertiesDialog extends AbstractPropertiesDialog { |
68 |
|
69 |
final PermissionsList permList;
|
70 |
|
71 |
private CheckBox readForAll;
|
72 |
|
73 |
/**
|
74 |
* An image bundle for this widgets images.
|
75 |
*/
|
76 |
public interface Images extends ClientBundle,MessagePanel.Images { |
77 |
|
78 |
@Source("gr/ebs/gss/resources/edit_user.png") |
79 |
ImageResource permUser(); |
80 |
|
81 |
@Source("gr/ebs/gss/resources/groupevent.png") |
82 |
ImageResource permGroup(); |
83 |
|
84 |
@Source("gr/ebs/gss/resources/editdelete.png") |
85 |
ImageResource delete(); |
86 |
|
87 |
@Source("gr/ebs/gss/resources/db_update.png") |
88 |
ImageResource restore(); |
89 |
|
90 |
@Source("gr/ebs/gss/resources/folder_inbox.png") |
91 |
ImageResource download(); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* The widget that holds the name of the file.
|
96 |
*/
|
97 |
private TextBox name = new TextBox(); |
98 |
|
99 |
private final CheckBox versioned = new CheckBox(); |
100 |
|
101 |
final FileResource file;
|
102 |
|
103 |
private String userFullName; |
104 |
|
105 |
/**
|
106 |
* The widget's constructor.
|
107 |
*
|
108 |
* @param images the dialog's ImageBundle
|
109 |
* @param groups
|
110 |
* @param bodies
|
111 |
*/
|
112 |
public FilePropertiesDialog(final Images images, final List<GroupResource> groups, List<FileResource> bodies, String _userFullName) { |
113 |
|
114 |
// Set the dialog's caption.
|
115 |
setText("File properties");
|
116 |
|
117 |
file = (FileResource) GSS.get().getCurrentSelection(); |
118 |
userFullName = _userFullName; |
119 |
permList = new PermissionsList(images, file.getPermissions(), file.getOwner());
|
120 |
|
121 |
|
122 |
// Outer contains inner and buttons.
|
123 |
final VerticalPanel outer = new VerticalPanel(); |
124 |
final FocusPanel focusPanel = new FocusPanel(outer); |
125 |
// Inner contains generalPanel and permPanel.
|
126 |
inner = new DecoratedTabPanel();
|
127 |
inner.setAnimationEnabled(true);
|
128 |
final VerticalPanel generalPanel = new VerticalPanel(); |
129 |
final VerticalPanel permPanel = new VerticalPanel(); |
130 |
final HorizontalPanel buttons = new HorizontalPanel(); |
131 |
final HorizontalPanel permButtons = new HorizontalPanel(); |
132 |
final HorizontalPanel permForAll = new HorizontalPanel(); |
133 |
final HorizontalPanel pathPanel = new HorizontalPanel(); |
134 |
final VerticalPanel verPanel = new VerticalPanel(); |
135 |
final HorizontalPanel vPanel = new HorizontalPanel(); |
136 |
final HorizontalPanel vPanel2 = new HorizontalPanel(); |
137 |
|
138 |
versioned.setValue(file.isVersioned()); |
139 |
versioned.getElement().setId("filePropertiesDialog.chechBox.versioned");
|
140 |
inner.add(generalPanel, "General");
|
141 |
inner.add(permPanel, "Sharing");
|
142 |
inner.add(verPanel, "Versions");
|
143 |
inner.selectTab(0);
|
144 |
|
145 |
final Label fileNameNote = new Label("Please note that slashes ('/') are not allowed in file names.", true); |
146 |
fileNameNote.setVisible(false);
|
147 |
fileNameNote.setStylePrimaryName("gss-readForAllNote");
|
148 |
|
149 |
final FlexTable generalTable = new FlexTable(); |
150 |
generalTable.setText(0, 0, "Name"); |
151 |
generalTable.setText(1, 0, "Folder"); |
152 |
generalTable.setText(2, 0, "Owner"); |
153 |
generalTable.setText(3, 0, "Last modified"); |
154 |
generalTable.setText(4, 0, "Tags"); |
155 |
name.setWidth("100%");
|
156 |
name.setText(file.getName()); |
157 |
name.getElement().setId("filePropertiesDialog.textBox.name");
|
158 |
generalTable.setWidget(0, 1, name); |
159 |
name.addChangeHandler(new ChangeHandler() {
|
160 |
|
161 |
@Override
|
162 |
public void onChange(ChangeEvent event) { |
163 |
if(name.getText().contains("/")) |
164 |
fileNameNote.setVisible(true);
|
165 |
else
|
166 |
fileNameNote.setVisible(false);
|
167 |
|
168 |
} |
169 |
}); |
170 |
|
171 |
if(file.getFolderName() != null) |
172 |
generalTable.setText(1, 1, file.getFolderName()); |
173 |
else
|
174 |
generalTable.setText(1, 1, "-"); |
175 |
generalTable.setWidget(0, 2, fileNameNote); |
176 |
generalTable.setText(2, 1,userFullName); |
177 |
|
178 |
final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); |
179 |
generalTable.setText(3, 1, formatter.format(file.getModificationDate())); |
180 |
// Get the tags.
|
181 |
StringBuffer tagsBuffer = new StringBuffer(); |
182 |
Iterator i = file.getTags().iterator();
|
183 |
while (i.hasNext()) {
|
184 |
String tag = (String) i.next(); |
185 |
tagsBuffer.append(tag).append(", ");
|
186 |
} |
187 |
if (tagsBuffer.length() > 1) |
188 |
tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); |
189 |
initialTagText = tagsBuffer.toString(); |
190 |
tags.setWidth("100%");
|
191 |
tags.getElement().setId("filePropertiesDialog.textBox.tags");
|
192 |
tags.setText(initialTagText); |
193 |
generalTable.setWidget(4, 1, tags); |
194 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
195 |
generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); |
196 |
generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); |
197 |
generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels"); |
198 |
generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels"); |
199 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
200 |
generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); |
201 |
generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); |
202 |
generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values"); |
203 |
generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values"); |
204 |
generalTable.setCellSpacing(4);
|
205 |
|
206 |
// Create the 'OK' button, along with a listener that hides the dialog
|
207 |
// when the button is clicked.
|
208 |
final Button ok = new Button("OK", new ClickHandler() { |
209 |
@Override
|
210 |
public void onClick(ClickEvent event) { |
211 |
if(name.getText().contains("/")) |
212 |
fileNameNote.setVisible(true);
|
213 |
else{
|
214 |
fileNameNote.setVisible(true);
|
215 |
accept(); |
216 |
closeDialog(); |
217 |
} |
218 |
} |
219 |
}); |
220 |
ok.getElement().setId("filePropertiesDialog.button.ok");
|
221 |
buttons.add(ok); |
222 |
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
223 |
// Create the 'Cancel' button, along with a listener that hides the
|
224 |
// dialog when the button is clicked.
|
225 |
final Button cancel = new Button("Cancel", new ClickHandler() { |
226 |
@Override
|
227 |
public void onClick(ClickEvent event) { |
228 |
closeDialog(); |
229 |
} |
230 |
}); |
231 |
cancel.getElement().setId("filePropertiesDialog.button.cancel");
|
232 |
buttons.add(cancel); |
233 |
buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
234 |
buttons.setSpacing(8);
|
235 |
buttons.addStyleName("gss-TabPanelBottom");
|
236 |
|
237 |
generalPanel.add(generalTable); |
238 |
|
239 |
// Asynchronously retrieve the tags defined by this user.
|
240 |
DeferredCommand.addCommand(new Command() {
|
241 |
|
242 |
@Override
|
243 |
public void execute() { |
244 |
updateTags(); |
245 |
} |
246 |
}); |
247 |
|
248 |
DisclosurePanel allTags = new DisclosurePanel("All tags"); |
249 |
allTagsContent = new FlowPanel();
|
250 |
allTagsContent.setWidth("100%");
|
251 |
allTags.setContent(allTagsContent); |
252 |
generalPanel.add(allTags); |
253 |
generalPanel.setSpacing(4);
|
254 |
|
255 |
final Button add = new Button("Add Group", new ClickHandler() { |
256 |
@Override
|
257 |
public void onClick(ClickEvent event) { |
258 |
PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, false); |
259 |
dlg.center(); |
260 |
} |
261 |
}); |
262 |
add.getElement().setId("filePropertiesDialog.button.addGroup");
|
263 |
permButtons.add(add); |
264 |
permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); |
265 |
|
266 |
final Button addUser = new Button("Add User", new ClickHandler() { |
267 |
@Override
|
268 |
public void onClick(ClickEvent event) { |
269 |
PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, true); |
270 |
dlg.center(); |
271 |
} |
272 |
}); |
273 |
add.getElement().setId("filePropertiesDialog.button.addUser");
|
274 |
permButtons.add(addUser); |
275 |
permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); |
276 |
|
277 |
permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
278 |
permButtons.setSpacing(8);
|
279 |
permButtons.addStyleName("gss-TabPanelBottom");
|
280 |
|
281 |
final Label readForAllNote = new Label("When this option is enabled, the file will be readable" + |
282 |
" by everyone. By checking this option, you are certifying that you have the right to " +
|
283 |
"distribute this file and that it does not violate the Terms of Use.", true); |
284 |
readForAllNote.setVisible(false);
|
285 |
readForAllNote.setStylePrimaryName("gss-readForAllNote");
|
286 |
|
287 |
readForAll = new CheckBox();
|
288 |
readForAll.getElement().setId("filePropertiesDialog.checkBox.public");
|
289 |
readForAll.setValue(file.isReadForAll()); |
290 |
readForAll.addClickHandler(new ClickHandler() {
|
291 |
@Override
|
292 |
public void onClick(ClickEvent event) { |
293 |
readForAllNote.setVisible(readForAll.getValue()); |
294 |
} |
295 |
|
296 |
}); |
297 |
|
298 |
permPanel.add(permList); |
299 |
permPanel.add(permButtons); |
300 |
// Only show the read for all permission if the user is the owner.
|
301 |
if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) {
|
302 |
permForAll.add(new Label("Public")); |
303 |
permForAll.add(readForAll); |
304 |
permForAll.setSpacing(8);
|
305 |
permForAll.addStyleName("gss-TabPanelBottom");
|
306 |
permForAll.add(readForAllNote); |
307 |
permPanel.add(permForAll); |
308 |
} |
309 |
|
310 |
TextBox path = new TextBox();
|
311 |
path.setWidth("100%");
|
312 |
path.addClickHandler(new ClickHandler() {
|
313 |
@Override
|
314 |
public void onClick(ClickEvent event) { |
315 |
GSS.enableIESelection(); |
316 |
((TextBox) event.getSource()).selectAll(); |
317 |
GSS.preventIESelection(); |
318 |
} |
319 |
|
320 |
}); |
321 |
path.setText(file.getUri()); |
322 |
path.getElement().setId("filePropertiesDialog.textBox.link");
|
323 |
path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
|
324 |
path.setWidth("100%");
|
325 |
path.setReadOnly(true);
|
326 |
pathPanel.setWidth("100%");
|
327 |
pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
328 |
pathPanel.add(new Label("Link")); |
329 |
pathPanel.setSpacing(8);
|
330 |
pathPanel.addStyleName("gss-TabPanelBottom");
|
331 |
pathPanel.add(path); |
332 |
permPanel.add(pathPanel); |
333 |
|
334 |
VersionsList verList = new VersionsList(this, images, bodies); |
335 |
verPanel.add(verList); |
336 |
|
337 |
vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
338 |
vPanel.setSpacing(8);
|
339 |
vPanel.addStyleName("gss-TabPanelBottom");
|
340 |
vPanel.add(new Label("Versioned")); |
341 |
|
342 |
vPanel.add(versioned); |
343 |
verPanel.add(vPanel); |
344 |
vPanel2.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
345 |
vPanel2.setSpacing(8);
|
346 |
vPanel2.addStyleName("gss-TabPanelBottom");
|
347 |
Button removeVersionsButton = new Button(AbstractImagePrototype.create(images.delete()).getHTML(), new ClickHandler() { |
348 |
@Override
|
349 |
public void onClick(ClickEvent event) { |
350 |
ConfirmationDialog confirm = new ConfirmationDialog("Really " + |
351 |
"remove all previous versions?", "Remove") { |
352 |
|
353 |
@Override
|
354 |
public void cancel() { |
355 |
} |
356 |
|
357 |
@Override
|
358 |
public void confirm() { |
359 |
FilePropertiesDialog.this.closeDialog(); |
360 |
removeAllOldVersions(); |
361 |
} |
362 |
|
363 |
}; |
364 |
confirm.center(); |
365 |
} |
366 |
|
367 |
}); |
368 |
HTML removeAllVersion = new HTML("<span>Remove all previous versions?</span>"); |
369 |
vPanel2.add(removeAllVersion); |
370 |
vPanel2.add(removeVersionsButton); |
371 |
verPanel.add(vPanel2); |
372 |
if(!file.isVersioned())
|
373 |
vPanel2.setVisible(false);
|
374 |
outer.add(inner); |
375 |
outer.add(buttons); |
376 |
outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); |
377 |
outer.addStyleName("gss-TabPanelBottom");
|
378 |
|
379 |
focusPanel.setFocus(true);
|
380 |
setWidget(outer); |
381 |
} |
382 |
|
383 |
|
384 |
/**
|
385 |
* Accepts any change and updates the file
|
386 |
*
|
387 |
*/
|
388 |
@Override
|
389 |
protected void accept() { |
390 |
String newFilename = null; |
391 |
permList.updatePermissionsAccordingToInput(); |
392 |
Set<PermissionHolder> perms = permList.getPermissions();
|
393 |
JSONObject json = new JSONObject();
|
394 |
if (!name.getText().equals(file.getName())) {
|
395 |
newFilename = name.getText(); |
396 |
json.put("name", new JSONString(newFilename)); |
397 |
} |
398 |
if (versioned.getValue() != file.isVersioned())
|
399 |
json.put("versioned", JSONBoolean.getInstance(versioned.getValue()));
|
400 |
//only update the read for all perm if the user is the owner
|
401 |
if (readForAll.getValue() != file.isReadForAll())
|
402 |
if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername()))
|
403 |
json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue()));
|
404 |
int i = 0; |
405 |
if (permList.hasChanges()) {
|
406 |
GWT.log("Permissions change", null); |
407 |
JSONArray perma = new JSONArray();
|
408 |
|
409 |
for (PermissionHolder p : perms) {
|
410 |
JSONObject po = new JSONObject();
|
411 |
if (p.getUser() != null) |
412 |
po.put("user", new JSONString(p.getUser())); |
413 |
if (p.getGroup() != null) |
414 |
po.put("group", new JSONString(p.getGroup())); |
415 |
po.put("read", JSONBoolean.getInstance(p.isRead()));
|
416 |
po.put("write", JSONBoolean.getInstance(p.isWrite()));
|
417 |
po.put("modifyACL", JSONBoolean.getInstance(p.isModifyACL()));
|
418 |
perma.set(i, po); |
419 |
i++; |
420 |
} |
421 |
json.put("permissions", perma);
|
422 |
} |
423 |
JSONArray taga = new JSONArray();
|
424 |
i = 0;
|
425 |
if (!tags.getText().equals(initialTagText)) {
|
426 |
String[] tagset = tags.getText().split(","); |
427 |
for (String t : tagset) { |
428 |
JSONString to = new JSONString(t);
|
429 |
taga.set(i, to); |
430 |
i++; |
431 |
} |
432 |
json.put("tags", taga);
|
433 |
} |
434 |
String jsonString = json.toString();
|
435 |
if(jsonString.equals("{}")){ |
436 |
GWT.log("NO CHANGES", null); |
437 |
return;
|
438 |
} |
439 |
final String newFilenameFinal = newFilename; |
440 |
PostCommand cf = new PostCommand(file.getUri() + "?update=", jsonString, 200) { |
441 |
|
442 |
@Override
|
443 |
public void onComplete() { |
444 |
GSS.get().getTreeView().refreshCurrentNode(); |
445 |
} |
446 |
|
447 |
@Override
|
448 |
public void onError(Throwable t) { |
449 |
GWT.log("", t);
|
450 |
if (t instanceof RestException) { |
451 |
int statusCode = ((RestException) t).getHttpStatusCode();
|
452 |
if (statusCode == 405) |
453 |
GSS.get().displayError("You don't have the necessary permissions");
|
454 |
else if (statusCode == 404) |
455 |
GSS.get().displayError("User in permissions does not exist");
|
456 |
else if (statusCode == 409) |
457 |
GSS.get().displayError("A file with the same name already exists");
|
458 |
else if (statusCode == 413) |
459 |
GSS.get().displayError("Your quota has been exceeded");
|
460 |
else
|
461 |
GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());
|
462 |
} else
|
463 |
GSS.get().displayError("System error modifying file:" + t.getMessage());
|
464 |
} |
465 |
|
466 |
}; |
467 |
DeferredCommand.addCommand(cf); |
468 |
|
469 |
} |
470 |
|
471 |
private void removeAllOldVersions() { |
472 |
JSONObject json = new JSONObject();
|
473 |
json.put("versioned", JSONBoolean.getInstance(false)); |
474 |
GWT.log(json.toString(), null);
|
475 |
PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) { |
476 |
|
477 |
@Override
|
478 |
public void onComplete() { |
479 |
toggleVersioned(true);
|
480 |
} |
481 |
|
482 |
@Override
|
483 |
public void onError(Throwable t) { |
484 |
GWT.log("", t);
|
485 |
if (t instanceof RestException) { |
486 |
int statusCode = ((RestException) t).getHttpStatusCode();
|
487 |
if (statusCode == 405) |
488 |
GSS.get().displayError("You don't have the necessary permissions");
|
489 |
else if (statusCode == 404) |
490 |
GSS.get().displayError("User in permissions does not exist");
|
491 |
else if (statusCode == 409) |
492 |
GSS.get().displayError("A folder with the same name already exists");
|
493 |
else if (statusCode == 413) |
494 |
GSS.get().displayError("Your quota has been exceeded");
|
495 |
else
|
496 |
GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());
|
497 |
} else
|
498 |
GSS.get().displayError("System error moifying file:" + t.getMessage());
|
499 |
} |
500 |
}; |
501 |
DeferredCommand.addCommand(cf); |
502 |
} |
503 |
|
504 |
private void toggleVersioned(boolean versionedValue) { |
505 |
JSONObject json = new JSONObject();
|
506 |
json.put("versioned", JSONBoolean.getInstance(versionedValue));
|
507 |
GWT.log(json.toString(), null);
|
508 |
PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) { |
509 |
|
510 |
@Override
|
511 |
public void onComplete() { |
512 |
GSS.get().getTreeView().refreshCurrentNode(); |
513 |
} |
514 |
|
515 |
@Override
|
516 |
public void onError(Throwable t) { |
517 |
GWT.log("", t);
|
518 |
if (t instanceof RestException) { |
519 |
int statusCode = ((RestException) t).getHttpStatusCode();
|
520 |
if (statusCode == 405) |
521 |
GSS.get().displayError("You don't have the necessary permissions");
|
522 |
else if (statusCode == 404) |
523 |
GSS.get().displayError("User in permissions does not exist");
|
524 |
else if (statusCode == 409) |
525 |
GSS.get().displayError("A folder with the same name already exists");
|
526 |
else if (statusCode == 413) |
527 |
GSS.get().displayError("Your quota has been exceeded");
|
528 |
else
|
529 |
GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());
|
530 |
} else
|
531 |
GSS.get().displayError("System error moifying file:" + t.getMessage());
|
532 |
} |
533 |
}; |
534 |
DeferredCommand.addCommand(cf); |
535 |
} |
536 |
|
537 |
} |