Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / mysharedtree / MysharedTreeViewModel.java @ 33d37f22

History | View | Annotate | Download (13.1 kB)

1 105b4e49 Christos Stathis
/*
2 cae2a8db Christos Stathis
 * Copyright 2011-2012 GRNET S.A. All rights reserved.
3 105b4e49 Christos Stathis
 *
4 105b4e49 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 105b4e49 Christos Stathis
 * without modification, are permitted provided that the following
6 105b4e49 Christos Stathis
 * conditions are met:
7 105b4e49 Christos Stathis
 *
8 105b4e49 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 105b4e49 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 105b4e49 Christos Stathis
 *      disclaimer.
11 105b4e49 Christos Stathis
 *
12 105b4e49 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 105b4e49 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 105b4e49 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 105b4e49 Christos Stathis
 *      provided with the distribution.
16 105b4e49 Christos Stathis
 *
17 105b4e49 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 105b4e49 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 105b4e49 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 105b4e49 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 105b4e49 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 105b4e49 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 105b4e49 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 105b4e49 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 105b4e49 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 105b4e49 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 105b4e49 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 105b4e49 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 105b4e49 Christos Stathis
 *
30 105b4e49 Christos Stathis
 * The views and conclusions contained in the software and
31 105b4e49 Christos Stathis
 * documentation are those of the authors and should not be
32 105b4e49 Christos Stathis
 * interpreted as representing official policies, either expressed
33 105b4e49 Christos Stathis
 * or implied, of GRNET S.A.
34 105b4e49 Christos Stathis
 */
35 105b4e49 Christos Stathis
36 105b4e49 Christos Stathis
package gr.grnet.pithos.web.client.mysharedtree;
37 105b4e49 Christos Stathis
38 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.FolderContextMenu;
39 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.Pithos;
40 ff06bcd5 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
41 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
42 a2f617f8 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.FolderTreeView;
43 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.mysharedtree.MysharedTreeView.Templates;
44 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.rest.GetRequest;
45 105b4e49 Christos Stathis
import gr.grnet.pithos.web.client.rest.RestException;
46 105b4e49 Christos Stathis
47 0ec61115 Christos Stathis
import java.util.ArrayList;
48 105b4e49 Christos Stathis
import java.util.HashMap;
49 ff06bcd5 Christos Stathis
import java.util.HashSet;
50 105b4e49 Christos Stathis
import java.util.Iterator;
51 105b4e49 Christos Stathis
import java.util.List;
52 105b4e49 Christos Stathis
import java.util.Map;
53 ff06bcd5 Christos Stathis
import java.util.Set;
54 105b4e49 Christos Stathis
55 105b4e49 Christos Stathis
import com.google.gwt.cell.client.AbstractCell;
56 105b4e49 Christos Stathis
import com.google.gwt.cell.client.Cell;
57 105b4e49 Christos Stathis
import com.google.gwt.cell.client.TextCell;
58 105b4e49 Christos Stathis
import com.google.gwt.cell.client.ValueUpdater;
59 105b4e49 Christos Stathis
import com.google.gwt.core.client.GWT;
60 105b4e49 Christos Stathis
import com.google.gwt.core.client.Scheduler;
61 105b4e49 Christos Stathis
import com.google.gwt.event.dom.client.ContextMenuEvent;
62 9539e23d Christos Stathis
import com.google.gwt.http.client.Response;
63 f5023f13 Christos Stathis
import com.google.gwt.http.client.URL;
64 105b4e49 Christos Stathis
import com.google.gwt.safehtml.shared.SafeHtml;
65 105b4e49 Christos Stathis
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
66 105b4e49 Christos Stathis
import com.google.gwt.text.shared.SafeHtmlRenderer;
67 105b4e49 Christos Stathis
import com.google.gwt.user.client.Command;
68 105b4e49 Christos Stathis
import com.google.gwt.user.client.ui.AbstractImagePrototype;
69 105b4e49 Christos Stathis
import com.google.gwt.view.client.ListDataProvider;
70 105b4e49 Christos Stathis
import com.google.gwt.view.client.SelectionChangeEvent;
71 105b4e49 Christos Stathis
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
72 105b4e49 Christos Stathis
import com.google.gwt.view.client.SingleSelectionModel;
73 105b4e49 Christos Stathis
import com.google.gwt.view.client.TreeViewModel;
74 105b4e49 Christos Stathis
75 105b4e49 Christos Stathis
public class MysharedTreeViewModel implements TreeViewModel {
76 105b4e49 Christos Stathis
77 105b4e49 Christos Stathis
    protected Pithos app;
78 105b4e49 Christos Stathis
79 f1b24b82 Christos Stathis
    private Cell<Folder> folderCell = new AbstractCell<Folder>() {
80 105b4e49 Christos Stathis
81 105b4e49 Christos Stathis
       @Override
82 ebead1b5 Christos Stathis
        public void render(Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) {
83 105b4e49 Christos Stathis
            String html = AbstractImagePrototype.create(MysharedTreeView.images.folderYellow()).getHTML();
84 a7b6e464 Christos Stathis
            safeHtmlBuilder.appendHtmlConstant(html).appendHtmlConstant("&nbsp;");
85 105b4e49 Christos Stathis
            safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName()));
86 105b4e49 Christos Stathis
        }
