示例#1
0
  /** {@inheritDoc} */
  protected ModelAndView handle(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final Object cmd,
      final BindException errors)
      throws Exception {

    logger.debug("Getting RSS feed");

    final BaseCommand command = (BaseCommand) cmd;
    logger.debug(command);

    if (!application.isConfigured()) {
      handleError(response, "sventon has not been configured yet!");
      return null;
    }

    final RepositoryConfiguration configuration =
        application.getRepositoryConfiguration(command.getName());
    if (configuration == null) {
      handleError(response, "Repository [" + command.getName() + "] does not exist!");
      return null;
    }

    addResponseHeaders(response);

    SVNRepository repository = null;

    try {
      final List<SVNLogEntry> logEntries = new ArrayList<SVNLogEntry>();
      repository = createRepositoryConnection(request, configuration);
      command.translateRevision(getRepositoryService().getLatestRevision(repository), repository);

      logger.debug("Outputting feed for [" + command.getPath() + "]");
      logEntries.addAll(
          getRepositoryService()
              .getRevisions(
                  command.getName(),
                  repository,
                  command.getRevisionNumber(),
                  FIRST_REVISION,
                  command.getPath(),
                  configuration.getRssItemsCount(),
                  false));
      rssFeedGenerator.outputFeed(configuration, logEntries, request, response);
    } catch (SVNAuthenticationException aex) {
      logger.info(aex.getMessage());
      httpAuthenticationHandler.sendChallenge(response);
    } catch (SVNException svnex) {
      handleSVNException(response, svnex);
    } finally {
      close(repository);
    }
    return null;
  }