public Optional extract()

in src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/AddPropertyToFieldParametersExtractor.java [34:63]


  public Optional<AddPropertyToFieldParameters> extract(
      ActionRequest actionRequest, Map<String, String> properties) {
    String[] parameters = actionRequest.getParameters();
    if (parameters.length != 2) {
      logger.atSevere().log(
          "Wrong number of received parameters. Received parameters are %s. Exactly two parameters are expected. The first one is the ITS field id, the second one is the event property id",
          Arrays.toString(parameters));
      return Optional.empty();
    }

    String propertyId = parameters[0];
    if (Strings.isNullOrEmpty(propertyId)) {
      logger.atSevere().log("Received property id is blank");
      return Optional.empty();
    }

    String fieldId = parameters[1];
    if (Strings.isNullOrEmpty(fieldId)) {
      logger.atSevere().log("Received field id is blank");
      return Optional.empty();
    }

    if (!properties.containsKey(propertyId)) {
      logger.atSevere().log("No event property found for id %s", propertyId);
      return Optional.empty();
    }

    String propertyValue = properties.get(propertyId);
    return Optional.of(new AddPropertyToFieldParameters(propertyValue, fieldId));
  }