コード例 #1
0
  public static List<RssUrlBean> getRssUrlBeanListFromPage(int rssCompo_id, String url) {
    List<RssUrlBean> rubList = new ArrayList<RssUrlBean>();
    if (url.equals("")) return rubList;
    try {
      URL feedUrl = new URL(url);
      // SyndFeedInput:从远程读到xml结构的内容转成SyndFeedImpl实例
      SyndFeedInput input = new SyndFeedInput();
      // rome按SyndFeed类型生成rss和atom的实例,
      // SyndFeed是rss和atom实现类SyndFeedImpl的接口
      SyndFeed syndFeed = input.build(new XmlReader(feedUrl));

      List<SyndEntry> entryList = syndFeed.getEntries();
      for (SyndEntry entry : entryList) {
        RssUrlBean rub = new RssUrlBean();
        rub.setRssCompo_id(rssCompo_id);
        rub.setTitle(entry.getTitle());
        rub.setLink(entry.getUri());
        rub.setPublishedDate(CommonUtil.getStandardDate(entry.getPublishedDate().toLocaleString()));
        rub.setDescription(entry.getDescription().getValue());
        if (entry.getUpdatedDate() != null)
          rub.setUpdatedDate(CommonUtil.getStandardDate(entry.getUpdatedDate().toLocaleString()));
        rub.setAuthors(entry.getAuthor());
        rubList.add(rub);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return rubList;
  }
コード例 #2
0
ファイル: UrlsAction.java プロジェクト: haiwi-song/Haiwi
 public String addUrls() {
   urlsVO.setMsg(null);
   String msg = null;
   String checkStr = checkInput();
   if (!CommonUtil.isNullOrEmpty(checkStr)) msg = checkStr;
   else {
     UrlsBean urlsBean = new UrlsBean();
     urlsBean.setIcon("images/icon/ie.gif");
     urlsBean.setTitle(urlsVO.getTitle());
     urlsBean.setRemark(urlsVO.getRemark());
     urlsBean.setUrl(urlsVO.getUrl());
     try {
       urlsServer.addUrls(urlsBean);
       msg = "添加成功!";
       urlsVO.setTitle(null);
       urlsVO.setRemark(null);
       urlsVO.setUrl(null);
     } catch (Exception e) {
       e.printStackTrace();
       msg = "添加失败!";
     }
   }
   urlsVO.setMsg(msg);
   getUrlsList();
   return "urls";
 }
コード例 #3
0
ファイル: UrlsAction.java プロジェクト: haiwi-song/Haiwi
 private String checkInput() {
   if (CommonUtil.isNullOrEmpty(urlsVO.getTitle())) return "书签名不能为空!";
   if (CommonUtil.isNullOrEmpty(urlsVO.getUrl())) return "URL不能为空!";
   return null;
 }