Пример #1
0
 public void addFile(File file) throws FileNotOpenableException {
   String key = FILENAME_KEY_PREFIX + (fileIncrement++) + FILENAME_KEY_POSTFIX;
   try {
     addFile(key, file);
   } catch (InvalidFieldKeyException e) {
     TransloaditLogger.logInfo(this.getClass(), "Generated file key already exist.");
   }
 }
Пример #2
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;
    }
  }
Пример #3
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;
    }
  }
Пример #4
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;
    }
  }