1 #include <Poco/JSON/Object.h>
2 #include <Poco/JSON/Array.h>
3 #include <Poco/JSON/JSON.h>
4 #include <Poco/JSON/Stringifier.h>
5 #include <Poco/JSON/Parser.h>
6 #include <Poco/JSON/JSONException.h>
7 #include <Poco/Dynamic/Var.h>
35 (*this) = std::forward<DRCETaskRequestSetExecute>(rhs);
57 sessionOptions = std::move(rhs.getSessionOptions());
58 commandLine = std::move(rhs.getCommandLine());
59 inputStream = std::move(rhs.getInputStream());
60 resourceLimits = std::move(rhs.getResourceLimits());
61 (*
dynamic_cast<DRCEFilesList*
>(
this)) = std::move(static_cast<DRCEFilesList>(rhs));
62 taskId = std::move(rhs.getTaskId());
63 taskState = std::move(rhs.getTaskState());
70 sessionOptions = std::move(std::forward<SessionOptions>(sessionOptions_));
76 resourceLimits = std::move(std::forward<ResourceLimits>(resourceLimits_));
81 sessionOptions.
clear();
84 resourceLimits.
clear();
94 Poco::JSON::Object::Ptr obj =
new Poco::JSON::Object();
96 Poco::JSON::Object::Ptr pSessionOptions =
new Poco::JSON::Object();
108 Poco::JSON::Array::Ptr pEnviroment =
new Poco::JSON::Array();
109 for (
size_t i=0;i<sessionOptions.
environments.size();++i)
111 Poco::JSON::Object::Ptr pEnviromentElem =
new Poco::JSON::Object();
113 pEnviroment->add(pEnviromentElem);
121 Poco::JSON::Object::Ptr pResourceLimits =
new Poco::JSON::Object();
140 Poco::JSON::Array::Ptr pFiles =
new Poco::JSON::Array();
143 for (
size_t i=0;i<filesCount;++i)
145 Poco::JSON::Object::Ptr pFileElem =
new Poco::JSON::Object();
149 pFiles->add(pFileElem);
153 std::stringstream ostr;
154 Poco::JSON::Stringifier::stringify(obj, ostr);
159 catch(std::exception& e)
176 Poco::JSON::Parser parser;
177 Poco::Dynamic::Var res = parser.parse(json);
178 Poco::JSON::Object::Ptr obj = res.extract<Poco::JSON::Object::Ptr>();
180 Poco::Dynamic::Var tmp;
182 if (!pSessionOptions.isNull())
190 sessionOptions.
port = convertVarToNumeric<unsigned int>(tmp, 0);
194 sessionOptions.
userName = tmp.convert<std::string>();
198 sessionOptions.
userPassword = tmp.convert<std::string>();
202 sessionOptions.
shellName = tmp.convert<std::string>();
206 sessionOptions.
homeDir = tmp.convert<std::string>();
209 sessionOptions.
timeout = convertVarToNumeric<unsigned int>(tmp, 0);
219 sessionOptions.
timeMax = convertVarToNumeric<unsigned int>(tmp, 0);
225 if (!pEnviroment.isNull())
227 for (
size_t j=0;j<pEnviroment->size();++j)
229 Poco::JSON::Object::Ptr pEnviromentElem = pEnviroment->getObject(j);
230 if (!pEnviromentElem.isNull())
232 std::vector<std::string> names;
233 pEnviromentElem->getNames(names);
234 for (
size_t k=0;k<names.size();++k)
236 tmp = pEnviromentElem->get(names[k]);
238 sessionOptions.
environments.push_back(std::make_pair(names[k], tmp.convert<std::string>()));
247 commandLine = tmp.convert<std::string>();
251 inputStream = tmp.convert<std::string>();
254 if (!pResourceLimits.isNull())
257 resourceLimits.
procMax = convertVarToNumeric<unsigned int>(tmp, 0);
260 resourceLimits.
threadsMax = convertVarToNumeric<unsigned int>(tmp, 0);
263 resourceLimits.
cpuMax = convertVarToNumeric<double>(tmp, 0);
266 resourceLimits.
iowaitMax = convertVarToNumeric<double>(tmp, 0);
269 resourceLimits.
vramFree = convertVarToNumeric<double>(tmp, 0);
272 resourceLimits.
vramFreeMin = convertVarToNumeric<size_t>(tmp, 0);
275 resourceLimits.
rramFree = convertVarToNumeric<double>(tmp, 0);
278 resourceLimits.
rramFreeMin = convertVarToNumeric<size_t>(tmp, 0);
281 resourceLimits.
diskFree = convertVarToNumeric<double>(tmp, 0);
284 resourceLimits.
diskFreeMin = convertVarToNumeric<size_t>(tmp, 0);
303 if (!pFiles.isNull())
305 for (
size_t i=0;i<pFiles->size();++i)
307 Poco::JSON::Object::Ptr pFileElem = pFiles->getObject(i);
308 if (!pFileElem.isNull())
321 catch(Poco::JSON::JSONException& e)
327 catch(Poco::Exception& e)
339 is.seekg(0, std::ios::end);
340 json.resize(is.tellg());
341 is.seekg(0, std::ios::beg);
342 is.read(const_cast<char*>(json.c_str()), json.size());