use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PermissionController method fetchPermissions.
private void fetchPermissions() {
final GetPermissionsRequest input = ApiHelper.setAccessCode(new GetPermissionsRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getPermissionsRequest != null) {
getPermissionsRequest.cancel();
}
getPermissionsRequest = ApiHelper.createUserClient().getPermissions(input, new AsyncCallback<GetPermissionsResponse>() {
@Override
public void onSuccess(GetPermissionsResponse output) {
getPermissionsRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.permissions != null && output.permissions.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.permissions);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Permission>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetPermissionsSuccess(input, output), PermissionController.this);
}
@Override
public void onFailure(Throwable caught) {
getPermissionsRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPermissionsFailure(input, caught), PermissionController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PostController method getPost.
public void getPost(Post post) {
final GetPostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostRequest())).post(post);
if (getPostRequest != null) {
getPostRequest.cancel();
}
getPostRequest = ApiHelper.createBlogClient().getPost(input, new AsyncCallback<GetPostResponse>() {
@Override
public void onSuccess(GetPostResponse output) {
getPostRequest = null;
boolean retryingGetWithSlug = false;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.post != null) {
}
} else {
if (input.post.id != null) {
getPost(new Post().slug(input.post.id.toString()));
retryingGetWithSlug = true;
}
}
if (!retryingGetWithSlug) {
DefaultEventBus.get().fireEventFromSource(new GetPostSuccess(input, output), PostController.this);
}
}
@Override
public void onFailure(Throwable caught) {
getPostRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPostFailure(input, caught), PostController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class ResourceController method fetchResources.
private void fetchResources() {
final GetResourcesRequest input = ApiHelper.setAccessCode(new GetResourcesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getResourcesRequest != null) {
getResourcesRequest.cancel();
}
getResourcesRequest = ApiHelper.createBlogClient().getResources(input, new AsyncCallback<GetResourcesResponse>() {
@Override
public void onSuccess(GetResourcesResponse output) {
getResourcesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.resources != null && output.resources.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.resources);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Resource>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetResourcesSuccess(input, output), ResourceController.this);
}
@Override
public void onFailure(Throwable caught) {
getResourcesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetResourcesFailure(input, caught), ResourceController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class SessionController method createAsyncResponse.
/**
* @param input
* @return
*/
private AsyncCallback<LoginResponse> createAsyncResponse(final LoginRequest input) {
return new AsyncCallback<LoginResponse>() {
@Override
public void onSuccess(LoginResponse result) {
if (result.status == StatusType.StatusTypeSuccess && result.session != null) {
session = result.session;
Cookies.setCookie(COOKIE_KEY_ID, session.id.toString(), DateTimeHelper.millisFromNow(DateTimeHelper.MILLIS_PER_DAY * 365L * 20L));
if (user() != null && user().lastLoggedIn == null) {
user().lastLoggedIn = new Date();
}
}
DefaultEventBus.get().fireEventFromSource(new LoginSuccess(input, result), SessionController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new LoginFailure(input, caught), SessionController.this);
}
};
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class UserController method fetchUsers.
private void fetchUsers() {
final GetUsersRequest input = ApiHelper.setAccessCode(new GetUsersRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getUsersRequest != null) {
getUsersRequest.cancel();
}
getUsersRequest = ApiHelper.createUserClient().getUsers(input, new AsyncCallback<GetUsersResponse>() {
@Override
public void onSuccess(GetUsersResponse output) {
getUsersRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.users != null && output.users.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.users);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<User>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetUsersSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
getUsersRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetUsersFailure(input, caught), UserController.this);
}
});
}
Aggregations