public void setTemplateID(String templateID) {
   if (templateID != null) {
     data.addParam("template_id", templateID);
   } else {
     data.getParams().remove("template_id");
   }
 }
 public void setNotifyURL(String notifyURL) {
   if (notifyURL != null) {
     data.addParam("notify_url", notifyURL);
   } else {
     data.getParams().remove("notify_url");
   }
 }
 public void setBlocking(boolean blocking) {
   if (blocking) {
     data.getParams().put("blocking", "true");
   } else {
     data.getParams().remove("blocking");
   }
 }
  /**
   * Creates a new TransloaditAssemblyBuilder object; sets steps, auth and files to empty
   * collections
   */
  public AssemblyBuilder() {
    auth = new HashMap<String, String>();
    steps = new LinkedHashMap<String, Object>();
    data = new ApiData();

    data.addParam("auth", auth);
    setAuthExpires(new Date(new Date().getTime() + DEFAULT_EXPIRATION_MINUTES * 60000));
  }
  public void setField(String key, String value)
      throws InvalidFieldKeyException, AlreadyDefinedKeyException {
    try {
      validateKey(key);

      if (data.getFiles().containsKey(key)) {
        throw new AlreadyDefinedKeyException(key, "files");
      }

      data.addField(key, value);
    } catch (InvalidFieldKeyException e) {
      TransloaditLogger.logError(this.getClass(), e);
      throw e;
    } catch (AlreadyDefinedKeyException e) {
      TransloaditLogger.logError(this.getClass(), e);
      throw e;
    }
  }
  public void setParam(String key, String value) throws InvalidFieldKeyException {

    try {
      validateKey(key);

      data.addParam(key, value);
    } catch (InvalidFieldKeyException e) {
      TransloaditLogger.logError(this.getClass(), e);
      throw e;
    }
  }
  public void addFile(String key, File file)
      throws InvalidFieldKeyException, FileNotOpenableException {
    try {
      validateKey(key);
      fileCheck(file);

      if (data.getFields().containsKey(key) || data.getFiles().containsKey(key)) {
        TransloaditLogger.logInfo(
            this.getClass(),
            "Autogenerated key will be used for %s file with key %s, because the specified key is already defined.",
            file,
            key);
        addFile(file);
      } else {
        data.addFile(key, file);
      }
    } catch (InvalidFieldKeyException e) {
      TransloaditLogger.logError(this.getClass(), e);
      throw e;
    } catch (FileNotOpenableException e) {
      TransloaditLogger.logError(this.getClass(), e);
      throw e;
    }
  }
  public ApiData toApiData() {
    if (hasSteps()) {
      LinkedHashMap<String, Object> reverse = new LinkedHashMap<String, Object>();

      List<Entry<String, Object>> list = new ArrayList<Entry<String, Object>>(steps.entrySet());

      for (int i = list.size() - 1; i >= 0; i--) {
        reverse.put(list.get(i).getKey(), list.get(i).getValue());
      }

      data.addParam("steps", reverse);
    }

    return data;
  }
 public boolean hasNotifyUrl() {
   return data.getParams().containsKey("notify_url");
 }
示例#10
0
 public boolean hasTemplateID() {
   return data.getParams().containsKey("template_id");
 }