Package org.jamwiki

Examples of org.jamwiki.WikiMessage


      if (StringUtils.isBlank(topic)) {
        VirtualWiki virtualWiki = null;
        try {
          virtualWiki = WikiBase.getDataHandler().lookupVirtualWiki(virtualWikiName);
        } catch (DataAccessException e) {
          throw new WikiException(new WikiMessage("error.unknown", e.getMessage()), e);
        }
        topic = virtualWiki.getDefaultTopicName();
      }
      target = "/" + virtualWikiName + "/" + topic;
      if (!StringUtils.isBlank(request.getQueryString())) {
        target += "?" + request.getQueryString();
      }
    }
    next.addObject("springSecurityTargetUrlField", JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGIN_TARGET_URL_FIELD_NAME);
    HttpSession session = request.getSession(false);
    if (request.getRequestURL().indexOf(request.getRequestURI()) != -1
        && (session == null || session.getAttribute(JAMWikiAuthenticationConstants.SPRING_SECURITY_SAVED_REQUEST_SESSION_KEY) == null)) {
      // Only add a target URL if Spring Security has not saved a request in the
      // session. The request
      // URL vs URI check is needed due to the fact that the first time a user
      // is redirected by Spring
      // Security to the login page the saved request attribute is not yet
      // available in the session
      // due to weirdness and magic which I've thus far been unable to track
      // down, so comparing the URI
      // to the URL provides a way of determining if the user was redirected.
      // Anyone who can create
      // a check that reliably captures whether or not Spring Security has a
      // saved request should
      // feel free to modify the conditional above.
      next.addObject("springSecurityTargetUrl", target);
    }
    String springSecurityLoginUrl = "/" + virtualWikiName + JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGIN_URL;
    next.addObject("springSecurityLoginUrl", springSecurityLoginUrl);
    next.addObject("springSecurityUsernameField", JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGIN_USERNAME_FIELD_NAME);
    next.addObject("springSecurityPasswordField", JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGIN_PASSWORD_FIELD_NAME);
    next.addObject("springSecurityRememberMeField", JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGIN_REMEMBER_ME_FIELD_NAME);
    pageInfo.setPageTitle(new WikiMessage("login.title"));
    pageInfo.setContentJsp(JSP_LOGIN);
    pageInfo.setSpecial(true);
    if (messageObject != null) {
      next.addObject("messageObject", messageObject);
    }
View Full Code Here


   */
  protected static void viewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, WikiMessage pageTitle,
      Topic topic, boolean sectionEdit, boolean allowRedirect) throws WikiException {
    // FIXME - what should the default be for topics that don't exist?
    if (topic == null) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    // WikiUtil.validateTopicName(topic.getName());
    // if (allowRedirect
    // && topic.getTopicType() == Topic.TYPE_REDIRECT
    // && (request.getParameter("redirect") == null || !request.getParameter(
    // "redirect").equalsIgnoreCase("no"))) {
    // Topic child = null;
    // try {
    // child = WikiUtil.findRedirectedTopic(topic, 0);
    // } catch (DataAccessException e) {
    // throw new WikiException(
    // new WikiMessage("error.unknown", e.getMessage()), e);
    // }
    // if (!child.getName().equals(topic.getName())) {
    // String redirectUrl = null;
    // try {
    // redirectUrl = LinkUtil.buildTopicUrl(request.getContextPath(), topic
    // .getVirtualWiki(), topic.getName(), true);
    // } catch (DataAccessException e) {
    // throw new WikiException(new WikiMessage("error.unknown", e
    // .getMessage()), e);
    // }
    // // FIXME - hard coding
    // redirectUrl += LinkUtil.appendQueryParam("", "redirect", "no");
    // String redirectName = topic.getName();
    // pageInfo.setRedirectInfo(redirectUrl, redirectName);
    // pageTitle = new WikiMessage("topic.title", child.getName());
    // topic = child;
    // // update the page info's virtual wiki in case this redirect is to
    // // another virtual wiki
    // pageInfo.setVirtualWikiName(topic.getVirtualWiki());
    // }
    // }
    String virtualWiki = topic.getVirtualWiki();
    String topicName = topic.getName();
    // WikiUserDetails userDetails = ServletUtil.currentUserDetails();
    // if (sectionEdit
    // && !ServletUtil.isEditable(virtualWiki, topicName, userDetails)) {
    // sectionEdit = false;
    // }
    WikiUser user = ServletUtil.currentWikiUser();
    ParserInput parserInput = new ParserInput();
    parserInput.setContext(request.getContextPath());
    parserInput.setLocale(request.getLocale());
    parserInput.setWikiUser(user);
    parserInput.setTopicName(topicName);
    parserInput.setUserDisplay(ServletUtil.getIpAddress(request));
    parserInput.setVirtualWiki(virtualWiki);
    parserInput.setAllowSectionEdit(sectionEdit);
    ParserOutput parserOutput = new ParserOutput();
    String content = null;
    try {
      content = ParserUtil.parse(parserInput, parserOutput, topic.getTopicContent());
    } catch (ParserException e) {
      throw new WikiException(new WikiMessage("error.unknown", e.getMessage()), e);
    }
    if (parserOutput.getCategories().size() > 0) {
      LinkedHashMap<String, String> categories = new LinkedHashMap<String, String>();
      for (String key : parserOutput.getCategories().keySet()) {
        String value = key.substring(NamespaceHandler.NAMESPACE_CATEGORY.length() + NamespaceHandler.NAMESPACE_SEPARATOR.length());
View Full Code Here

  /**
  *
  */
  private static void checkLength(String value, int maxLength) throws WikiException {
    if (value != null && value.length() > maxLength) {
      throw new WikiException(new WikiMessage("error.fieldlength", value, Integer.valueOf(maxLength).toString()));
    }
  }
View Full Code Here

  */
  protected void validateUserDetails(WikiUserDetails userDetails) throws WikiException {
    checkLength(userDetails.getUsername(), 100);
    // do not throw exception containing password info
    if (userDetails.getPassword() != null && userDetails.getPassword().length() > 100) {
      throw new WikiException(new WikiMessage("error.fieldlength", "-", "100"));
    }
  }
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.