use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method getHistoryChanges.
public String getHistoryChanges(String repoID, String commitId) throws SeafException {
try {
String apiPath = String.format("api2/repo_history_changes/%s/", repoID);
Map<String, Object> params = Maps.newHashMap();
params.put("commit_id", commitId);
HttpRequest req = prepareApiGetRequest(apiPath, params);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
String result = new String(req.bytes(), "UTF-8");
return result;
} catch (SeafException e) {
throw e;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
} catch (IOException e) {
throw SeafException.networkException;
}
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method deleteShareLink.
public boolean deleteShareLink(String token) throws SeafException {
try {
HttpRequest req = prepareApiDeleteRequest(String.format("api/v2.1/share-links/%s/", token), null);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
String result = new String(req.bytes(), "UTF-8");
if (result != null && Utils.parseJsonObject(result) != null) {
JSONObject obj = Utils.parseJsonObject(result);
return obj.getBoolean("success");
} else {
throw SeafException.illFormatException;
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return false;
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method unstar.
public void unstar(String repoID, String path) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
params.put("repo_id", repoID);
params.put("p", path);
HttpRequest req = prepareApiDeleteRequest("api2/starredfiles/", params);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
} catch (SeafException e) {
throw e;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
}
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method getAccountInfo.
/**
* <p>
* get Account info, which consists of three fields, usage, total and email.
* </p>
* use GET to send HTTP request.
*
* @return
* @throws SeafException
*/
public String getAccountInfo() throws SeafException {
String result;
try {
HttpRequest req = prepareApiGetRequest("api2/account/info/");
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
result = new String(req.bytes(), "UTF-8");
} catch (SeafException e) {
throw e;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
} catch (IOException e) {
throw SeafException.networkException;
}
return result;
}
use of com.github.kevinsawicki.http.HttpRequest in project sunlogin-exp-gui by theLSA.
the class GetSunloginInfo method get_fastcode.
public String get_fastcode() {
/*
class FastCodeClass{
public String fastcode;
}
*/
String fastcode = "";
try {
HttpRequest responseRst = HttpRequest.get(url).connectTimeout(httpTimeout).readTimeout(httpTimeout);
String responseBody = responseRst.body();
fastcode = responseBody;
} catch (Exception e) {
// TODO: handle exception
SunloginExpGui.expResultTextArea.append("get_fastcode failed. Caused exception.\n");
}
// FastCodeClass fcc = new Gson().fromJson(responseBody, FastCodeClass.class);
return fastcode;
}
Aggregations