87 105b4e49 Christos Stathis
88 105b4e49 Christos Stathis
        @Override
89 a2f617f8 Christos Stathis
        public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element parent, final Folder folder, com.google.gwt.dom.client.NativeEvent event, ValueUpdater<Folder> valueUpdater) {
90 105b4e49 Christos Stathis
            if (event.getType().equals(ContextMenuEvent.getType().getName())) {
91 a2f617f8 Christos Stathis
                    final int x = event.getClientX();
92 a2f617f8 Christos Stathis
                    final int y = event.getClientY();
93 105b4e49 Christos Stathis
                MysharedTreeViewModel.this.selectionModel.setSelected(folder, true);
94 a2f617f8 Christos Stathis
                app.scheduleFolderHeadCommand(folder, new Command() {
95 a2f617f8 Christos Stathis
                                        
96 a2f617f8 Christos Stathis
                                        @Override
97 a2f617f8 Christos Stathis
                                        public void execute() {
98 a2f617f8 Christos Stathis
                                FolderContextMenu menu = new FolderContextMenu(app, MysharedTreeView.images, app.getSelectedTree(), folder);
99 a2f617f8 Christos Stathis
                                menu.setPopupPosition(x, y);
100 a2f617f8 Christos Stathis
                                menu.show();
101 a2f617f8 Christos Stathis
                                        }
102 a2f617f8 Christos Stathis
                                });
103 105b4e49 Christos Stathis
            }
104 105b4e49 Christos Stathis
        }
105 105b4e49 Christos Stathis
    };
106 105b4e49 Christos Stathis
107 cf49bbc9 Christos Stathis
    protected ListDataProvider<Folder> firstLevelDataProvider = new ListDataProvider<Folder>();
108 105b4e49 Christos Stathis
109 cf49bbc9 Christos Stathis
    private Map<Folder, ListDataProvider<Folder>> dataProviderMap = new HashMap<Folder, ListDataProvider<Folder>>();
110 ff06bcd5 Christos Stathis
    
111 ff06bcd5 Christos Stathis
    protected Set<File> sharedFiles = new HashSet<File>();
112 105b4e49 Christos Stathis
113 220831bd Christos Stathis
    protected SingleSelectionModel<Folder> selectionModel;
114 105b4e49 Christos Stathis
115 105b4e49 Christos Stathis
    public MysharedTreeViewModel(Pithos _app, SingleSelectionModel<Folder> selectionModel) {
116 105b4e49 Christos Stathis
        app = _app;
117 105b4e49 Christos Stathis
        this.selectionModel = selectionModel;
118 105b4e49 Christos Stathis
    }
