indexing description: "Provide an interface to release data." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class RELEASE_INTERFACE inherit BASE_INTERFACE redefine make end O_CONFIG_CONSTANTS O_WORKITEM_CONSTANTS create make feature {NONE} -- Initialization make (a_node: like node; a_db_handler: like db_handler; a_policy_cache: like policy_cache) is -- Initialize. do Precursor (a_node, a_db_handler, a_policy_cache) end feature -- Commands release_list_do (a_project: INTEGER; a_msg: O_MESSAGE) is -- List workitems. require a_msg_ok: a_msg /= Void local l_reply: O_RELEASE_LIST_REPLY_MESSAGE l_releases: DS_HASH_TABLE [TUPLE [project: INTEGER; creation_time: INTEGER; name: STRING; description: STRING; version: STRING; files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]]], INTEGER] l_release_t: TUPLE [project: INTEGER; creation_time: INTEGER; name: STRING; description: STRING; version: STRING; files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]]] l_query_result: ARRAYED_LIST[TUPLE [release_id: INTEGER; project: INTEGER; creation_time: INTEGER; name: STRING; description: STRING; version: STRING; files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]]]] do l_query_result := release_access.retrieve_releases (a_project) from create l_releases.make (l_query_result.count) l_query_result.start until l_query_result.after loop create l_release_t l_release_t.project := l_query_result.item.project l_release_t.creation_time := l_query_result.item.creation_time l_release_t.name := l_query_result.item.name l_release_t.description := l_query_result.item.description l_release_t.version := l_query_result.item.version l_release_t.files := l_query_result.item.files l_releases.force (l_release_t, l_query_result.item.release_id) l_query_result.forth end create l_reply.make(l_releases) node.send_message_reply (l_reply, a_msg) end release_list (a_msg: O_MESSAGE) is -- List workitems. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_LIST_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check release_list_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then -- retrieve releases and map them into a HASH_TABLE release_list_do (l_msg.project, a_msg) else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end release_list_internal (a_msg: O_MESSAGE) is -- List workitems. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_LIST_INTERNAL_MESSAGE do l_msg ?= a_msg check release_list_message: l_msg /= Void end release_list_do (l_msg.project, a_msg) end release_retrieve_do (a_release_id: INTEGER; a_msg: O_MESSAGE) is -- Retrieve release. require a_msg_ok: a_msg /= Void local l_reply: O_RELEASE_RETRIEVE_REPLY_MESSAGE l_release_t: TUPLE [project: INTEGER; creation_time: INTEGER; name: STRING; description: STRING; version: STRING; files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]]] l_status: O_GENERAL_STATUS_MESSAGE do release_access.retrieve_release_by_id (a_release_id) if release_access.is_found then create l_release_t l_release_t.project := release_access.last_release.project_id l_release_t.creation_time := release_access.last_release.creation_time l_release_t.name := release_access.last_release.name l_release_t.description := release_access.last_release.description l_release_t.version := release_access.last_release.version l_release_t.files := release_access.last_release.files create l_reply.make (l_release_t.project, l_release_t.creation_time, l_release_t.name, l_release_t.description, l_release_t.version, l_release_t.files) node.send_message_reply (l_reply, a_msg) else create l_status.make (False, err_invalid_release) node.send_message_reply (l_status, a_msg) end end release_retrieve (a_msg: O_MESSAGE) is -- Retrieve release. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_RETRIEVE_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session) if user_access.is_found then -- retrieve release release_retrieve_do(l_msg.release_id, a_msg) else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end release_retrieve_internal (a_msg: O_MESSAGE) is -- Retrieve release. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_RETRIEVE_INTERNAL_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end release_retrieve_do(l_msg.release_id, a_msg) end release_add (a_msg: O_MESSAGE) is -- Add a new release according to a_msg. require a_msg_ok: a_msg /= Void local l_pc_msg: O_RELEASE_ADD_MESSAGE l_workitem: WORKITEM l_workitem_release: WORKITEM_RELEASE l_release: RELEASE l_release_file: RELEASE_FILE l_status: O_GENERAL_STATUS_MESSAGE l_user_ret: USER l_project_ret: PROJECT l_workitem_id: INTEGER l_release_id: INTEGER l_workitem_add_reply: O_GENERIC_MESSAGE do l_pc_msg ?= a_msg check release_add_message: l_pc_msg /= Void end user_access.retrieve_user_by_session (l_pc_msg.session) if user_access.is_found then l_user_ret := user_access.last_user project_access.retrieve_project_by_id (l_pc_msg.project_id) if project_access.is_found then l_project_ret := project_access.last_project create l_release.make l_release.set_project_id (l_project_ret.project_id) l_release.set_name (l_pc_msg.name) l_release.set_description (l_pc_msg.description) l_release.set_version (l_pc_msg.version) release_access.insert_release(l_release) l_release_id := release_access.last_insert_id from l_pc_msg.files.start until l_pc_msg.files.after loop create l_release_file.make l_release_file.set_name (l_pc_msg.files.item.name) l_release_file.set_platform (l_pc_msg.files.item.platform) l_release_file.set_release_id (l_release_id) release_access.insert_release_file (l_release_file) l_pc_msg.files.forth end create l_workitem.make l_workitem.set_type_id (2) l_workitem.set_user_id (l_user_ret.user_id) l_workitem.set_project_id (l_project_ret.project_id) workitem_access.insert_workitem (l_workitem) l_workitem_id := workitem_access.last_insert_id create l_workitem_release.make l_workitem_release.set_workitem_id (l_workitem_id) l_workitem_release.set_release_id (l_release_id) release_access.insert_release_workitem(l_workitem_release) create l_workitem_add_reply.make (workitem_namespace, workitem_add_reply_type) l_workitem_add_reply.add_argument ("workitem_id", l_workitem_id.out) l_workitem_add_reply.add_argument ("project_name", l_project_ret.name) l_workitem_add_reply.add_argument ("user_name", l_user_ret.name) l_workitem_add_reply.add_argument ("release_id", l_release_id.out) 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_session_timeout) node.send_message_reply (l_status, a_msg) end end -- file_move_configuration (a_msg: O_MESSAGE) is -- -- Retrieve username and projectname for file move -- require -- a_msg_ok: a_msg /= Void -- local -- l_pc_msg: O_RELEASE_FILE_MOVE_CONFIG_REQUEST_MESSAGE -- l_config: O_GENERIC_MESSAGE -- l_status: O_GENERAL_STATUS_MESSAGE -- l_user_ret: USER -- l_project_ret: PROJECT -- do -- l_pc_msg ?= a_msg -- check -- valid_message: l_pc_msg /= Void -- end -- user_access.retrieve_user_by_session (l_pc_msg.session) -- if user_access.is_found then -- l_user_ret := user_access.last_user -- project_access.retrieve_project_by_id (l_pc_msg.project) -- if project_access.is_found then -- l_project_ret := project_access.last_project -- create l_config.make (config_namespace, config_release_move_file_type) -- l_config.add_argument ("user", l_user_ret.name) -- l_config.add_argument ("project", l_project_ret.name) -- node.send_message_reply (l_config, 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 release_delete (a_msg: O_MESSAGE) is -- Delete a release according to a_msg. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_DELETE_MESSAGE l_status: O_GENERAL_STATUS_MESSAGE l_release_workitem_id: INTEGER do l_msg ?= a_msg check valid_msg: l_msg /= Void end release_access.retrieve_release_by_id (l_msg.release_id) if release_access.is_found then -- delete release_workitem l_release_workitem_id := workitem_access.retrieve_release_workitem_id_by_release_id (l_msg.release_id) if l_release_workitem_id > 0 then workitem_access.delete_release_workitem (l_release_workitem_id) end -- delete release if release_access.last_release.project_id = l_msg.project_id then release_access.delete_release (l_msg.release_id) create l_status.make (True, "") else create l_status.make (False, err_access_denied) end else create l_status.make (False, err_invalid_release) end -- send status node.send_message_reply (l_status, a_msg) end end