Package org.jamwiki

Examples of org.jamwiki.WikiMessage


   */
  private void view(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    String topicName = WikiUtil.getTopicFromRequest(request);
    String virtualWiki = pageInfo.getVirtualWikiName();
    if (StringUtils.isBlank(topicName)) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    Topic topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName, false, null);
    if (topic == null) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    String commentsPage = WikiUtil.extractCommentsLink(topicName);
    Topic commentsTopic = WikiBase.getDataHandler().lookupTopic(virtualWiki, commentsPage, false, null);
    if (commentsTopic != null) {
      // add option to also move comments page
      next.addObject("moveCommentsPage", commentsPage);
    }
    WikiMessage pageTitle = new WikiMessage("move.title", topicName);
    pageInfo.setPageTitle(pageTitle);
    pageInfo.setContentJsp(JSP_MOVE);
    pageInfo.setTopicName(topicName);
    String moveDestination = (StringUtils.isBlank(request.getParameter("moveDestination")) ? topicName : request.getParameter("moveDestination"));
    next.addObject("moveDestination", moveDestination);
View Full Code Here


    List<LogItem> logItems = WikiBase.getDataHandler().getLogItems(virtualWiki, logType, pagination, true);
    next.addObject("logItems", logItems);
    next.addObject("logTypes", LogItem.LOG_TYPES);
    int numLogs = logItems.size();
    next.addObject("numLogs", numLogs);
    pageInfo.setPageTitle(new WikiMessage("log.title"));
    pageInfo.setContentJsp(JSP_LOG);
    pageInfo.setSpecial(true);
  }
View Full Code Here

   */
  private void print(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    String virtualWiki = pageInfo.getVirtualWikiName();
    String topicName = WikiUtil.getTopicFromRequest(request);
    if (StringUtils.isBlank(topicName)) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    Topic topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName, false, null);
    if (topic == null) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    WikiMessage pageTitle = new WikiMessage("topic.title", topicName);
    ServletUtil.viewTopic(request, next, pageInfo, pageTitle, topic, false, true);
  }
View Full Code Here

   */
  private void view(HttpServletRequest request, ModelAndView next,
      WikiPageInfo pageInfo) throws Exception {
    pageInfo.setContentJsp(JSP_SETUP);
    pageInfo.setSpecial(true);
    pageInfo.setPageTitle(new WikiMessage("setup.title",
        WikiVersion.CURRENT_WIKI_VERSION));
    List<WikiConfigurationObject> dataHandlers = WikiConfiguration
        .getInstance().getDataHandlers();
    next.addObject("dataHandlers", dataHandlers);
    WikiMessage logMessage = new WikiMessage("setup.help.logfile", WikiLogger
        .getDefaultLogFile(), WikiLogger.getLogConfigFile());
    next.addObject("logMessage", logMessage);
  }
View Full Code Here

    if (!(t instanceof WikiException)) {
      logger.severe("Servlet error", t);
    }
    ModelAndView next = new ModelAndView("wiki");
    WikiPageInfo pageInfo = new WikiPageInfo(request);
    pageInfo.setPageTitle(new WikiMessage("error.title"));
    pageInfo.setContentJsp(JSP_ERROR);
    pageInfo.setSpecial(true);
    if (t instanceof WikiException) {
      WikiException we = (WikiException) t;
      next.addObject("messageObject", we.getWikiMessage());
    } else {
      next.addObject("messageObject", new WikiMessage("error.unknown", t
          .toString()));
    }
    try {
      this.loadLayout(request, next, pageInfo);
    } catch (Exception err) {
View Full Code Here

      logger.severe(msg);
      throw new Exception(msg);
    }
    List<WikiDiff> diffs = DiffUtil.diff(contents1, contents2);
    next.addObject("diffs", diffs);
    pageInfo.setPageTitle(new WikiMessage("diff.title", topicName));
    pageInfo.setTopicName(topicName);
    pageInfo.setContentJsp(JSP_DIFF);
  }
View Full Code Here

   * @param name The topic name to validate.
   * @throws WikiException Thrown if the user name is invalid.
   */
  public static void validateTopicName(String name) throws WikiException {
    if (StringUtils.isBlank(name)) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    if (PseudoTopicHandler.isPseudoTopic(name)) {
      throw new WikiException(new WikiMessage("common.exception.pseudotopic", name));
    }
    WikiLink wikiLink = LinkUtil.parseWikiLink(name);
    String namespace = StringUtils.trimToNull(wikiLink.getNamespace());
    String article = StringUtils.trimToNull(wikiLink.getArticle());
    if (StringUtils.startsWith(namespace, "/") || StringUtils.startsWith(article, "/")) {
      throw new WikiException(new WikiMessage("common.exception.name", name));
    }
    if (namespace != null && namespace.toLowerCase().equals(NamespaceHandler.NAMESPACE_SPECIAL.toLowerCase())) {
      throw new WikiException(new WikiMessage("common.exception.name", name));
    }
    Matcher m = WikiUtil.INVALID_TOPIC_NAME_PATTERN.matcher(name);
    if (m.find()) {
      throw new WikiException(new WikiMessage("common.exception.name", name));
    }
  }
View Full Code Here

   * @throws WikiException Thrown if the role is invalid.
   */
  public static void validateRole(Role role) throws WikiException {
    Matcher m = WikiUtil.INVALID_ROLE_NAME_PATTERN.matcher(role.getAuthority());
    if (!m.matches()) {
      throw new WikiException(new WikiMessage("roles.error.name", role.getAuthority()));
    }
    if (!StringUtils.isBlank(role.getDescription()) && role.getDescription().length() > 200) {
      throw new WikiException(new WikiMessage("roles.error.description"));
    }
    // FIXME - throw a user-friendly error if the role name is already in use
  }
View Full Code Here

   * @param confirmPassword Passwords must be entered twice to avoid tying errors.
   *  This field represents the confirmed password entry.
   */
  public static void validatePassword(String password, String confirmPassword) throws WikiException {
    if (StringUtils.isBlank(password)) {
      throw new WikiException(new WikiMessage("error.newpasswordempty"));
    }
    if (StringUtils.isBlank(confirmPassword)) {
      throw new WikiException(new WikiMessage("error.passwordconfirm"));
    }
    if (!password.equals(confirmPassword)) {
      throw new WikiException(new WikiMessage("admin.message.passwordsnomatch"));
    }
  }
View Full Code Here

   * @param name The username to validate.
   * @throws WikiException Thrown if the user name is invalid.
   */
  public static void validateUserName(String name) throws WikiException {
    if (StringUtils.isBlank(name)) {
      throw new WikiException(new WikiMessage("error.loginempty"));
    }
    Matcher m = WikiUtil.VALID_USER_LOGIN_PATTERN.matcher(name);
    if (!m.matches()) {
      throw new WikiException(new WikiMessage("common.exception.name", name));
    }
  }
View Full Code Here

TOP

Related Classes of org.jamwiki.WikiMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.