Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / FilePermissionsDialog.java @ a16cddac

History | View | Annotate | Download (12.7 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 b3c9eba8 Christos Stathis
import gr.grnet.pithos.web.client.rest.HeadRequest;
39 9326b841 Christos Stathis
import gr.grnet.pithos.web.client.rest.PostRequest;
40 9326b841 Christos Stathis
41 9326b841 Christos Stathis
import java.util.Map;
42 9326b841 Christos Stathis
43 9326b841 Christos Stathis
import com.google.gwt.core.client.GWT;
44 9326b841 Christos Stathis
import com.google.gwt.core.client.Scheduler;
45 b3c9eba8 Christos Stathis
import com.google.gwt.dom.client.NativeEvent;
46 9326b841 Christos Stathis
import com.google.gwt.event.dom.client.ClickEvent;
47 9326b841 Christos Stathis
import com.google.gwt.event.dom.client.ClickHandler;
48 b3c9eba8 Christos Stathis
import com.google.gwt.event.dom.client.KeyCodes;
49 9326b841 Christos Stathis
import com.google.gwt.http.client.Response;
50 9326b841 Christos Stathis
import com.google.gwt.http.client.URL;
51 4d869bf1 Christos Stathis
import com.google.gwt.http.client.UrlBuilder;
52 9326b841 Christos Stathis
import com.google.gwt.resources.client.ImageResource;
53 9326b841 Christos Stathis
import com.google.gwt.user.client.Command;
54 9326b841 Christos Stathis
import com.google.gwt.user.client.Window;
55 b3c9eba8 Christos Stathis
import com.google.gwt.user.client.Event.NativePreviewEvent;
56 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.Anchor;
57 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.Button;
58 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.FocusPanel;
59 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
60 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.HorizontalPanel;
61 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.Label;
62 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.TextBox;
63 9326b841 Christos Stathis
import com.google.gwt.user.client.ui.VerticalPanel;
64 9326b841 Christos Stathis
65 9326b841 Christos Stathis
/**
66 9326b841 Christos Stathis
 * The 'File properties' dialog box implementation.
67 9326b841 Christos Stathis
 *
68 9326b841 Christos Stathis
 */
69 9326b841 Christos Stathis
public class FilePermissionsDialog extends AbstractPropertiesDialog {
70 9326b841 Christos Stathis
71 9326b841 Christos Stathis
        protected PermissionsList permList;
72 9326b841 Christos Stathis
73 b3c9eba8 Christos Stathis
        private HorizontalPanel pathPanel;
74 b3c9eba8 Christos Stathis
        
75 b3c9eba8 Christos Stathis
        private TextBox path;
76 b3c9eba8 Christos Stathis
        
77 9326b841 Christos Stathis
        /**
78 9326b841 Christos Stathis
         * An image bundle for this widgets images.
79 9326b841 Christos Stathis
         */
80 9326b841 Christos Stathis
        public interface Images extends MessagePanel.Images {
81 9326b841 Christos Stathis
82 9326b841 Christos Stathis
                @Source("gr/grnet/pithos/resources/edit_user.png")
83 9326b841 Christos Stathis
                ImageResource permUser();
84 9326b841 Christos Stathis
85 9326b841 Christos Stathis
                @Source("gr/grnet/pithos/resources/groups22.png")
86 9326b841 Christos Stathis
                ImageResource permGroup();
87 9326b841 Christos Stathis
88 2dfc5957 Christos Stathis
                @Source("gr/grnet/pithos/resources/delete.gif")
89 9326b841 Christos Stathis
                ImageResource delete();
90 9326b841 Christos Stathis
        }
91 9326b841 Christos Stathis
92 9326b841 Christos Stathis
        final File file;
93 9326b841 Christos Stathis
94 9326b841 Christos Stathis
    Images images = GWT.create(Images.class);
95 9326b841 Christos Stathis
96 9326b841 Christos Stathis
        /**
97 9326b841 Christos Stathis
         * The widget's constructor.
98 9326b841 Christos Stathis
         */
99 9326b841 Christos Stathis
        public FilePermissionsDialog(Pithos _app, File _file) {
100 9326b841 Christos Stathis
        super(_app);
101 9326b841 Christos Stathis
        file = _file;
102 9326b841 Christos Stathis
103 96705b13 Christos Stathis
                Anchor close = new Anchor("close");
104 9326b841 Christos Stathis
                close.addStyleName("close");
105 9326b841 Christos Stathis
                close.addClickHandler(new ClickHandler() {
106 9326b841 Christos Stathis
                        
107 9326b841 Christos Stathis
                        @Override
108 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
109 9326b841 Christos Stathis
                                hide();
110 9326b841 Christos Stathis
                        }
111 9326b841 Christos Stathis
                });
112 9326b841 Christos Stathis
                // Set the dialog's caption.
113 9326b841 Christos Stathis
                setText("File permissions");
114 9326b841 Christos Stathis
                setGlassEnabled(true);
115 9326b841 Christos Stathis
                setStyleName("pithos-DialogBox");
116 9326b841 Christos Stathis
117 9326b841 Christos Stathis
                // Outer contains inner and buttons.
118 9326b841 Christos Stathis
                final VerticalPanel outer = new VerticalPanel();
119 9326b841 Christos Stathis
                outer.add(close);
120 9326b841 Christos Stathis
                final FocusPanel focusPanel = new FocusPanel(outer);
121 9326b841 Christos Stathis
                // Inner contains generalPanel and permPanel.
122 9326b841 Christos Stathis
                inner = new VerticalPanel();
123 9326b841 Christos Stathis
                inner.addStyleName("inner");
124 9326b841 Christos Stathis
125 9326b841 Christos Stathis
        inner.add(createSharingPanel());
126 9326b841 Christos Stathis
127 9326b841 Christos Stathis
        outer.add(inner);
128 9326b841 Christos Stathis
129 22c24bda Christos Stathis
                final Button ok = new Button("OK", new ClickHandler() {
130 9326b841 Christos Stathis
                        @Override
131 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
132 9326b841 Christos Stathis
                                closeDialog();
133 9326b841 Christos Stathis
                        }
134 9326b841 Christos Stathis
                });
135 9326b841 Christos Stathis
                ok.addStyleName("button");
136 9326b841 Christos Stathis
137 9326b841 Christos Stathis
        outer.add(ok);
138 9326b841 Christos Stathis
        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
139 9326b841 Christos Stathis
140 9326b841 Christos Stathis
        focusPanel.setFocus(true);
141 9326b841 Christos Stathis
        setWidget(outer);
142 9326b841 Christos Stathis
        }
