コード例 #1
0
  @Override
  public void handleRSSRequest(RSSRequest rssRequest) throws IOException {
    String feedParentFolder = null;
    String feedFile = null;
    String category = getCategory(rssRequest.getExtraUri());
    String extraURI = rssRequest.getExtraUri();
    if (extraURI == null) {
      extraURI = CoreConstants.EMPTY;
    }
    if ((!extraURI.endsWith(CoreConstants.SLASH)) && (extraURI.length() != 0)) {
      extraURI = extraURI.concat(CoreConstants.SLASH);
    }

    List<String> categories = new ArrayList<String>();
    List<String> articles = new ArrayList<String>();
    if (category != null) categories.add(category);

    IWContext iwc = getIWContext(rssRequest);
    String language = iwc.getLocale().getLanguage();

    if (StringUtil.isEmpty(extraURI)) {
      feedParentFolder = ARTICLE_RSS;
      feedFile = "all_".concat(language).concat(".xml");
    } else if (category != null) {
      feedParentFolder =
          ARTICLE_RSS.concat("category/").concat(category).concat(CoreConstants.SLASH);
      feedFile = "feed_.".concat(language).concat(".xml");
    } else {
      //	Have page URI
      feedParentFolder = ARTICLE_RSS.concat("page/").concat(extraURI);
      feedFile = "feed_".concat(language).concat(".xml");
      categories = getCategoriesByURI(extraURI, iwc);
      if (ListUtil.isEmpty(categories)) {
        articles = getArticlesByURI(extraURI, iwc);
      }
    }

    String realURI = CoreConstants.WEBDAV_SERVLET_URI + feedParentFolder + feedFile;
    if (rssFileURIsCacheList.contains(feedFile)) {
      try {
        this.dispatch(realURI, rssRequest);
      } catch (ServletException e) {
        LOGGER.log(Level.WARNING, "Error dispatching: " + realURI, e);
      }
    } else {
      //	Generate RSS and store and the dispatch to it and add a listener to that directory
      try {
        // todo code the 3 different cases (see description)
        searchForArticles(rssRequest, feedParentFolder, feedFile, categories, articles, extraURI);
        rssFileURIsCacheList.add(feedFile);

        this.dispatch(realURI, rssRequest);
      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Error while searching or dispatching: " + realURI, e);
        throw new IOException(e.getMessage());
      }
    }
  }
コード例 #2
0
  /**
   * @param rssRequest
   * @return
   */
  protected String fixURI(RSSRequest rssRequest) {
    String uri = CoreConstants.SLASH + rssRequest.getExtraUri();
    if (!uri.endsWith(CoreConstants.SLASH)) {
      uri += CoreConstants.SLASH;
    }

    if (!uri.startsWith(CoreConstants.PATH_FILES_ROOT)) {
      uri = CoreConstants.PATH_FILES_ROOT + uri;
    }
    return uri;
  }
コード例 #3
0
  @Override
  public void handleRSSRequest(RSSRequest rssRequest) throws IOException {
    String extraURI = rssRequest.getExtraUri();
    if (extraURI == null) extraURI = "";
    if ((!extraURI.endsWith("/")) && (extraURI.length() != 0)) extraURI = extraURI.concat("/");

    try {
      IWContext iwc = getIWContext(rssRequest);
      this.dispatch(
          iwc.getIWMainApplication().getApplicationContextURI()
              + "content"
              + getFeedFile(extraURI, rssRequest),
          rssRequest);
    } catch (ServletException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }