Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / FolderPropertiesDialog.java @ 5f91f72d

History | View | Annotate | Download (12.3 kB)

1 a57faaf0 Christos Stathis
/*
2 63366925 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 63366925 Christos Stathis
 *
4 63366925 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 63366925 Christos Stathis
 * without modification, are permitted provided that the following
6 63366925 Christos Stathis
 * conditions are met:
7 63366925 Christos Stathis
 *
8 63366925 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 63366925 Christos Stathis
 *      disclaimer.
11 63366925 Christos Stathis
 *
12 63366925 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 63366925 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 63366925 Christos Stathis
 *      provided with the distribution.
16 63366925 Christos Stathis
 *
17 63366925 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 63366925 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 63366925 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 63366925 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 63366925 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 63366925 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 63366925 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 63366925 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 63366925 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 63366925 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 63366925 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 63366925 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 63366925 Christos Stathis
 *
30 63366925 Christos Stathis
 * The views and conclusions contained in the software and
31 63366925 Christos Stathis
 * documentation are those of the authors and should not be
32 63366925 Christos Stathis
 * interpreted as representing official policies, either expressed
33 63366925 Christos Stathis
 * or implied, of GRNET S.A.
34 a57faaf0 Christos Stathis
 */
35 a57faaf0 Christos Stathis
package gr.grnet.pithos.web.client;
36 a57faaf0 Christos Stathis
37 d6be39da Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
38 447407c8 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
39 b651e67f Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Resource;
40 b651e67f Christos Stathis
import gr.grnet.pithos.web.client.rest.PutRequest;
41 a57faaf0 Christos Stathis
import gr.grnet.pithos.web.client.rest.RestException;
42 a57faaf0 Christos Stathis
43 6b7d024f Christos Stathis
import java.util.Iterator;
44 6b7d024f Christos Stathis
45 a57faaf0 Christos Stathis
import com.google.gwt.core.client.GWT;
46 6b7d024f Christos Stathis
import com.google.gwt.core.client.Scheduler;
47 a57faaf0 Christos Stathis
import com.google.gwt.dom.client.NativeEvent;
48 903f3402 Christos Stathis
import com.google.gwt.event.dom.client.ChangeEvent;
49 903f3402 Christos Stathis
import com.google.gwt.event.dom.client.ChangeHandler;
50 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickEvent;
51 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickHandler;
52 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.KeyCodes;
53 6b7d024f Christos Stathis
import com.google.gwt.event.dom.client.KeyDownEvent;
54 f1b24b82 Christos Stathis
import com.google.gwt.http.client.Response;
55 a57faaf0 Christos Stathis
import com.google.gwt.i18n.client.DateTimeFormat;
56 6b7d024f Christos Stathis
import com.google.gwt.user.client.Command;
57 a57faaf0 Christos Stathis
import com.google.gwt.user.client.Event.NativePreviewEvent;
58 4420a247 Christos Stathis
import com.google.gwt.user.client.ui.Anchor;
59 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.Button;
60 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.DialogBox;
61 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.FlexTable;
62 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
63 903f3402 Christos Stathis
import com.google.gwt.user.client.ui.Label;
64 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.TextBox;
65 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.VerticalPanel;
66 a57faaf0 Christos Stathis
67 a57faaf0 Christos Stathis
/**
68 a57faaf0 Christos Stathis
 * The 'Folder properties' dialog box implementation.
69 a57faaf0 Christos Stathis
 */
