适用于 Java 的 Sharepoint API [英] Sharepoint API for Java

查看:81
本文介绍了适用于 Java 的 Sharepoint API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过 Java 执行以下步骤的步骤:

Steps that I am trying to perform the following steps through Java:

1) 使用给定 URL 连接到共享点站点.

1) Connect to a sharepoint site with a given URL.

2) 获取该页面上列出的文件列表

2) Get the list of files listed on that page

3) 使用修改日期过滤文件

3) Filter the files using Modified date

4) 使用创建日期和修改日期执行更多检查

4) Perform some more checks using Create Date and Modified Date

5) 最后将该文件保存到 Unix 框中.

5) And finally save that file(s) into the Unix box.

截至目前,我能够访问特定文件并通读它.但是,我需要在阅读文件之前掌握它的元数据.是否有 API 或方法可以在 Java 中完成所有这些操作.

As of now, I am able to access a particular file and read through it. However I need to get hold of file's metadata before reading it. Is there an API or a way to do all these in Java.

谢谢

推荐答案

使用 SharePoint 2013,REST 服务将使您的生活更轻松.在以前的版本中,您可以使用旧的 SOAP 网络服务.

With SharePoint 2013, the REST services will make your life easier. In previous versions, you could use the good old SOAP web services.

例如,您可以使用 REST API 上的此查询连接到列表:

For instance, you could connect to a list with this query on the REST API:

http://server/site/_api/lists/getbytitle('listname')/items

这将为您提供该列表中的所有项目.使用 OData,您可以执行其他操作,例如过滤:

This will give you all items from that list. With OData you can do additional stuff like filtering:

$filter=StartDate ge datetime'2015-05-21T00%3a00%3a00'

此外,您可以向这些服务提供 CAML 查询,从而允许您定义详细的查询.这是 Javascript 中的示例:

Additionally, you can provide CAML queries to these services, allowing you to define detailed queries. Here's an example in Javascript:

var re = new SP.RequestExecutor(webUrl);
re.executeAsync({
url: "http://server/site/_api/web/lists/getbytitle('listname')/GetItems",
method: 'POST',
headers: { 
    "Accept": "application/json; odata=verbose",
    "Content-Type": "application/json; odata=verbose"
  },
body: { 
    "query" : {
      "__metadata": {
        "type": "SP.CamlQuery" 
      },
      "ViewXml": "<View>" +
        "<Query>" + query + "</Query>" +                       
      "</View>"
    }
  },
success: successHandler,
error: errorHandler
});

如果所有这些都不能提供足够的灵活性,您不妨将这些列表项保存在内存中,并在您的(服务器端)代码中做额外的工作.

If all of this doesn't provide enough flexibility, you might as well take these list items in memory and do additional work in your (server side) code.

这篇关于适用于 Java 的 Sharepoint API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