// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/base/BaseDeployerRunner.java
// public abstract class BaseDeployerRunner implements AgentBuildRunner {
//   protected final ExtensionHolder myExtensionHolder;
// 
//   public BaseDeployerRunner(@NotNull final ExtensionHolder extensionHolder) {
//     myExtensionHolder = extensionHolder;
//   }
// 
//   @NotNull
//   @Override
//   public BuildProcess createBuildProcess(@NotNull final AgentRunningBuild runningBuild,
//                                          @NotNull final BuildRunnerContext context) throws RunBuildException {
// 
//     final Map<String, String> runnerParameters = context.getRunnerParameters();
//     final String username = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_USERNAME));
//     final String password = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_PASSWORD));
//     final String target = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_TARGET_URL));
//     final String sourcePaths = runnerParameters.get(DeployerRunnerConstants.PARAM_SOURCE_PATH);
// 
//     final Collection<ArtifactsPreprocessor> preprocessors = myExtensionHolder.getExtensions(ArtifactsPreprocessor.class);
// 
//     final ArtifactsBuilder builder = new ArtifactsBuilder();
//     builder.setPreprocessors(preprocessors);
//     builder.setBaseDir(runningBuild.getCheckoutDirectory());
//     builder.setArtifactsPaths(sourcePaths);
// 
//     final List<ArtifactsCollection> artifactsCollections = builder.build();
// 
//     return getDeployerProcess(context, username, password, target, artifactsCollections);
//   }
// 
//   protected abstract BuildProcess getDeployerProcess(@NotNull final BuildRunnerContext context,
//                                                      @NotNull final String username,
//                                                      @NotNull final String password,
//                                                      @NotNull final String target,
//                                                      @NotNull final List<ArtifactsCollection> artifactsCollections) throws RunBuildException;
// 
//   @NotNull
//   @Override
//   public abstract AgentBuildRunnerInfo getRunnerInfo();
// }
// 
// Path: deploy-runner-common/src/main/java/jetbrains/buildServer/deployer/common/FTPRunnerConstants.java
// public class FTPRunnerConstants {
//   public static final String PARAM_AUTH_METHOD = "jetbrains.buildServer.deployer.ftp.authMethod";
//   public static final String PARAM_TRANSFER_MODE = "jetbrains.buildServer.deployer.ftp.transferMethod";
//   public static final String TRANSFER_MODE_AUTO = "AUTO";
//   public static final String TRANSFER_MODE_BINARY = "BINARY";
//   public static final String TRANSFER_MODE_ASCII = "ASCII";
//   public static final String AUTH_METHOD_USER_PWD = "USER_PWD";
//   public static final String AUTH_METHOD_ANONYMOUS = "ANONYMOUS";
//   public static final String PARAM_SSL_MODE = "jetbrains.buildServer.deployer.ftp.securityMode";
//   public static final String DATA_CHANNEL_PROTECTION = "jetbrains.buildServer.deployer.ftp.dataChannelProtection";
//   public static final String PARAM_FTP_MODE = "jetbrains.buildServer.deployer.ftp.ftpMode";
//   public static final String PARAM_FTP_CONNECT_TIMEOUT = "jetbrains.deployer.ftp.connectTimeout";
//   public static final String PARAM_FTP_CONTROL_KEEP_ALIVE_TIMEOUT = "jetbrains.deployer.ftp.controlKeepAliveTimeout.seconds";
// }