70 a57faaf0 Christos Stathis
public class FolderPropertiesDialog extends DialogBox {
71 a57faaf0 Christos Stathis
72 7811b9d1 Christos Stathis
    protected Pithos app;
73 b651e67f Christos Stathis
74 a57faaf0 Christos Stathis
        /**
75 a57faaf0 Christos Stathis
         * The widget that holds the folderName of the folder.
76 a57faaf0 Christos Stathis
         */
77 903f3402 Christos Stathis
        TextBox folderName = new TextBox();
78 a57faaf0 Christos Stathis
79 a57faaf0 Christos Stathis
        /**
80 a57faaf0 Christos Stathis
         * A flag that denotes whether the dialog will be used to create or modify a
81 a57faaf0 Christos Stathis
         * folder.
82 a57faaf0 Christos Stathis
         */
83 a57faaf0 Christos Stathis
        private final boolean create;
84 a57faaf0 Christos Stathis
85 447407c8 Christos Stathis
        final Folder folder;
86 a57faaf0 Christos Stathis
87 6b7d024f Christos Stathis
        final VerticalPanel inner;
88 a57faaf0 Christos Stathis
89 a57faaf0 Christos Stathis
        /**
90 a57faaf0 Christos Stathis
         * The widget's constructor.
91 a57faaf0 Christos Stathis
         */
92 ecf95c9e Christos Stathis
        public FolderPropertiesDialog(final Pithos app, boolean _create,  Folder selected) {
93 b651e67f Christos Stathis
        this.app = app;
94 4420a247 Christos Stathis
                Anchor close = new Anchor();
95 4420a247 Christos Stathis
                close.addStyleName("close");
96 4420a247 Christos Stathis
                close.addClickHandler(new ClickHandler() {
97 4420a247 Christos Stathis
                        
98 4420a247 Christos Stathis
                        @Override
99 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
100 4420a247 Christos Stathis
                                hide();
101 4420a247 Christos Stathis
                        }
102 4420a247 Christos Stathis
                });
103 4420a247 Christos Stathis
104 a57faaf0 Christos Stathis
                setAnimationEnabled(true);
105 4420a247 Christos Stathis
                setGlassEnabled(true);
106 4420a247 Christos Stathis
                setStyleName("pithos-DialogBox");
107 a57faaf0 Christos Stathis
108 a57faaf0 Christos Stathis
                // Enable IE selection for the dialog (must disable it upon closing it)
109 7811b9d1 Christos Stathis
                Pithos.enableIESelection();
110 a57faaf0 Christos Stathis
111 a57faaf0 Christos Stathis
                create = _create;
112 a57faaf0 Christos Stathis
                
113 447407c8 Christos Stathis
                folder = selected;
114 a57faaf0 Christos Stathis
115 a57faaf0 Christos Stathis
                // Use this opportunity to set the dialog's caption.
116 a57faaf0 Christos Stathis
                if (create)
117 a57faaf0 Christos Stathis
                        setText("Create folder");
118 a57faaf0 Christos Stathis
                else
119 a57faaf0 Christos Stathis
                        setText("Folder properties");
120 a57faaf0 Christos Stathis
121 a57faaf0 Christos Stathis
                // Outer contains inner and buttons
122 a57faaf0 Christos Stathis
                VerticalPanel outer = new VerticalPanel();
123 4420a247 Christos Stathis
                outer.add(close);
124 a57faaf0 Christos Stathis
                // Inner contains generalPanel and permPanel
125 6b7d024f Christos Stathis
                inner = new VerticalPanel();
126 4420a247 Christos Stathis
                inner.addStyleName("inner");
127 ecf95c9e Christos Stathis
128 a57faaf0 Christos Stathis
                VerticalPanel generalPanel = new VerticalPanel();
129 ecf95c9e Christos Stathis
        FlexTable generalTable = new FlexTable();
130 ecf95c9e Christos Stathis
        generalTable.setText(0, 0, "Name");
131 ecf95c9e Christos Stathis
        generalTable.setText(1, 0, "Parent");
132 ecf95c9e Christos Stathis
        generalTable.setText(2, 0, "Creator");
133 ecf95c9e Christos Stathis
        generalTable.setText(3, 0, "Last modified");
134 903f3402 Christos Stathis
135 903f3402 Christos Stathis
                folderName.setText(create ? "" : folder.getName());
136 4fe76337 Christos Stathis
        folderName.setReadOnly(folder.isContainer() && !create);
137 ecf95c9e Christos Stathis
        generalTable.setWidget(0, 1, folderName);
138 ecf95c9e Christos Stathis
139 903f3402 Christos Stathis
        final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true);
140 903f3402 Christos Stathis
                folderNameNote.setVisible(false);
141 903f3402 Christos Stathis
                folderNameNote.setStylePrimaryName("gss-readForAllNote");
142 903f3402 Christos Stathis
                generalTable.setWidget(0, 2, folderNameNote);
143 903f3402 Christos Stathis
                
144 ecf95c9e Christos Stathis
        if (create)
145 ecf95c9e Christos Stathis
            generalTable.setText(1, 1, folder.getName());
146 ecf95c9e Christos Stathis
        else
147 ecf95c9e Christos Stathis
            generalTable.setText(1, 1, folder.getPrefix());
148 ecf95c9e Christos Stathis
        generalTable.setText(2, 1, "");
