2013-05-15 28 views
0

我有一個使用Java中的雲端點的gae項目,這是一個非常簡單的CRUD應用程序。無法使用雲終點休息API查看保存的實體API

我有一些PUT請求更改數據存儲實體和GET請求來檢索它們。我發現GET請求總是不返回實體的最新值。這發生在幾個GET請求中。當我檢查我的數據存儲區查看器中保存的值時,我可以確認新值已正確保存。

我試着用谷歌API瀏覽器和另一個REST客戶端(稱爲Postman在Chrome網上商店中可用)。

的模式似乎是這樣的 -
1)發送PUT請求改變實體
2)發送GET請求來檢索實體。有時我會看到舊的價值,有時我會看到新的價值。我可以確認最新的數據是從數據存儲查看器保存的。這發生在多個GET請求中。

這似乎是非常基本的功能,可能是我做錯了什麼。這是我的API註解看怎麼​​樣 -

@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. 
    } 


有沒有人遇到過這樣的問題?任何幫助,將不勝感激。

[編輯] - 這看起來像一個數據存儲問題,而不是雲端點問題。我已經打開[這裏]另一個問題(Unable to get saved entity using objectify

問候,
沙迪亞

+0

你是否檢查過,如果你調用GET方法時只是PUT方法,我的意思是非常快......因爲我注意到一些延遲時堅持谷歌的數據存儲,但我沒有知道...這只是一個建議... – MikO

+0

嗨米科,它看起來像是一個數據存儲問題,而不是一個終端問題。我已經發布了另一個quesion stackoverflow問題[這裏](http://stackoverflow.com/questions/16626712/unable-to-get-saved-entity-using-objectify)。 – Sathya

回答

0

事實證明,這不是雲終點的問題。

我使用物化爲我的數據訪問API,我已經忘記了在Objectify wiki page

提到在web.xml中添加對象化過濾器我加在我的web.xml以下,問題得到了解決。

<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>