143 9326b841 Christos Stathis
144 9326b841 Christos Stathis
    private VerticalPanel createSharingPanel() {
145 9326b841 Christos Stathis
        VerticalPanel permPanel = new VerticalPanel();
146 9326b841 Christos Stathis
147 8d09767f Christos KK Loverdos
        permList = new PermissionsList(app, images, file.getPermissions(), file.getOwnerID(), false, new Command() {
148 4d869bf1 Christos Stathis
                        
149 4d869bf1 Christos Stathis
                        @Override
150 4d869bf1 Christos Stathis
                        public void execute() {
151 4d869bf1 Christos Stathis
                                accept();
152 4d869bf1 Christos Stathis
                        }
153 4d869bf1 Christos Stathis
                });
154 9326b841 Christos Stathis
        permPanel.add(permList);
155 9326b841 Christos Stathis
156 b3c3954b Christos Stathis
        HorizontalPanel permButtons = new HorizontalPanel();
157 57ab6e0b Christos Stathis
        final Button addUser = new Button("Add User", new ClickHandler() {
158 b3c3954b Christos Stathis
            @Override
159 b3c3954b Christos Stathis
            public void onClick(ClickEvent event) {
160 57ab6e0b Christos Stathis
                PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true);
161 b3c3954b Christos Stathis
                dlg.center();
162 b3c3954b Christos Stathis
                permList.updatePermissionTable();
163 b3c3954b Christos Stathis
            }
164 b3c3954b Christos Stathis
        });
165 57ab6e0b Christos Stathis
        addUser.addStyleName("button");
166 57ab6e0b Christos Stathis
        permButtons.add(addUser);
167 57ab6e0b Christos Stathis
        permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER);