149 ecf95c9e Christos Stathis
        DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
150 ecf95c9e Christos Stathis
        if(folder.getLastModified() != null)
151 ecf95c9e Christos Stathis
            generalTable.setText(3, 1, formatter.format(folder.getLastModified()));
152 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
153 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
154 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");
155 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels");
156 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");
157 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");
158 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");
159 ecf95c9e Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values");
160 ecf95c9e Christos Stathis
        generalTable.setCellSpacing(4);
161 ecf95c9e Christos Stathis
        generalPanel.add(generalTable);
162 6b7d024f Christos Stathis
        inner.add(generalPanel);
163 ecf95c9e Christos Stathis
164 ecf95c9e Christos Stathis
        outer.add(inner);
165 ecf95c9e Christos Stathis
166 a57faaf0 Christos Stathis
                // Create the 'Create/Update' button, along with a listener that hides the dialog
167 a57faaf0 Christos Stathis
                // when the button is clicked and quits the application.
168 a57faaf0 Christos Stathis
                String okLabel;
169 a57faaf0 Christos Stathis
                if (create)
170 a57faaf0 Christos Stathis
                        okLabel = "Create";
171 a57faaf0 Christos Stathis
                else
172 a57faaf0 Christos Stathis
                        okLabel = "Update";
173 903f3402 Christos Stathis
                final Button ok = new Button(okLabel, new ClickHandler() {
174 a57faaf0 Christos Stathis
                        @Override
175 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
176 447407c8 Christos Stathis
                                createOrUpdateFolder();
177 447407c8 Christos Stathis
                                closeDialog();
178 a57faaf0 Christos Stathis
                        }
179 a57faaf0 Christos Stathis
                });
180 4420a247 Christos Stathis
                ok.addStyleName("button");
181 4420a247 Christos Stathis
                outer.add(ok);
182 4420a247 Christos Stathis
        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
183 a57faaf0 Christos Stathis
184 903f3402 Christos Stathis
        folderName.addChangeHandler(new ChangeHandler() {
185 903f3402 Christos Stathis
                        
186 903f3402 Christos Stathis
                        @Override
187 ebead1b5 Christos Stathis
                        public void onChange(ChangeEvent event) {
188 903f3402 Christos Stathis
                                if(folderName.getText().contains("/")) {
189 903f3402 Christos Stathis
                                        folderNameNote.setVisible(true);
190 903f3402 Christos Stathis
                                        ok.setEnabled(false);
191 903f3402 Christos Stathis
                                }
192 903f3402 Christos Stathis
                                else {
193 903f3402 Christos Stathis
                                        folderNameNote.setVisible(false);
194 903f3402 Christos Stathis
                                        ok.setEnabled(true);
195 903f3402 Christos Stathis
                                }
196 903f3402 Christos Stathis
                        }
197 903f3402 Christos Stathis
                });
198 903f3402 Christos Stathis
199 ecf95c9e Christos Stathis
        setWidget(outer);
200 a57faaf0 Christos Stathis
        }
201 a57faaf0 Christos Stathis
202 a57faaf0 Christos Stathis
        @Override
203 a57faaf0 Christos Stathis
        public void center() {
204 a57faaf0 Christos Stathis
                super.center();
205 a57faaf0 Christos Stathis
                folderName.setFocus(true);
206 a57faaf0 Christos Stathis
        }
207 a57faaf0 Christos Stathis
208 a57faaf0 Christos Stathis
        @Override
209 a57faaf0 Christos Stathis
        protected void onPreviewNativeEvent(NativePreviewEvent preview) {
210 a57faaf0 Christos Stathis
                super.onPreviewNativeEvent(preview);
211 a57faaf0 Christos Stathis
212 a57faaf0 Christos Stathis
                NativeEvent evt = preview.getNativeEvent();
213 447407c8 Christos Stathis
                if (evt.getType().equals(KeyDownEvent.getType().getName()))
214 a57faaf0 Christos Stathis
                        // Use the popup's key preview hooks to close the dialog when either
215 a57faaf0 Christos Stathis
                        // enter or escape is pressed.
216 a57faaf0 Christos Stathis
                        switch (evt.getKeyCode()) {
217 a57faaf0 Christos Stathis
                                case KeyCodes.KEY_ENTER:
218 a57faaf0 Christos Stathis
                                        createOrUpdateFolder();
219 ecf95c9e Christos Stathis
                    closeDialog();
220 a57faaf0 Christos Stathis
                                        break;
221 a57faaf0 Christos Stathis
                                case KeyCodes.KEY_ESCAPE:
222 a57faaf0 Christos Stathis
                                        closeDialog();
223 a57faaf0 Christos Stathis
                                        break;
224 a57faaf0 Christos Stathis
                        }
225 a57faaf0 Christos Stathis
        }
