fintp_connectors
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
FileFetcher.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef FILEFETCHER_H
22 #define FILEFETCHER_H
23 
24 #include "FS/FsWatcher.h"
25 #include "../Endpoint.h"
26 
27 #include <fstream>
28 
29 using namespace std;
30 
31 class FileFetcher : public Endpoint
32 {
33  protected :
34 
35  // methods for controlling the endpoint
36  void internalStart();
37  void internalStop();
38  void FinalMove( string& finalPath );
39 
40  public:
41 
42  // constructor
43  FileFetcher();
44 
45  //destructor
46  ~FileFetcher();
47 
48  // called before start. allows the endpoint to prepare environment
49  void Init();
50 
51  // methods for transactional execution
54  string Prepare();
55 
57  void Commit();
58 
60  void Abort();
61 
63  void Rollback();
64 
67  void Process( const string& correlationId );
68 
69  static void NotificationCallback( const AbstractWatcher::NotificationObject* notification );
70 
71  bool moreMessages() const;
72  pthread_t getWatcherThreadId() { return m_Watcher.getThreadId(); }
73 
74  private :
75 
76  static int m_PrevBatchItem;
77  BatchItem m_LastBatchItem;
78 
79  FsWatcher m_Watcher;
80 
83  ifstream m_CurrentFile;
84  unsigned long m_CurrentFileSize;
85  string m_ReconSource;
86 
87  string m_WatchPath;
88  string m_SuccessPath;
89  string m_ErrorPath;
90 
92 
93 #ifdef USING_REGULATIONS
94  string m_RepliesPath;
95  string m_Regulations;
96  string m_ParamFilePattern;
97  string m_ParamFileXslt;
98  string m_ReplyServiceName;
99  string m_RejectLAUKey;
100 #endif// USING_REGULATIONS
101 
102  static FileFetcher* m_Me;
103 
104  public :
105 
106  string getWatchPath() const { return m_WatchPath; }
107  string Serialize( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, const string& xsltFilename, const string& paramFilename, const long paramFileSize, const string& HMAC = "" );
108 };
109 
110 #endif