indexing description: "Blog add use case." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class BLOG_ADD inherit AUTH_USE_CASE O_BLOG_CONSTANTS create make feature -- Access namespace: STRING is -- Namespace of this use case. once Result := blog_namespace end type: STRING is -- Message type of this use case. once Result := blog_add_type end feature -- Basic operation start (a_msg: O_MESSAGE) is -- Start the use case by a_msg. local l_msg: O_BLOG_ADD_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end -- check if the user is authorized and act accordingly is_authorized_for_project (l_msg, "blog_add", l_msg.project, auth_node) end feature {NONE} -- Callbacks handle_auth_success (a_msg: O_MESSAGE) is -- a_msg has been authorized, execute it. local l_msg: O_BLOG_ADD_MESSAGE l_storage_msg: O_BLOG_ADD_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end create l_storage_msg.make (l_msg.session, l_msg.project, l_msg.title, l_msg.diff, l_msg.revision, l_msg.old_revision) l_storage_msg.set_reply_handler (agent process_storage_reply (?, a_msg)) node.send_message_node (l_storage_msg, "storage1") end 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_blog_add_msg: O_BLOG_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_blog_add_msg ?= a_orig_msg check valid_message: l_blog_add_msg /= Void end l_status_reply ?= a_msg if l_status_reply = Void then -- send ok back to api 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. 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