Statistics
| Branch: | Tag: | Revision:

root / src / org / gss_project / gss / web / client / commands / EmptyTrashCommand.java @ 1205:fbeae20462e6

History | View | Annotate | Download (2.2 kB)

1 1:e7bf0801e8c6 pastith
/*
2 1:e7bf0801e8c6 pastith
 * Copyright 2008, 2009 Electronic Business Systems Ltd.
3 1:e7bf0801e8c6 pastith
 *
4 1:e7bf0801e8c6 pastith
 * This file is part of GSS.
5 1:e7bf0801e8c6 pastith
 *
6 1:e7bf0801e8c6 pastith
 * GSS is free software: you can redistribute it and/or modify
7 1:e7bf0801e8c6 pastith
 * it under the terms of the GNU General Public License as published by
8 1:e7bf0801e8c6 pastith
 * the Free Software Foundation, either version 3 of the License, or
9 1:e7bf0801e8c6 pastith
 * (at your option) any later version.
10 1:e7bf0801e8c6 pastith
 *
11 1:e7bf0801e8c6 pastith
 * GSS is distributed in the hope that it will be useful,
12 1:e7bf0801e8c6 pastith
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1:e7bf0801e8c6 pastith
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 1:e7bf0801e8c6 pastith
 * GNU General Public License for more details.
15 1:e7bf0801e8c6 pastith
 *
16 1:e7bf0801e8c6 pastith
 * You should have received a copy of the GNU General Public License
17 1:e7bf0801e8c6 pastith
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18 1:e7bf0801e8c6 pastith
 */
19 1205:fbeae20462e6 chstath
package org.gss_project.gss.web.client.commands;
20 1:e7bf0801e8c6 pastith
21 1205:fbeae20462e6 chstath
import org.gss_project.gss.web.client.GSS;
22 1205:fbeae20462e6 chstath
import org.gss_project.gss.web.client.rest.DeleteCommand;
23 1205:fbeae20462e6 chstath
import org.gss_project.gss.web.client.rest.RestException;
24 1:e7bf0801e8c6 pastith
25 1:e7bf0801e8c6 pastith
import com.google.gwt.core.client.GWT;
26 1:e7bf0801e8c6 pastith
import com.google.gwt.user.client.Command;
27 33:d0ede1eef517 koutsoub
import com.google.gwt.user.client.DeferredCommand;
28 1:e7bf0801e8c6 pastith
import com.google.gwt.user.client.ui.PopupPanel;
29 1:e7bf0801e8c6 pastith
30 1:e7bf0801e8c6 pastith
31 1:e7bf0801e8c6 pastith
/**
32 228:4f024b1c4f38 pastith
 * Command to empty trash bin.
33 228:4f024b1c4f38 pastith
 *
34 1:e7bf0801e8c6 pastith
 * @author kman
35 1:e7bf0801e8c6 pastith
 */
36 1:e7bf0801e8c6 pastith
public class EmptyTrashCommand implements Command{
37 1:e7bf0801e8c6 pastith
        private PopupPanel containerPanel;
38 1:e7bf0801e8c6 pastith
39 1:e7bf0801e8c6 pastith
        public EmptyTrashCommand(PopupPanel _containerPanel){
40 1:e7bf0801e8c6 pastith
                containerPanel = _containerPanel;
41 1:e7bf0801e8c6 pastith
        }
42 228:4f024b1c4f38 pastith
43 623:66f69a7348ed pastith
        @Override
44 1:e7bf0801e8c6 pastith
        public void execute() {
45 1:e7bf0801e8c6 pastith
                containerPanel.hide();
46 984:8cc6d94b1ae5 koutsoub
                DeleteCommand df = new DeleteCommand(GSS.get().getTreeView().getTrash().getUri()){
47 1:e7bf0801e8c6 pastith
48 228:4f024b1c4f38 pastith
                        @Override
49 33:d0ede1eef517 koutsoub
                        public void onComplete() {
50 1060:2966f4e6b0d4 koutsoub
                                GSS.get().getTreeView().updateTrashNode();
51 90:955751fed6ed koutsoub
                                GSS.get().showFileList(true);
52 1:e7bf0801e8c6 pastith
                        }
53 1:e7bf0801e8c6 pastith
54 228:4f024b1c4f38 pastith
                        @Override
55 33:d0ede1eef517 koutsoub
                        public void onError(Throwable t) {
56 33:d0ede1eef517 koutsoub
                                GWT.log("", t);
57 33:d0ede1eef517 koutsoub
                                if(t instanceof RestException){
58 33:d0ede1eef517 koutsoub
                                        int statusCode = ((RestException)t).getHttpStatusCode();
59 33:d0ede1eef517 koutsoub
                                        if(statusCode == 405)
60 33:d0ede1eef517 koutsoub
                                                GSS.get().displayError("You don't have the necessary permissions");
61 33:d0ede1eef517 koutsoub
                                        else if(statusCode == 404)
62 33:d0ede1eef517 koutsoub
                                                GSS.get().displayError("Resource does not exist");
63 33:d0ede1eef517 koutsoub
                                        else
64 135:ed072b926723 koutsoub
                                                GSS.get().displayError("Unable to empty trash:"+((RestException)t).getHttpStatusText());
65 33:d0ede1eef517 koutsoub
                                }
66 1:e7bf0801e8c6 pastith
                                else
67 33:d0ede1eef517 koutsoub
                                        GSS.get().displayError("System error emptying trash:"+t.getMessage());
68 1:e7bf0801e8c6 pastith
                        }
69 33:d0ede1eef517 koutsoub
                };
70 33:d0ede1eef517 koutsoub
                DeferredCommand.addCommand(df);
71 1:e7bf0801e8c6 pastith
        }
72 1:e7bf0801e8c6 pastith
73 1:e7bf0801e8c6 pastith
}