// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/DeployerAgentUtils.java
// public static void logBuildProblem(BuildProgressLogger logger, String message) {
//   logger.logBuildProblem(BuildProblemData
//           .createBuildProblem(String.valueOf(message.hashCode()),
//                   DeployerRunnerConstants.BUILD_PROBLEM_TYPE,
//                   "Deployment problem: " + message));
// }


import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.agent.BuildFinishedStatus;
import jetbrains.buildServer.agent.BuildProgressLogger;
import jetbrains.buildServer.agent.impl.artifacts.ArtifactsCollection;
import jetbrains.buildServer.util.StringUtil;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicReference;
import static jetbrains.buildServer.deployer.agent.DeployerAgentUtils.logBuildProblem;
import static jetbrains.buildServer.util.FileUtil.getExtension;
          InputStream inputStream = null;
          try {
            if (myIsAutoType) {
              checkResult(myClient.setFileType(detectType(source.getName())));
            }
            inputStream = new FileInputStream(source);
            checkResult(myClient.storeFile(source.getName(), inputStream));
          } finally {
            if (inputStream != null) {
              inputStream.close();
            }
          }
          checkResult(myClient.changeWorkingDirectory(remoteRoot));
          LOG.debug("done transferring [" + source.getAbsolutePath() + "]");
          count++;
          if (count < BY_FILE_LOGGING_THRESHOLD) {
            myLogger.message("Uploaded [" + source.getPath() + "] (" + StringUtil.formatFileSize(source) + ")");
          } else if (count == BY_FILE_LOGGING_THRESHOLD) {
            myLogger.message("< and continued >");
          }
          if (checkIsInterrupted())
            throw new FailureDetectedException("Process has been interrupted.");
        }
        myLogger.message("Uploaded [" + count + "] files for [" + artifactsCollection.getSourcePath() + "] pattern");
      }
      myFinishStatus.set(BuildFinishedStatus.FINISHED_SUCCESS);
    } catch (FailureDetectedException | IOException t) {
      if (myRetryCount == 1 && myClient.getReplyCode() == FTP_REPLY_CODE_DATA_CONNECTION_MUST_BE_ENCRYPTED) {
        throw new RetryWithPrivateSettingsException();
      }
// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/DeployerAgentUtils.java
// public static void logBuildProblem(BuildProgressLogger logger, String message) {
//   logger.logBuildProblem(BuildProblemData
//           .createBuildProblem(String.valueOf(message.hashCode()),
//                   DeployerRunnerConstants.BUILD_PROBLEM_TYPE,
//                   "Deployment problem: " + message));
// }


// Path: deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/ftp/InterruptibleUploadProcess.java
import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.agent.BuildFinishedStatus;
import jetbrains.buildServer.agent.BuildProgressLogger;
import jetbrains.buildServer.agent.impl.artifacts.ArtifactsCollection;
import jetbrains.buildServer.util.StringUtil;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicReference;
import static jetbrains.buildServer.deployer.agent.DeployerAgentUtils.logBuildProblem;
import static jetbrains.buildServer.util.FileUtil.getExtension;

          InputStream inputStream = null;
          try {
            if (myIsAutoType) {
              checkResult(myClient.setFileType(detectType(source.getName())));
            }
            inputStream = new FileInputStream(source);
            checkResult(myClient.storeFile(source.getName(), inputStream));
          } finally {
            if (inputStream != null) {
              inputStream.close();
            }
          }
          checkResult(myClient.changeWorkingDirectory(remoteRoot));
          LOG.debug("done transferring [" + source.getAbsolutePath() + "]");
          count++;
          if (count < BY_FILE_LOGGING_THRESHOLD) {
            myLogger.message("Uploaded [" + source.getPath() + "] (" + StringUtil.formatFileSize(source) + ")");
          } else if (count == BY_FILE_LOGGING_THRESHOLD) {
            myLogger.message("< and continued >");
          }
          if (checkIsInterrupted())
            throw new FailureDetectedException("Process has been interrupted.");
        }
        myLogger.message("Uploaded [" + count + "] files for [" + artifactsCollection.getSourcePath() + "] pattern");
      }
      myFinishStatus.set(BuildFinishedStatus.FINISHED_SUCCESS);
    } catch (FailureDetectedException | IOException t) {
      if (myRetryCount == 1 && myClient.getReplyCode() == FTP_REPLY_CODE_DATA_CONNECTION_MUST_BE_ENCRYPTED) {
        throw new RetryWithPrivateSettingsException();
      }
      logBuildProblem(myLogger, t.getMessage());