使用Java GWT复制Google Docs文档

时间:2011-01-21 15:41:51

标签: java gwt google-docs-api

根据Google文档列表数据API,可以选择复制文档: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#CopyingDocs

但是当我查看API的GWT Java文档时,缺少此菜单点。 http://code.google.com/apis/documents/docs/3.0/developers_guide_java.html

您知道吗,是否有方法在Java GWT API中复制GDocs文档?哪些可能没有记录?

查看python API,我找到了python方法: http://code.google.com/apis/documents/docs/3.0/developers_guide_python.html#CopyingDocs

1 个答案:

答案 0 :(得分:0)

我现在设法写了自己的复制请求:

t7Z3GLNuO641hOO737UH60Q替换为文档密钥,您要复制

String = "new File";
String userEmail= new CurrentUser ().getUser ().getEmail ();

String body = "<?xml version='1.0' encoding='UTF-8'?>"
      + "<entry xmlns=\"http://www.w3.org/2005/Atom\">"
      + "<id>t7Z3GLNuO641hOO737UH60Q</id>"
      + "<title>"+ title +"</title>"
      + "</entry>";

try {
  GDataRequest gdr = docsService.createRequest(Service.GDataRequest.RequestType.INSERT,
    new URL("https://docs.google.com/feeds/default/private/full/?xoauth_requestor_id="+ userEmail),
    ContentType.ATOM);

  gdr.setHeader("GData-Version", "3.0");
  OutputStream requestStream = gdr.getRequestStream();
  requestStream.write(body.getBytes());

  log.info(gdr.toString());
  gdr.execute();    
}
[.. catch]