Skip to content

Notifications in Commands

Created by: osbornjd

Overview

This PR implements a notification scheme for commands. There are two notification options - via an POST call or via an email.

Design

The design is with an interface ICommandUpdateHandler which defines the necessary implementation for concrete implementations. The two implementations at the moment are HTTPCommandUpdateHandler and EmailUpdateHandler. Additional implementations could be added, if desired.

The HTTP notification takes a message and a URL and creates a POST call with the httpclient package from Apache. At the moment, is up to the user to properly format the POST call for their specific needs. There is nothing fancy about the call (e.g. with html or something else), it is a string and that string is what is sent to the POST call.

The EmailUpdateHandler takes a user provided email address, password, and email host and sends an email from that address to that address (with a specified message). This was the easiest conceivable way to implement this so that email passwords are kept private to the user of Commands.

The actual Command is given an optional member variable which corresponds to the updater. If the Command has a non-null ICommandUpdateHandler, then upon the job "finishing" (in whatever state that may be), the update will be posted via the given UpdateHandler.

Note on Tests

The HTTPHandlerTest functions as is. The EmailHandlerTest requires some additional information, as is specified in the README. To pass, it requires a text file that is similar to the credential file for the RemoteCommand tests that contains the user's email address, password, and email host.

Merge request reports