root / src / gr / grnet / pithos / web / client / FilePermissionsDialog.java @ 60a94150
History | View | Annotate | Download (12.9 kB)
1 | 9326b841 | Christos Stathis | /*
|
---|---|---|---|
2 | cae2a8db | Christos Stathis | * Copyright 2011-2012 GRNET S.A. All rights reserved.
|
3 | 9326b841 | Christos Stathis | *
|
4 | 9326b841 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 9326b841 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 9326b841 | Christos Stathis | * conditions are met:
|
7 | 9326b841 | Christos Stathis | *
|
8 | 9326b841 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 9326b841 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 9326b841 | Christos Stathis | * disclaimer.
|
11 | 9326b841 | Christos Stathis | *
|
12 | 9326b841 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 9326b841 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 9326b841 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 9326b841 | Christos Stathis | * provided with the distribution.
|
16 | 9326b841 | Christos Stathis | *
|
17 | 9326b841 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 9326b841 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 9326b841 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 9326b841 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 9326b841 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 9326b841 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 9326b841 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 9326b841 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 9326b841 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 9326b841 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 9326b841 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 9326b841 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 9326b841 | Christos Stathis | *
|
30 | 9326b841 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 9326b841 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 9326b841 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 9326b841 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | 9326b841 | Christos Stathis | */
|
35 | 9326b841 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | 9326b841 | Christos Stathis | |
37 | 9326b841 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.File; |
38 | 9326b841 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Resource; |
39 | b3c9eba8 | Christos Stathis | import gr.grnet.pithos.web.client.rest.HeadRequest; |
40 | 9326b841 | Christos Stathis | import gr.grnet.pithos.web.client.rest.PostRequest; |
41 | 9326b841 | Christos Stathis | |
42 | 9326b841 | Christos Stathis | import java.util.Map; |
43 | 9326b841 | Christos Stathis | |
44 | 9326b841 | Christos Stathis | import com.google.gwt.core.client.GWT; |
45 | 9326b841 | Christos Stathis | import com.google.gwt.core.client.Scheduler; |
46 | b3c9eba8 | Christos Stathis | import com.google.gwt.dom.client.NativeEvent; |
47 | 9326b841 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
48 | 9326b841 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
49 | b3c9eba8 | Christos Stathis | import com.google.gwt.event.dom.client.KeyCodes; |
50 | 9326b841 | Christos Stathis | import com.google.gwt.http.client.Response; |
51 | 9326b841 | Christos Stathis | import com.google.gwt.http.client.URL; |
52 | 4d869bf1 | Christos Stathis | import com.google.gwt.http.client.UrlBuilder; |
53 | 4d869bf1 | Christos Stathis | import com.google.gwt.i18n.client.Dictionary; |
54 | 9326b841 | Christos Stathis | import com.google.gwt.resources.client.ImageResource; |
55 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.Command; |
56 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.Window; |
57 | b3c9eba8 | Christos Stathis | import com.google.gwt.user.client.Event.NativePreviewEvent; |
58 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.Anchor; |
59 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.Button; |
60 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.CheckBox; |
61 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.FocusPanel; |
62 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
63 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.HorizontalPanel; |
64 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.Label; |
65 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.TextBox; |
66 | 9326b841 | Christos Stathis | import com.google.gwt.user.client.ui.VerticalPanel; |
67 | 9326b841 | Christos Stathis | |
68 | 9326b841 | Christos Stathis | /**
|
69 | 9326b841 | Christos Stathis | * The 'File properties' dialog box implementation.
|
70 | 9326b841 | Christos Stathis | *
|
71 | 9326b841 | Christos Stathis | */
|
72 | 9326b841 | Christos Stathis | public class FilePermissionsDialog extends AbstractPropertiesDialog { |
73 | 9326b841 | Christos Stathis | |
74 | 9326b841 | Christos Stathis | protected PermissionsList permList;
|
75 | 9326b841 | Christos Stathis | |
76 | b3c9eba8 | Christos Stathis | private HorizontalPanel pathPanel;
|
77 | b3c9eba8 | Christos Stathis | |
78 | b3c9eba8 | Christos Stathis | private TextBox path;
|
79 | b3c9eba8 | Christos Stathis | |
80 | 9326b841 | Christos Stathis | /**
|
81 | 9326b841 | Christos Stathis | * An image bundle for this widgets images.
|
82 | 9326b841 | Christos Stathis | */
|
83 | 9326b841 | Christos Stathis | public interface Images extends MessagePanel.Images { |
84 | 9326b841 | Christos Stathis | |
85 | 9326b841 | Christos Stathis | @Source("gr/grnet/pithos/resources/edit_user.png") |
86 | 9326b841 | Christos Stathis | ImageResource permUser(); |
87 | 9326b841 | Christos Stathis | |
88 | 9326b841 | Christos Stathis | @Source("gr/grnet/pithos/resources/groups22.png") |
89 | 9326b841 | Christos Stathis | ImageResource permGroup(); |
90 | 9326b841 | Christos Stathis | |
91 | 2dfc5957 | Christos Stathis | @Source("gr/grnet/pithos/resources/delete.gif") |
92 | 9326b841 | Christos Stathis | ImageResource delete(); |
93 | 9326b841 | Christos Stathis | } |
94 | 9326b841 | Christos Stathis | |
95 | 9326b841 | Christos Stathis | final File file; |
96 | 9326b841 | Christos Stathis | |
97 | 9326b841 | Christos Stathis | Images images = GWT.create(Images.class); |
98 | 9326b841 | Christos Stathis | |
99 | 9326b841 | Christos Stathis | /**
|
100 | 9326b841 | Christos Stathis | * The widget's constructor.
|
101 | 9326b841 | Christos Stathis | */
|
102 | 9326b841 | Christos Stathis | public FilePermissionsDialog(Pithos _app, File _file) { |
103 | 9326b841 | Christos Stathis | super(_app);
|
104 | 9326b841 | Christos Stathis | file = _file; |
105 | 9326b841 | Christos Stathis | |
106 | 96705b13 | Christos Stathis | Anchor close = new Anchor("close"); |
107 | 9326b841 | Christos Stathis | close.addStyleName("close");
|
108 | 9326b841 | Christos Stathis | close.addClickHandler(new ClickHandler() {
|
109 | 9326b841 | Christos Stathis | |
110 | 9326b841 | Christos Stathis | @Override
|
111 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
112 | 9326b841 | Christos Stathis | hide(); |
113 | 9326b841 | Christos Stathis | } |
114 | 9326b841 | Christos Stathis | }); |
115 | 9326b841 | Christos Stathis | // Set the dialog's caption.
|
116 | 9326b841 | Christos Stathis | setText("File permissions");
|
117 | 9326b841 | Christos Stathis | setAnimationEnabled(true);
|
118 | 9326b841 | Christos Stathis | setGlassEnabled(true);
|
119 | 9326b841 | Christos Stathis | setStyleName("pithos-DialogBox");
|
120 | 9326b841 | Christos Stathis | |
121 | 9326b841 | Christos Stathis | // Outer contains inner and buttons.
|
122 | 9326b841 | Christos Stathis | final VerticalPanel outer = new VerticalPanel(); |
123 | 9326b841 | Christos Stathis | outer.add(close); |
124 | 9326b841 | Christos Stathis | final FocusPanel focusPanel = new FocusPanel(outer); |
125 | 9326b841 | Christos Stathis | // Inner contains generalPanel and permPanel.
|
126 | 9326b841 | Christos Stathis | inner = new VerticalPanel();
|
127 | 9326b841 | Christos Stathis | inner.addStyleName("inner");
|
128 | 9326b841 | Christos Stathis | |
129 | 9326b841 | Christos Stathis | inner.add(createSharingPanel()); |
130 | 9326b841 | Christos Stathis | |
131 | 9326b841 | Christos Stathis | outer.add(inner); |
132 | 9326b841 | Christos Stathis | |
133 | 22c24bda | Christos Stathis | final Button ok = new Button("OK", new ClickHandler() { |
134 | 9326b841 | Christos Stathis | @Override
|
135 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
136 | 9326b841 | Christos Stathis | closeDialog(); |
137 | 9326b841 | Christos Stathis | } |
138 | 9326b841 | Christos Stathis | }); |
139 | 9326b841 | Christos Stathis | ok.addStyleName("button");
|
140 | 9326b841 | Christos Stathis | |
141 | 9326b841 | Christos Stathis | outer.add(ok); |
142 | 9326b841 | Christos Stathis | outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
143 | 9326b841 | Christos Stathis | |
144 | 9326b841 | Christos Stathis | focusPanel.setFocus(true);
|
145 | 9326b841 | Christos Stathis | setWidget(outer); |
146 | 9326b841 | Christos Stathis | } |
147 | 9326b841 | Christos Stathis | |
148 | 9326b841 | Christos Stathis | private VerticalPanel createSharingPanel() {
|
149 | 9326b841 | Christos Stathis | VerticalPanel permPanel = new VerticalPanel();
|
150 | 9326b841 | Christos Stathis | |
151 | 4d869bf1 | Christos Stathis | permList = new PermissionsList(images, file.getPermissions(), file.getOwner(), false, new Command() { |
152 | 4d869bf1 | Christos Stathis | |
153 | 4d869bf1 | Christos Stathis | @Override
|
154 | 4d869bf1 | Christos Stathis | public void execute() { |
155 | 4d869bf1 | Christos Stathis | accept(); |
156 | 4d869bf1 | Christos Stathis | } |
157 | 4d869bf1 | Christos Stathis | }); |
158 | 9326b841 | Christos Stathis | permPanel.add(permList); |
159 | 9326b841 | Christos Stathis | |
160 | b3c3954b | Christos Stathis | HorizontalPanel permButtons = new HorizontalPanel();
|
161 | 57ab6e0b | Christos Stathis | final Button addUser = new Button("Add User", new ClickHandler() { |
162 | b3c3954b | Christos Stathis | @Override
|
163 | b3c3954b | Christos Stathis | public void onClick(ClickEvent event) { |
164 | 57ab6e0b | Christos Stathis | PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true); |
165 | b3c3954b | Christos Stathis | dlg.center(); |
166 | b3c3954b | Christos Stathis | permList.updatePermissionTable(); |
167 | b3c3954b | Christos Stathis | } |
168 | b3c3954b | Christos Stathis | }); |
169 | 57ab6e0b | Christos Stathis | addUser.addStyleName("button");
|
170 | 57ab6e0b | Christos Stathis | permButtons.add(addUser); |
171 | 57ab6e0b | Christos Stathis | permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); |
172 | b3c3954b | Christos Stathis | |
173 | 57ab6e0b | Christos Stathis | Button add = new Button("Add Group", new ClickHandler() { |
174 | b3c3954b | Christos Stathis | @Override
|
175 | b3c3954b | Christos Stathis | public void onClick(ClickEvent event) { |
176 | 5ec7b091 | Christos Stathis | if (app.getAccount().getGroups().isEmpty()) {
|
177 | 5ec7b091 | Christos Stathis | new GroupCreateDialog(app, new Command() { |
178 | 5ec7b091 | Christos Stathis | |
179 | 5ec7b091 | Christos Stathis | @Override
|
180 | 5ec7b091 | Christos Stathis | public void execute() { |
181 | 5ec7b091 | Christos Stathis | if (app.getAccount().getGroups().isEmpty())
|
182 | 5ec7b091 | Christos Stathis | return;
|
183 | 5ec7b091 | Christos Stathis | PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false); |
184 | 5ec7b091 | Christos Stathis | dlg.center(); |
185 | 5ec7b091 | Christos Stathis | permList.updatePermissionTable(); |
186 | 5ec7b091 | Christos Stathis | } |
187 | 5ec7b091 | Christos Stathis | }).center(); |
188 | 5ec7b091 | Christos Stathis | } |
189 | 5ec7b091 | Christos Stathis | else {
|
190 | 5ec7b091 | Christos Stathis | PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false); |
191 | 5ec7b091 | Christos Stathis | dlg.center(); |
192 | 5ec7b091 | Christos Stathis | permList.updatePermissionTable(); |
193 | 5ec7b091 | Christos Stathis | } |
194 | b3c3954b | Christos Stathis | } |
195 | b3c3954b | Christos Stathis | }); |
196 | 57ab6e0b | Christos Stathis | add.addStyleName("button");
|
197 | 57ab6e0b | Christos Stathis | permButtons.add(add); |
198 | 57ab6e0b | Christos Stathis | permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); |
199 | b3c3954b | Christos Stathis | |
200 | b3c3954b | Christos Stathis | permButtons.setSpacing(8);
|
201 | b3c3954b | Christos Stathis | permButtons.addStyleName("pithos-TabPanelBottom");
|
202 | b3c3954b | Christos Stathis | permPanel.add(permButtons); |
203 | 9326b841 | Christos Stathis | |
204 | 9326b841 | Christos Stathis | final Label readForAllNote = new Label("When this option is enabled, the file will be readable" + |
205 | 9326b841 | Christos Stathis | " by everyone. By checking this option, you are certifying that you have the right to " +
|
206 | 9326b841 | Christos Stathis | "distribute this file and that it does not violate the Terms of Use.", true); |
207 | 9326b841 | Christos Stathis | readForAllNote.setStylePrimaryName("pithos-readForAllNote");
|
208 | 9326b841 | Christos Stathis | |
209 | b3c9eba8 | Christos Stathis | pathPanel = new HorizontalPanel();
|
210 | b3c9eba8 | Christos Stathis | pathPanel.setVisible(false);
|
211 | b3c9eba8 | Christos Stathis | pathPanel.setWidth("100%");
|
212 | b3c9eba8 | Christos Stathis | pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
213 | b3c9eba8 | Christos Stathis | pathPanel.add(new Label("Link")); |
214 | b3c9eba8 | Christos Stathis | pathPanel.setSpacing(8);
|
215 | b3c9eba8 | Christos Stathis | pathPanel.addStyleName("pithos-TabPanelBottom");
|
216 | b3c9eba8 | Christos Stathis | |
217 | b3c9eba8 | Christos Stathis | path = new TextBox();
|
218 | b3c9eba8 | Christos Stathis | path.setWidth("100%");
|
219 | b3c9eba8 | Christos Stathis | path.addClickHandler(new ClickHandler() {
|
220 | b3c9eba8 | Christos Stathis | @Override
|
221 | b3c9eba8 | Christos Stathis | public void onClick(ClickEvent event) { |
222 | b3c9eba8 | Christos Stathis | Pithos.enableIESelection(); |
223 | b3c9eba8 | Christos Stathis | ((TextBox) event.getSource()).selectAll(); |
224 | b3c9eba8 | Christos Stathis | Pithos.preventIESelection(); |
225 | b3c9eba8 | Christos Stathis | } |
226 | b3c9eba8 | Christos Stathis | }); |
227 | b3c9eba8 | Christos Stathis | path.setText(Window.Location.getHost() + file.getPublicUri());
|
228 | b3c9eba8 | Christos Stathis | path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
|
229 | b3c9eba8 | Christos Stathis | path.setWidth("100%");
|
230 | b3c9eba8 | Christos Stathis | path.setReadOnly(true);
|
231 | b3c9eba8 | Christos Stathis | pathPanel.add(path); |
232 | b3c9eba8 | Christos Stathis | permPanel.add(pathPanel); |
233 | b3c9eba8 | Christos Stathis | |
234 | b3c9eba8 | Christos Stathis | Scheduler.get().scheduleDeferred(new Command() {
|
235 | b3c9eba8 | Christos Stathis | |
236 | b3c9eba8 | Christos Stathis | @Override
|
237 | b3c9eba8 | Christos Stathis | public void execute() { |
238 | 71875b42 | Christos Stathis | showLinkIfShared(); |
239 | b3c9eba8 | Christos Stathis | } |
240 | b3c9eba8 | Christos Stathis | }); |
241 | 9326b841 | Christos Stathis | return permPanel;
|
242 | 9326b841 | Christos Stathis | } |
243 | 9326b841 | Christos Stathis | |
244 | 71875b42 | Christos Stathis | void showLinkIfShared() {
|
245 | 4d869bf1 | Christos Stathis | if (file.isShared()) {
|
246 | 4d869bf1 | Christos Stathis | UrlBuilder b = Window.Location.createUrlBuilder();
|
247 | 71875b42 | Christos Stathis | b.setPath(app.getApiPath() + file.getOwner() + file.getUri()); |
248 | 71875b42 | Christos Stathis | String href = Window.Location.getHref(); |
249 | 71875b42 | Christos Stathis | boolean hasParameters = href.contains("?"); |
250 | 71875b42 | Christos Stathis | path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString()); |
251 | b3c9eba8 | Christos Stathis | pathPanel.setVisible(true);
|
252 | b3c9eba8 | Christos Stathis | } |
253 | b3c9eba8 | Christos Stathis | else {
|
254 | b3c9eba8 | Christos Stathis | pathPanel.setVisible(false);
|
255 | b3c9eba8 | Christos Stathis | } |
256 | b3c9eba8 | Christos Stathis | } |
257 | 9326b841 | Christos Stathis | /**
|
258 | 9326b841 | Christos Stathis | * Accepts any change and updates the file
|
259 | 9326b841 | Christos Stathis | *
|
260 | 9326b841 | Christos Stathis | */
|
261 | 9326b841 | Christos Stathis | @Override
|
262 | 0099339a | Christos Stathis | protected boolean accept() { |
263 | 71875b42 | Christos Stathis | updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", permList.getPermissions());
|
264 | 0099339a | Christos Stathis | return true; |
265 | 9326b841 | Christos Stathis | } |
266 | 9326b841 | Christos Stathis | |
267 | 71875b42 | Christos Stathis | protected void updateMetaData(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) { |
268 | 71875b42 | Christos Stathis | if (newPermissions != null) { |
269 | 9326b841 | Christos Stathis | PostRequest updateFile = new PostRequest(api, owner, path) {
|
270 | 9326b841 | Christos Stathis | @Override
|
271 | ebead1b5 | Christos Stathis | public void onSuccess(Resource result) { |
272 | b3c9eba8 | Christos Stathis | HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwner(), path, file) { |
273 | b3c9eba8 | Christos Stathis | |
274 | 9326b841 | Christos Stathis | @Override
|
275 | b3c9eba8 | Christos Stathis | public void onSuccess(File _result) { |
276 | 71875b42 | Christos Stathis | showLinkIfShared(); |
277 | 5d18aa82 | Christos Stathis | if (!app.isMySharedSelected())
|
278 | 5d18aa82 | Christos Stathis | app.updateFolder(file.getParent(), true, new Command() { |
279 | 5d18aa82 | Christos Stathis | |
280 | 5d18aa82 | Christos Stathis | @Override
|
281 | 5d18aa82 | Christos Stathis | public void execute() { |
282 | 5d18aa82 | Christos Stathis | app.updateMySharedRoot(); |
283 | 5d18aa82 | Christos Stathis | } |
284 | 5d18aa82 | Christos Stathis | }, true);
|
285 | 5d18aa82 | Christos Stathis | else
|
286 | 5d18aa82 | Christos Stathis | app.updateSharedFolder(file.getParent(), true);
|
287 | 9326b841 | Christos Stathis | } |
288 | b3c9eba8 | Christos Stathis | |
289 | b3c9eba8 | Christos Stathis | @Override
|
290 | b3c9eba8 | Christos Stathis | public void onError(Throwable t) { |
291 | b3c9eba8 | Christos Stathis | GWT.log("", t);
|
292 | b3c9eba8 | Christos Stathis | app.setError(t); |
293 | b3c9eba8 | Christos Stathis | app.displayError("System error modifying file:" + t.getMessage());
|
294 | b3c9eba8 | Christos Stathis | } |
295 | b3c9eba8 | Christos Stathis | |
296 | b3c9eba8 | Christos Stathis | @Override
|
297 | b3c9eba8 | Christos Stathis | protected void onUnauthorized(Response response) { |
298 | b3c9eba8 | Christos Stathis | app.sessionExpired(); |
299 | b3c9eba8 | Christos Stathis | } |
300 | b3c9eba8 | Christos Stathis | }; |
301 | b3c9eba8 | Christos Stathis | headFile.setHeader("X-Auth-Token", app.getToken());
|
302 | b3c9eba8 | Christos Stathis | Scheduler.get().scheduleDeferred(headFile); |
303 | 9326b841 | Christos Stathis | } |
304 | 9326b841 | Christos Stathis | |
305 | 9326b841 | Christos Stathis | @Override
|
306 | 9326b841 | Christos Stathis | public void onError(Throwable t) { |
307 | 9326b841 | Christos Stathis | GWT.log("", t);
|
308 | 9326b841 | Christos Stathis | app.setError(t); |
309 | 9326b841 | Christos Stathis | app.displayError("System error modifying file:" + t.getMessage());
|
310 | 9326b841 | Christos Stathis | } |
311 | 9326b841 | Christos Stathis | |
312 | 9326b841 | Christos Stathis | @Override
|
313 | ebead1b5 | Christos Stathis | protected void onUnauthorized(Response response) { |
314 | 9326b841 | Christos Stathis | app.sessionExpired(); |
315 | 9326b841 | Christos Stathis | } |
316 | 9326b841 | Christos Stathis | }; |
317 | 9326b841 | Christos Stathis | updateFile.setHeader("X-Auth-Token", app.getToken());
|
318 | 9326b841 | Christos Stathis | |
319 | 71875b42 | Christos Stathis | String readPermHeader = "read="; |
320 | 71875b42 | Christos Stathis | String writePermHeader = "write="; |
321 | 71875b42 | Christos Stathis | for (String u : newPermissions.keySet()) { |
322 | 71875b42 | Christos Stathis | Boolean[] p = newPermissions.get(u); |
323 | 71875b42 | Christos Stathis | if (p[0] != null && p[0]) |
324 | 71875b42 | Christos Stathis | readPermHeader += u + ",";
|
325 | 71875b42 | Christos Stathis | if (p[1] != null && p[1]) |
326 | 71875b42 | Christos Stathis | writePermHeader += u + ",";
|
327 | 9326b841 | Christos Stathis | } |
328 | 71875b42 | Christos Stathis | if (readPermHeader.endsWith("=")) |
329 | 71875b42 | Christos Stathis | readPermHeader = "";
|
330 | 71875b42 | Christos Stathis | else if (readPermHeader.endsWith(",")) |
331 | 71875b42 | Christos Stathis | readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1); |
332 | 71875b42 | Christos Stathis | if (writePermHeader.endsWith("=")) |
333 | 71875b42 | Christos Stathis | writePermHeader = "";
|
334 | 71875b42 | Christos Stathis | else if (writePermHeader.endsWith(",")) |
335 | 71875b42 | Christos Stathis | writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1); |
336 | 71875b42 | Christos Stathis | String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader; |
337 | 71875b42 | Christos Stathis | if (permHeader.length() == 0) |
338 | 71875b42 | Christos Stathis | permHeader="~";
|
339 | 71875b42 | Christos Stathis | else
|
340 | 71875b42 | Christos Stathis | permHeader = URL.encodePathSegment(permHeader);
|
341 | 71875b42 | Christos Stathis | updateFile.setHeader("X-Object-Sharing", permHeader);
|
342 | 9326b841 | Christos Stathis | Scheduler.get().scheduleDeferred(updateFile); |
343 | 9326b841 | Christos Stathis | } |
344 | 5d18aa82 | Christos Stathis | else if (!app.isMySharedSelected()) |
345 | 9326b841 | Christos Stathis | app.updateFolder(file.getParent(), true, new Command() { |
346 | 9326b841 | Christos Stathis | |
347 | 9326b841 | Christos Stathis | @Override
|
348 | 9326b841 | Christos Stathis | public void execute() { |
349 | 71875b42 | Christos Stathis | if (file.isSharedOrPublished())
|
350 | 9326b841 | Christos Stathis | app.updateMySharedRoot(); |
351 | 9326b841 | Christos Stathis | } |
352 | 6acd4df3 | Christos Stathis | }, true);
|
353 | 5d18aa82 | Christos Stathis | else
|
354 | 5d18aa82 | Christos Stathis | app.updateSharedFolder(file.getParent(), true);
|
355 | 9326b841 | Christos Stathis | } |
356 | b3c9eba8 | Christos Stathis | |
357 | b3c9eba8 | Christos Stathis | @Override
|
358 | b3c9eba8 | Christos Stathis | protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
359 | b3c9eba8 | Christos Stathis | super.onPreviewNativeEvent(preview);
|
360 | b3c9eba8 | Christos Stathis | |
361 | b3c9eba8 | Christos Stathis | NativeEvent evt = preview.getNativeEvent(); |
362 | b3c9eba8 | Christos Stathis | if (evt.getType().equals("keydown") && evt.getKeyCode() == KeyCodes.KEY_ENTER) |
363 | b3c9eba8 | Christos Stathis | closeDialog(); |
364 | b3c9eba8 | Christos Stathis | } |
365 | 9326b841 | Christos Stathis | } |