public static String subscribe()

in amazon-sns-trigger-server/src/main/java/jetbrains/buildServer/clouds/amazon/sns/trigger/utils/AwsSnsMessageDetailsHelper.java [44:59]


  public static String subscribe(@NotNull Map<String, Object> payload,
                                 @NotNull HttpApi serverApi) throws AwsSnsHttpEndpointException {
    try {
      String subscribeUrl = (String) payload.get(AwsSnsTriggerConstants.SUBSCRIBE_URL_KEY);
      HttpApi.Response response = serverApi.get(subscribeUrl);
      String body = response.getBody();

      try (Reader bodyReader = new StringReader(body)) {
        XPath xpath = XPath.newInstance(AwsSnsTriggerConstants.SUBSCRIBE_CONFIRMATION_ARN_XPATH);
        String subscribeArn = xpath.valueOf(new SAXBuilder().build(bodyReader));
        return subscribeArn != null ? subscribeArn.trim() : null;
      }
    } catch (Exception e) {
      throw new AwsSnsHttpEndpointException("Couldn't subscribe", e);
    }
  }