Matrix Science header

ms_http_client_session.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_http_client_session.hpp                                                #
00004 # 'msparser' toolkit                                                         #
00005 # Represents a session on a Mascot server                                    #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2013 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011  * @(#)$Source: parser/inc/ms_http_client_session.hpp $
00012  * @(#)$Revision: ad538b116c843eb04f4e6cb8ff8f73b915de025f | MSPARSER_REL_2_8_1-0-gea32989045 $
00013  * @(#)$Date: 2020-02-14 10:16:25 +0000 $
00014 ##############################################################################
00015  */
00016 
00017 #ifndef MS_HTTP_CLIENT_SESSION_HPP
00018 #define MS_HTTP_CLIENT_SESSION_HPP
00019 
00020 
00021 #include <string>
00022 #include <vector>
00023 
00024 namespace matrix_science
00025 {
00031     class ms_http_client;
00032     class ms_http_client_search;
00033 
00035 
00046     class MS_MASCOTRESFILE_API ms_http_client_session :
00047         public ms_errors
00048     {
00049     public:
00051 
00057         enum SequenceShowOptions
00058         {
00059             SHOW_PI = 0x0001, 
00060             SHOW_TITLE = 0x0002, 
00061             SHOW_LENGTH = 0x0004, 
00062             SHOW_SEQUENCE = 0x0008, 
00063             SHOW_REFERENCE = 0x0010, 
00064 
00065             SHOW_NONE = 0, 
00066             SHOW_ALL = 0xFFFF 
00067         };
00068 
00069 
00071         ms_http_client_session();
00072 
00074         ms_http_client_session(const ms_http_helper connection, const std::string sessionId);
00075 
00077         virtual ~ms_http_client_session();
00078 
00079         ms_http_client_session(const ms_http_client_session & src);
00080 #ifndef SWIG
00081         ms_http_client_session& operator=(const ms_http_client_session & right);
00082 #endif
00083         void copyFrom(const ms_http_client_session * right);
00084 
00086         std::string getSessionID() const;
00087         std::string sessionId() const { return getSessionID(); }   // Deprecated. Released with 2.5.2
00088 #ifndef SWIG
00089 
00090         bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & returnIsPermitted);
00091 #else // SWIG Multiple return values
00092         bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & OUTPUT);
00093 #endif
00094 
00095 #ifndef SWIGCSHARP
00096 
00097         bool submitSearch(
00098             ms_http_client_search & returnTask,
00099             const std::string & httpHeader,
00100             const std::string & prologue,
00101             const std::string & filename,
00102             const std::string & epilogue,
00103             ms_http_helper_progress & progress,
00104             bool batch = false);
00105 #else
00106         bool submitSearch(
00107             ms_http_client_search & returnTask,
00108             const std::wstring & httpHeader,
00109             const std::wstring & prologue,
00110             const std::wstring & filename,
00111             const std::wstring & epilogue,
00112             ms_http_helper_progress & progress,
00113             bool batch = false) {
00114                 return submitSearchWide(returnTask, httpHeader, prologue, filename, epilogue, progress, batch);
00115             };
00116 #endif
00117 
00119             bool getSequenceFile(
00120                     const std::string & database,
00121                     const std::vector<std::string> & accessionNames,
00122                     const std::vector<int> & accessionFrames,
00123                     const std::string & filename,
00124                     const SequenceShowOptions options = SHOW_ALL
00125                     );
00126 
00128             bool logout();
00129 
00131             bool getIsXmlUploadedList(const std::vector<std::string> & taskIds, std::vector<int> & xmlUploaded);
00132 
00133         private:
00134 
00135             // type of login for the session to allow re-login if session has expired
00136             enum SessionSecurityType {
00137                 SECURITY_NONE,
00138                 SECURITY_DISABLED,
00139                 SECURITY_GUEST,
00140                 SECURITY_WEB,
00141                 SECURITY_USER
00142             };
00143 
00144             ms_http_client_session(
00145                     ms_http_helper connection,
00146                     std::string sessionId,
00147                     SessionSecurityType security,
00148                     const std::string & username = "",
00149                     const std::string & password = "");
00150 
00151             // Create a new Mascot task attached to this Mascot session.
00152             bool createTask(
00153                     ms_http_client_search & returnTask);
00154 
00155             // http functions to be used by the task class to re-try is Mascot session has expired
00156             bool httpGetString(const std::string & action, std::string & result);
00157             bool httpGetResponseUsingSessionId(const std::string & action, ms_http_helper_response & response);
00158             bool httpGetFileUsingSessionId(
00159                     const std::string & action,
00160                     const std::string & filename,
00161                     ms_http_helper_progress & progress,
00162                     ms_http_helper::FileMode fileMode = ms_http_helper::FM_binary);
00163             bool httpPostFileAppendingSessionId(
00164                     const std::string & action,
00165                     const std::string & httpHeader,
00166                     const std::string & prologue,
00167                     const std::string & filename,
00168                     const std::string & epilogue,
00169                     ms_http_helper_handles & handles,
00170                     ms_http_helper_progress & progress);
00171             bool relogin();
00172 
00173             bool submitSearchWide(
00174                 ms_http_client_search & returnTask,
00175                 const std::wstring & httpHeader,
00176                 const std::wstring & prologue,
00177                 const std::wstring & filename,
00178                 const std::wstring & epilogue,
00179                 ms_http_helper_progress & progress,
00180                 bool batch = false
00181             );
00182 
00183             ms_http_helper connection_;
00184             std::string sessionId_;
00185 
00186             SessionSecurityType security_;
00187             std::string username_;
00188             std::string password_;
00189 
00190             bool isLoggedIn_;
00191 
00192         friend class ms_http_client; // access to private constructor used when logging in
00193         friend class ms_http_client_search; // access to useful getString and getFile functions
00194     };
00195  // end of http_client_group
00197 } // namespace matrix_science
00198 
00199 #endif // MS_HTTP_CLIENT_SESSION_HPP
00200 
00201 /*------------------------------- End of File -------------------------------*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29