Class WebhookUtils (2.1.2)

public final class WebhookUtils

Beta
Utilities for Webhook notifications.

Inheritance

java.lang.Object > WebhookUtils

Static Fields

TYPE

public static final String TYPE

Webhook notification channel type to use in the watch request.

Field Value
Type Description
String

Static Methods

processWebhookNotification(HttpServletRequest req, HttpServletResponse resp, DataStore<StoredChannel> channelDataStore)

public static void processWebhookNotification(HttpServletRequest req, HttpServletResponse resp, DataStore<StoredChannel> channelDataStore)

Utility method to process the webhook notification from HttpServlet#doPost.

The HttpServletRequest#getInputStream() is closed in a finally block inside this method. If it is not detected to be a webhook notification, an HttpServletResponse#SC_BAD_REQUEST error will be displayed. If the notification channel is found in the given notification channel data store, it will call UnparsedNotificationCallback#onNotification for the registered notification callback method.

Parameters
Name Description
req HttpServletRequest

an HttpServletRequest object that contains the request the client has made of the servlet

resp HttpServletResponse

an HttpServletResponse object that contains the response the servlet sends to the client

channelDataStore com.google.api.client.util.store.DataStore<StoredChannel>

notification channel data store

Exceptions
Type Description
ServletException
IOException

processWebhookNotification(HttpServletRequest req, HttpServletResponse resp, DataStoreFactory dataStoreFactory)

public static void processWebhookNotification(HttpServletRequest req, HttpServletResponse resp, DataStoreFactory dataStoreFactory)

Utility method to process the webhook notification from HttpServlet#doPost by finding the notification channel in the given data store factory.

It is a wrapper around #processWebhookNotification(HttpServletRequest, HttpServletResponse, DataStore) that uses the data store from StoredChannel#getDefaultDataStore(DataStoreFactory).

Parameters
Name Description
req HttpServletRequest

an HttpServletRequest object that contains the request the client has made of the servlet

resp HttpServletResponse

an HttpServletResponse object that contains the response the servlet sends to the client

dataStoreFactory com.google.api.client.util.store.DataStoreFactory

data store factory

Exceptions
Type Description
ServletException
IOException