protected void addAssetReference(
      PortletDataContext portletDataContext,
      StagedAssetLink stagedAssetLink,
      Element stagedAssetLinkElement,
      AssetEntry assetEntry) {

    AssetRenderer<? extends StagedModel> assetRenderer = null;
    StagedModel stagedModel = null;

    try {
      assetRenderer = (AssetRenderer<? extends StagedModel>) assetEntry.getAssetRenderer();

      stagedModel = assetRenderer.getAssetObject();
    } catch (Exception e) {
      return;
    }

    if (stagedModel == null) {
      return;
    }

    portletDataContext.addReferenceElement(
        stagedAssetLink,
        stagedAssetLinkElement,
        stagedModel,
        PortletDataContext.REFERENCE_TYPE_DEPENDENCY_DISPOSABLE,
        true);
  }
  protected void exportKBArticleAttachments(
      PortletDataContext portletDataContext, Element kbArticleElement, KBArticle kbArticle)
      throws Exception {

    List<FileEntry> attachmentsFileEntries = kbArticle.getAttachmentsFileEntries();

    for (FileEntry fileEntry : attachmentsFileEntries) {
      String path = ExportImportPathUtil.getModelPath(kbArticle, fileEntry.getTitle());

      Element fileEntryElement = portletDataContext.getExportDataElement(fileEntry);

      fileEntryElement.addAttribute("path", path);
      fileEntryElement.addAttribute("file-name", fileEntry.getTitle());

      portletDataContext.addZipEntry(path, fileEntry.getContentStream());

      portletDataContext.addReferenceElement(
          kbArticle, kbArticleElement, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK, false);
    }
  }
  @Override
  protected String getExportPortletPreferencesUuid(
      PortletDataContext portletDataContext, Portlet portlet, String className, long primaryKeyLong)
      throws Exception {

    String uuid = null;

    Element rootElement = portletDataContext.getExportDataRootElement();

    if (className.equals(Organization.class.getName())) {
      Organization organization = _organizationLocalService.fetchOrganization(primaryKeyLong);

      if (organization != null) {
        uuid = organization.getUuid();

        portletDataContext.addReferenceElement(
            portlet, rootElement, organization, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);
      }
    }

    return uuid;
  }
  protected void exportTheme(PortletDataContext portletDataContext, Layout layout)
      throws Exception {

    boolean exportThemeSettings =
        MapUtil.getBoolean(
            portletDataContext.getParameterMap(), PortletDataHandlerKeys.THEME_REFERENCE);

    if (_log.isDebugEnabled()) {
      _log.debug("Export theme settings " + exportThemeSettings);
    }

    if (exportThemeSettings
        && !portletDataContext.isPerformDirectBinaryImport()
        && !layout.isInheritLookAndFeel()) {

      StagedTheme stagedTheme = new StagedThemeImpl(layout.getTheme());

      Element layoutElement = portletDataContext.getExportDataElement(layout);

      portletDataContext.addReferenceElement(
          layout, layoutElement, stagedTheme, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);
    }
  }