public Optional extract()

in src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/CreateVersionFromPropertyParametersExtractor.java [30:53]


  public Optional<CreateVersionFromPropertyParameters> extract(
      ActionRequest actionRequest, Map<String, String> properties) {
    String[] parameters = actionRequest.getParameters();
    if (parameters.length != 1) {
      logger.atSevere().log(
          "Wrong number of received parameters. Received parameters are %s. Only one parameter is expected, the 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();
    }

    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 CreateVersionFromPropertyParameters(propertyValue));
  }