1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.oscal.tools.cli.core.commands;
7   
8   import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
9   import gov.nist.secauto.metaschema.cli.processor.command.CommandExecutionException;
10  import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor;
11  
12  import org.apache.commons.cli.CommandLine;
13  import org.apache.logging.log4j.LogManager;
14  import org.apache.logging.log4j.Logger;
15  
16  import edu.umd.cs.findbugs.annotations.NonNull;
17  
18  /**
19   * This abstract command implementation provides user feedback about extending
20   * command being deprecated in favor of the {@link ValidateCommand}.
21   */
22  public abstract class AbstractDeprecatedOscalValidationSubcommand
23      extends AbstractOscalValidationCommand {
24    private static final Logger LOGGER = LogManager.getLogger(AbstractDeprecatedOscalValidationSubcommand.class);
25  
26    @Override
27    public ICommandExecutor newExecutor(CallingContext callingContext, CommandLine commandLine) {
28      return new CommandExecutor(callingContext, commandLine);
29    }
30  
31    private final class CommandExecutor
32        extends AbstractOscalValidationCommand.OscalValidationCommandExecutor {
33  
34      private CommandExecutor(
35          @NonNull CallingContext callingContext,
36          @NonNull CommandLine commandLine) {
37        super(callingContext, commandLine);
38      }
39  
40      @Override
41      public void execute() throws CommandExecutionException {
42        LOGGER.atWarn().log("This command path is deprecated. Please use 'validate'.");
43  
44        super.execute();
45      }
46    }
47  }