سؤال

I have this simple ednpoint method:

@ApiMethod(name = "createCategory")
public RCategory createCategory(@Named("userHash")String userHash, @Nullable @Named("synchronously")Boolean synchronously, Category category) throws AccessForbiddenException, DuplicateEntityNameException, SubscriptionRequiredException {
    User user = OwlEndpoint.getUser(userHash);
    if (!user.hasSubscriptionActive()) throw new SubscriptionRequiredException();

    //Sprawdzam czy w profilu uzytkownika jest wiecej niz on sam (o ile w ogole ma profil)
    List<Long> usersInProfileIds = getUsersInProfilesIds(user);

    if (ofy().load().type(Category.class).filter("creatorId in", usersInProfileIds).filter("name", category.getName()).count() > 0) throw new DuplicateEntityNameException();
    category.setCreatorId(user.getId());

    if (synchronously != null && synchronously) ofy().save().entity(category).now();
    else ofy().save().entity(category);

    return new RCategory(category, user.getId());
}

It works just fine on the DEV server, but after uploading to GAE it started to fail. I found this in the logs, but that doesn't make sense to me:

    Request URL: https://myapp.appspot.com/_ah/api/owlendpoint/v1/createCategory/0A71A4A761C2B0C49BE3CE4ED19E78E93911DAE1E53732BE5635B29F923DBBFD5C54DEBE7F80831364D8255861D46878ADB657D0DDA95EEAF19956A6C5967CADF903543D1DA577677FEAEC70F0019B055C4CBA168A4A188D41393A9BF08834A92F8BB13D5E03F7F901C1281878BE8B79
    Method: myappendpoint.createCategory
    Error Code: 400
    Reason: badRequest    
    Message: java.lang.IllegalArgumentException: offset may not be above 1000
هل كانت مفيدة؟

المحلول

I made this method:

@SuppressWarnings("rawtypes")
public static boolean hasItems(Query query) {
    Iterator it = query.iterator();
    return it.hasNext();
}

I'm using it to define, if there is at least one element on the query without using count(). Still would like to know how can I use count() and how can not...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top