226 a57faaf0 Christos Stathis
227 a57faaf0 Christos Stathis
228 a57faaf0 Christos Stathis
        /**
229 a57faaf0 Christos Stathis
         * Enables IE selection prevention and hides the dialog
230 a57faaf0 Christos Stathis
         * (we disable the prevention on creation of the dialog)
231 a57faaf0 Christos Stathis
         */
232 a57faaf0 Christos Stathis
        public void closeDialog() {
233 7811b9d1 Christos Stathis
                Pithos.preventIESelection();
234 a57faaf0 Christos Stathis
                hide();
235 a57faaf0 Christos Stathis
        }
236 a57faaf0 Christos Stathis
237 a57faaf0 Christos Stathis
        /**
238 a57faaf0 Christos Stathis
         * Generate an RPC request to create a new folder.
239 a57faaf0 Christos Stathis
         */
240 a57faaf0 Christos Stathis
        private void createFolder() {
241 903f3402 Christos Stathis
                String name = folderName.getText().trim();
242 b51c628b Christos Stathis
        String path = folder.getUri() + "/" + name;
243 63ee965c Christos Stathis
        PutRequest createFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path) {
244 b651e67f Christos Stathis
            @Override
245 ebead1b5 Christos Stathis
            public void onSuccess(Resource result) {
246 64f42c0b Christos Stathis
                app.updateFolder(folder, true, new Command() {
247 64f42c0b Christos Stathis
                                        
248 64f42c0b Christos Stathis
                                        @Override
249 64f42c0b Christos Stathis
                                        public void execute() {
250 64f42c0b Christos Stathis
                                                app.updateStatistics();
251 64f42c0b Christos Stathis
                                        }
252 64f42c0b Christos Stathis
                                });
253 b651e67f Christos Stathis
            }
254 b651e67f Christos Stathis
255 b651e67f Christos Stathis
            @Override
256 b651e67f Christos Stathis
            public void onError(Throwable t) {
257 b651e67f Christos Stathis
                                GWT.log("", t);
258 3f8622d4 Christos Stathis
                                app.setError(t);
259 b651e67f Christos Stathis
                                if (t instanceof RestException) {
260 b651e67f Christos Stathis
                                        app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());
261 b651e67f Christos Stathis
                                }
262 b651e67f Christos Stathis
                                else
263 b651e67f Christos Stathis
                                        app.displayError("System error creating folder:" + t.getMessage());
264 b651e67f Christos Stathis
            }
265 9539e23d Christos Stathis
266 9539e23d Christos Stathis
                        @Override
267 ebead1b5 Christos Stathis
                        protected void onUnauthorized(Response response) {
268 9539e23d Christos Stathis
                                app.sessionExpired();
269 9539e23d Christos Stathis
                        }
270 9539e23d Christos Stathis
       };
271 f1aabd89 Christos Stathis
        createFolder.setHeader("X-Auth-Token", app.getToken());
272 b651e67f Christos Stathis
        createFolder.setHeader("Accept", "*/*");
273 b651e67f Christos Stathis
        createFolder.setHeader("Content-Length", "0");
274 b3fd800b Christos Stathis
        createFolder.setHeader("Content-Type", "application/directory");
275 b651e67f Christos Stathis
        Scheduler.get().scheduleDeferred(createFolder);
276 a57faaf0 Christos Stathis
        }
277 a57faaf0 Christos Stathis
278 a57faaf0 Christos Stathis
        /**
279 a57faaf0 Christos Stathis
         * Upon closing the dialog by clicking OK or pressing ENTER this method does
280 a57faaf0 Christos Stathis
         * the actual work of modifying folder properties or creating a new Folder
281 a57faaf0 Christos Stathis
         * depending on the value of the create field
282 a57faaf0 Christos Stathis
         */
283 7811b9d1 Christos Stathis
        protected void createOrUpdateFolder() {
284 a57faaf0 Christos Stathis
                if (create)
285 a57faaf0 Christos Stathis
                        createFolder();
286 a57faaf0 Christos Stathis
                else
287 a57faaf0 Christos Stathis
                        updateFolder();
288 a57faaf0 Christos Stathis
289 a57faaf0 Christos Stathis
        }
