java sharepoint,适用于Java的Sharepoint API

这篇博客介绍了如何通过Java利用SharePoint 2013的REST服务连接到SharePoint站点,获取列表中的文件,根据修改日期进行过滤,并进行额外的检查。还提到了可以使用ODATA进行更复杂的查询,以及通过CAML查询进行详细的数据检索。最后,讨论了如何将文件保存到Unix服务器。示例代码展示了使用SP.RequestExecutor执行异步请求的方法。
摘要由CSDN通过智能技术生成

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

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

2) Get the list of files listed on that page

3) Filter the files using Modified date

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

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

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.

Thanks

解决方案

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

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

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

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'

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": "" +

"" + query + "" +

""

}

},

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值