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.client.rest;
21 import gr.ebs.gss.client.GSS;
22 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
24 import com.google.gwt.http.client.Request;
25 import com.google.gwt.http.client.RequestCallback;
26 import com.google.gwt.http.client.Response;
33 public abstract class DeleteCommand extends RestCommand{
35 boolean complete = false;
37 public DeleteCommand(String pathToDelete){
38 this(pathToDelete, true);
42 public DeleteCommand(String pathToDelete, boolean showLoading){
43 setShowLoadingIndicator(showLoading);
44 if(isShowLoadingIndicator())
45 GSS.get().showLoadingIndicator();
47 if(pathToDelete.endsWith("/"))
50 path = pathToDelete+"/";
51 RestRequestBuilder builder = new RestRequestBuilder("DELETE", path);
54 handleHeaders(builder, path);
55 builder.sendRequest("", new RequestCallback() {
58 public void onError(Request arg0, Throwable arg1) {
60 DeleteCommand.this.onError(arg1);
64 public void onResponseReceived(Request arg0, Response arg1) {
66 if(arg1.getStatusCode() == 204)
68 else if(arg1.getStatusCode() == 403)
70 else if(arg1.getStatusCode() == 405)
71 DeleteCommand.this.onError(new InsufficientPermissionsException("You don't have permissions to delete this resource"));
73 DeleteCommand.this.onError(new RestException(path, arg1.getStatusCode(), arg1.getStatusText(), arg1.getText()));
77 } catch (Exception ex) {
83 public boolean isComplete() {
87 public boolean execute() {
88 boolean com = isComplete();
90 if(isShowLoadingIndicator())
91 GSS.get().hideLoadingIndicator();