119 105b4e49 Christos Stathis
120 105b4e49 Christos Stathis
    @Override
121 105b4e49 Christos Stathis
    public <T> NodeInfo<?> getNodeInfo(T value) {
122 105b4e49 Christos Stathis
        if (value == null) {
123 ff06bcd5 Christos Stathis
            ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
124 c9ccc229 Christos Stathis
            rootDataProvider.getList().add("Shared by me");
125 105b4e49 Christos Stathis
            final SingleSelectionModel<String> selectionModel2 = new SingleSelectionModel<String>();
126 105b4e49 Christos Stathis
            selectionModel2.addSelectionChangeHandler(new Handler() {
127 105b4e49 Christos Stathis
128 105b4e49 Christos Stathis
                @Override
129 ebead1b5 Christos Stathis
                public void onSelectionChange(SelectionChangeEvent event) {
130 105b4e49 Christos Stathis
                    if (selectionModel2.getSelectedObject() != null) {
131 f1b24b82 Christos Stathis
                            app.deselectOthers(app.getMySharedTreeView(), selectionModel2);
132 3ebb88f4 Christos Stathis
                            app.applyPermissions(null);
133 3601b114 Christos Stathis
                            fetchSharedFiles(true);
134 80a65a5f Christos Stathis
                                            app.showRelevantToolbarButtons();
135 105b4e49 Christos Stathis
                    }
136 80a65a5f Christos Stathis
                                    else {
137 33d37f22 Christos Stathis
                                            if (app.getSelectedTree().equals(app.getMySharedTreeView()) && app.getMySharedTreeView().getSelection() == null)
138 80a65a5f Christos Stathis
                                                    app.setSelectedTree(null);
139 80a65a5f Christos Stathis
                                            if (app.getSelectedTree() == null)
140 80a65a5f Christos Stathis
                                                    app.showRelevantToolbarButtons();
141 80a65a5f Christos Stathis
                                    }
142 105b4e49 Christos Stathis
                }
143 105b4e49 Christos Stathis
            });
144 105b4e49 Christos Stathis
            app.addSelectionModel(selectionModel2);
145 105b4e49 Christos Stathis
            return new DefaultNodeInfo<String>(rootDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
146 105b4e49 Christos Stathis
                @Override
147 105b4e49 Christos Stathis
                public SafeHtml render(String object) {
148 105b4e49 Christos Stathis
                    SafeHtmlBuilder builder = new SafeHtmlBuilder();
149 105b4e49 Christos Stathis
                    render(object, builder);
150 105b4e49 Christos Stathis
                    return builder.toSafeHtml();
151 105b4e49 Christos Stathis
                }
152 105b4e49 Christos Stathis
153 105b4e49 Christos Stathis
                @Override
154 105b4e49 Christos Stathis
                public void render(String object, SafeHtmlBuilder builder) {
155 105b4e49 Christos Stathis
                    String html = AbstractImagePrototype.create(MysharedTreeView.images.myShared()).getHTML();
156 a7b6e464 Christos Stathis
                    builder.appendHtmlConstant(html).appendHtmlConstant("&nbsp;");
157 105b4e49 Christos Stathis
                    builder.append(MysharedTreeView.Templates.INSTANCE.nameSpan(object));
158 105b4e49 Christos Stathis
                }
159 105b4e49 Christos Stathis
            }),  selectionModel2, null);
160 105b4e49 Christos Stathis
        }
161 105b4e49 Christos Stathis
        else if (value instanceof String) {
162 cf49bbc9 Christos Stathis
                fetchSharedContainers(null);
163 105b4e49 Christos Stathis
            return new DefaultNodeInfo<Folder>(firstLevelDataProvider, folderCell, selectionModel, null);
164 105b4e49 Christos Stathis
        }
