static {
   final Set<ChecksumType> availableTypes = checksumProviderFactory.getAvailableTypes();
   final ImmutableList.Builder<ChecksumAlgorithm> builder = ImmutableList.builder();
   for (final ChecksumAlgorithm checksumAlgorithm :
       ChecksumAlgorithmMapper.getAllChecksumAlgorithms()) {
     final ChecksumType checksumType = ChecksumAlgorithmMapper.getChecksumType(checksumAlgorithm);
     if (availableTypes.contains(checksumType)) {
       builder.add(checksumAlgorithm);
     }
   }
   availableChecksumAlgorithms = builder.build();
 }
  public String uploadFile(
      final ImportProcessPrx proc,
      final String[] srcFiles,
      final int index,
      final ChecksumProviderFactory cpf,
      TimeEstimator estimator,
      final byte[] buf)
      throws ServerError, IOException {

    final ChecksumProvider cp =
        cpf.getProvider(
            ChecksumAlgorithmMapper.getChecksumType(proc.getImportSettings().checksumAlgorithm));

    final File file = new File(Location.getMappedId(srcFiles[index]));

    try {
      return transfer.transfer(
          new TransferState(file, index, srcFiles.length, proc, this, estimator, cp, buf));
    } catch (Exception e) {
      // Required to bump the error count
      notifyObservers(
          new ErrorHandler.FILE_EXCEPTION(file.getAbsolutePath(), e, srcFiles, "unknown"));
      // The state that we're entering, i.e. exiting upload via error
      notifyObservers(
          new ImportEvent.FILE_UPLOAD_ERROR(
              file.getAbsolutePath(), index, srcFiles.length, null, null, e));
      if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
      } else if (e instanceof ServerError) {
        throw (ServerError) e;
      } else if (e instanceof IOException) {
        throw (IOException) e;
      } else {
        String msg = "Unexpected exception thrown!";
        log.error(msg, e);
        throw new RuntimeException(msg, e);
      }
    }
  }