Package org.jamwiki.model

Examples of org.jamwiki.model.Topic


            + wiki.generatePageId(FilterUtil.normalizeWikiLink(decodedName)), OlatWikiDataHandler.class);
      } catch (UnsupportedEncodingException e) {
        //
      }
    }
    Topic topic = new Topic();
    if (decodedName.startsWith(IMAGE_NAMESPACE)) {
      String imageName = topicName.substring(IMAGE_NAMESPACE.length());
      if (!wiki.mediaFileExists(imageName)) return null;
      topic.setName(imageName);
      topic.setTopicType(Topic.TYPE_IMAGE);
      return topic;
    } else if (decodedName.startsWith(MEDIA_NAMESPACE)) {
      String mediaName = topicName.substring(MEDIA_NAMESPACE.length(), topicName.length());
      if (!wiki.mediaFileExists(mediaName)) return null;
      topic.setName(mediaName);
      topic.setTopicType(Topic.TYPE_FILE);
      return topic;
    }
    if (wiki.pageExists(wiki.generatePageId(FilterUtil.normalizeWikiLink(decodedName)))) {
      topic.setName(topicName);
      return topic;
    }
    return null;
  }
View Full Code Here


  /**
   * @see org.jamwiki.DataHandler#lookupTopic(java.lang.String, java.lang.String, boolean, java.lang.Object)
   */
  public Topic lookupTopic(String virtualWiki, String topicName, boolean deleteOK, Object transactionObject) throws Exception {
    Topic topic = new Topic();
    if (topicName.startsWith("Image:")) { //TODO:gs:b now about the german "Bild"
      String imageName = topicName.substring(NamespaceHandler.NAMESPACE_IMAGE.length() + 1);
      topic.setName(imageName);
      topic.setTopicType(Topic.TYPE_IMAGE);
      return topic;
    }
      topic.setName(topicName);
      return topic;
  }
View Full Code Here

    if (result != null) {
      return result;
    }
    try {
      topicName = topicName.replaceAll("_", " ");
      Topic topic = WikiBase.getDataHandler().lookupTopic(fParserInput.getVirtualWiki(), namespace + ':' + topicName, false, null);
      if (topic == null) {
        return null;
      }
      return topic.getTopicContent();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return result;
  }
View Full Code Here

    return page;
  }

  public static Topic update(Topic page,
      LinkedHashMap<String, String> categories) {
    Topic existingEntity = null;
    try {
      Objectify ofy = OS.begin();
      existingEntity = ofy.get(Topic.class, page.getName());
      existingEntity.setName(page.getName());
      existingEntity.setTopicContent(page.getTopicContent());
      ofy.put(existingEntity);
      // if (catList != null && catList.size() > 0) {
      // ofy.put(catList);
      // }
      cache.put(existingEntity.getName(), existingEntity);

    } catch (EntityNotFoundException enf) {
    }
    return existingEntity;
  }
View Full Code Here

    Objectify ofy = OS.begin();
    ofy.delete(page);
  }

  public static Topic findByTitle(String title) {
    Topic page = (Topic) cache.get(title);
    if (page != null) {
      return page;
    }
    try {
      Objectify ofy = OS.begin();
      page = ofy.get(new Key<Topic>(Topic.class, title));
      // Query<Topic> q = ofy.query(Topic.class);
      // q.filter("title", title);
      // page = ofy.prepare(q).asSingle();
      cache.put(page.getName(), page);
      return page;
    } catch (EntityNotFoundException enfe) {
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public static String getHTMLContent(String title) {
    Topic topic = findByTitle(title);
    if (topic != null) {

      String virtualWiki = topic.getVirtualWiki();
      String topicName = topic.getName();
      // WikiUserDetails userDetails = ServletUtil.currentUserDetails();
      // if (sectionEdit && !ServletUtil.isEditable(virtualWiki, topicName,
      // userDetails)) {
      boolean 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.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) {
        throw new WikiException(
            new WikiMessage("error.unknown", e.getMessage()), e);
      }
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;
    }
    WikiLink fromWikiLink = LinkUtil.parseWikiLink(moveFrom);
    WikiLink destinationWikiLink = LinkUtil.parseWikiLink(moveDestination);
    if (!StringUtils.equals(fromWikiLink.getNamespace(), destinationWikiLink.getNamespace())) {
      // do not allow moving into or out of image & category namespace
      if (StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY)
          || StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY_COMMENTS)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY_COMMENTS)
        ) {
        next.addObject("messageObject", new WikiMessage("move.exception.namespacecategory"));
        this.view(request, next, pageInfo);
        return false;
      } else if (StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE)
          || StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE_COMMENTS)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE_COMMENTS)
        ) {
        next.addObject("messageObject", new WikiMessage("move.exception.namespaceimage"));
        this.view(request, next, pageInfo);
        return false;
      }
    }
    WikiUserDetails userDetails = ServletUtil.currentUserDetails();
    if (!ServletUtil.isMoveable(virtualWiki, moveFrom, userDetails)) {
      this.view(request, next, pageInfo);
      next.addObject("messageObject", new WikiMessage("move.exception.permission", moveFrom));
      return false;
    }
    if (!WikiBase.getDataHandler().canMoveTopic(fromTopic, moveDestination)) {
      this.view(request, next, pageInfo);
      next.addObject("messageObject", new WikiMessage("move.exception.destinationexists", moveDestination));
      return false;
    }
    String moveComment = request.getParameter("moveComment");
    WikiUser user = ServletUtil.currentWikiUser();
    TopicVersion topicVersion = new TopicVersion(user, ServletUtil.getIpAddress(request), moveComment, fromTopic.getTopicContent(), 0);
    topicVersion.setEditType(TopicVersion.EDIT_MOVE);
    WikiBase.getDataHandler().moveTopic(fromTopic, topicVersion, moveDestination);
    return true;
  }
View Full Code Here

    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);
View Full Code Here

    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

      return LinkUtil.buildInternalLinkHtml(context, virtualWiki, uploadLink,
          topicName, "edit", null, true);
    }
    // WikiFile wikiFile = WikiBase.getDataHandler().lookupWikiFile(virtualWiki,
    // topicName);
    Topic topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName,
        false, null);
    StringBuffer html = new StringBuffer();
    // if (topic.getTopicType() == Topic.TYPE_FILE) {
    // // file, not an image
    // if (StringUtils.isBlank(caption)) {
View Full Code Here

TOP

Related Classes of org.jamwiki.model.Topic

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.