165 105b4e49 Christos Stathis
        else {
166 105b4e49 Christos Stathis
            final Folder f = (Folder) value;
167 105b4e49 Christos Stathis
            if (dataProviderMap.get(f) == null) {
168 cf49bbc9 Christos Stathis
                dataProviderMap.put(f, new ListDataProvider<Folder>());
169 105b4e49 Christos Stathis
            }
170 cf49bbc9 Christos Stathis
            final ListDataProvider<Folder> dataProvider = dataProviderMap.get(f);
171 cf49bbc9 Christos Stathis
            fetchFolder(f, dataProvider, false);
172 105b4e49 Christos Stathis
            return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
173 105b4e49 Christos Stathis
        }
174 105b4e49 Christos Stathis
    }
175 105b4e49 Christos Stathis
176 3601b114 Christos Stathis
        protected void fetchSharedFiles(final boolean showFiles) {
177 3601b114 Christos Stathis
                sharedFiles.clear();
178 ff06bcd5 Christos Stathis
            final List<Folder> containers = app.getAccount().getContainers();
179 cf49bbc9 Christos Stathis
            final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
180 ff06bcd5 Christos Stathis
            Iterator<Folder> iter = containers.iterator();
181 ff06bcd5 Christos Stathis
            fetchFolder(iter, tempProvider, new Command() {
182 ff06bcd5 Christos Stathis
                        
183 ff06bcd5 Christos Stathis
                        @Override
184 ff06bcd5 Christos Stathis
                        public void execute() {
185 cf49bbc9 Christos Stathis
                                firstLevelDataProvider.getList().clear();
186 cf49bbc9 Christos Stathis
                                firstLevelDataProvider.getList().addAll(tempProvider.getList());
187 3601b114 Christos Stathis
                                if (showFiles)
188 3601b114 Christos Stathis
                                        app.showFiles(sharedFiles);
189 ff06bcd5 Christos Stathis
                        }
190 ff06bcd5 Christos Stathis
                });
191 ff06bcd5 Christos Stathis
        }
192 105b4e49 Christos Stathis
193 7c54d867 Christos Stathis
        private void fetchSharedContainers(final Command callback) {
194 ff06bcd5 Christos Stathis
            final List<Folder> containers = app.getAccount().getContainers();
195 cf49bbc9 Christos Stathis
            final ListDataProvider<Folder> tempProvider = new ListDataProvider<Folder>();
196 0ec61115 Christos Stathis
            Iterator<Folder> iter = containers.listIterator();
197 ff06bcd5 Christos Stathis
            fetchFolder(iter, tempProvider, new Command() {
198 ff06bcd5 Christos Stathis
                        
199 ff06bcd5 Christos Stathis
                        @Override
200 ff06bcd5 Christos Stathis
                        public void execute() {
201 cf49bbc9 Christos Stathis
                                firstLevelDataProvider.getList().clear();
202 cf49bbc9 Christos Stathis
                                firstLevelDataProvider.getList().addAll(tempProvider.getList());
203 7c54d867 Christos Stathis
                                if (callback != null)
204 7c54d867 Christos Stathis
                                        callback.execute();
205 ff06bcd5 Christos Stathis
                        }
206 ff06bcd5 Christos Stathis
                });
207 105b4e49 Christos Stathis
        }
208 105b4e49 Christos Stathis
209 105b4e49 Christos Stathis
        @Override
210 105b4e49 Christos Stathis
    public boolean isLeaf(Object o) {
211 7c54d867 Christos Stathis
                if (o == null)
212 7c54d867 Christos Stathis
                        return false;
213 7c54d867 Christos Stathis
                else if (o instanceof Folder) {
214 105b4e49 Christos Stathis
            Folder f = (Folder) o;
215 105b4e49 Christos Stathis
            return f.getSubfolders().isEmpty();
216 105b4e49 Christos Stathis
        }
217 7c54d867 Christos Stathis
                else {
218 cf49bbc9 Christos Stathis
                        return firstLevelDataProvider.getList().isEmpty();
219 7c54d867 Christos Stathis
                }
220 105b4e49 Christos Stathis
    }
