コード例 #1
0
 public void setTemplateID(String templateID) {
   if (templateID != null) {
     data.addParam("template_id", templateID);
   } else {
     data.getParams().remove("template_id");
   }
 }
コード例 #2
0
 public void setNotifyURL(String notifyURL) {
   if (notifyURL != null) {
     data.addParam("notify_url", notifyURL);
   } else {
     data.getParams().remove("notify_url");
   }
 }
コード例 #3
0
 public void setBlocking(boolean blocking) {
   if (blocking) {
     data.getParams().put("blocking", "true");
   } else {
     data.getParams().remove("blocking");
   }
 }
コード例 #4
0
  /**
   * 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));
  }
コード例 #5
0
  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;
    }
  }
コード例 #6
0
  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;
    }
  }
コード例 #7
0
  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;
    }
  }
コード例 #8
0
  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;
  }
コード例 #9
0
 public boolean hasNotifyUrl() {
   return data.getParams().containsKey("notify_url");
 }
コード例 #10
0
 public boolean hasTemplateID() {
   return data.getParams().containsKey("template_id");
 }