0

我可以使用 Java API 在文件夹/集合中插入 Google 文档。但我想将此文档放在多个文件夹中。方法

public void addFolder(Person owner, java.lang.String folderName)

已弃用。在 javadoc 中,它指的是:BaseEntry.addLink(Link). 我尝试使用该方法如下:

docEntry.addLink(DocumentListLink.Rel.PARENT, Link.Type.ATOM,
        folderEntry.getSelfLink().getHref());

这个方法不行,可能是我用错了参数。那么如何将文档链接到多个文件夹/集合?

4

1 回答 1

0

在这里找到它:http: //gdata-java-client.googlecode.com/svn/trunk/java/sample/docs/DocumentList.java

使用以下方法中的代码将文档两次插入到不同的集合中。我仍然很好奇为什么 addlink 方法对我来说失败了。

  public DocumentListEntry moveObjectToFolder(String resourceId, String folderId)
      throws IOException, MalformedURLException, ServiceException, DocumentListException {
    if (resourceId == null || folderId == null) {
      throw new DocumentListException("null passed in for required parameters");
    }

    DocumentListEntry doc = new DocumentListEntry();
    doc.setId(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId).toString());

    URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderId + URL_FOLDERS);
    return service.insert(url, doc);
  }
于 2012-04-30T14:51:35.043 回答