221 0ec61115 Christos Stathis
        
222 0ec61115 Christos Stathis
        private native void log(String msg) /*-{
223 0ec61115 Christos Stathis
                $wnd.console.log(msg);
224 0ec61115 Christos Stathis
        }-*/;
225 105b4e49 Christos Stathis
226 cf49bbc9 Christos Stathis
    protected void fetchFolder(final Iterator<Folder> iter, final ListDataProvider<Folder> dataProvider, final Command callback) {
227 105b4e49 Christos Stathis
        if (iter.hasNext()) {
228 105b4e49 Christos Stathis
            final Folder f = iter.next();
229 105b4e49 Christos Stathis
230 f5023f13 Christos Stathis
            String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
231 63ee965c Christos Stathis
            GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
232 105b4e49 Christos Stathis
                @Override
233 7811b9d1 Christos Stathis
                public void onSuccess(Folder _result) {
234 7811b9d1 Christos Stathis
                        if (!_result.isShared()) {
235 7811b9d1 Christos Stathis
                                for (File file : _result.getFiles()) {
236 ff06bcd5 Christos Stathis
                                        if (file.isShared())
237 ff06bcd5 Christos Stathis
                                                sharedFiles.add(file);
238 ff06bcd5 Christos Stathis
                                }
239 0ec61115 Christos Stathis
                                Iterator<Folder> iter2 = new ArrayList<Folder>(result.getSubfolders()).listIterator();
240 ff06bcd5 Christos Stathis
                                fetchFolder(iter2, dataProvider, new Command() {
241 ff06bcd5 Christos Stathis
                                                        
242 ff06bcd5 Christos Stathis
                                                        @Override
243 ff06bcd5 Christos Stathis
                                                        public void execute() {
244 ff06bcd5 Christos Stathis
                                            fetchFolder(iter, dataProvider, callback);
245 ff06bcd5 Christos Stathis
                                                        }
246 ff06bcd5 Christos Stathis
                                                });
247 ff06bcd5 Christos Stathis
                        }
248 ff06bcd5 Christos Stathis
                        else {
249 cf49bbc9 Christos Stathis
                                dataProvider.getList().add(_result);
250 ff06bcd5 Christos Stathis
                            fetchFolder(iter, dataProvider, callback);
251 ff06bcd5 Christos Stathis
                        }
252 105b4e49 Christos Stathis
                }
253 105b4e49 Christos Stathis
254 105b4e49 Christos Stathis
                @Override
255 105b4e49 Christos Stathis
                public void onError(Throwable t) {
256 105b4e49 Christos Stathis
                    GWT.log("Error getting folder", t);
257 3f8622d4 Christos Stathis
                                        app.setError(t);
258 105b4e49 Christos Stathis
                    if (t instanceof RestException)
259 105b4e49 Christos Stathis
                        app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
260 105b4e49 Christos Stathis
                    else
261 105b4e49 Christos Stathis
                        app.displayError("System error fetching folder: " + t.getMessage());
262 105b4e49 Christos Stathis
                }
263 9539e23d Christos Stathis
264 9539e23d Christos Stathis
                                @Override
265 9539e23d Christos Stathis
                                protected void onUnauthorized(Response response) {
266 9539e23d Christos Stathis
                                        app.sessionExpired();
267 9539e23d Christos Stathis
                                }
268 105b4e49 Christos Stathis
            };
269 105b4e49 Christos Stathis
            getFolder.setHeader("X-Auth-Token", app.getToken());
270 105b4e49 Christos Stathis
            Scheduler.get().scheduleDeferred(getFolder);
271 105b4e49 Christos Stathis
        }
272 105b4e49 Christos Stathis
        else if (callback != null)
273 105b4e49 Christos Stathis
            callback.execute();
274 105b4e49 Christos Stathis
    }