168 b3c3954b Christos Stathis
169 57ab6e0b Christos Stathis
        Button add = new Button("Add Group", new ClickHandler() {
170 b3c3954b Christos Stathis
            @Override
171 b3c3954b Christos Stathis
            public void onClick(ClickEvent event) {
172 5ec7b091 Christos Stathis
                    if (app.getAccount().getGroups().isEmpty()) {
173 5ec7b091 Christos Stathis
                    new GroupCreateDialog(app, new Command() {
174 5ec7b091 Christos Stathis
                                                
175 5ec7b091 Christos Stathis
                                                @Override
176 5ec7b091 Christos Stathis
                                                public void execute() {
177 5ec7b091 Christos Stathis
                                            if (app.getAccount().getGroups().isEmpty())
178 5ec7b091 Christos Stathis
                                                    return;
179 5ec7b091 Christos Stathis
                                        PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
180 5ec7b091 Christos Stathis
                                        dlg.center();
181 5ec7b091 Christos Stathis
                                        permList.updatePermissionTable();
182 5ec7b091 Christos Stathis
                                                }
183 5ec7b091 Christos Stathis
                                        }).center();
184 5ec7b091 Christos Stathis
                    }
185 5ec7b091 Christos Stathis
                    else {
186 5ec7b091 Christos Stathis
                        PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
187 5ec7b091 Christos Stathis
                        dlg.center();
188 5ec7b091 Christos Stathis
                        permList.updatePermissionTable();
189 5ec7b091 Christos Stathis
                    }
190 b3c3954b Christos Stathis
            }
191 b3c3954b Christos Stathis
        });
192 57ab6e0b Christos Stathis
        add.addStyleName("button");
193 57ab6e0b Christos Stathis
        permButtons.add(add);
194 57ab6e0b Christos Stathis
        permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);
195 b3c3954b Christos Stathis
196 b3c3954b Christos Stathis
        permButtons.setSpacing(8);
197 b3c3954b Christos Stathis
        permButtons.addStyleName("pithos-TabPanelBottom");
198 b3c3954b Christos Stathis
        permPanel.add(permButtons);
199 9326b841 Christos Stathis
200 9326b841 Christos Stathis
        final Label readForAllNote = new Label("When this option is enabled, the file will be readable" +
201 9326b841 Christos Stathis
                    " by everyone. By checking this option, you are certifying that you have the right to " +
202 9326b841 Christos Stathis
                    "distribute this file and that it does not violate the Terms of Use.", true);
203 9326b841 Christos Stathis
        readForAllNote.setStylePrimaryName("pithos-readForAllNote");
204 9326b841 Christos Stathis
205 b3c9eba8 Christos Stathis
        pathPanel = new HorizontalPanel();
206 b3c9eba8 Christos Stathis
        pathPanel.setVisible(false);
207 b3c9eba8 Christos Stathis
        pathPanel.setWidth("100%");
208 b3c9eba8 Christos Stathis
        pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
209 b3c9eba8 Christos Stathis
        pathPanel.add(new Label("Link"));
210 b3c9eba8 Christos Stathis
        pathPanel.setSpacing(8);
211 b3c9eba8 Christos Stathis
        pathPanel.addStyleName("pithos-TabPanelBottom");
212 b3c9eba8 Christos Stathis
213 b3c9eba8 Christos Stathis
        path = new TextBox();
214 b3c9eba8 Christos Stathis
        path.setWidth("100%");
215 b3c9eba8 Christos Stathis
        path.addClickHandler(new ClickHandler() {
216 b3c9eba8 Christos Stathis
            @Override
217 b3c9eba8 Christos Stathis
            public void onClick(ClickEvent event) {
218 b3c9eba8 Christos Stathis
                Pithos.enableIESelection();
219 b3c9eba8 Christos Stathis
                ((TextBox) event.getSource()).selectAll();
220 b3c9eba8 Christos Stathis
                Pithos.preventIESelection();
221 b3c9eba8 Christos Stathis
            }
222 b3c9eba8 Christos Stathis
        });
223 b3c9eba8 Christos Stathis
        path.setText(Window.Location.getHost() + file.getPublicUri());
224 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)");
225 b3c9eba8 Christos Stathis
        path.setWidth("100%");
226 b3c9eba8 Christos Stathis
        path.setReadOnly(true);
227 b3c9eba8 Christos Stathis
        pathPanel.add(path);
228 b3c9eba8 Christos Stathis
        permPanel.add(pathPanel);
229 b3c9eba8 Christos Stathis
230 b3c9eba8 Christos Stathis
        Scheduler.get().scheduleDeferred(new Command() {
231 b3c9eba8 Christos Stathis
                        
232 b3c9eba8 Christos Stathis
                        @Override
233 b3c9eba8 Christos Stathis
                        public void execute() {
234 71875b42 Christos Stathis
                                showLinkIfShared();
235 b3c9eba8 Christos Stathis
                        }
236 b3c9eba8 Christos Stathis
                });