import jetbrains.buildServer.ExtensionHolder;
import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.agent.AgentBuildRunnerInfo;
import jetbrains.buildServer.agent.BuildProcess;
import jetbrains.buildServer.agent.BuildRunnerContext;
import jetbrains.buildServer.agent.impl.artifacts.ArtifactsCollection;
import jetbrains.buildServer.deployer.agent.base.BaseDeployerRunner;
import jetbrains.buildServer.deployer.common.FTPRunnerConstants;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
/*
 * Copyright 2000-2022 JetBrains s.r.o.
 *
 * Licensed 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 jetbrains.buildServer.deployer.agent.ftp;



public class FtpDeployerRunner extends BaseDeployerRunner {

  public FtpDeployerRunner(@NotNull final ExtensionHolder extensionHolder) {
    super(extensionHolder);
  }


  @Override
  protected BuildProcess getDeployerProcess(@NotNull final BuildRunnerContext context,
                                            @NotNull final String username,
                                            @NotNull final String password,
                                            @NotNull final String target,
                                            @NotNull final List<ArtifactsCollection> artifactsCollections) throws RunBuildException {
    final Map<String, String> runnerParameters = context.getRunnerParameters();
// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/base/BaseDeployerRunner.java
// public abstract class BaseDeployerRunner implements AgentBuildRunner {
//   protected final ExtensionHolder myExtensionHolder;
// 
//   public BaseDeployerRunner(@NotNull final ExtensionHolder extensionHolder) {
//     myExtensionHolder = extensionHolder;
//   }
// 
//   @NotNull
//   @Override
//   public BuildProcess createBuildProcess(@NotNull final AgentRunningBuild runningBuild,
//                                          @NotNull final BuildRunnerContext context) throws RunBuildException {
// 
//     final Map<String, String> runnerParameters = context.getRunnerParameters();
//     final String username = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_USERNAME));
//     final String password = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_PASSWORD));
//     final String target = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_TARGET_URL));
//     final String sourcePaths = runnerParameters.get(DeployerRunnerConstants.PARAM_SOURCE_PATH);
// 
//     final Collection<ArtifactsPreprocessor> preprocessors = myExtensionHolder.getExtensions(ArtifactsPreprocessor.class);
// 
//     final ArtifactsBuilder builder = new ArtifactsBuilder();
//     builder.setPreprocessors(preprocessors);
//     builder.setBaseDir(runningBuild.getCheckoutDirectory());
//     builder.setArtifactsPaths(sourcePaths);
// 
//     final List<ArtifactsCollection> artifactsCollections = builder.build();
// 
//     return getDeployerProcess(context, username, password, target, artifactsCollections);
//   }
// 
//   protected abstract BuildProcess getDeployerProcess(@NotNull final BuildRunnerContext context,
//                                                      @NotNull final String username,
//                                                      @NotNull final String password,
//                                                      @NotNull final String target,
//                                                      @NotNull final List<ArtifactsCollection> artifactsCollections) throws RunBuildException;
// 
//   @NotNull
//   @Override
//   public abstract AgentBuildRunnerInfo getRunnerInfo();
// }
// 
// Path: deploy-runner-common/src/main/java/jetbrains/buildServer/deployer/common/FTPRunnerConstants.java
// public class FTPRunnerConstants {
//   public static final String PARAM_AUTH_METHOD = "jetbrains.buildServer.deployer.ftp.authMethod";
//   public static final String PARAM_TRANSFER_MODE = "jetbrains.buildServer.deployer.ftp.transferMethod";
//   public static final String TRANSFER_MODE_AUTO = "AUTO";
//   public static final String TRANSFER_MODE_BINARY = "BINARY";
//   public static final String TRANSFER_MODE_ASCII = "ASCII";
//   public static final String AUTH_METHOD_USER_PWD = "USER_PWD";
//   public static final String AUTH_METHOD_ANONYMOUS = "ANONYMOUS";
//   public static final String PARAM_SSL_MODE = "jetbrains.buildServer.deployer.ftp.securityMode";
//   public static final String DATA_CHANNEL_PROTECTION = "jetbrains.buildServer.deployer.ftp.dataChannelProtection";
//   public static final String PARAM_FTP_MODE = "jetbrains.buildServer.deployer.ftp.ftpMode";
//   public static final String PARAM_FTP_CONNECT_TIMEOUT = "jetbrains.deployer.ftp.connectTimeout";
//   public static final String PARAM_FTP_CONTROL_KEEP_ALIVE_TIMEOUT = "jetbrains.deployer.ftp.controlKeepAliveTimeout.seconds";
// }


// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/ftp/FtpDeployerRunner.java
import jetbrains.buildServer.ExtensionHolder;
import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.agent.AgentBuildRunnerInfo;
import jetbrains.buildServer.agent.BuildProcess;
import jetbrains.buildServer.agent.BuildRunnerContext;
import jetbrains.buildServer.agent.impl.artifacts.ArtifactsCollection;
import jetbrains.buildServer.deployer.agent.base.BaseDeployerRunner;
import jetbrains.buildServer.deployer.common.FTPRunnerConstants;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;

/*
 * Copyright 2000-2022 JetBrains s.r.o.
 *
 * Licensed 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 jetbrains.buildServer.deployer.agent.ftp;



public class FtpDeployerRunner extends BaseDeployerRunner {

  public FtpDeployerRunner(@NotNull final ExtensionHolder extensionHolder) {
    super(extensionHolder);
  }


  @Override
  protected BuildProcess getDeployerProcess(@NotNull final BuildRunnerContext context,
                                            @NotNull final String username,
                                            @NotNull final String password,
                                            @NotNull final String target,
                                            @NotNull final List<ArtifactsCollection> artifactsCollections) throws RunBuildException {
    final Map<String, String> runnerParameters = context.getRunnerParameters();
    final String authMethod = runnerParameters.get(FTPRunnerConstants.PARAM_AUTH_METHOD);