使用沙丁鱼报告方法从CalDAV服务器查询事件 [英] Using Sardines report method to query events from CalDAV server

查看:234
本文介绍了使用沙丁鱼报告方法从CalDAV服务器查询事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用沙丁鱼(和每两周)。

I'm trying to fetch events from a CalDAV server using Sardine (and biweekly). Fetching an entire calendar is working for me:

Sardine sardine = SardineFactory.begin();
InputStream is = sardine.get(CALDAV_URL_STRING);
ICalendar iCalendar = Biweekly.parse(is).first();

现在,我想获取特定时间范围内的事件。基于这篇 构建CalDAV客户端的文章,我认为您应该使用沙丁鱼 report 方法,对吗?

Now I would like to fetch events for specific time range. Based on this "Building a CalDAV client" article, I assume you should use Sardines report method to do so, right?

如果这样,您应该如何使用该方法?它没有在Wiki中记录,并且Javadoc也不太清楚。

If so, how should you use that method? It's not documented in the wiki, and the Javadoc is also not very clear.

我应该编写自己的 SardineReport ?我似乎应该以以下内容结束:

Should I write my own SardineReport? I looks like I should end up with something like:

Sardine sardine = SardineFactory.begin();
SardineReport<List<VEvent>> report = new MyRangeReport(FROM_DATE, END_DATE);
List<VEvent> result = sardine.report(CALDAV_URL_STRING, 1, report);

我在正确的轨道上吗?没有人有任何指向如何编写自己的沙丁鱼报告的指针吗?

Am I on the right track? Does anyone have any pointers to how to write your own Sardine report?

推荐答案

您是正确的,可以运行时间范围查询吗需要发出包含日历查询的HTTP REPORT 请求。您可以在 RFC 4719第7.8.1节中找到示例。我不知道沙丁鱼,但是是的, report 听起来不错;-)

You are correct, to run a time range query you need to issue an HTTP REPORT request containing a calendar-query. You can find a sample in RFC 4719 Section 7.8.1. I don't know Sardine, but yes, report sounds right ;-)

甚至可以进一步简化:

 REPORT /bernard/work/ HTTP/1.1
 Host: cal.example.com
 Depth: 1
 Content-Type: application/xml; charset="utf-8"
 Content-Length: xxxx

 <?xml version="1.0" encoding="utf-8" ?>
 <calendar-query xmlns:D="DAV:" xmlns="urn:ietf:params:xml:ns:caldav">
   <D:prop>
     <D:getetag/>
     <calendar-data />
   </D:prop>
   <filter>
     <comp-filter name="VCALENDAR">
       <comp-filter name="VEVENT">
         <time-range start="20060104T000000Z" end="20060105T000000Z"/>
       </comp-filter>
     </comp-filter>
  </filter>
</calendar-query>




我应该编写自己的SardineReport吗?

Should I write my own SardineReport?

看起来,在Sardine的GitHub上进行扫描似乎不包含CalDAV查询。您可能可以基于它们的
SyncCollectionReport.java

Looks like, scanning over the GitHub of Sardine it doesn't seem to include CalDAV queries. You can probably base yours on their SyncCollectionReport.java.

请注意,对日历查询 报告只是普通的WebDAV 207 多状态响应。不需要额外的东西。 ( Result 对象与它们的 SyncCollectionReport 相同,但没有额外的syncToken)。

Note that the response to the calendar-query REPORT is just a regular WebDAV 207 multi-status response. Nothing extra required. (the Result object would be the same like in their SyncCollectionReport but w/o the extra syncToken).

这篇关于使用沙丁鱼报告方法从CalDAV服务器查询事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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