您的位置:首页 > 编程语言 > Java开发

用JAVA访问Domino资源,实现Domino邮件的RSS

2010-12-08 08:21 288 查看
源代码(草草的写的,请多包涵):

package net.jite.jitebook.servlet;

import java.io.FileOutputStream;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.NotesFactory;
import lotus.domino.Session;
import lotus.domino.View;

import com.rsslibj.elements.Channel;
public class RSSServlet extends HttpServlet {
public static void main(String[] args)throws InstantiationException, ClassNotFoundException,
IllegalAccessException {
try{
Session session = NotesFactory.createSession("127.0.0.1:63148","R/chengs","7758521");
Database mail = session.getDatabase("","mail\\r.nsf");
View view = mail.getView("($Inbox)");
Document doc = view.getFirstDocument();
Channel channel=new Channel();
channel.setDescription("This is my First channel.");
channel.setLink("http://l92.168.1.7/mail/r.nsf");
channel.setTitle("Domino Mail");
channel.setImage("http://l92.168.1.7/",
"The Channel Image",
"http://localhost/foo.jpg");
while(doc !=null){
channel.addItem("http://192.168.1.7/mail/"+mail.getFileName()+"/0/"+doc.getNoteID(),doc.getItemValueString("subject"),doc.getItemValueString("body")).setDcContributor("roc");
doc = view.getNextDocument(doc);
}
PrintWriter pw = new PrintWriter(new FileOutputStream("E:\\SoftWare\\Lotus\\Domino\\Data\\domino\\html\\mail.xml"));
pw.print(channel.getFeed("rss"));
pw.close();
}
catch(Exception e){
e.printStackTrace();
}

}
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: