use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class Persistence method findById.
protected <E> void findById(E entity, List<String> relations, Integer relationsDepth, AsyncCallback<E> responder) {
try {
if (entity == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_ENTITY);
IChainedResponder chainedResponder = new AdaptingResponder<E>((Class<E>) entity.getClass(), new PoJoAdaptingPolicy<E>());
Object entityArg = ReflectionUtil.hasField(entity.getClass(), Persistence.DEFAULT_OBJECT_ID_FIELD) ? entity : FootprintsManager.getInstance().getObjectId(entity);
Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "findById", new Object[] { BackendlessSerializer.getSimpleName(entity.getClass()), entityArg, relations, relationsDepth }, responder, chainedResponder);
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class UserService method update.
public void update(final BackendlessUser user, final AsyncCallback<BackendlessUser> responder) {
try {
checkUserToBeProperForUpdate(user);
BackendlessSerializer.serializeUserProperties(user);
if (user.getUserId() != null && user.getUserId().equals(""))
throw new IllegalArgumentException(ExceptionMessage.WRONG_USER_ID);
Invoker.invokeAsync(USER_MANAGER_SERVER_ALIAS, "update", new Object[] { user.getProperties() }, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
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 (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.core.responder.AdaptingResponder in project Android-SDK by Backendless.
the class UserService method update.
public BackendlessUser update(final BackendlessUser user) throws BackendlessException {
checkUserToBeProperForUpdate(user);
BackendlessSerializer.serializeUserProperties(user);
if (user.getUserId() != null && user.getUserId().equals(""))
throw new IllegalArgumentException(ExceptionMessage.WRONG_USER_ID);
BackendlessUser userToReturn = Invoker.invokeSync(USER_MANAGER_SERVER_ALIAS, "update", new Object[] { user.getProperties() }, new AdaptingResponder(BackendlessUser.class, new BackendlessUserAdaptingPolicy()));
user.clearProperties();
user.putProperties(userToReturn.getProperties());
return userToReturn;
}
Aggregations