note description: "Internal API interface to issue services." author: "Dennis Rietmann " date: "$Date$" revision: "$Revision$" class INTERNAL_ISSUE_SERVICE inherit ISSUE_SERVICE redefine make, self_register, issue_add_attachment, issue_remove_attachment, issue_remove_all_attachments, issue_delete end create make feature {NONE} -- Initialization make (a_node: A_NODE) -- Creates the service do Precursor (a_node) is_internal := true end feature -- Initialisation self_register -- Register all actions for this service do register_with_help (agent issue_add_2, issue_add_2_name, "Add issue. Version 2") register_with_help (agent issue_update_2, issue_update_2_name, "Update issue. Version 2") register_with_help (agent issue_comment, issue_comment_name, "Add issue reply.") register_with_help (agent issue_comment_extended_2, issue_comment_extended_2_name, "Add issue reply with new tags. Version 2") register_with_help (agent issue_retrieve_planning_data, issue_retrieve_planning_data_name, "Retrieves the planning data of an issue") register_with_help (agent issue_add_attachment, issue_add_attachment_name, "Add an attachment to an issue.") register_with_help (agent issue_retrieve_attachments, issue_retrieve_attachments_name, "Retrieve all attachments of an issue.") register_with_help (agent issue_remove_attachment, issue_remove_attachment_name, "Remove an attachment from an issue.") register_with_help (agent issue_remove_all_attachments, issue_remove_all_attachments_name, "Remove all attachments of an issue.") register_with_help (agent issue_delete, issue_delete_name, "Delete an issue from a project.") register_with_help (agent issue_add_subscription, issue_add_subscription_name, "Add the issue subscription for the user, who invoked the call") register_with_help (agent issue_remove_subscription, issue_remove_subscription_name, "Remove the issue subscription for the user, who invoked the call") end feature -- Basic operations issue_add_attachment (a_session: STRING; a_project_id, a_project_issue_id: INTEGER_REF; a_file_name, a_description: STRING): INTEGER_REF -- adds a file attachment to an existing issue local l_msg: O_ISSUE_ADD_ATTACHMENT_MESSAGE l_add_attachment_reply_msg: O_ISSUE_ADD_ATTACHMENT_STORAGE_REPLY_MESSAGE do if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project_issue_id <= 0 then last_fault := err_invalid_issue elseif a_project_id <= 0 then last_fault := err_invalid_project else -- generate and send message create l_msg.make ( create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project_id.item), create {A_INTEGER_VALUE}.make (a_project_issue_id.item), create {A_STRING_VALUE}.make (a_file_name), create {A_STRING_VALUE}.make (a_description), create {A_BOOLEAN_VALUE}.make (true)) send_and_wait_for_reply (l_msg) if is_ok then l_add_attachment_reply_msg ?= last_reply check valid_reply: l_add_attachment_reply_msg /= Void end create Result Result.set_item (l_add_attachment_reply_msg.issue_attachment_id.value.to_integer) end end end issue_remove_attachment (a_session: STRING; a_project_id, a_project_issue_id: INTEGER_REF; a_file_name: STRING): BOOLEAN_REF -- remove an attachment from an issue local l_msg: O_ISSUE_REMOVE_ATTACHMENT_MESSAGE do if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project_id <= 0 then last_fault := err_invalid_project elseif a_project_issue_id <= 0 then last_fault := err_invalid_issue else create l_msg.make ( create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project_id.item), create {A_INTEGER_VALUE}.make (a_project_issue_id.item), create {A_STRING_VALUE}.make (a_file_name), create {A_BOOLEAN_VALUE}.make (true)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end issue_remove_all_attachments (a_session: STRING; a_project_id, a_project_issue_id: INTEGER_REF): BOOLEAN_REF -- remove an attachment from an issue local l_msg: O_ISSUE_REMOVE_ALL_ATTACHMENTS_MESSAGE do if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project_id <= 0 then last_fault := err_invalid_project elseif a_project_issue_id <= 0 then last_fault := err_invalid_issue else create l_msg.make (a_session, a_project_id.item, a_project_issue_id.item, true) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end issue_delete (a_session: STRING; a_project_id, a_project_issue_id: INTEGER_REF): BOOLEAN_REF -- Delete the issue with `a_project_issue_id' from the project `a_project_id' local l_msg: O_ISSUE_DELETE_MESSAGE do if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project_id <= 0 then last_fault := err_invalid_project elseif a_project_issue_id <= 0 then last_fault := err_invalid_issue else create l_msg.make (a_session, a_project_id.item, a_project_issue_id.item, true) send_and_wait_for_reply (l_msg) if is_ok then create result result.set_item (True) end end end end