I have an App-Engine app that compile fine and i test the methods calls using the Google Apis Explorer on localhost (https://developers.google.com/apis-explorer/?base=http://localhost:8888/_ah/api#p/) It works fine and i can test my api method using the Apis Explorer interface but as soon as i add a new Apimethod like
@ApiMethod(name = "users.insertrandomuserv4")
public User insertrandomuserv4() {
User user = new User("234","myfirstname","mysecondname");
return user;
}
and i redeploy locally my application, the Apis Explorer didn't show me the list of the different api method. Why? (FYI:When i remove the new method, it works again)
Edit: Here is the rest of my class(yes I use PersistentManager and DataStoreService but it just for testing):
public class UserEndpoint {
@ApiMethod(name = "users.get")
public User get(@Named("key") String key) {
//Key k = KeyFactory.createKey(User.class.getSimpleName(), key);
PersistenceManager pm = getPersistenceManager();
User user = pm.getObjectById(User.class, key);
pm.close();
return user;
}
@ApiMethod(name = "users.list")
public List<User> list() {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query query = new Query("User");
//query.setKeysOnly();
PreparedQuery pq = datastore.prepare(query);
List<Entity> ls = pq.asList(FetchOptions.Builder.withLimit(500));
List<User> flist = new ArrayList<User>();
for (Entity user : ls) {
User u = new User(user);
flist.add(u);
}
return flist;
}
@ApiMethod(name = "users.insert")
public User insert(User user) {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity ent = user.toEntity();
datastore.put(ent);
return user;
}
@ApiMethod(name = "users.insertrandomuserv4")
public User insertrandomuserv4() {
User user = new User("234","myfirstname","mysecondname");
return user;
}
@ApiMethod(name = "users.getuserswithsamehometown")
public List<User> getUsersWithSameHometown(@Named("home")String home) {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query query = new Query("User");
//query.addProjection(new PropertyProjection("firstname", User.class));
query.setFilter(new Query.FilterPredicate("hometown",FilterOperator.EQUAL,home));
PreparedQuery pq = datastore.prepare(query);
List<Entity> ls = pq.asList(FetchOptions.Builder.withLimit(500));
List<User> flist = new ArrayList<User>();
for (Entity ent : ls) {
User u = new User(ent);
flist.add(u);
}
return flist;
}
private static PersistenceManager getPersistenceManager() {
return JDOHelper.getPersistenceManagerFactory("transactions-optional").getPersistenceManager();
}
}