use of com.willshex.blogwt.shared.api.user.call.GetRolesRequest in project blogwt by billy1380.
the class RoleOracle method lookup.
/* (non-Javadoc)
*
* @see
* com.willshex.blogwt.client.oracle.SuggestOracle#lookup(com.google.gwt
* .user.client.ui.SuggestOracle.Request,
* com.google.gwt.user.client.ui.SuggestOracle.Callback) */
@Override
protected void lookup(final Request request, final Callback callback) {
final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
input.session = SessionController.get().sessionForApiCall();
input.query = request.getQuery();
input.pager = PagerHelper.createDefaultPager();
input.pager.count = Integer.valueOf(request.getLimit());
if (getRolesRequest != null) {
getRolesRequest.cancel();
}
getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {
@Override
public void onSuccess(GetRolesResponse output) {
if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
foundItems(request, callback, output.roles);
} else {
foundItems(request, callback, Collections.<Role>emptyList());
}
}
@Override
public void onFailure(Throwable caught) {
GWT.log("Error getting roles with query " + input.query, caught);
foundItems(request, callback, Collections.<Role>emptyList());
}
});
}
use of com.willshex.blogwt.shared.api.user.call.GetRolesRequest in project blogwt by billy1380.
the class UserJsonServlet method processAction.
@Override
protected String processAction(String action, JsonObject request) {
String output = "null";
if ("GetUsers".equals(action)) {
GetUsersRequest input = new GetUsersRequest();
input.fromJson(request);
output = new GetUsersActionHandler().handle(input).toString();
} else if ("BlockUsers".equals(action)) {
BlockUsersRequest input = new BlockUsersRequest();
input.fromJson(request);
output = new BlockUsersActionHandler().handle(input).toString();
} else if ("FollowUsers".equals(action)) {
FollowUsersRequest input = new FollowUsersRequest();
input.fromJson(request);
output = new FollowUsersActionHandler().handle(input).toString();
} else if ("ChangeUserAccess".equals(action)) {
ChangeUserAccessRequest input = new ChangeUserAccessRequest();
input.fromJson(request);
output = new ChangeUserAccessActionHandler().handle(input).toString();
} else if ("GetRoles".equals(action)) {
GetRolesRequest input = new GetRolesRequest();
input.fromJson(request);
output = new GetRolesActionHandler().handle(input).toString();
} else if ("GetPermissions".equals(action)) {
GetPermissionsRequest input = new GetPermissionsRequest();
input.fromJson(request);
output = new GetPermissionsActionHandler().handle(input).toString();
} else if ("GetRolesAndPermissions".equals(action)) {
GetRolesAndPermissionsRequest input = new GetRolesAndPermissionsRequest();
input.fromJson(request);
output = new GetRolesAndPermissionsActionHandler().handle(input).toString();
} else if ("VerifyAccount".equals(action)) {
VerifyAccountRequest input = new VerifyAccountRequest();
input.fromJson(request);
output = new VerifyAccountActionHandler().handle(input).toString();
} else if ("ResetPassword".equals(action)) {
ResetPasswordRequest input = new ResetPasswordRequest();
input.fromJson(request);
output = new ResetPasswordActionHandler().handle(input).toString();
} else if ("GetEmailAvatar".equals(action)) {
GetEmailAvatarRequest input = new GetEmailAvatarRequest();
input.fromJson(request);
output = new GetEmailAvatarActionHandler().handle(input).toString();
} else if ("RegisterUser".equals(action)) {
RegisterUserRequest input = new RegisterUserRequest();
input.fromJson(request);
output = new RegisterUserActionHandler().handle(input).toString();
} else if ("ChangeUserDetails".equals(action)) {
ChangeUserDetailsRequest input = new ChangeUserDetailsRequest();
input.fromJson(request);
output = new ChangeUserDetailsActionHandler().handle(input).toString();
} else if ("Login".equals(action)) {
LoginRequest input = new LoginRequest();
input.fromJson(request);
output = new LoginActionHandler().handle(input).toString();
} else if ("Logout".equals(action)) {
LogoutRequest input = new LogoutRequest();
input.fromJson(request);
output = new LogoutActionHandler().handle(input).toString();
} else if ("ChangePassword".equals(action)) {
ChangePasswordRequest input = new ChangePasswordRequest();
input.fromJson(request);
output = new ChangePasswordActionHandler().handle(input).toString();
} else if ("CheckUsername".equals(action)) {
CheckUsernameRequest input = new CheckUsernameRequest();
input.fromJson(request);
output = new CheckUsernameActionHandler().handle(input).toString();
} else if ("IsAuthorised".equals(action)) {
IsAuthorisedRequest input = new IsAuthorisedRequest();
input.fromJson(request);
output = new IsAuthorisedActionHandler().handle(input).toString();
} else if ("GetUserDetails".equals(action)) {
GetUserDetailsRequest input = new GetUserDetailsRequest();
input.fromJson(request);
output = new GetUserDetailsActionHandler().handle(input).toString();
} else if ("ForgotPassword".equals(action)) {
ForgotPasswordRequest input = new ForgotPasswordRequest();
input.fromJson(request);
output = new ForgotPasswordActionHandler().handle(input).toString();
}
return output;
}
use of com.willshex.blogwt.shared.api.user.call.GetRolesRequest in project blogwt by billy1380.
the class RoleController method fetchRoles.
private void fetchRoles() {
final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getRolesRequest != null) {
getRolesRequest.cancel();
}
getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {
@Override
public void onSuccess(GetRolesResponse output) {
getRolesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.roles != null && output.roles.size() > 0) {
pager = output.pager;
updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
updateRowData(input.pager.start.intValue(), output.roles);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Role>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetRolesSuccess(input, output), RoleController.this);
}
@Override
public void onFailure(Throwable caught) {
getRolesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetRolesFailure(input, caught), RoleController.this);
}
});
}
use of com.willshex.blogwt.shared.api.user.call.GetRolesRequest in project blogwt by billy1380.
the class UserService method getRoles.
public Request getRoles(GetRolesRequest input, AsyncSuccess<GetRolesRequest, GetRolesResponse> onSuccess, AsyncFailure<GetRolesRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodGetRoles, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetRolesResponse outputParameter = new GetRolesResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodGetRoles, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRoles, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRoles, input, exception);
}
});
onCallStart(UserService.this, UserMethodGetRoles, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRoles, input, exception);
}
return handle;
}
Aggregations