public String getNodePagesRSS(
      long nodeId,
      int max,
      String type,
      double version,
      String displayStyle,
      String feedURL,
      String entryURL)
      throws PortalException, SystemException {

    WikiNodePermission.check(getPermissionChecker(), nodeId, ActionKeys.VIEW);

    WikiNode node = wikiNodePersistence.findByPrimaryKey(nodeId);

    long companyId = node.getCompanyId();
    String name = node.getName();
    String description = node.getDescription();
    List<WikiPage> pages = getNodePages(nodeId, max);
    boolean diff = false;
    Locale locale = null;

    return exportToRSS(
        companyId,
        name,
        description,
        type,
        version,
        displayStyle,
        feedURL,
        entryURL,
        pages,
        diff,
        locale);
  }
Ejemplo n.º 2
0
  protected void processSpecialPages(
      long userId, WikiNode node, Element rootElement, List<String> specialNamespaces)
      throws PortalException {

    ProgressTracker progressTracker = ProgressTrackerThreadLocal.getProgressTracker();

    List<Element> pageElements = rootElement.elements("page");

    for (int i = 0; i < pageElements.size(); i++) {
      Element pageElement = pageElements.get(i);

      String title = pageElement.elementText("title");

      if (!title.startsWith("Category:")) {
        if (isSpecialMediaWikiPage(title, specialNamespaces)) {
          rootElement.remove(pageElement);
        }

        continue;
      }

      String categoryName = title.substring("Category:".length());

      categoryName = normalize(categoryName, 75);

      Element revisionElement = pageElement.element("revision");

      String description = revisionElement.elementText("text");

      description = normalizeDescription(description);

      try {
        AssetTag assetTag = null;

        try {
          assetTag = AssetTagLocalServiceUtil.getTag(node.getCompanyId(), categoryName);
        } catch (NoSuchTagException nste) {
          ServiceContext serviceContext = new ServiceContext();

          serviceContext.setAddGroupPermissions(true);
          serviceContext.setAddGuestPermissions(true);
          serviceContext.setScopeGroupId(node.getGroupId());

          assetTag = AssetTagLocalServiceUtil.addTag(userId, categoryName, null, serviceContext);
        }

        if (Validator.isNotNull(description)) {
          AssetTagPropertyLocalServiceUtil.addTagProperty(
              userId, assetTag.getTagId(), "description", description);
        }
      } catch (SystemException se) {
        _log.error(se, se);
      }

      if ((i % 5) == 0) {
        progressTracker.setPercent((i * 10) / pageElements.size());
      }
    }
  }
Ejemplo n.º 3
0
  protected long getUserId(
      long userId, WikiNode node, String author, Map<String, String> usersMap) {

    User user = null;

    String emailAddress = usersMap.get(author);

    if (Validator.isNotNull(emailAddress)) {
      user = UserLocalServiceUtil.fetchUserByEmailAddress(node.getCompanyId(), emailAddress);
    } else {
      user =
          UserLocalServiceUtil.fetchUserByScreenName(
              node.getCompanyId(), StringUtil.toLowerCase(author));
    }

    if (user != null) {
      return user.getUserId();
    }

    return userId;
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    WikiNode newWikiNode = _persistence.create(pk);

    newWikiNode.setUuid(RandomTestUtil.randomString());

    newWikiNode.setGroupId(RandomTestUtil.nextLong());

    newWikiNode.setCompanyId(RandomTestUtil.nextLong());

    newWikiNode.setUserId(RandomTestUtil.nextLong());

    newWikiNode.setUserName(RandomTestUtil.randomString());

    newWikiNode.setCreateDate(RandomTestUtil.nextDate());

    newWikiNode.setModifiedDate(RandomTestUtil.nextDate());

    newWikiNode.setName(RandomTestUtil.randomString());

    newWikiNode.setDescription(RandomTestUtil.randomString());

    newWikiNode.setLastPostDate(RandomTestUtil.nextDate());

    newWikiNode.setStatus(RandomTestUtil.nextInt());

    newWikiNode.setStatusByUserId(RandomTestUtil.nextLong());

    newWikiNode.setStatusByUserName(RandomTestUtil.randomString());

    newWikiNode.setStatusDate(RandomTestUtil.nextDate());

    _persistence.update(newWikiNode);

    WikiNode existingWikiNode = _persistence.findByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertEquals(existingWikiNode.getUuid(), newWikiNode.getUuid());
    Assert.assertEquals(existingWikiNode.getNodeId(), newWikiNode.getNodeId());
    Assert.assertEquals(existingWikiNode.getGroupId(), newWikiNode.getGroupId());
    Assert.assertEquals(existingWikiNode.getCompanyId(), newWikiNode.getCompanyId());
    Assert.assertEquals(existingWikiNode.getUserId(), newWikiNode.getUserId());
    Assert.assertEquals(existingWikiNode.getUserName(), newWikiNode.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getCreateDate()),
        Time.getShortTimestamp(newWikiNode.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getModifiedDate()),
        Time.getShortTimestamp(newWikiNode.getModifiedDate()));
    Assert.assertEquals(existingWikiNode.getName(), newWikiNode.getName());
    Assert.assertEquals(existingWikiNode.getDescription(), newWikiNode.getDescription());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getLastPostDate()),
        Time.getShortTimestamp(newWikiNode.getLastPostDate()));
    Assert.assertEquals(existingWikiNode.getStatus(), newWikiNode.getStatus());
    Assert.assertEquals(existingWikiNode.getStatusByUserId(), newWikiNode.getStatusByUserId());
    Assert.assertEquals(existingWikiNode.getStatusByUserName(), newWikiNode.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getStatusDate()),
        Time.getShortTimestamp(newWikiNode.getStatusDate()));
  }