use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Persistence method loadRelations.
public <T> void loadRelations(String parentType, String objectId, LoadRelationsQueryBuilder queryBuilder, Class<T> relatedType, final AsyncCallback<List<T>> responder) {
StringUtils.checkEmpty(objectId, ExceptionMessage.NULL_ENTITY);
if (queryBuilder == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_FIELD("queryBuilder"));
BackendlessDataQuery dataQuery = queryBuilder.build();
String relationName = dataQuery.getQueryOptions().getRelated().iterator().next();
int pageSize = dataQuery.getPageSize();
int offset = dataQuery.getOffset();
try {
Object[] args = new Object[] { parentType, objectId, relationName, pageSize, offset };
Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "loadRelations", args, responder, ResponderHelper.getCollectionAdaptingResponder(relatedType));
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Persistence method getObjectCount.
<E> void getObjectCount(final Class<E> entity, DataQueryBuilder queryBuilder, AsyncCallback<Integer> responder) {
if (queryBuilder == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_FIELD("queryBuilder"));
BackendlessDataQuery dataQuery = queryBuilder.build();
try {
Object[] args = new Object[] { BackendlessSerializer.getSimpleName(entity), dataQuery };
Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "count", args, responder);
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Persistence method findById.
protected <E> void findById(final E entity, final DataQueryBuilder queryBuilder, AsyncCallback<E> responder) {
try {
if (entity == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_ENTITY);
if (queryBuilder == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_FIELD("queryBuilder"));
Object entityArg = ReflectionUtil.hasField(entity.getClass(), Persistence.DEFAULT_OBJECT_ID_FIELD) ? entity : FootprintsManager.getInstance().getObjectId(entity);
Object[] args = new Object[] { BackendlessSerializer.getSimpleName(entity.getClass()), entityArg, queryBuilder.build() };
Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "findById", args, responder, ResponderHelper.getPOJOAdaptingResponder(entity.getClass()));
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault 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.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class AdaptingResponder method adaptFault.
public static BackendlessFault adaptFault(AnonymousObject bodyHolder) {
final StringType faultMessage = (StringType) bodyHolder.getProperties().get("faultString");
final StringType faultDetail = (StringType) bodyHolder.getProperties().get("faultDetail");
final StringType faultCode = (StringType) bodyHolder.getProperties().get("faultCode");
final AnonymousObject extendedData = (AnonymousObject) bodyHolder.getProperties().get("extendedData");
return new BackendlessFault(new Fault((String) faultMessage.defaultAdapt(), (String) faultDetail.defaultAdapt(), (String) faultCode.defaultAdapt()), (Map<String, Object>) extendedData.defaultAdapt());
}
Aggregations