290 a57faaf0 Christos Stathis
291 a57faaf0 Christos Stathis
        private void updateFolder() {
292 5ebc9312 Christos Stathis
        final String newName = folderName.getText().trim();
293 d6be39da Christos Stathis
        if (!folder.isContainer() && !folder.getName().equals(newName)) {
294 b51c628b Christos Stathis
            final String path = folder.getParent().getUri() + "/" + newName;
295 63ee965c Christos Stathis
            PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getParent().getOwner(), path) {
296 d6be39da Christos Stathis
                @Override
297 ebead1b5 Christos Stathis
                public void onSuccess(Resource result) {
298 d6be39da Christos Stathis
                    Iterator<File> iter = folder.getFiles().iterator();
299 63ee965c Christos Stathis
                    app.copyFiles(iter, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {
300 d6be39da Christos Stathis
                        @Override
301 d6be39da Christos Stathis
                        public void execute() {
302 d6be39da Christos Stathis
                            Iterator<Folder> iterf = folder.getSubfolders().iterator();
303 63ee965c Christos Stathis
                            app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() {
304 d6be39da Christos Stathis
                                @Override
305 d6be39da Christos Stathis
                                public void execute() {
306 d6be39da Christos Stathis
                                    app.deleteFolder(folder);
307 6b7d024f Christos Stathis
                                    app.updateFolder(folder.getParent(), false, new Command() {
308 6b7d024f Christos Stathis
                                                    
309 6b7d024f Christos Stathis
                                                    @Override
310 6b7d024f Christos Stathis
                                                    public void execute() {
311 6b7d024f Christos Stathis
                                                            app.updateMySharedRoot();
312 6b7d024f Christos Stathis
                                                    }
313 6b7d024f Christos Stathis
                                            });
314 d6be39da Christos Stathis
                                }
315 d6be39da Christos Stathis
                            });
316 d6be39da Christos Stathis
                        }
317 d6be39da Christos Stathis
                    });
318 d6be39da Christos Stathis
                }
319 d6be39da Christos Stathis
320 d6be39da Christos Stathis
                @Override
321 d6be39da Christos Stathis
                public void onError(Throwable t) {
322 d6be39da Christos Stathis
                    GWT.log("", t);
323 3f8622d4 Christos Stathis
                                        app.setError(t);
324 d6be39da Christos Stathis
                    if(t instanceof RestException){
325 d6be39da Christos Stathis
                        app.displayError("Unable to update folder: " + ((RestException) t).getHttpStatusText());
326 d6be39da Christos Stathis
                    }
327 d6be39da Christos Stathis
                    else
328 d6be39da Christos Stathis
                        app.displayError("System error modifying folder: " + t.getMessage());
329 d6be39da Christos Stathis
                }
330 9539e23d Christos Stathis
331 9539e23d Christos Stathis
                                @Override
332 ebead1b5 Christos Stathis
                                protected void onUnauthorized(Response response) {
333 9539e23d Christos Stathis
                                        app.sessionExpired();
334 9539e23d Christos Stathis
                                }
335 d6be39da Christos Stathis
            };
336 d6be39da Christos Stathis
            newFolder.setHeader("X-Auth-Token", app.getToken());
337 d6be39da Christos Stathis
            newFolder.setHeader("Content-Type", "application/folder");
338 d6be39da Christos Stathis
            newFolder.setHeader("Accept", "*/*");
339 d6be39da Christos Stathis
            newFolder.setHeader("Content-Length", "0");
340 d6be39da Christos Stathis
            Scheduler.get().scheduleDeferred(newFolder);
341 d6be39da Christos Stathis
        }
342 5ebc9312 Christos Stathis
        else
343 8fd8a487 Christos Stathis
            app.updateFolder(folder.getParent(), false, new Command() {
344 6b7d024f Christos Stathis
                            
345 6b7d024f Christos Stathis
                            @Override
346 6b7d024f Christos Stathis
                            public void execute() {
347 6b7d024f Christos Stathis
                                    app.updateMySharedRoot();
348 6b7d024f Christos Stathis
                            }
349 6b7d024f Christos Stathis
                    });
350 a57faaf0 Christos Stathis
        }
351 a57faaf0 Christos Stathis
}