Package org.jamwiki

Examples of org.jamwiki.WikiException


      String content = null;
      try {
        content = ParserUtil.parse(parserInput, parserOutput, topic
            .getTopicContent());
      } catch (ParserException e) {
        throw new WikiException(
            new WikiMessage("error.unknown", e.getMessage()), e);
      }
      return content;
      // return topic.getHtmlContent();
    }
View Full Code Here


   *
   */
  private void move(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    String topicName = WikiUtil.getTopicFromRequest(request);
    if (StringUtils.isBlank(topicName)) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    WikiMessage pageTitle = new WikiMessage("move.title", topicName);
    pageInfo.setPageTitle(pageTitle);
    pageInfo.setTopicName(topicName);
    String moveDestination = request.getParameter("moveDestination");
View Full Code Here

   */
  private boolean movePage(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, String moveFrom, String moveDestination) throws Exception {
    String virtualWiki = pageInfo.getVirtualWikiName();
    Topic fromTopic = WikiBase.getDataHandler().lookupTopic(virtualWiki, moveFrom, false, null);
    if (fromTopic == null) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    if (StringUtils.isBlank(moveDestination)) {
      next.addObject("messageObject", new WikiMessage("move.exception.nodestination"));
      this.view(request, next, pageInfo);
      return false;
View Full Code Here

   */
  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
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

    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 {
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.WikiException

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.