RequestExportResult.cpp
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "RequestExportResult.h"
#include "../TimeManager/TimeManager.h"
#include "../File/FileFormatManager.h"
using namespace TREPS::TimeManager;
using namespace TREPS::File;
namespace TREPS
{
namespace RequestManager
{
RequestExportResultClass::RequestExportResultClass(void): filePath(""), fileFormat(""), success(false)
{
}
RequestExportResultClass::~RequestExportResultClass(void)
{
}
string RequestExportResultClass::getRequestId(void)
{
return "export_result";
}
bool RequestExportResultClass::load(RequestLoaderClass *loader)
{
this->success = false;
//init request and lock working dir
if (!this->initOpId(loader,true))
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot get op Id");
return false;
}
return true;
}
bool RequestExportResultClass::run(void)
{
this->success = false;
//get export path
this->filePath = this->dirMgr->getExportedPathFromId(this->opId.c_str());
if (this->filePath.compare("") == 0)
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot get exported file path");
return false;
}
//
FileFormatManagerClass *formatMgr = new FileFormatManagerClass();
t_FileFormat format = formatMgr->detectFileFormat(this->filePath.c_str());
if (format == FF_NONE)
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Unknown file format");
delete formatMgr;
return false;
}
this->fileFormat = formatMgr->getFileFormatIdFromFileFormat(format);
delete formatMgr;
this->success = true;
return this->success;
}
void RequestExportResultClass::writeResult(ResultWriterClass *writer)
{
if (!this->success)
writer->setError("Internal error during export result request");
else
{
writer->setSuccess();
writer->addStrArg("path",this->filePath.c_str());
writer->addStrArg("format",this->fileFormat.c_str());
}
}
string RequestExportResultClass::getResultFileSuffix(void)
{
//nothing to do
return "";
}
string RequestExportResultClass::getXMLFilePath(void)
{
//nothing to do
return "";
}
string RequestExportResultClass::getStringResult(void)
{
//nothing to do
return "";
}
}
}