Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_http_client_session.hpp
1/*
2##############################################################################
3# file: ms_http_client_session.hpp #
4# 'msparser' toolkit #
5# Represents a session on a Mascot server #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11 * @(#)$Source: parser/inc/ms_http_client_session.hpp $
12 * @(#)$Revision: ad538b116c843eb04f4e6cb8ff8f73b915de025f | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
13 * @(#)$Date: 2020-02-14 10:16:25 +0000 $
14##############################################################################
15 */
16
17#ifndef MS_HTTP_CLIENT_SESSION_HPP
18#define MS_HTTP_CLIENT_SESSION_HPP
19
20
21#include <string>
22#include <vector>
23
24namespace matrix_science
25{
31 class ms_http_client;
32 class ms_http_client_search;
33
35
46 class MS_MASCOTRESFILE_API ms_http_client_session :
47 public ms_errors
48 {
49 public:
51
58 {
59 SHOW_PI = 0x0001,
60 SHOW_TITLE = 0x0002,
61 SHOW_LENGTH = 0x0004,
62 SHOW_SEQUENCE = 0x0008,
63 SHOW_REFERENCE = 0x0010,
64
65 SHOW_NONE = 0,
66 SHOW_ALL = 0xFFFF
67 };
68
69
72
74 ms_http_client_session(const ms_http_helper connection, const std::string sessionId);
75
78
80#ifndef SWIG
81 ms_http_client_session& operator=(const ms_http_client_session & right);
82#endif
83 void copyFrom(const ms_http_client_session * right);
84
86 std::string getSessionID() const;
87 std::string sessionId() const { return getSessionID(); } // Deprecated. Released with 2.5.2
88#ifndef SWIG
90 bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & returnIsPermitted);
91#else // SWIG Multiple return values
92 bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & OUTPUT);
93#endif
94
95#ifndef SWIGCSHARP
97 bool submitSearch(
98 ms_http_client_search & returnTask,
99 const std::string & httpHeader,
100 const std::string & prologue,
101 const std::string & filename,
102 const std::string & epilogue,
103 ms_http_helper_progress & progress,
104 bool batch = false);
105#else
106 bool submitSearch(
107 ms_http_client_search & returnTask,
108 const std::wstring & httpHeader,
109 const std::wstring & prologue,
110 const std::wstring & filename,
111 const std::wstring & epilogue,
112 ms_http_helper_progress & progress,
113 bool batch = false) {
114 return submitSearchWide(returnTask, httpHeader, prologue, filename, epilogue, progress, batch);
115 };
116#endif
117
119 bool getSequenceFile(
120 const std::string & database,
121 const std::vector<std::string> & accessionNames,
122 const std::vector<int> & accessionFrames,
123 const std::string & filename,
124 const SequenceShowOptions options = SHOW_ALL
125 );
126
128 bool logout();
129
131 bool getIsXmlUploadedList(const std::vector<std::string> & taskIds, std::vector<int> & xmlUploaded);
132
133 private:
134
135 // type of login for the session to allow re-login if session has expired
136 enum SessionSecurityType {
137 SECURITY_NONE,
138 SECURITY_DISABLED,
139 SECURITY_GUEST,
140 SECURITY_WEB,
141 SECURITY_USER
142 };
143
144 ms_http_client_session(
145 ms_http_helper connection,
146 std::string sessionId,
147 SessionSecurityType security,
148 const std::string & username = "",
149 const std::string & password = "");
150
151 // Create a new Mascot task attached to this Mascot session.
152 bool createTask(
153 ms_http_client_search & returnTask);
154
155 // http functions to be used by the task class to re-try is Mascot session has expired
156 bool httpGetString(const std::string & action, std::string & result);
157 bool httpGetResponseUsingSessionId(const std::string & action, ms_http_helper_response & response);
158 bool httpGetFileUsingSessionId(
159 const std::string & action,
160 const std::string & filename,
161 ms_http_helper_progress & progress,
162 ms_http_helper::FileMode fileMode = ms_http_helper::FM_binary);
163 bool httpPostFileAppendingSessionId(
164 const std::string & action,
165 const std::string & httpHeader,
166 const std::string & prologue,
167 const std::string & filename,
168 const std::string & epilogue,
169 ms_http_helper_handles & handles,
170 ms_http_helper_progress & progress);
171 bool relogin();
172
173 bool submitSearchWide(
174 ms_http_client_search & returnTask,
175 const std::wstring & httpHeader,
176 const std::wstring & prologue,
177 const std::wstring & filename,
178 const std::wstring & epilogue,
179 ms_http_helper_progress & progress,
180 bool batch = false
181 );
182
183 ms_http_helper connection_;
184 std::string sessionId_;
185
186 SessionSecurityType security_;
187 std::string username_;
188 std::string password_;
189
190 bool isLoggedIn_;
191
192 friend class ms_http_client; // access to private constructor used when logging in
193 friend class ms_http_client_search; // access to useful getString and getFile functions
194 };
195 // end of http_client_group
197} // namespace matrix_science
198
199#endif // MS_HTTP_CLIENT_SESSION_HPP
200
201/*------------------------------- End of File -------------------------------*/
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
This gives access to a Mascot session so searches may be submitted.
Definition: ms_http_client_session.hpp:48
SequenceShowOptions
Information to include in a request for sequence data.
Definition: ms_http_client_session.hpp:58
The class provides HTTP, FTP and FILE protocol access to a server.
Definition: ms_http_helper.hpp:57