use of com.willshex.blogwt.shared.api.user.call.GetPermissionsResponse 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.willshex.blogwt.shared.api.user.call.GetPermissionsResponse 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.willshex.blogwt.shared.api.user.call.GetPermissionsResponse in project blogwt by billy1380.
the class UserService method getPermissions.
public Request getPermissions(GetPermissionsRequest input, AsyncSuccess<GetPermissionsRequest, GetPermissionsResponse> onSuccess, AsyncFailure<GetPermissionsRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodGetPermissions, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetPermissionsResponse outputParameter = new GetPermissionsResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodGetPermissions, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetPermissions, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetPermissions, input, exception);
}
});
onCallStart(UserService.this, UserMethodGetPermissions, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetPermissions, input, exception);
}
return handle;
}
Aggregations