适用于Java的Sharepoint API [英] Sharepoint API for Java
问题描述
我尝试通过Java执行以下步骤的步骤:
Steps that I am trying to perform the following steps through Java:
1)使用给定的URL连接到sharepoint站点。
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 Web服务。
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屋!