237 9326b841 Christos Stathis
        return permPanel;
238 9326b841 Christos Stathis
    }
239 9326b841 Christos Stathis
240 71875b42 Christos Stathis
    void showLinkIfShared() {
241 4d869bf1 Christos Stathis
                if (file.isShared()) {
242 4d869bf1 Christos Stathis
                        UrlBuilder b = Window.Location.createUrlBuilder();
243 cde22209 Christos KK Loverdos
                        b.setPath(app.getApiPath() + file.getOwnerID() + file.getUri());
244 71875b42 Christos Stathis
                        String href = Window.Location.getHref();
245 71875b42 Christos Stathis
                        boolean hasParameters = href.contains("?");
246 71875b42 Christos Stathis
                        path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString());
247 b3c9eba8 Christos Stathis
                pathPanel.setVisible(true);
248 b3c9eba8 Christos Stathis
                }
249 b3c9eba8 Christos Stathis
                else {
250 b3c9eba8 Christos Stathis
                        pathPanel.setVisible(false);
251 b3c9eba8 Christos Stathis
                }
252 b3c9eba8 Christos Stathis
    }
253 9326b841 Christos Stathis
        /**
254 9326b841 Christos Stathis
         * Accepts any change and updates the file
255 9326b841 Christos Stathis
         *
256 9326b841 Christos Stathis
         */
257 9326b841 Christos Stathis
        @Override
258 0099339a Christos Stathis
        protected boolean accept() {
259 cc0120ab Christos KK Loverdos
        updateMetaData(app.getApiPath(), app.getUserID(), file.getUri() + "?update=", permList.getPermissions());
260 0099339a Christos Stathis
        return true;
261 9326b841 Christos Stathis
        }
262 9326b841 Christos Stathis
263 71875b42 Christos Stathis
        protected void updateMetaData(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) {
264 71875b42 Christos Stathis
        if (newPermissions != null) {
265 9326b841 Christos Stathis
            PostRequest updateFile = new PostRequest(api, owner, path) {
266 9326b841 Christos Stathis
                @Override
267 ebead1b5 Christos Stathis
                public void onSuccess(Resource result) {
268 cde22209 Christos KK Loverdos
                        HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) {
269 b3c9eba8 Christos Stathis
270 9326b841 Christos Stathis
                                                @Override
271 b3c9eba8 Christos Stathis
                                                public void onSuccess(File _result) {
272 71875b42 Christos Stathis
                                                        showLinkIfShared();
273 5d18aa82 Christos Stathis
                                                        if (!app.isMySharedSelected())
274 5d18aa82 Christos Stathis
                                            app.updateFolder(file.getParent(), true, new Command() {
275 5d18aa82 Christos Stathis
                                                                        
276 5d18aa82 Christos Stathis
                                                                        @Override
277 5d18aa82 Christos Stathis
                                                                        public void execute() {
278 5d18aa82 Christos Stathis
                                                                                app.updateMySharedRoot();
279 5d18aa82 Christos Stathis
                                                                        }
280 5d18aa82 Christos Stathis
                                                                }, true);
281 5d18aa82 Christos Stathis
                                                        else
282 5d18aa82 Christos Stathis
                                                                app.updateSharedFolder(file.getParent(), true);
283 9326b841 Christos Stathis
                                                }
284 b3c9eba8 Christos Stathis
285 b3c9eba8 Christos Stathis
                                                @Override
286 b3c9eba8 Christos Stathis
                                                public void onError(Throwable t) {
287 b3c9eba8 Christos Stathis
                                    GWT.log("", t);
288 b3c9eba8 Christos Stathis
                                                        app.setError(t);
289 b3c9eba8 Christos Stathis
                                    app.displayError("System error modifying file:" + t.getMessage());
290 b3c9eba8 Christos Stathis
                                                }
291 b3c9eba8 Christos Stathis
292 b3c9eba8 Christos Stathis
                                                @Override
293 b3c9eba8 Christos Stathis
                                                protected void onUnauthorized(Response response) {
294 b3c9eba8 Christos Stathis
                                                        app.sessionExpired();
295 b3c9eba8 Christos Stathis
                                                }
296 b3c9eba8 Christos Stathis
                                        };
297 cc0120ab Christos KK Loverdos
                                        headFile.setHeader("X-Auth-Token", app.getUserToken());
298 b3c9eba8 Christos Stathis
                                        Scheduler.get().scheduleDeferred(headFile);
299 9326b841 Christos Stathis
                }
300 9326b841 Christos Stathis
301 9326b841 Christos Stathis
                @Override
302 9326b841 Christos Stathis
                public void onError(Throwable t) {
303 9326b841 Christos Stathis
                    GWT.log("", t);
304 9326b841 Christos Stathis
                                        app.setError(t);
305 9326b841 Christos Stathis
                    app.displayError("System error modifying file:" + t.getMessage());
306 9326b841 Christos Stathis
                }
307 9326b841 Christos Stathis
308 9326b841 Christos Stathis
                                @Override
309 ebead1b5 Christos Stathis
                                protected void onUnauthorized(Response response) {
310 9326b841 Christos Stathis
                                        app.sessionExpired();
311 9326b841 Christos Stathis
                                }
312 9326b841 Christos Stathis
            };
313 cc0120ab Christos KK Loverdos
            updateFile.setHeader("X-Auth-Token", app.getUserToken());
314 9326b841 Christos Stathis
            
315 71875b42 Christos Stathis
            String readPermHeader = "read=";
316 71875b42 Christos Stathis
            String writePermHeader = "write=";
317 71875b42 Christos Stathis
            for (String u : newPermissions.keySet()) {
318 71875b42 Christos Stathis
                Boolean[] p = newPermissions.get(u);
319 71875b42 Christos Stathis
                if (p[0] != null && p[0])
320 71875b42 Christos Stathis
                    readPermHeader += u + ",";
321 71875b42 Christos Stathis
                if (p[1] != null && p[1])
322 71875b42 Christos Stathis
                    writePermHeader += u + ",";
323 9326b841 Christos Stathis
            }
324 71875b42 Christos Stathis
            if (readPermHeader.endsWith("="))
325 71875b42 Christos Stathis
                readPermHeader = "";
326 71875b42 Christos Stathis
            else if (readPermHeader.endsWith(","))
327 71875b42 Christos Stathis
                readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);
