indexing description: "Commit add use case." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class COMMIT_ADD inherit USE_CASE O_COMMIT_CONSTANTS create make feature -- Access namespace: STRING is -- Namespace of this use case. once Result := commit_namespace end type: STRING is -- Message type of this use case. once Result := commit_add_type end feature -- Basic operation start (a_msg: O_MESSAGE) is -- Start the use case by a_msg. local l_msg: O_COMMIT_ADD_MESSAGE l_storage_msg: O_COMMIT_ADD_MESSAGE do -- send message to storage node l_msg ?= a_msg check valid_message: l_msg /= Void end create l_storage_msg.make (l_msg.user, l_msg.project, l_msg.revision, l_msg.log, l_msg.diff) l_storage_msg.set_reply_handler (agent process_storage_reply (?, a_msg)) node.send_message_node (l_storage_msg, "storage1") end feature {NONE} -- Callbacks process_storage_reply (a_msg, a_orig_msg: O_MESSAGE) is -- Process reply from storage node. require a_msg_not_void: a_msg /= Void a_orig_msg_not_void: a_orig_msg /= Void local l_workitem_add_reply: O_GENERIC_MESSAGE l_commit_add_msg: O_COMMIT_ADD_MESSAGE l_status_reply: O_GENERAL_STATUS_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_mail_addressses_msg: O_WORKITEM_MAIL_MESSAGE do l_commit_add_msg ?= a_orig_msg check valid_message: l_commit_add_msg /= Void end l_status_reply ?= a_msg if l_status_reply = Void then create l_status.make (True, Void) node.send_message_reply (l_status, a_orig_msg) -- send mails to users l_workitem_add_reply ?= a_msg if l_workitem_add_reply /= Void then create l_mail_addressses_msg.make (l_workitem_add_reply.arguments.item ("workitem_id").to_integer) l_mail_addressses_msg.set_reply_handler (agent process_mail_reply (?, a_msg)) node.send_message_node (l_mail_addressses_msg, "storage1") end else -- send status from storage back to api node.send_message_reply (l_status_reply, a_orig_msg) end end process_mail_reply (a_msg, a_orig_msg: O_MESSAGE) is -- Process reply from storage node for mail addresses. local l_mail_msg: O_MAIL_MESSAGE l_workitem_mail_reply: O_WORKITEM_MAIL_REPLY_MESSAGE do l_workitem_mail_reply ?= a_msg check valid_message: l_workitem_mail_reply /= Void end from l_workitem_mail_reply.addresses.start until l_workitem_mail_reply.addresses.after loop create l_mail_msg.make (l_workitem_mail_reply.addresses.item, l_workitem_mail_reply.sender, l_workitem_mail_reply.subject, l_workitem_mail_reply.body) node.send_message_node (l_mail_msg, "mail1") l_workitem_mail_reply.addresses.forth end end end