275 105b4e49 Christos Stathis
276 105b4e49 Christos Stathis
    public Folder getSelection() {
277 105b4e49 Christos Stathis
        return selectionModel.getSelectedObject();
278 105b4e49 Christos Stathis
    }
279 105b4e49 Christos Stathis
280 cf49bbc9 Christos Stathis
    public void updateFolder(Folder folder, boolean showfiles) {
281 105b4e49 Christos Stathis
        if (dataProviderMap.get(folder) == null) {
282 cf49bbc9 Christos Stathis
            dataProviderMap.put(folder, new ListDataProvider<Folder>());
283 105b4e49 Christos Stathis
        }
284 cf49bbc9 Christos Stathis
        final ListDataProvider<Folder> dataProvider = dataProviderMap.get(folder);
285 105b4e49 Christos Stathis
        fetchFolder(folder, dataProvider, showfiles);
286 105b4e49 Christos Stathis
    }
287 105b4e49 Christos Stathis
288 cf49bbc9 Christos Stathis
    public void fetchFolder(final Folder f, final ListDataProvider<Folder> dataProvider, final boolean showfiles) {
289 f5023f13 Christos Stathis
        String path = "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix());
290 63ee965c Christos Stathis
        GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, app.getApiPath(), f.getOwner(), path, f) {
291 105b4e49 Christos Stathis
            @Override
292 7811b9d1 Christos Stathis
            public void onSuccess(final Folder _result) {
293 105b4e49 Christos Stathis
                if (showfiles)
294 7811b9d1 Christos Stathis
                    app.showFiles(_result);
295 7811b9d1 Christos Stathis
                Iterator<Folder> iter = _result.getSubfolders().iterator();
296 cf49bbc9 Christos Stathis
                fetchFolder(iter, dataProvider, new Command() {
297 105b4e49 Christos Stathis
                    @Override
298 105b4e49 Christos Stathis
                    public void execute() {
299 cf49bbc9 Christos Stathis
                        dataProvider.getList().clear();
300 cf49bbc9 Christos Stathis
                                   dataProvider.getList().addAll(_result.getSubfolders());
301 105b4e49 Christos Stathis
                        app.getMySharedTreeView().updateChildren(f);
302 105b4e49 Christos Stathis
                    }
303 105b4e49 Christos Stathis
                });
304 105b4e49 Christos Stathis
            }
305 105b4e49 Christos Stathis
306 105b4e49 Christos Stathis
            @Override
307 105b4e49 Christos Stathis
            public void onError(Throwable t) {
308 105b4e49 Christos Stathis
                GWT.log("Error getting folder", t);
309 3f8622d4 Christos Stathis
                                app.setError(t);
310 105b4e49 Christos Stathis
                if (t instanceof RestException)
311 105b4e49 Christos Stathis
                    app.displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
312 105b4e49 Christos Stathis
                else
313 105b4e49 Christos Stathis
                    app.displayError("System error fetching folder: " + t.getMessage());
314 105b4e49 Christos Stathis
            }
315 9539e23d Christos Stathis
316 9539e23d Christos Stathis
                        @Override
317 9539e23d Christos Stathis
                        protected void onUnauthorized(Response response) {
318 9539e23d Christos Stathis
                                app.sessionExpired();
319 9539e23d Christos Stathis
                        }
320 105b4e49 Christos Stathis
        };
321 105b4e49 Christos Stathis
        getFolder.setHeader("X-Auth-Token", app.getToken());
322 105b4e49 Christos Stathis
        Scheduler.get().scheduleDeferred(getFolder);
323 105b4e49 Christos Stathis
    }
324 7c54d867 Christos Stathis
325 7c54d867 Christos Stathis
        public void initialize(Command callback) {
326 7c54d867 Christos Stathis
                fetchSharedContainers(callback);
327 7c54d867 Christos Stathis
        }
328 105b4e49 Christos Stathis
}