328 71875b42 Christos Stathis
            if (writePermHeader.endsWith("="))
329 71875b42 Christos Stathis
                writePermHeader = "";
330 71875b42 Christos Stathis
            else if (writePermHeader.endsWith(","))
331 71875b42 Christos Stathis
                writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);
332 71875b42 Christos Stathis
            String permHeader = readPermHeader +  ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  ";" : "") + writePermHeader;
333 71875b42 Christos Stathis
            if (permHeader.length() == 0)
334 71875b42 Christos Stathis
                permHeader="~";
335 71875b42 Christos Stathis
            else
336 71875b42 Christos Stathis
                    permHeader = URL.encodePathSegment(permHeader);
337 71875b42 Christos Stathis
            updateFile.setHeader("X-Object-Sharing", permHeader);
338 9326b841 Christos Stathis
            Scheduler.get().scheduleDeferred(updateFile);
339 9326b841 Christos Stathis
        }
340 5d18aa82 Christos Stathis
        else if (!app.isMySharedSelected())
341 9326b841 Christos Stathis
            app.updateFolder(file.getParent(), true, new Command() {
342 9326b841 Christos Stathis
                                
343 9326b841 Christos Stathis
                                @Override
344 9326b841 Christos Stathis
                                public void execute() {
345 71875b42 Christos Stathis
                                        if (file.isSharedOrPublished())
346 9326b841 Christos Stathis
                                                app.updateMySharedRoot();
347 9326b841 Christos Stathis
                                }
348 6acd4df3 Christos Stathis
                        }, true);
349 5d18aa82 Christos Stathis
        else
350 5d18aa82 Christos Stathis
                app.updateSharedFolder(file.getParent(), true);
351 9326b841 Christos Stathis
    }
352 b3c9eba8 Christos Stathis
353 b3c9eba8 Christos Stathis
        @Override
354 b3c9eba8 Christos Stathis
        protected void onPreviewNativeEvent(NativePreviewEvent preview) {
355 b3c9eba8 Christos Stathis
            super.onPreviewNativeEvent(preview);
356 b3c9eba8 Christos Stathis
357 b3c9eba8 Christos Stathis
            NativeEvent evt = preview.getNativeEvent();
358 b3c9eba8 Christos Stathis
            if (evt.getType().equals("keydown") && evt.getKeyCode() == KeyCodes.KEY_ENTER)
359 b3c9eba8 Christos Stathis
                                closeDialog();
360 b3c9eba8 Christos Stathis
        }
361 9326b841 Christos Stathis
}