protected File[] exportLayouts(long userGroupId, Map<String, String[]> parameterMap)
      throws PortalException {

    File[] files = new File[2];

    UserGroup userGroup = userGroupPersistence.findByPrimaryKey(userGroupId);

    User user = userLocalService.getUser(GetterUtil.getLong(PrincipalThreadLocal.getName()));

    Group group = userGroup.getGroup();

    if (userGroup.hasPrivateLayouts()) {
      Map<String, Serializable> exportLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildExportLayoutSettingsMap(
              user,
              group.getGroupId(),
              true,
              ExportImportHelperUtil.getAllLayoutIds(group.getGroupId(), true),
              parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT,
              exportLayoutSettingsMap);

      files[0] = exportImportLocalService.exportLayoutsAsFile(exportImportConfiguration);
    }

    if (userGroup.hasPublicLayouts()) {
      Map<String, Serializable> exportLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildExportLayoutSettingsMap(
              user,
              group.getGroupId(),
              false,
              ExportImportHelperUtil.getAllLayoutIds(group.getGroupId(), false),
              parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT,
              exportLayoutSettingsMap);

      files[1] = exportImportLocalService.exportLayoutsAsFile(exportImportConfiguration);
    }

    return files;
  }
예제 #2
0
  protected static ExportImportConfiguration buildDefaultRemotePublishingExportImportConfiguration(
      User user,
      long sourceGroupId,
      boolean privateLayout,
      String remoteAddress,
      int remotePort,
      String remotePathContext,
      boolean secureConnection,
      long remoteGroupId,
      Map<String, String[]> parameterMap)
      throws PortalException {

    Map<String, Serializable> publishLayoutRemoteSettingsMap =
        ExportImportConfigurationSettingsMapFactory.buildPublishLayoutRemoteSettingsMap(
            user.getUserId(),
            sourceGroupId,
            privateLayout,
            ExportImportHelperUtil.getAllLayoutIdsMap(sourceGroupId, privateLayout),
            parameterMap,
            remoteAddress,
            remotePort,
            remotePathContext,
            secureConnection,
            remoteGroupId,
            privateLayout,
            user.getLocale(),
            user.getTimeZone());

    return ExportImportConfigurationLocalServiceUtil.addDraftExportImportConfiguration(
        user.getUserId(),
        ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE,
        publishLayoutRemoteSettingsMap);
  }
  protected void importLayouts(
      long userId,
      Map<String, String[]> parameterMap,
      File privateLayoutsFile,
      File publicLayoutsFile)
      throws PortalException {

    User user = userPersistence.findByPrimaryKey(userId);

    long groupId = user.getGroupId();

    if (privateLayoutsFile != null) {
      Map<String, Serializable> importLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildImportLayoutSettingsMap(
              user, groupId, true, null, parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_IMPORT_LAYOUT,
              importLayoutSettingsMap);

      exportImportLocalService.importLayouts(exportImportConfiguration, privateLayoutsFile);
    }

    if (publicLayoutsFile != null) {
      Map<String, Serializable> importLayoutSettingsMap =
          ExportImportConfigurationSettingsMapFactory.buildImportLayoutSettingsMap(
              user, groupId, false, null, parameterMap);

      ExportImportConfiguration exportImportConfiguration =
          exportImportConfigurationLocalService.addDraftExportImportConfiguration(
              user.getUserId(),
              ExportImportConfigurationConstants.TYPE_IMPORT_LAYOUT,
              importLayoutSettingsMap);

      exportImportLocalService.importLayouts(exportImportConfiguration, publicLayoutsFile);
    }
  }
예제 #4
0
  public static ExportImportConfiguration buildDefaultLocalPublishingExportImportConfiguration(
      User user,
      long sourceGroupId,
      long targetGroupId,
      boolean privateLayout,
      Map<String, String[]> parameterMap)
      throws PortalException {

    Map<String, Serializable> publishLayoutLocalSettingsMap =
        ExportImportConfigurationSettingsMapFactory.buildPublishLayoutLocalSettingsMap(
            user,
            sourceGroupId,
            targetGroupId,
            privateLayout,
            ExportImportHelperUtil.getAllLayoutIds(sourceGroupId, privateLayout),
            parameterMap);

    return ExportImportConfigurationLocalServiceUtil.addDraftExportImportConfiguration(
        user.getUserId(),
        ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_LOCAL,
        publishLayoutLocalSettingsMap);
  }