note description: "Provide an interface to commit data." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class COMMIT_INTERFACE inherit BASE_INTERFACE O_WORKITEM_CONSTANTS create make feature -- Commands commit_add (a_msg: A_MESSAGE) -- Add a new commit workitem according to a_msg. require a_msg_ok: a_msg /= Void local l_pc_msg: O_COMMIT_ADD_MESSAGE l_workitem: WORKITEM l_status: A_GENERAL_STATUS_MESSAGE l_user_ret: USER l_project_ret: PROJECT l_workitem_add_reply: O_COMMIT_ADD_REPLY_MESSAGE l_commit_workitem: WI_FULL_COMMIT l_web_reference: STRING do l_pc_msg ?= a_msg check commit_add_message: l_pc_msg /= Void end create l_workitem.make user_access.retrieve_user_by_name (l_pc_msg.user.value, False) if user_access.is_found then l_user_ret := user_access.last_user project_access.retrieve_project_by_name (l_pc_msg.project.value) if project_access.is_found then l_project_ret := project_access.last_project if l_pc_msg.webref /= Void and then not l_pc_msg.webref.is_empty then l_web_reference := l_pc_msg.webref else l_web_reference := get_wsvn_link (l_project_ret.name, l_pc_msg.revision) end create l_commit_workitem.make ( l_project_ret.project_id, l_project_ret.name, l_user_ret.user_id, l_user_ret.name, l_web_reference, "Commit - Revision " + l_pc_msg.revision.out, l_project_ret.project_type /= 2, l_pc_msg.revision, l_pc_msg.diff, l_pc_msg.commit_log) workitem_access.store_wi (l_commit_workitem) create l_workitem_add_reply.make (workitem_access.last_insert_id) node.send_message_reply (l_workitem_add_reply, a_msg) else create l_status.make (False, err_invalid_project) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_invalid_user) node.send_message_reply (l_status, a_msg) end end feature {NONE} -- Implementation get_wsvn_link (a_project_name: STRING; a_revision: STRING): STRING -- Given `a_project_name' and a revision, this utility function will return -- a link to the corresponding Web-SVN page. require project_specified: a_project_name /= Void and then not a_project_name.is_empty revision_specified: a_revision /= Void and then not a_revision.is_empty do if use_subdomains then Result := "http://svn." + config_parser.get("origo_domain") else -- Appliance Result := "http://" + config_parser.get("origo_domain") + "/websvn" end Result.append ("/wsvn/" + a_project_name.as_lower + "/?rev=" + a_revision + "&sc=1") end end