class Localizer {

  public void handleLocalizations(Service service)
      throws IOException {
    // Handle localizations
    Path stagingDir =
        remoteDirectoryManager.getJobStagingArea(
            parameters.getName(), true);
    List<Localization> localizations = parameters.getLocalizations();

    // Check to fail fast
    checkFilesExist(localizations);

    // Start download remote if needed and upload to HDFS
    for (Localization localization : localizations) {
      LocalizationState localizationState = new LocalizationState(localization,
          remoteDirectoryManager);
      Path resourceToLocalize = new Path(localizationState.remoteUri);
      String sourceFile = determineSourceFile(localizationState);

      if (localizationState.needUploadToHDFS) {
        resourceToLocalize =
            fsOperations.uploadToRemoteFile(stagingDir, sourceFile);
      }
      if (localizationState.needToDeleteTempFile) {
        fsOperations.deleteFiles(sourceFile);
      }
      // Remove .zip from zipped dir name
      if (isZippedArchive(sourceFile, localizationState.destFileType)) {
        // Delete local zip file
        fsOperations.deleteFiles(sourceFile);
        sourceFile = getNameUntilUnderscore(sourceFile);
      }

      String containerLocalPath = localizationState.containerLocalPath;
      // If provided, use the name of local uri
      if (!containerLocalPath.equals(".")
          && !containerLocalPath.equals("./")) {
        // Change the YARN localized file name to what will be used in container
        sourceFile = getLastNameFromPath(containerLocalPath);
      }
      String localizedName = getLastNameFromPath(sourceFile);
      LOG.info("The file or directory to be localized is {}. " +
          "Its localized filename will be {}",
          resourceToLocalize.toString(), localizedName);
      ConfigFile configFile = new ConfigFile()
          .srcFile(resourceToLocalize.toUri().toString())
          .destFile(localizedName)
          .type(localizationState.destFileType);
      service.getConfiguration().getFiles().add(configFile);

      if (containerLocalPath.startsWith("/")) {
        addToMounts(service, localization, containerLocalPath, sourceFile);
      }
    }
  }

  public  Localizer(FileSystemOperations fsOperations,
      RemoteDirectoryManager remoteDirectoryManager,
      RunJobParameters parameters);

}