2
* Copyright 2005-2012 Restlet S.A.S.
4
* The contents of this file are subject to the terms of one of the following
5
* open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
6
* 1.0 (the "Licenses"). You can select the license that you prefer but you may
7
* not use this file except in compliance with one of these Licenses.
9
* You can obtain a copy of the Apache 2.0 license at
10
* http://www.opensource.org/licenses/apache-2.0
12
* You can obtain a copy of the LGPL 3.0 license at
13
* http://www.opensource.org/licenses/lgpl-3.0
15
* You can obtain a copy of the LGPL 2.1 license at
16
* http://www.opensource.org/licenses/lgpl-2.1
18
* You can obtain a copy of the CDDL 1.0 license at
19
* http://www.opensource.org/licenses/cddl1
21
* You can obtain a copy of the EPL 1.0 license at
22
* http://www.opensource.org/licenses/eclipse-1.0
24
* See the Licenses for the specific language governing permissions and
25
* limitations under the Licenses.
27
* Alternatively, you can obtain a royalty free commercial license with less
28
* limitations, transferable or non-transferable, directly at
29
* http://www.restlet.com/products/restlet-framework
31
* Restlet is a registered trademark of Restlet S.A.S.
34
package org.restlet.example.book.restlet.ch07.sec2.sub2;
36
import java.util.List;
38
import org.restlet.ext.atom.Entry;
39
import org.restlet.ext.atom.Feed;
40
import org.restlet.resource.ClientResource;
42
import com.sun.syndication.feed.synd.SyndEntry;
43
import com.sun.syndication.feed.synd.SyndFeed;
46
* Mail client updating a mail by submitting a form.
48
public class MailClient {
50
public static void main(String[] args) throws Exception {
51
ClientResource mailClient = new ClientResource(
52
"http://localhost:8111/accounts/123/feeds/xyz");
54
// Display the retrieved Atom feed and entries
55
Feed atomFeed = mailClient.get(Feed.class);
56
System.out.println("\nAtom feed: " + atomFeed.getTitle() + "\n");
58
for (Entry entry : atomFeed.getEntries()) {
59
System.out.println("Title : " + entry.getTitle());
60
System.out.println("Summary: " + entry.getSummary());
63
// Display the retrieved RSS feed and entries
64
SyndFeed rssFeed = mailClient.get(SyndFeed.class);
65
System.out.println("\nRSS feed: " + rssFeed.getTitle() + "\n");
67
@SuppressWarnings("unchecked")
68
List<SyndEntry> entries = (List<SyndEntry>) rssFeed.getEntries();
70
for (SyndEntry entry : entries) {
71
System.out.println("Title : " + entry.getTitle());
72
System.out.println("Summary: " + entry.getDescription().getValue());