使用“DocumentListEntry.updateMedia()”时 GData API 出现问题方法

发布于 2024-12-08 02:13:30 字数 3486 浏览 3 评论 0原文

我正在使用 GData API 中 DocumentListEntry 的 updateMedia(boolean) 方法。 有时这个命令有效,但大多数时候会抛出异常。

代码(documentList 是 DocumentListEntry 对象):

public void flush() throws IOException {
    try {
        if(((ByteArrayOutputStream)os).size()>0){
            documentList.setMediaSource(
                    new MediaByteArraySource(((ByteArrayOutputStream)os).toByteArray(), mimeType));
            documentList.updateMedia(true);
            ((ByteArrayOutputStream)os).reset();
        }
    } catch (ServiceException ex) {
        throw new IOException(ex);
    }
}

命令“documentList.updateMedia(true);”抛出这个异常:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
        at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:162)
        at com.ralph.agente.Agent.run(Agent.java:191)
        at com.ralph.agente.Agent.run(Agent.java:134)
        at company.google.conexao.RecebeObjetoThread.geraSinaisVitaisAgent(RecebeObjetoThread.java:61)
        at company.google.conexao.RecebeObjetoThread.run(RecebeObjetoThread.java:133)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: com.google.gdata.util.InvalidEntryException: Unexpected resource version ID
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>invalidResourceVersion</code><internalReason>Unexpected resource version ID</internalReason></error></errors>

        at com.company.google.io.GoogleDocsOutputStream.flush(GoogleDocsOutputStream.java:142)
        at com.company.google.io.GoogleDocsOutputStream.close(GoogleDocsOutputStream.java:148)
        at br.edu.company.google.processo.GeraSinaisVitaisAgent.bodyAgent(GeraSinaisVitaisAgent.java:133)
        ... 11 more
Caused by: com.google.gdata.util.InvalidEntryException: Unexpected resource version ID
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>invalidResourceVersion</code><internalReason>Unexpected resource version ID</internalReason></error></errors>

        at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
        at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
        at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
        at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
        at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
        at com.google.gdata.client.Service.update(Service.java:1563)
        at com.google.gdata.client.Service.update(Service.java:1530)
        at com.google.gdata.client.GoogleService.update(GoogleService.java:583)
        at com.google.gdata.client.media.MediaService.update(MediaService.java:484)
        at com.company.google.io.GoogleDocsOutputStream.flush(GoogleDocsOutputStream.java:137)

有人可以帮助我吗?

I'm using the updateMedia(boolean) method of DocumentListEntry from GData API.
Sometimes this command worked, but in the most times an exception is threw.

The code (documentList is an DocumentListEntry object):

public void flush() throws IOException {
    try {
        if(((ByteArrayOutputStream)os).size()>0){
            documentList.setMediaSource(
                    new MediaByteArraySource(((ByteArrayOutputStream)os).toByteArray(), mimeType));
            documentList.updateMedia(true);
            ((ByteArrayOutputStream)os).reset();
        }
    } catch (ServiceException ex) {
        throw new IOException(ex);
    }
}

The command "documentList.updateMedia(true);" throw's this exception:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
        at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:162)
        at com.ralph.agente.Agent.run(Agent.java:191)
        at com.ralph.agente.Agent.run(Agent.java:134)
        at company.google.conexao.RecebeObjetoThread.geraSinaisVitaisAgent(RecebeObjetoThread.java:61)
        at company.google.conexao.RecebeObjetoThread.run(RecebeObjetoThread.java:133)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: com.google.gdata.util.InvalidEntryException: Unexpected resource version ID
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>invalidResourceVersion</code><internalReason>Unexpected resource version ID</internalReason></error></errors>

        at com.company.google.io.GoogleDocsOutputStream.flush(GoogleDocsOutputStream.java:142)
        at com.company.google.io.GoogleDocsOutputStream.close(GoogleDocsOutputStream.java:148)
        at br.edu.company.google.processo.GeraSinaisVitaisAgent.bodyAgent(GeraSinaisVitaisAgent.java:133)
        ... 11 more
Caused by: com.google.gdata.util.InvalidEntryException: Unexpected resource version ID
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>invalidResourceVersion</code><internalReason>Unexpected resource version ID</internalReason></error></errors>

        at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
        at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
        at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
        at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
        at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
        at com.google.gdata.client.Service.update(Service.java:1563)
        at com.google.gdata.client.Service.update(Service.java:1530)
        at com.google.gdata.client.GoogleService.update(GoogleService.java:583)
        at com.google.gdata.client.media.MediaService.update(MediaService.java:484)
        at com.company.google.io.GoogleDocsOutputStream.flush(GoogleDocsOutputStream.java:137)

Someone can help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℡寂寞咖啡 2024-12-15 02:13:30

我发现缺少命令“documentList.setETag(String)”。然后我设置了一个“*”字符,它起作用了!

参考:http://code.google.com /p/gdata-java-client/issues/detail?id=250#c0

I've discovered that was missing the command "documentList.setETag(String)". Then I set an '*' character, and it works!

Reference: http://code.google.com/p/gdata-java-client/issues/detail?id=250#c0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文