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