EnvelopQuerySender

public class EnvelopQuerySender extends HttpSender

The EnvelopSender is abstract base class for sending HTTP remote request to H2O for querying the message envelop through the administration page.

Author:Twinsen Tsang

Fields

MSGBOX_FORM_PARAM

protected static final String MSGBOX_FORM_PARAM

The constant field representing the HTTP request parameter name for Message box.

MSGBOX_IN

public static final String MSGBOX_IN

The constant field representing the standardized incoming message box representation

MSGBOX_OUT

public static final String MSGBOX_OUT

The constant field representing the standardized outgoing message box representation

MSGID_FORM_PARAM

protected static final String MSGID_FORM_PARAM

The constant field representing the HTTP request parameter name for Message id.

Constructors

EnvelopQuerySender

protected EnvelopQuerySender(FileLogger logger, Data d)

Explicit Constructor. Create an instance of EnvelopQuerySender

Parameters:
  • logger – The logger for log the sending process.
  • d – The data used for generate Envelop query request. It must be a kind of Admin data.

Methods

getEnvelopStream

public final InputStream getEnvelopStream()

This method should be called after executed run() successfully.

Returns:The message envelop stream.

getMessageBoxMapping

protected Map getMessageBoxMapping()

Get the message box mapping from standardized representation to proprietary representation. It should return a HashMap like this:

HashMap m = new HashMap();
m.put(MSGBOX_IN , "Your Inbox representation");
m.put(MSGBOX_OUT, "Your outbox representation");
Returns:the message box mapping.

See also: EnvelopQuerySender.MSGBOX_IN, EnvelopQuerySender.MSGBOX_OUT

getMessageBoxToDownload

public final String getMessageBoxToDownload()
Returns:The message box to donw-load the message envelop. either INBOX or OUTBOX.

getMessageIdToDownload

public final String getMessageIdToDownload()
Returns:The message id to down-load the message envelop.

onCreateRequest

protected HttpMethod onCreateRequest()

[@EVENT] This method is invoked when the sender is required to create a HTTP Request from configuration. It generates a form-url-encoded content embedded in the HTTP POST request. It contains two parameters, message_id and message_box. The value of these parameters are extracted from getMessageIdToDownload() and getMessageBoxToDownload() respectively. NOTE: The values of message_box parameter may differ to what you see because it may transform getMessageBoxMapping().

Throws:

onResponse

protected void onResponse()

[@EVENT] This method is invoked when received the reply HTTP response from the server. It saves the response body stream and then available to get through by getEnvelopStream()

onStart

protected void onStart()

[@EVENT] The method onStart log all new configuration.

setMessageCriteriaToDownload

public final void setMessageCriteriaToDownload(String messageId, String messageBox)

Set the message criteria for down-load the message envelop (and payload).

Parameters:
  • messageId – The message id to down-load the message envelop.
  • messageBox – The message box to down-load the message envelop. either INBOX or OUTBOX.
Throws: