protected void exportAssetTag(
      PortletDataContext portletDataContext, AssetTag assetTag, Element assetTagsElement)
      throws SystemException, PortalException {

    String path = getAssetTagPath(portletDataContext, assetTag.getTagId());

    if (!portletDataContext.isPathNotProcessed(path)) {
      return;
    }

    Element assetTagElement = assetTagsElement.addElement("tag");

    assetTagElement.addAttribute("path", path);

    assetTag.setUserUuid(assetTag.getUserUuid());

    portletDataContext.addZipEntry(path, assetTag);

    List<AssetTagProperty> assetTagProperties =
        AssetTagPropertyLocalServiceUtil.getTagProperties(assetTag.getTagId());

    for (AssetTagProperty assetTagProperty : assetTagProperties) {
      Element propertyElement = assetTagElement.addElement("property");

      propertyElement.addAttribute("key", assetTagProperty.getKey());
      propertyElement.addAttribute("value", assetTagProperty.getValue());
    }

    portletDataContext.addPermissions(AssetTag.class, assetTag.getTagId());
  }
  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());
      }
    }
  }