use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class UserController method getUser.
/**
* @param user
*/
public void getUser(User user) {
final GetUserDetailsRequest input = ApiHelper.setAccessCode(new GetUserDetailsRequest());
input.session = SessionController.get().sessionForApiCall();
input.user = user;
if (getUserRequest != null) {
getUserRequest.cancel();
}
getUserRequest = ApiHelper.createUserClient().getUserDetails(input, new AsyncCallback<GetUserDetailsResponse>() {
@Override
public void onSuccess(GetUserDetailsResponse output) {
getUserRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
}
DefaultEventBus.get().fireEventFromSource(new GetUserDetailsSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new GetUserDetailsFailure(input, caught), UserController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class UserController method fetchUserRolesAndPremissions.
/**
* @param user
*/
private void fetchUserRolesAndPremissions() {
if (user != null) {
if (getRolesAndPermissionsRequest != null) {
getRolesAndPermissionsRequest.cancel();
getRolesAndPermissionsRequest = null;
}
final GetRolesAndPermissionsRequest input = ApiHelper.setAccessCode(new GetRolesAndPermissionsRequest());
input.session = SessionController.get().sessionForApiCall();
input.user = user;
getRolesAndPermissionsRequest = ApiHelper.createUserClient().getRolesAndPermissions(input, new AsyncCallback<GetRolesAndPermissionsResponse>() {
@Override
public void onSuccess(GetRolesAndPermissionsResponse output) {
getRolesAndPermissionsRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.roles != null) {
USER_ROLES_PROVIDER.updateRowData(0, output.roles);
} else {
USER_ROLES_PROVIDER.updateRowCount(0, true);
}
if (output.permissions != null) {
USER_PERMISSIONS_PROVIDER.updateRowData(0, output.permissions);
} else {
USER_PERMISSIONS_PROVIDER.updateRowCount(0, true);
}
}
DefaultEventBus.get().fireEventFromSource(new GetRolesAndPermissionsSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
getRolesAndPermissionsRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetRolesAndPermissionsFailure(input, caught), UserController.this);
}
});
}
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class UserController method getEmailAvatar.
/**
* @param email
*/
public void getEmailAvatar(String email) {
final GetEmailAvatarRequest input = ApiHelper.setAccessCode(new GetEmailAvatarRequest());
input.session = SessionController.get().sessionForApiCall();
input.email = email;
if (getEmailAvatarRequest != null) {
getEmailAvatarRequest.cancel();
}
getEmailAvatarRequest = ApiHelper.createUserClient().getEmailAvatar(input, new AsyncCallback<GetEmailAvatarResponse>() {
@Override
public void onSuccess(GetEmailAvatarResponse output) {
getEmailAvatarRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
}
DefaultEventBus.get().fireEventFromSource(new GetEmailAvatarSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new GetEmailAvatarFailure(input, caught), UserController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PermissionOracle 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 GetPermissionsRequest input = ApiHelper.setAccessCode(new GetPermissionsRequest());
input.session = SessionController.get().sessionForApiCall();
input.query = request.getQuery();
input.pager = PagerHelper.createDefaultPager();
input.pager.count = Integer.valueOf(request.getLimit());
if (getPermissionsRequest != null) {
getPermissionsRequest.cancel();
}
getPermissionsRequest = ApiHelper.createUserClient().getPermissions(input, new AsyncCallback<GetPermissionsResponse>() {
@Override
public void onSuccess(GetPermissionsResponse output) {
if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
foundItems(request, callback, output.permissions);
} else {
foundItems(request, callback, Collections.<Permission>emptyList());
}
}
@Override
public void onFailure(Throwable caught) {
GWT.log("Error getting permissions with query " + input.query, caught);
foundItems(request, callback, Collections.<Permission>emptyList());
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback 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());
}
});
}
Aggregations