use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class UserService method register.
public BackendlessUser register(BackendlessUser user) throws BackendlessException {
checkUserToBeProper(user);
BackendlessSerializer.serializeUserProperties(user);
String password = user.getPassword();
BackendlessUser userToReturn = Invoker.invokeSync(USER_MANAGER_SERVER_ALIAS, "register", new Object[] { user.getProperties() }, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
user.clearProperties();
userToReturn.setPassword(password);
user.putProperties(userToReturn.getProperties());
return userToReturn;
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class UserService method register.
public void register(final BackendlessUser user, final AsyncCallback<BackendlessUser> responder) {
try {
checkUserToBeProper(user);
BackendlessSerializer.serializeUserProperties(user);
Invoker.invokeAsync(USER_MANAGER_SERVER_ALIAS, "register", new Object[] { user.getProperties() }, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
response.setPassword(user.getPassword());
user.clearProperties();
user.putProperties(response.getProperties());
if (responder != null)
responder.handleResponse(response);
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
}, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
} catch (BackendlessException e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class UserServiceAndroidExtra method getBackendlessUser.
private void getBackendlessUser(final AccessToken accessToken, final Map<String, String> facebookFieldsMappings, final AsyncCallback<BackendlessUser> responder) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
FacebookBundle facebookBundle = new FacebookBundle(response, accessToken);
Object[] requestData = new Object[] { null, facebookBundle.accessToken, null, null, facebookFieldsMappings };
Invoker.invokeAsync(UserService.USER_MANAGER_SERVER_ALIAS, "loginWithFacebook", requestData, responder, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class CustomService method invoke.
public <E> void invoke(String serviceName, String method, Object[] arguments, Class<?> clazz, AsyncCallback<E> callback) {
Object[] args = new Object[] { serviceName, method, arguments };
Invoker.invokeAsync(CUSTOM_SERVICE_ALIAS, METHOD_NAME_ALIAS, args, callback, new AdaptingResponder(clazz, new UniversalAdaptingPolicy()));
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class Invoker method invokeSync.
public static <T> T invokeSync(String className, String methodName, Object[] args, IChainedResponder chainedResponder) throws BackendlessException {
SyncResponder invokeResponder = new SyncResponder();
if (chainedResponder == null)
chainedResponder = new AdaptingResponder<T>();
chainedResponder.setNextResponder(invokeResponder);
try {
ThreadContext.cleanup();
getWebOrbClient().invoke(className, methodName, args, null, null, HeadersManager.getInstance().getHeaders(), chainedResponder);
} catch (Exception e) {
throw new BackendlessException(ExceptionMessage.SERVER_ERROR, e.getMessage());
}
return (T) invokeResponder.getResult();
}
Aggregations