StatusMessageService

public interface StatusMessageService

Message service used to send status messages and manage notification rules.

See also: org.motechproject.admin.domain.StatusMessage, org.motechproject.admin.domain.NotificationRule

Methods

critical

void critical(String text, String moduleName)

Creates a status message with CRITICAL level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with

critical

void critical(String text, String moduleName, DateTime timeout)

Creates a status message with CRITICAL level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • timeout – the message expiry date

debug

void debug(String text, String moduleName)

Creates a status message with DEBUG level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with

debug

void debug(String text, String moduleName, DateTime timeout)

Creates a status message with DEBUG level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • timeout – the message expiry date

error

void error(String text, String moduleName)

Creates a status message with ERROR level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with

error

void error(String text, String moduleName, DateTime timeout)

Creates a status message with ERROR level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • timeout – the message expiry date

getActiveMessages

List<StatusMessage> getActiveMessages()

Retrieves status messages that have not expired.

Returns:list of active status messages

getAllMessages

List<StatusMessage> getAllMessages()

Retrieves all status messages, including those that expired.

Returns:list of all status messages

getNotificationRules

List<NotificationRule> getNotificationRules()

Retrieves all notification rules.

Returns:list of all notification rules

info

void info(String text, String moduleName)

Creates a status message and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with

info

void info(String text, String moduleName, DateTime timeout)

Creates a status message with INFO level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • timeout – the message expiry date

postMessage

void postMessage(StatusMessage message)

Creates a status message and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • message – the message to send

postMessage

void postMessage(String text, String moduleName, Level level)

Creates a status message and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • level – the message level

postMessage

void postMessage(String text, String moduleName, Level level, DateTime timeout)

Creates a status message and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • level – the message level
  • timeout – the message expiry date

removeMessage

void removeMessage(StatusMessage message)

Removes the given message.

Parameters:
  • message – the message to remove

removeNotificationRule

void removeNotificationRule(String id)

Removes notification rule with given id. Method is deprecated because now Motech is using Long type for primary key.

Parameters:
  • id – the id of notification rule which will be removed

removeNotificationRule

void removeNotificationRule(Long id)

Removes notification rule with the given id.

Parameters:
  • id – the id of notification rule which will be removed

saveNotificationRules

void saveNotificationRules(List<NotificationRule> notificationRules)

Creates or updates notification rules. Rule is updated when it has the id field set.

Parameters:
  • notificationRules – the list of notification rules to create/update

saveRule

void saveRule(NotificationRule notificationRule)

Creates or updates a notification rule. Rule is updated when it has the id field set.

Parameters:
  • notificationRule – the rule to create/update

warn

void warn(String text, String moduleName)

Creates a status message with WARN level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires. The value of timeout is set to the default.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with

warn

void warn(String text, String moduleName, DateTime timeout)

Creates a status message with WARN level and posts it in the system. If the message matches any notification rules, appropriate notifications will be triggered. The message will be visible in the message UI until it expires.

Parameters:
  • text – the message content
  • moduleName – the name of the module this message is related with
  • timeout – the message expiry date