@Override
  public UploadAnswer handleUploadCommand(UploadCommand cmd) {
    s_logger.warn("Handling the upload " + cmd.getInstallPath() + " " + cmd.getId());
    if (cmd instanceof UploadProgressCommand) {
      return handleUploadProgressCmd((UploadProgressCommand) cmd);
    }

    String user = null;
    String password = null;
    String jobId =
        uploadPublicTemplate(
            cmd.getId(),
            cmd.getUrl(),
            cmd.getName(),
            cmd.getFormat(),
            cmd.getAccountId(),
            cmd.getDescription(),
            cmd.getChecksum(),
            cmd.getInstallPath(),
            user,
            password,
            cmd.getTemplateSizeInBytes());
    sleep();
    if (jobId == null) {
      return new UploadAnswer(
          null, 0, "Internal Error", com.cloud.storage.UploadVO.Status.UPLOAD_ERROR, "", "", 0);
    }
    return new UploadAnswer(
        jobId,
        getUploadPct(jobId),
        getUploadError(jobId),
        getUploadStatus2(jobId),
        getUploadLocalPath(jobId),
        getInstallPath(jobId),
        getUploadTemplateSize(jobId));
  }
 public UploadJob(TemplateUploader td, String jobId, UploadCommand cmd) {
   this.tu = td;
   this.jobId = jobId;
   this.name = cmd.getName();
   this.format = cmd.getFormat();
 }