Examples of ParserOutput


Examples of org.jamwiki.parser.ParserOutput

  public static String parseFragment(ParserInput parserInput, String raw, int mode) throws ParserException {
    if (StringUtils.isBlank(raw)) {
      return raw;
    }
    JFlexParser parser = new JFlexParser(parserInput);
    ParserOutput parserOutput = new ParserOutput();
    return parser.parseFragment(parserOutput, raw, mode);
  }
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

      parserInput.setWikiUser(user);
      parserInput.setTopicName(topicName);
      // parserInput.setUserIpAddress(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) {
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

    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());
        categories.put(key, value);
      }
      next.addObject("categories", categories);
    }
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

    List<String> unlinkedTopics = WikiBase.getDataHandler().getAllTopicNames(
        virtualWiki);
    Topic topic;
    List<SearchResultEntry> topicLinks = null;
    ParserInput parserInput;
    ParserOutput parserOutput;
    for (String topicName : unlinkedTopics) {
      topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName,
          true, null);
      if (topic == null) {
        logger.warning("No topic found: " + virtualWiki + " / " + topicName);
        continue;
      }
      if (topic.getTopicType() != Topic.TYPE_ARTICLE) {
        continue;
      }
      // only mark them orphaned if there is neither category defined in it, nor
      // a link to it!
      // topicLinks = WikiBase.getSearchEngine().findLinkedTo(virtualWiki,
      // topicName);
      if (topicLinks == null || !topicLinks.isEmpty()) {
        continue;
      }
      parserInput = new ParserInput();
      parserInput.setContext(request.getContextPath());
      parserInput.setLocale(request.getLocale());
      parserInput.setWikiUser(ServletUtil.currentWikiUser());
      parserInput.setTopicName(topicName);
      parserInput.setUserDisplay(ServletUtil.getIpAddress(request));
      parserInput.setVirtualWiki(virtualWiki);
      parserInput.setAllowSectionEdit(false);
      parserOutput = new ParserOutput();
      ParserUtil.parse(parserInput, parserOutput, topic.getTopicContent());
      if (parserOutput.getCategories().size() == 0) {
        allItems.add(topic.getName());
      }
    }
    // FIXME - this is a nasty hack until data can be retrieved properly for
    // pagination
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

    String contents = request.getParameter("contents");
    String sectionName = "";
    if (!StringUtils.isBlank(request.getParameter("section"))) {
      // load section of topic
      int section = Integer.valueOf(request.getParameter("section"));
      ParserOutput parserOutput = new ParserOutput();
      String[] spliceResult = ParserUtil.parseSplice(parserOutput, request
          .getContextPath(), request.getLocale(), virtualWiki, topicName,
          section, contents);
      contents = spliceResult[1];
      sectionName = parserOutput.getSectionName();
    }
    if (contents == null) {
      logger.warning("The topic " + topicName + " has no content");
      throw new WikiException(new WikiMessage("edit.exception.nocontent",
          topicName));
    }
    // strip line feeds
    contents = StringUtils.remove(contents, '\r');
    String lastTopicContent = (lastTopic != null) ? StringUtils.remove(
        lastTopic.getTopicContent(), '\r') : "";
    if (lastTopic != null && StringUtils.equals(lastTopicContent, contents)) {
      // topic hasn't changed. redirect to prevent user from refreshing and
      // re-submitting
      ServletUtil.redirect(next, virtualWiki, topic.getName());
      return;
    }
    if (handleSpam(request, next, topicName, contents)) {
      this.loadEdit(request, next, pageInfo, contents, virtualWiki, topicName,
          false);
      return;
    }
    // parse for signatures and other syntax that should not be saved in raw
    // form
    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);
    ParserOutput parserOutput = ParserUtil.parseMetadata(parserInput, contents);
    // parse signatures and other values that need to be updated prior to saving
    contents = ParserUtil.parseMinimal(parserInput, contents);
    topic.setTopicContent(contents);
    // if (!StringUtils.isBlank(parserOutput.getRedirect())) {
    // // set up a redirect
    // topic.setRedirectTo(parserOutput.getRedirect());
    // topic.setTopicType(Topic.TYPE_REDIRECT);
    // } else if (topic.getTopicType() == Topic.TYPE_REDIRECT) {
    // // no longer a redirect
    // topic.setRedirectTo(null);
    // topic.setTopicType(Topic.TYPE_ARTICLE);
    // }
    int charactersChanged = StringUtils.length(contents)
        - StringUtils.length(lastTopicContent);
    TopicVersion topicVersion = new TopicVersion(user, ServletUtil
        .getIpAddress(request), request.getParameter("editComment"), contents,
        charactersChanged);
    if (request.getParameter("minorEdit") != null) {
      topicVersion.setEditType(TopicVersion.EDIT_MINOR);
    }
    WikiBase.getDataHandler().writeTopic(topic, topicVersion,
        parserOutput.getCategories(), parserOutput.getLinks());
    // // update watchlist
    WikiUserDetails userDetails = ServletUtil.currentUserDetails();
    if (!userDetails.hasRole(RoleImpl.ROLE_ANONYMOUS)) {
      // Watchlist watchlist = ServletUtil.currentWatchlist(request,
      // virtualWiki);
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

   * @throws ParserException Thrown if any error occurs during parsing.
   */
  public String parseMinimal(String raw) throws ParserException {
    long start = System.currentTimeMillis();
    String output = raw;
    ParserOutput parserOutput = new ParserOutput();
    output = this.parsePreProcess(parserOutput, output, JFlexParser.MODE_MINIMAL);
    String topicName = (!StringUtils.isBlank(this.parserInput.getTopicName())) ? this.parserInput.getTopicName() : null;
    logger.info("Parse time (parseHTML) for " + topicName + " (" + ((System.currentTimeMillis() - start) / 1000.000) + " s.)");
    return output;
  }
View Full Code Here

Examples of org.jamwiki.parser.ParserOutput

   */
  @Override
  public String parseMinimal(String raw) throws ParserException {
    long start = System.currentTimeMillis();
    String output = raw;
    ParserOutput parserOutput = new ParserOutput();
    JAMWikiModel wikiModel = new JAMWikiModel(parserInput, parserOutput, "");
    output = wikiModel.parseTemplates(raw, true);
    output = output == null ? "" : output;
    String topicName = (!StringUtils.isBlank(this.parserInput.getTopicName())) ? this.parserInput.getTopicName() : null;
    logger.info("Parse time (parseMinimal) for " + topicName + " (" + ((System.currentTimeMillis() - start) / 1000.000) + " s.)");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.