/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
package gr.grnet.pithos.web.client.rest;
+import gr.grnet.pithos.web.client.foldertree.Resource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
-import gr.grnet.pithos.web.client.foldertree.Resource;
-import java.util.HashMap;
-import java.util.Map;
public abstract class PostRequest implements ScheduledCommand {
protected String owner;
private String path;
+
+ String data = "";
private Map<String, String> headers = new HashMap<String, String>();
this.path = path;
}
+ public PostRequest(String api, String owner, String path, String data) {
+ this.api = api;
+ this.owner = owner;
+ this.path = path;
+ this.data = data;
+ }
+
@Override
public void execute() {
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, api + owner + path);
builder.setHeader(header, headers.get(header));
}
try {
- builder.sendRequest("", new RestRequestCallback<Resource>(api + owner + path, Response.SC_ACCEPTED) {
+ builder.sendRequest(data, new RestRequestCallback<Resource>(api + owner + path, Response.SC_ACCEPTED) {
@Override
public void onSuccess(Resource object) {
PostRequest.this.onSuccess(object);
}
@Override
- public void onError(@SuppressWarnings("unused") Request request, Throwable throwable) {
+ public void onError(Request request, Throwable throwable) {
PostRequest.this.onError(throwable);
}
});
}
catch (RequestException e) {
+ GWT.log("", e);
}
}