1

I have a gae project that uses cloud end points in Java which is a very simple CRUD application.

I have some PUT requests that change the datastore entities and GET requests that retrieve them. I find the GET requests always do not return the latest value of the entities. This is happening for several GET requests. When I check the saved value in my datastore viewer I can confirm the new value is saved correctly.

I tried this with Google API explorer and also with another REST client (called Postman available in chrome web store).

The pattern seems to be this -
1) send PUT request to change entity
2) send GET request to retrieve entity. sometimes I see old value and sometime I see new value. I can confirm latest data is saved from datastore viewer. This happens for multiple GET requests.

This seems like pretty basic functionality and may be I am doing something wrong. This is how my api annotations look like -

@Api (name = "content", 
scopes = { "https://www.googleapis.com/auth/userinfo.email" }
)
public class ContentAPI extends APIBase {

  @ApiMethod(path="setcontent", httpMethod = HttpMethod.PUT)
  public APIResponse setContent(@Named("content_html") String html, 
        @Named("tag") String tag, @Named("publish") boolean publish, User   user) {
     ...
    //save content in the datastore
  }

  @ApiMethod(path="getcontent", httpMethod = HttpMethod.GET)
  public APIResponse getContent(@Named("tag") String tag, 
      User user) {
      ...
      //retrieve the saved content and send it back.
  }


Has anyone encountered such issues before ? Any help would be appreciated.

[Edit] - this looks like a datastore issue and not a cloud endpoint issue. I have opened another question [here] (Unable to get saved entity using objectify)

Regards,
Sathya

Community
  • 1
  • 1
Sathya
  • 1,076
  • 1
  • 8
  • 17
  • Have you checked if you get the wrong value when you call the GET method just afer the PUT method, I mean very quickly... because I noticed some delay when persisting in Google's Datastore, but I don't know... it's only a suggestion... – MikO May 19 '13 at 22:56
  • Hi Miko, It looks like it is a datastore issue and not an endpoint issue. I have posted another quesion stackoverflow question [here](http://stackoverflow.com/questions/16626712/unable-to-get-saved-entity-using-objectify). – Sathya May 21 '13 at 02:11

1 Answers1

0

It turns out this is not an issue with cloud end point.

I am using objectify as my data access API and I had forgotten to add objectify filter in web.xml as mentioned in Objectify wiki page

I added the following in my web.xml and the problem was solved.

<filter>
    <filter-name>ObjectifyFilter</filter-name>
    <filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ObjectifyFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Sathya
  • 1,076
  • 1
  • 8
  • 17