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