/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.apache.geode.management.internal.cli.commands;

import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.Set;

import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.management.internal.cli.CliUtil;

class DiskStoreCommandsUtils {
  static void configureLogging(final List<String> commandList) {
    URL configUrl = LogService.class.getResource(LogService.CLI_CONFIG);
    String configFilePropertyValue = configUrl.toString();
    commandList.add("-Dlog4j.configurationFile=" + configFilePropertyValue);
  }

  static String validatedDirectories(String[] diskDirs) {
    String invalidDirectories = null;
    StringBuilder builder = null;
    File diskDir;
    for (String diskDirPath : diskDirs) {
      diskDir = new File(diskDirPath);
      if (!diskDir.exists()) {
        if (builder == null) {
          builder = new StringBuilder();
        } else if (builder.length() != 0) {
          builder.append(", ");
        }
        builder.append(diskDirPath);
      }
    }
    if (builder != null) {
      invalidDirectories = builder.toString();
    }
    return invalidDirectories;
  }

  static Set<DistributedMember> getNormalMembers(final InternalCache cache) {
    // TODO determine what this does (as it is untested and unmockable!)
    return CliUtil.getAllNormalMembers(cache);
  }
}

@@ -783,17 +783,16 @@
 se.%0A */%0A
-%0A
 package 
@@ -843,16 +843,118 @@
 mands;%0A%0A
+import static org.apache.logging.log4j.core.config.ConfigurationFactory.CONFIGURATION_FILE_PROPERTY;%0A%0A
 import j
@@ -1033,16 +1033,61 @@
 l.Set;%0A%0A
+import org.apache.commons.lang.StringUtils;%0A%0A
 import o
@@ -1329,16 +1329,17 @@
 Utils %7B%0A
+%0A
   static
@@ -1391,24 +1391,168 @@
 mandList) %7B%0A
+    String configFilePropertyValue = System.getProperty(CONFIGURATION_FILE_PROPERTY);%0A    if (StringUtils.isBlank(configFilePropertyValue)) %7B%0A  
     URL conf
@@ -1612,30 +1612,25 @@
 ONFIG);%0A    
-String
+ 
  configFileP
@@ -1662,24 +1662,30 @@
 toString();%0A
+    %7D%0A
     commandL
@@ -1699,31 +1699,43 @@
 (%22-D
-log4j.configurationFile
+%22 + CONFIGURATION_FILE_PROPERTY + %22
 =%22 +
@@ -2433,81 +2433,8 @@
 ) %7B%0A
-    // TODO determine what this does (as it is untested and unmockable!)%0A
     

Allow disk store commands to use custom log4j2 config