2 * Copyright 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.web.client.rest;
21 import gr.ebs.gss.web.client.GSS;
22 import gr.ebs.gss.common.exceptions.InsufficientPermissionsException;
24 import com.google.gwt.http.client.Request;
25 import com.google.gwt.http.client.RequestBuilder;
26 import com.google.gwt.http.client.RequestCallback;
27 import com.google.gwt.http.client.Response;
34 public abstract class DeleteCommand extends RestCommand{
36 boolean complete = false;
38 public DeleteCommand(String pathToDelete){
39 this(pathToDelete, true);
43 public DeleteCommand(String pathToDelete, boolean showLoading){
44 setShowLoadingIndicator(showLoading);
45 if(isShowLoadingIndicator())
46 GSS.get().showLoadingIndicator();
48 if(pathToDelete.endsWith("/"))
51 path = pathToDelete+"/";
52 RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, path);
55 handleHeaders(builder, path);
56 builder.sendRequest("", new RequestCallback() {
59 public void onError(Request arg0, Throwable arg1) {
61 DeleteCommand.this.onError(arg1);
65 public void onResponseReceived(Request arg0, Response arg1) {
67 if(arg1.getStatusCode() == 204)
69 else if(arg1.getStatusCode() == 403)
71 else if(arg1.getStatusCode() == 405)
72 DeleteCommand.this.onError(new InsufficientPermissionsException("You don't have permissions to delete this resource"));
74 DeleteCommand.this.onError(new RestException(path, arg1.getStatusCode(), arg1.getStatusText(), arg1.getText()));
78 } catch (Exception ex) {
84 public boolean isComplete() {
89 public boolean execute() {
90 boolean com = isComplete();
92 if(isShowLoadingIndicator())
93 GSS.get().hideLoadingIndicator();