geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommand.java
@CliCommand(value = {CliStrings.EXPORT_CONFIG}, help = CliStrings.EXPORT_CONFIG__HELP)
  @CliMetaData(
      interceptor = "org.apache.geode.management.internal.cli.commands.ExportConfigCommand$Interceptor",
      relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
  @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER,
      operation = ResourcePermission.Operation.READ)
  public Result exportConfig(
      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
          optionContext = ConverterHint.ALL_MEMBER_IDNAME,
          help = CliStrings.EXPORT_CONFIG__MEMBER__HELP) String[] member,
      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
          optionContext = ConverterHint.MEMBERGROUP,
          help = CliStrings.EXPORT_CONFIG__GROUP__HELP) String[] group,
      @CliOption(key = {CliStrings.EXPORT_CONFIG__DIR},
          help = CliStrings.EXPORT_CONFIG__DIR__HELP) String dir) {
    InfoResultData infoData = ResultBuilder.createInfoResultData();

    Set<DistributedMember> targetMembers = CliUtil.findMembers(group, member);
    if (targetMembers.isEmpty()) {
      return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
    }

    ResultCollector<?, ?> rc =
        CliUtil.executeFunction(this.exportConfigFunction, null, targetMembers);
    List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());

    for (CliFunctionResult result : results) {
      if (result.getThrowable() != null) {
        infoData.addLine(CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__EXCEPTION,
            result.getMemberIdOrName(), result.getThrowable()));
      } else if (result.isSuccessful()) {
        String cacheFileName = result.getMemberIdOrName() + "-cache.xml";
        String propsFileName = result.getMemberIdOrName() + "-gf.properties";
        String[] fileContent = (String[]) result.getSerializables();
        infoData.addAsFile(cacheFileName, fileContent[0], "Downloading Cache XML file: {0}", false);
        infoData.addAsFile(propsFileName, fileContent[1], "Downloading properties file: {0}",
            false);
      }
    }
    return ResultBuilder.buildResult(infoData);

  }
/**
   * Export the cache configuration in XML format.
   *
   * @param member Member for which to write the configuration
   * @param group Group or groups for which to write the configuration
   * @return Results of the attempt to write the configuration
   */
Export the cache configuration in XML format.
@param member Member for which to write the configuration
@param group Group or groups for which to write the configuration
@return Results of the attempt to write the configuration
Export the cache configuration in XML format . @param member Member for which to write the configuration @param group Group or groups for which to write the configuration @return Results of the attempt to write the configuration
@CliCommand(value = {CliStrings.EXPORT_CONFIG}, help = CliStrings.EXPORT_CONFIG__HELP)
  @CliMetaData(
      interceptor = "org.apache.geode.management.internal.cli.commands.ExportConfigCommand$Interceptor",
      relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
  @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER,
      operation = ResourcePermission.Operation.READ)
  public Result exportConfig(
      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
          optionContext = ConverterHint.ALL_MEMBER_IDNAME,
          help = CliStrings.EXPORT_CONFIG__MEMBER__HELP) String[] member,
      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
          optionContext = ConverterHint.MEMBERGROUP,
          help = CliStrings.EXPORT_CONFIG__GROUP__HELP) String[] group,
      @CliOption(key = {CliStrings.EXPORT_CONFIG__DIR},
          help = CliStrings.EXPORT_CONFIG__DIR__HELP) String dir) {
    InfoResultData infoData = ResultBuilder.createInfoResultData();
    Set<DistributedMember> targetMembers = CliUtil.findMembers(group, member);
    if (targetMembers.isEmpty()) {
      return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
    }
    ResultCollector<?, ?> rc =
        CliUtil.executeFunction(this.exportConfigFunction, null, targetMembers);
    List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
    for (CliFunctionResult result : results) {
      if (result.getThrowable() != null) {
        infoData.addLine(CliStrings.format(CliStrings.EXPORT_CONFIG__MSG__EXCEPTION,
            result.getMemberIdOrName(), result.getThrowable()));
      } else if (result.isSuccessful()) {
        String cacheFileName = result.getMemberIdOrName() + "-cache.xml";
        String propsFileName = result.getMemberIdOrName() + "-gf.properties";
        String[] fileContent = (String[]) result.getSerializables();
        infoData.addAsFile(cacheFileName, fileContent[0], "Downloading Cache XML file: {0}", false);
        infoData.addAsFile(propsFileName, fileContent[1], "Downloading properties file: {0}",
            false);
      }
    }
    return ResultBuilder.buildResult(infoData);
  }
@ CliCommand ( value = { CliStrings . EXPORT_CONFIG } , help = CliStrings . EXPORT_CONFIG__HELP ) @ CliMetaData ( interceptor = "org.apache.geode.management.internal.cli.commands.ExportConfigCommand$Interceptor" , relatedTopic = { CliStrings . TOPIC_GEODE_CONFIG } ) @ ResourceOperation ( resource = ResourcePermission . Resource . CLUSTER , operation = ResourcePermission . Operation . READ ) public Result exportConfig ( @ CliOption ( key = { CliStrings . MEMBER , CliStrings . MEMBERS } , optionContext = ConverterHint . ALL_MEMBER_IDNAME , help = CliStrings . EXPORT_CONFIG__MEMBER__HELP ) String [ ] member , @ CliOption ( key = { CliStrings . GROUP , CliStrings . GROUPS } , optionContext = ConverterHint . MEMBERGROUP , help = CliStrings . EXPORT_CONFIG__GROUP__HELP ) String [ ] group , @ CliOption ( key = { CliStrings . EXPORT_CONFIG__DIR } , help = CliStrings . EXPORT_CONFIG__DIR__HELP ) String dir ) { InfoResultData infoData = ResultBuilder . createInfoResultData ( ) ; Set < DistributedMember > targetMembers = CliUtil . findMembers ( group , member ) ; if ( targetMembers . isEmpty ( ) ) { return ResultBuilder . createUserErrorResult ( CliStrings . NO_MEMBERS_FOUND_MESSAGE ) ; } ResultCollector < ? , ? > rc = CliUtil . executeFunction ( this . exportConfigFunction , null , targetMembers ) ; List < CliFunctionResult > results = CliFunctionResult . cleanResults ( ( List < ? > ) rc . getResult ( ) ) ; for ( CliFunctionResult result : results ) { if ( result . getThrowable ( ) != null ) { infoData . addLine ( CliStrings . format ( CliStrings . EXPORT_CONFIG__MSG__EXCEPTION , result . getMemberIdOrName ( ) , result . getThrowable ( ) ) ) ; } else if ( result . isSuccessful ( ) ) { String cacheFileName = result . getMemberIdOrName ( ) + "-cache.xml" ; String propsFileName = result . getMemberIdOrName ( ) + "-gf.properties" ; String [ ] fileContent = ( String [ ] ) result . getSerializables ( ) ; infoData . addAsFile ( cacheFileName , fileContent [ 0 ] , "Downloading Cache XML file: {0}" , false ) ; infoData . addAsFile ( propsFileName , fileContent [ 1 ] , "Downloading properties file: {0}" , false ) ; } } return ResultBuilder . buildResult ( infoData ) ; }
Export the cache configuration in XML format.
Export the cache configuration in XML format .