indexing description: "Project create use case." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class PROJECT_CREATE inherit AUTH_USE_CASE O_PROJECT_CONSTANTS O_CONFIG_CONSTANTS create make feature -- Access namespace: STRING is -- Namespace of this use case. once Result := project_namespace end type: STRING is -- Message type of this use case. once Result := project_create_type end feature -- Basic operation start (a_msg: O_MESSAGE) is -- Start the use case by a_msg. local l_msg: O_PROJECT_CREATE_MESSAGE do l_msg ?= a_msg check project_create_message: l_msg /= Void end -- check if the user is authorized and act accordingly is_authorized_for_project (l_msg, "project_create", 0, auth_node) end feature {NONE} -- Implementation handle_auth_success (a_msg: O_MESSAGE) is -- a_msg has been authorized, execute it. local l_msg: O_PROJECT_CREATE_MESSAGE l_storage_msg: O_PROJECT_CREATE_MESSAGE do l_msg ?= a_msg check project_create_message: l_msg /= Void end create l_storage_msg.make (l_msg.session, l_msg.name, l_msg.description, l_msg.is_closed_source, l_msg.is_hidden) 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_conf_1: O_GENERIC_MESSAGE l_conf_2: O_GENERIC_MESSAGE l_project_create: O_PROJECT_CREATE_MESSAGE l_status_reply: O_GENERAL_STATUS_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_projectname: STRING do l_project_create ?= a_orig_msg check valid_message: l_project_create /= Void end l_status_reply ?= a_msg if l_status_reply = Void then l_projectname := l_project_create.name.out l_projectname.to_lower create l_conf_1.make (config_namespace, config_command_type) l_conf_1.add_argument ("config1", "/usr/local/lib/origo/origo-create-svn.sh " + l_projectname) node.send_message_node (l_conf_1, "config1") create l_conf_2.make (config_namespace, config_command_type) l_conf_2.add_argument ("config2", "/usr/bin/php /usr/local/lib/origo/create_project.php " + a_msg.arguments.item ("project_id").out + " " + l_projectname) node.send_message_node (l_conf_2, "config2") -- create shared jabber roster create l_conf_2.make (config_namespace, config_command_type) l_conf_2.add_argument ("config2", "/usr/sbin/ejabberdctl srg-create " + l_projectname + " " + config_parser.get ("jabber_domain") + " " + l_projectname + "%"Project members for " + l_projectname + "%" " + l_projectname) node.send_message_node (l_conf_2, "config2") create l_status.make (True, Void) node.send_message_reply (l_status, a_orig_msg) else -- send status from storage back to api node.send_message_reply (l_status_reply, a_orig_msg) end end end