use of com.willshex.gson.web.service.client.HttpException in project blogwt by billy1380.
the class UserService method registerUser.
public Request registerUser(RegisterUserRequest input, AsyncSuccess<RegisterUserRequest, RegisterUserResponse> onSuccess, AsyncFailure<RegisterUserRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodRegisterUser, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
RegisterUserResponse outputParameter = new RegisterUserResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodRegisterUser, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodRegisterUser, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodRegisterUser, input, exception);
}
});
onCallStart(UserService.this, UserMethodRegisterUser, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodRegisterUser, input, exception);
}
return handle;
}
use of com.willshex.gson.web.service.client.HttpException in project blogwt by billy1380.
the class UserService method forgotPassword.
public Request forgotPassword(ForgotPasswordRequest input, AsyncSuccess<ForgotPasswordRequest, ForgotPasswordResponse> onSuccess, AsyncFailure<ForgotPasswordRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodForgotPassword, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
ForgotPasswordResponse outputParameter = new ForgotPasswordResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodForgotPassword, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodForgotPassword, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodForgotPassword, input, exception);
}
});
onCallStart(UserService.this, UserMethodForgotPassword, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodForgotPassword, input, exception);
}
return handle;
}
use of com.willshex.gson.web.service.client.HttpException in project blogwt by billy1380.
the class UserService method getRolesAndPermissions.
public Request getRolesAndPermissions(GetRolesAndPermissionsRequest input, AsyncSuccess<GetRolesAndPermissionsRequest, GetRolesAndPermissionsResponse> onSuccess, AsyncFailure<GetRolesAndPermissionsRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodGetRolesAndPermissions, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetRolesAndPermissionsResponse outputParameter = new GetRolesAndPermissionsResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodGetRolesAndPermissions, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
});
onCallStart(UserService.this, UserMethodGetRolesAndPermissions, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
return handle;
}
use of com.willshex.gson.web.service.client.HttpException in project blogwt by billy1380.
the class RecaptchaHelper method isHuman.
public static boolean isHuman(String input, String key) {
boolean isHuman = false;
try {
String requestData = "secret=" + key + "&response=" + input + "&";
URL url = new URL(VERIFY_URL);
HTTPRequest request = new HTTPRequest(url, HTTPMethod.POST);
HTTPHeader contentTypeHeader = new HTTPHeader("Content-Type", "application/x-www-form-urlencoded");
request.setHeader(contentTypeHeader);
request.setPayload(requestData.getBytes(ServletHelper.UTF8));
String responseText = null;
HTTPResponse response = client.fetch(request);
if (response.getResponseCode() >= 200 && response.getResponseCode() < 300 && (responseText = getResponseBody(response)) != null && !"".equals(responseText) && !"null".equalsIgnoreCase(responseText)) {
JsonElement element = (new JsonParser()).parse(responseText);
JsonObject jsonObject;
if (element.isJsonObject()) {
jsonObject = element.getAsJsonObject();
element = jsonObject.get("success");
if (element.isJsonPrimitive()) {
isHuman = element.getAsBoolean();
}
}
} else if (response.getResponseCode() >= 400)
throw new HttpException(response.getResponseCode());
} catch (Exception e) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "Error verifying error", e);
}
}
return isHuman;
}
use of com.willshex.gson.web.service.client.HttpException in project blogwt by billy1380.
the class BlogService method deleteResource.
public Request deleteResource(DeleteResourceRequest input, AsyncSuccess<DeleteResourceRequest, DeleteResourceResponse> onSuccess, AsyncFailure<DeleteResourceRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(BlogMethodDeleteResource, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
DeleteResourceResponse outputParameter = new DeleteResourceResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(BlogService.this, BlogMethodDeleteResource, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodDeleteResource, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodDeleteResource, input, exception);
}
});
onCallStart(BlogService.this, BlogMethodDeleteResource, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodDeleteResource, input, exception);
}
return handle;
}
Aggregations