@Override
  protected void doExportStagedModel(
      PortletDataContext portletDataContext, DLFileEntryType fileEntryType) throws Exception {

    Element fileEntryTypeElement = portletDataContext.getExportDataElement(fileEntryType);

    List<DDMStructure> ddmStructures = fileEntryType.getDDMStructures();

    for (DDMStructure ddmStructure : ddmStructures) {
      com.liferay.dynamic.data.mapping.model.DDMStructure structure =
          _ddmStructureLocalService.getStructure(ddmStructure.getStructureId());

      Element referenceElement =
          StagedModelDataHandlerUtil.exportReferenceStagedModel(
              portletDataContext,
              fileEntryType,
              structure,
              PortletDataContext.REFERENCE_TYPE_STRONG);

      referenceElement.addAttribute(
          "structure-id", StringUtil.valueOf(ddmStructure.getStructureId()));
    }

    long defaultUserId = UserLocalServiceUtil.getDefaultUserId(fileEntryType.getCompanyId());

    if (defaultUserId == fileEntryType.getUserId()) {
      fileEntryTypeElement.addAttribute("preloaded", "true");
    }

    portletDataContext.addClassedModel(
        fileEntryTypeElement, ExportImportPathUtil.getModelPath(fileEntryType), fileEntryType);
  }
  @Override
  protected void doExportStagedModel(
      PortletDataContext portletDataContext, DLFileEntryType fileEntryType) throws Exception {

    Element fileEntryTypeElement = portletDataContext.getExportDataElement(fileEntryType);

    List<DDMStructure> ddmStructures = fileEntryType.getDDMStructures();

    for (DDMStructure ddmStructure : ddmStructures) {
      StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, ddmStructure);

      Element referenceElement =
          portletDataContext.addReferenceElement(
              fileEntryType,
              fileEntryTypeElement,
              ddmStructure,
              PortletDataContext.REFERENCE_TYPE_STRONG,
              false);

      referenceElement.addAttribute(
          "structure-id", StringUtil.valueOf(ddmStructure.getStructureId()));
    }

    portletDataContext.addClassedModel(
        fileEntryTypeElement,
        ExportImportPathUtil.getModelPath(fileEntryType),
        fileEntryType,
        DLPortletDataHandler.NAMESPACE);
  }
  protected String checkPortletPreferences(
      PortletDataContext portletDataContext,
      long companyId,
      long ownerId,
      int ownerType,
      long plid,
      String portletId,
      String xml)
      throws Exception {

    String rootPotletId = PortletConstants.getRootPortletId(portletId);

    if (!rootPotletId.equals(PortletKeys.ASSET_PUBLISHER)) {
      return xml;
    }

    PortletPreferencesImpl portletPreferences =
        (PortletPreferencesImpl)
            PortletPreferencesFactoryUtil.fromXML(
                companyId, ownerId, ownerType, plid, portletId, xml);

    Enumeration<String> enu = portletPreferences.getNames();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      String value = GetterUtil.getString(portletPreferences.getValue(name, StringPool.BLANK));

      String prefix = "queryName";

      if (value.equalsIgnoreCase("assetCategories") && name.startsWith(prefix)) {

        String index = name.substring(prefix.length(), name.length());

        String queryValuesName = "queryValues" + index;

        String[] importedCategoryPKs = portletPreferences.getValues(queryValuesName, null);

        Map<Long, Long> assetCategoryPKs =
            (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(AssetCategory.class);

        String[] newCategoryPKs = new String[importedCategoryPKs.length];

        int i = 0;

        for (String importedCategoryPK : importedCategoryPKs) {
          newCategoryPKs[i++] =
              StringUtil.valueOf(assetCategoryPKs.get(new Long(importedCategoryPK)));
        }

        portletPreferences.setValues(queryValuesName, newCategoryPKs);
      }
    }

    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
  }
  @Override
  public String getFirstNumberIncrement(String locator) {
    String firstNumber = getFirstNumber(locator);

    return StringUtil.valueOf(GetterUtil.getInteger(firstNumber) + 1);
  }
  @Override
  public String getCurrentYear() {
    Calendar calendar = Calendar.getInstance();

    return StringUtil.valueOf(calendar.get(Calendar.YEAR));
  }
  @Override
  public String getCurrentMonth() {
    Calendar calendar = Calendar.getInstance();

    return StringUtil.valueOf(calendar.get(Calendar.MONTH) + 1);
  }
  @Override
  public String getCurrentDay() {
    Calendar calendar = Calendar.getInstance();

    return StringUtil.valueOf(calendar.get(Calendar.DATE));
  }