indexing description: "Send mail to all origo users use case." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class SYSTEM_MAIL_ALL inherit AUTH_USE_CASE O_MAIL_CONSTANTS O_USER_CONSTANTS O_SYSTEM_CONSTANTS create make feature -- Access namespace: STRING is -- Namespace of this use case. once Result := system_namespace end type: STRING is -- Message type of this use case. once Result := system_mail_all_type end feature -- Basic operation start (a_msg: O_MESSAGE) is -- Start the use case by a_msg. local l_msg: O_SESSION_MESSAGE do l_msg ?= a_msg check session_message: l_msg /= Void end -- check if the user is authorized and act accordingly is_authorized_for_project (l_msg, "system_mail_all", 0, auth_node) end feature {NONE} -- Implementation handle_auth_success (a_msg: O_MESSAGE) is -- a_msg has been authorized, execute it. local l_mail_all_msg: O_SYSTEM_MAIL_ALL_MESSAGE l_status_msg: O_GENERAL_STATUS_MESSAGE l_add_msg: O_GENERIC_MESSAGE do l_mail_all_msg ?= a_msg check mail_all_msg: l_mail_all_msg /= Void end -- query storage for mail addresses create l_add_msg.make (user_namespace, user_mail_list_type) l_add_msg.set_reply_handler (agent handle_addresses (?, l_mail_all_msg.subject, l_mail_all_msg.text)) node.send_message_node (l_add_msg, "storage1") -- report success to api create l_status_msg.make (True, Void) node.send_message_reply (l_status_msg, a_msg) end handle_addresses (a_msg: O_MESSAGE; a_subject, a_text: STRING) is -- Handle received addresses from the storage node. local l_addresses: HASH_TABLE [STRING, STRING] l_mail_msg: O_MAIL_MESSAGE do from l_addresses := a_msg.arguments l_addresses.start until l_addresses.after loop create l_mail_msg.make (l_addresses.item_for_iteration, "Origo News", a_subject, a_text) node.send_message_node (l_mail_msg, "mail1") l_addresses.forth end end end