Exemple #1
0
  public static ExportImportConfiguration cloneExportImportConfiguration(
      ExportImportConfiguration exportImportConfiguration) throws PortalException {

    if (exportImportConfiguration == null) {
      return null;
    }

    return ExportImportConfigurationLocalServiceUtil.addExportImportConfiguration(
        exportImportConfiguration.getUserId(),
        exportImportConfiguration.getGroupId(),
        exportImportConfiguration.getName(),
        exportImportConfiguration.getDescription(),
        exportImportConfiguration.getType(),
        exportImportConfiguration.getSettingsMap(),
        exportImportConfiguration.getStatus(),
        new ServiceContext());
  }
  @Override
  protected void doReceive(Message message, MessageStatus messageStatus) throws PortalException {

    long exportImportConfigurationId = GetterUtil.getLong(message.getPayload());

    ExportImportConfiguration exportImportConfiguration =
        _exportImportConfigurationLocalService.fetchExportImportConfiguration(
            exportImportConfigurationId);

    if (exportImportConfiguration == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(
            "Unable to find export import configuration with ID " + exportImportConfigurationId);
      }

      return;
    }

    messageStatus.setPayload(exportImportConfiguration);

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    long userId = MapUtil.getLong(settingsMap, "userId");
    long sourceGroupId = MapUtil.getLong(settingsMap, "sourceGroupId");
    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
    boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout");
    long[] layoutIds = GetterUtil.getLongValues(settingsMap.get("layoutIds"));
    Map<String, String[]> parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap");

    initThreadLocals(userId, parameterMap);

    try {
      StagingUtil.publishLayouts(
          userId,
          sourceGroupId,
          targetGroupId,
          privateLayout,
          layoutIds,
          exportImportConfiguration.getName(),
          parameterMap);
    } finally {
      resetThreadLocals();
    }
  }