Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsFsDaemonClient.cpp
Go to the documentation of this file.
1 
14 //#ifdef HAS_DAEMON
15 
16 #include "WsFsDaemonClient.h"
20 #include <Include/WsGlobalConfig.h>
21 #include <Include/WsRequestType.h>
22 
23 using namespace zmq;
24 using namespace Json;
25 
26 zmq::context_t* WsFsDaemonClient::m_context = 0;
27 
28 WsFsDaemonClient::WsFsDaemonClient(const string& id, const string& pass, const string& ip):
29  m_uid(id),
30  m_pass(pass),
31  m_ip(ip),
32  m_name(""),
33  m_surname(""),
34  m_email(""),
35  m_rootPath(""),
36  m_isAdmin(-1),
37  m_isEditor(-1),
38  m_listen(true),
39  m_compressor(0),
40  m_decompressor(0),
41  m_sendMutex(0),
42  m_updateThread(0)
43 {
44  //Init ZMQ context
45  if (m_context == 0) {
46  LOG(DEBUG) << "WsFsDaemonClient::WsFsDaemonClient() : Context created";
47  m_context = new context_t(1);
48  }
49  m_sock = new socket_t(*m_context, ZMQ_REQ);
50  m_sendMutex = new boost::mutex();
51 }
52 
54 {
55  m_listen = false;
56  LOG(INFO) << "WsFsDaemonClient::~WsFsDaemonClient() : Sending Clear Cache request to Server";
58  if (m_updateThread) {
59  LOG(INFO) << "WsFsDaemonClient::~WsFsDaemonClient() : interrupting thread";
60  m_updateThread->interrupt();
61  LOG(INFO) << "WsFsDaemonClient::~WsFsDaemonClient() : joining thread";
62  m_updateThread->join();
63  LOG(INFO) << "WsFsDaemonClient::~WsFsDaemonClient() : thread ended";
64  delete m_updateThread;
65  LOG(INFO) << "WsFsDaemonClient::~WsFsDaemonClient() : thread deleted";
66  }
67  if (m_sendMutex)
68  delete m_sendMutex;
69  if (m_sock) {
70  m_sock->close();
71  delete m_sock;
72  }
73  if (m_compressor)
74  delete m_compressor;
75  if (m_decompressor)
76  delete m_decompressor;
77  m_updateThread = 0;
78  m_sendMutex = 0;
79  m_sock = 0;
80  m_compressor = 0;
81  m_decompressor = 0;
82 }
83 
85 {
86  /* load conf file */
88  m_conf = pio;
89  //Load Server conf
90  m_proto = m_conf->get("global", "protocol", "tcp");
91  m_host = m_conf->get("global", "host", "127.0.0.1");
92  m_port = m_conf->get("global", "port", "5555");
93  //Enable Server-Client Compression ?
94  if ( m_conf->get("global", "enable_compression", "true") == "true") {
95  m_compressor = new WsCompressor();
97  m_compress = true;
98  } else m_compress = false;
99  try {
100  /* Connect to the server */
101  m_sock->connect((m_proto + "://" + m_host + ":" + m_port).c_str());
102  } catch (zmq::error_t e) {
103  LOG(ERROR) << "WsFsDaemonClient::load() : Could not connect to host" << endl;
104  return ErrorCode::Failure;
105  }
106  if ( authentify() == ErrorCode::Failure)
107  return ErrorCode::Failure;
108  //Launch Thread that will download the tree if updated
109  m_updateThread = new boost::thread(boost::bind(&WsFsDaemonClient::threadUpdate, this));
110  return ErrorCode::Success;
111 }
112 
114 {
115  /* Prepare message to send */
116  Value v;
120  v[RequestField::Ip] = m_ip;
121  //Send request
122  if (send(v.toStyledString()) == ErrorCode::Failure)
123  return ErrorCode::Failure;
125  return ErrorCode::Failure;
126  return ErrorCode::Success;
127 }
128 
129 int WsFsDaemonClient::receive(string& receivedData)
130 {
131  message_t reply;
132  try {
133  m_sock->recv (&reply);
134  } catch (zmq::error_t e) {
135  LOG(ERROR) << "WsFsDaemonClient::receive() : Could not receive on socket" << endl;
136  m_sendMutex->unlock();
137  return ErrorCode::Failure;
138  }
139  receivedData = rawDataToString(reply);
140  m_sendMutex->unlock();
141  return ErrorCode::Success;
142 }
143 
144 int WsFsDaemonClient::send(const string& s)
145 {
146  try {
147  m_sendMutex->lock();
148  try {
149  if (m_compress) {
150  /* Compress data */
151  char* data;
152  long r = m_compressor->compress(s, &data);
153  if (r == ErrorCode::Failure)
154  return ErrorCode::Failure;
155  message_t reply(r);
156  /* Copy contents of the message */
157  if (memcpy ((void*) reply.data (), data, r) == NULL) {
158  LOG(ERROR) << "WsFsDaemonClient::send() : Could not memcpy in Server" << endl;
159  m_sendMutex->unlock();
160  return ErrorCode::Failure;
161  }
162  /* Send the message */
163  if (m_sock->send (reply) < 0) {
164  LOG(ERROR) << "WsFsDaemonClient::send() : Could not send on socket " << endl;
165  m_sendMutex->unlock();
166  return ErrorCode::Failure;
167  }
168  } else {
169  /* Send without compression */
170  message_t reply(s.length());
171  if (memcpy ((void*) reply.data (), s.c_str(), s.length()) == NULL) {
172  LOG(ERROR) << "WsFsDaemonClient::send() : Could not memcpy in Server" << endl;
173  m_sendMutex->unlock();
174  return ErrorCode::Failure;
175  }
176  if (m_sock->send (reply) < 0) {
177  LOG(ERROR) << "WsFsDaemonClient::send() : Could not send on socket " << endl;
178  m_sendMutex->unlock();
179  return ErrorCode::Failure;
180  }
181  }
182  return ErrorCode::Success;
183  } catch (zmq::error_t e) {
184  LOG(ERROR) << "WsFsDaemonClienti::send(): Could not send on socket" << endl;
185  m_sendMutex->unlock();
186  return ErrorCode::Failure;
187  }
188  } catch (boost::thread_resource_error e) {
189  return ErrorCode::Failure;
190  }
191  return ErrorCode::Success;
192 }
193 
195 {
196  string resp;
197  if (receive(resp) == ErrorCode::Failure)
198  return ErrorCode::Failure;
199  if (resp == RequestField::Failure || resp == "notlogged") {
200  LOG(ERROR) << "WsFsDaemon::receiveAuthAnswer() : Could not authenticate on server " << m_uid;
201  return ErrorCode::Failure;
202  }
203  if (parse(resp) == ErrorCode::Failure) {
204  LOG(ERROR) << "WsFsDaemon::receiveAuthAnswer() : Could not parse server response ";
205  return ErrorCode::Failure;
206  }
208  if (v != Value::null)
209  m_uid = v.asString();
211  if (v != Value::null)
212  m_name = v.asString();
214  if (v != Value::null)
215  m_surname = v.asString();
217  if (v != Value::null)
218  m_email = v.asString();
219  return ErrorCode::Success;
220 }
221 
222 int WsFsDaemonClient::parse(const string& s)
223 {
224  if (!m_reader.parse(s, m_root, false)) {
225  LOG(ERROR) << "WsFsDaemonClient::parse() : Could not parse received input" << endl;
226  return ErrorCode::Failure;
227  }
228  return ErrorCode::Success;
229 }
230 
232 {
233  string resp;
234  if ( receive(resp) == ErrorCode::Failure)
235  return ErrorCode::Failure;
236  if (resp == "success")
237  return ErrorCode::Success;
238  return ErrorCode::Failure;
239 }
240 
241 
243 {
244  Value v;
248  v[RequestField::Ip] = m_ip;
249  if (send(v.toStyledString()) == ErrorCode::Failure)
250  return ErrorCode::Failure;
252  return ErrorCode::Failure;
253  return ErrorCode::Success;
254 }
255 
256 int WsFsDaemonClient::getLock(const std::string& path)
257 {
258  Value v;
262  v[RequestField::Ip] = m_ip;
263  v[RequestField::Path] = path;
264  if (send(v.toStyledString()) == ErrorCode::Failure)
265  return ErrorCode::Failure;
266  return receiveInt();
267 }
268 
269 int WsFsDaemonClient::isLocked(const std::string& path, std::string& uid)
270 {
271  Value v;
275  v[RequestField::Ip] = m_ip;
276  v[RequestField::Path] = path;
277  if (send(v.toStyledString()) == ErrorCode::Failure)
278  return ErrorCode::Failure;
279  return receiveIsLockedStatus(uid);
280 }
281 
282 int WsFsDaemonClient::putLock(const std::string& path)
283 {
284  Value v;
288  v[RequestField::Ip] = m_ip;
289  v[RequestField::Path] = path;
290  if (send(v.toStyledString()) == ErrorCode::Failure)
291  return ErrorCode::Failure;
292  return receiveInt();
293 }
294 
295 NodePtr WsFsDaemonClient::getAccessRoot( const bool& forceUpdate)
296 {
297  /* Lock the mutex to avoid context error with zmq as 2 threads are accessing the same socket */
298  if (!forceUpdate && m_accessRoot.get() != 0)
299  return m_accessRoot;
300  Value v;
304  v[RequestField::Ip] = m_ip;
305  if (send( v.toStyledString()) == ErrorCode::Failure)
306  return NodePtr();
307  return receiveAccessItems();
308 }
309 
311 {
312  /* Avoid fetching path each time */
313  if (m_rootPath.size() > 0)
314  return m_rootPath;
315  Value v;
319  v[RequestField::Ip] = m_ip;
320  if (send(v.toStyledString()) == ErrorCode::Failure)
321  return "";;
323  return m_rootPath;
324 }
325 
327 {
328  string resp;
329  if (receive(resp) == ErrorCode::Failure)
330  return NodePtr();
331  /* Check if no error occured server-side */
332  if (resp == RequestField::Failure || resp == "notlogged")
333  return NodePtr();
334  /* Deserialize the tree */
335  WsTreeDeserializer des(resp);
336  if (des.deserialize() == ErrorCode::Failure) {
337  LOG(ERROR) << "WsFsDaemonClient::receiveAccessItems() : receiveMenuItems deserialize error " << endl;
338  return NodePtr();
339  }
340  /* Set the new access tree and it's stamp */
341  m_accessRoot = des.getMenuRoot();
342  m_accessTreeStamp = des.getStamp();
343  return m_accessRoot;
344 }
345 
347 {
348  string resp;
349  if (receive( resp) == ErrorCode::Failure)
350  return ErrorCode::NoAccess;
351  if (resp == RequestField::Failure)
352  return ErrorCode::NoAccess;
353  if (resp == "notlogged")
354  return ErrorCode::NotLogged;
355  try {
356  return boost::lexical_cast<int>(resp);
357  } catch (boost::bad_lexical_cast&) {
358  LOG(ERROR) << "WsFsDaemonClient::receivePermissions() : Cannot cast received permissions to int. Possible transmission problem.";
359  return ErrorCode::NoAccess;
360  }
361  return ErrorCode::NoAccess;
362 }
363 
365 {
366  Value root;
367  Reader reader;
368  string resp;
369  if (receive( resp) == ErrorCode::Failure)
370  return NULL;
371  if (resp == RequestField::Failure || resp == "notlogged")
372  return NULL;
373  if (!reader.parse(resp, root, false))
374  return NULL;
375  WsNodeProperties* props = new WsNodeProperties(resp);
376  return props;
377 }
378 
379 
381 {
382  Value root;
383  Reader reader;
384  string resp;
385  if (receive( resp) == ErrorCode::Failure)
386  return "";
387  if (resp == RequestField::Failure || resp == "notlogged")
388  return "";
389  return resp;
390 }
391 
393 {
394  Value root;
395  vector<WsResultItem> l;
396  Reader reader;
397  string resp;
398  if (receive( resp) == ErrorCode::Failure) {
399  return l;
400  }
401  if (resp == RequestField::Failure || resp == "notlogged")
402  return l;
403  if (!reader.parse(resp, root, false))
404  return l;
405  /* Get the rootPath */
406  path basePath(WsGlobalProperties::instance()->get("global", "root_path", "/"));
407  /* For each item found create a ResultItem */
408  for (int i = 0; i < root.size(); ++i) {
409  path p(root[i][RequestField::Path].asString());
410  /* Result item is like a WsNode, needs fullPath and rootPath */
411  WsResultItem r(basePath / p, basePath, root[i][RequestField::Body].asString(), root[i][RequestField::Type].asString(), root[i][RequestField::Size].asInt());
412  r.setModifyDate(root[i][RequestField::ModifyDate].asInt());
413  l.push_back(r);
414  }
415  return l;
416 }
417 
419  Value root;
420  Reader reader;
421  string resp;
422  if(receive(resp) == ErrorCode::Failure)
423  return ErrorCode::Failure;
424  if (!reader.parse(resp, root, false))
425  return ErrorCode::Failure;
426  int v = root[RequestField::Value].asInt();
427  uid = root[RequestField::Uid].asString();
428  return v;
429 }
430 
432 {
433  string resp;
434  if (receive( resp) == ErrorCode::Failure) {
435  return set<string>();
436  }
437  WsArrayDeserializer s(resp);
438  if ( s.deserialize() == ErrorCode::Failure)
439  return set<string>();
440  return s.getContents();
441 }
442 
444 {
445  string resp;
446  if (receive( resp) == ErrorCode::Failure) {
447  return false;
448  }
449  if (resp == "true")
450  return true;
451  return false;
452 }
453 
455 {
456  string resp;
457  if (receive( resp) == ErrorCode::Failure) {
458  return ErrorCode::Failure;
459  }
460  try {
461  int ret = boost::lexical_cast<int>(resp);
462  return ret;
463  } catch (boost::bad_lexical_cast&) {
464  LOG(ERROR) << "WsFsDaemonClient::receiveInt() : Could not cast received data to int";
465  return ErrorCode::Failure;
466  }
467 }
468 
470 {
471  Value root;
472  Reader reader;
473  string resp;
474  if (receive(resp) == ErrorCode::Failure)
475  return "";
476  if (resp == RequestField::Failure || resp == "notlogged")
477  return "";
478  return resp;
479 }
480 
481 
483 {
484  Value v;
488  v[RequestField::Ip] = m_ip;
489  v[RequestField::Path] = p;
490  if (send(v.toStyledString()) == ErrorCode::Failure)
491  return ErrorCode::NoAccess;
492  return receivePermissions();
493 }
494 
496 {
497  Value v;
501  v[RequestField::Ip] = m_ip;
502  v[RequestField::Path] = p;
503  if (send(v.toStyledString()) == ErrorCode::Failure) {
504  LOG(DEBUG) << "WsAbstractProperties :: Could not send on socket";
505  return NULL;
506  }
507  return receiveProperties();
508 }
509 
510 string WsFsDaemonClient::getProperty(const std::string& section, const string& p, const string& prop)
511 {
512  Value v;
516  v[RequestField::Ip] = m_ip;
517  v[RequestField::Path] = p;
518  v[RequestField::Section] = section;
519  v[RequestField::Property] = prop;
520  if (send(v.toStyledString()) == ErrorCode::Failure) {
521  LOG(DEBUG) << "WsAbstractProperties::getProperty() : Could not send on socket";
522  return NULL;
523  }
524  return receiveProperty();
525 }
526 
527 const string& WsFsDaemonClient::getSurname() const
528 {
529  return m_surname;
530 }
531 
532 const string& WsFsDaemonClient::getFirstName() const
533 {
534  return m_name;
535 }
536 
537 const string& WsFsDaemonClient::getEmail() const
538 {
539  return m_email;
540 }
541 
542 vector<WsResultItem> WsFsDaemonClient::getSearchResults(const string& terms)
543 {
544  Value v;
548  v[RequestField::Ip] = m_ip;
549  v[RequestField::Terms] = terms;
550  vector<WsResultItem> l;
551  if (send( v.toStyledString()) == ErrorCode::Failure)
552  return l;
553  return receiveSearchResults();
554 }
555 
557 {
558  Value v;
562  v[RequestField::Ip] = m_ip;
563  if (send(v.toStyledString()) == ErrorCode::Failure)
564  return set<string>();
565  return receiveAllGroups();
566 }
567 
569 {
570  Value v;
574  v[RequestField::Ip] = m_ip;
575  v[RequestField::Path] = p;
576  v[RequestField::Property] = props->getRoot();
577  if (send( v.toStyledString()) == ErrorCode::Failure)
578  return ErrorCode::Failure;
579  return receiveSuccessCode();
580 }
581 
582 int WsFsDaemonClient::saveProperty(const std::string& p, const std::string& section, const string& attr, const string& val)
583 {
584  Value v;
588  v[RequestField::Ip] = m_ip;
589  v[RequestField::Path] = p;
590  v[RequestField::Section] = section;
591  v[RequestField::Key] = attr;
592  v[RequestField::Value] = val;
593  if (send( v.toStyledString()) == ErrorCode::Failure)
594  return ErrorCode::Failure;
595  return receiveSuccessCode();
596 }
597 
598 int WsFsDaemonClient::createNode(const string& p, int type)
599 {
600  Value v;
604  v[RequestField::Ip] = m_ip;
605  v[RequestField::Path] = p;
606  v[RequestField::NodeType] = type;
607  if (send( v.toStyledString()) == ErrorCode::Failure)
608  return ErrorCode::Failure;
610  getAccessRoot(true);
611  return ErrorCode::Success;
612  }
613  LOG(ERROR)<<"WsFsDaemonClient::createNode() : Failure";
614  return ErrorCode::Failure;
615 }
616 
617 int WsFsDaemonClient::deleteNode(const string& p)
618 {
619  Value v;
623  v[RequestField::Ip] = m_ip;
624  v[RequestField::Path] = p;
625  if (send(v.toStyledString()) == ErrorCode::Failure)
626  return ErrorCode::Failure;
628  getAccessRoot(true);
629  return ErrorCode::Success;
630  }
631  return ErrorCode::Failure;
632 }
633 
634 int WsFsDaemonClient::renameNode(const string& p, const string& newPath)
635 {
636  Value v;
640  v[RequestField::Ip] = m_ip;
641  v[RequestField::Path] = p;
642  v[RequestField::NewPath] = newPath;
643  if (send(v.toStyledString()) == ErrorCode::Failure)
644  return ErrorCode::Failure;
646  getAccessRoot(true);
647  return ErrorCode::Success;
648  }
649 }
650 
652 {
653  if ( m_isEditor != -1)
654  return m_isEditor == 0 ? false : true;
655  Value v;
659  v[RequestField::Ip] = m_ip;
660  if (send( v.toStyledString()) == ErrorCode::Failure)
661  return false;
662  bool r = receiveBoolean();
663  m_isEditor = r ? 1 : 0;
664  return r;
665 }
666 
668 {
669  if ( m_isAdmin != -1)
670  return m_isAdmin == 0 ? false : true;
671  Value v;
675  v[RequestField::Ip] = m_ip;
676  if (send( v.toStyledString()) == ErrorCode::Failure)
677  return false;
678  bool r = receiveBoolean();
679  m_isAdmin = r ? 1 : 0;
680  return r;
681 }
682 
683 vector<string> WsFsDaemonClient::getTemplatesList(const string& path)
684 {
685  //TODO
686  return vector<string>();
687 }
688 
689 string WsFsDaemonClient::rawDataToString(zmq::message_t& msg)
690 {
691  string ret;
692  if (m_compress) {
693  m_decompressor->decompress(static_cast<char*>(msg.data()), msg.size(), ret);
694  } else ret = string( static_cast<char*>(msg.data()), msg.size());
695  return ret;
696 }
697 
699 {
700  Value v;
704  v[RequestField::Ip] = m_ip;
705  int delay;
706  try {
707  delay = boost::lexical_cast<int>(m_conf->get("global", "tree_check_delay", "120"));
708  } catch (boost::bad_lexical_cast&) {
709  LOG(ERROR) << "WsFsDaemonClient::threadUpdate() : Could not cast tree_check_delay to int. Assuming 120s";
710  delay = 120;
711  }
712  //Loop and check if new tree exists every 'delay'. Retrieve it if updated
713  while (m_listen) {
714  try {
715  //Socket is closed
716  if (!m_sock || !m_listen)
717  return ErrorCode::Success;
718  //Send the request
719  if (send(v.toStyledString()) == ErrorCode::Failure)
720  return ErrorCode::Failure;
721  string v = receiveString();
722  if ( v != m_accessTreeStamp )
723  getAccessRoot(true);
724  boost::this_thread::sleep(boost::posix_time::milliseconds(delay * 1000));
725  } catch (std::exception& e) {
726  LOG(ERROR) << "WsFsDaemonClient::threadUpdate :" << e.what();
727  return ErrorCode::Failure;
728  }
729  }
730 }
731 
732 //#endif // HAS_DAEMON
Global properties.
int authentify()
authenticate user. Sends an auth request to the daemon
const std::string receiveProperty()
receive a property after a getProperty request
int send(const std::string &message)
sends a string to the daemon
RequestType enum variables.
WsFsDaemonClient(const std::string &id, const std::string &pass, const std::string &ip)
constructor
std::set< string > getAllGroups()
boost::shared_ptr< WsAbstractNode > NodePtr
const std::string Surname
Definition: WsRequestType.h:24
const std::string Path
Definition: WsRequestType.h:28
WsDecompressor * m_decompressor
std::string getProperty(const std::string &section, const std::string &p, const std::string &prop)
returns the properties of a node
int deserialize()
Deserialize contents serialized by WsArraySerialize::serialize.
#define DEBUG
Definition: WsLogger.h:27
NodePtr receiveAccessItems()
receive the access tree items after a getAccessRoot request
Global properties class.
boost::mutex * m_sendMutex
int receiveAuthAnswer()
receive the answer after performing an Auth request to the daemon
int receiveInt()
receive an int after a request that returns an int
int threadUpdate()
Launch the routine that will retrieve new AccessTree from fsdaemon This method should be called in a ...
const int Failure
const std::string NodeType
Definition: WsRequestType.h:40
const std::string & getStamp()
Get the Stamp of the serialized tree.
static zmq::context_t * m_context
~WsFsDaemonClient()
destructor
int receiveSuccessCode()
receive the success code after a request that returns a SUCCESS or FAILURE answer only ...
void setModifyDate(const time_t &t)
sets the modification date of the file. This method does not change the actual modification date of t...
Definition: WsNode.cpp:254
WsCompressor * m_compressor
const WsNodeProperties * receiveProperties()
receive the properties after a getProperties request
int clearServerCache()
clears the server cache (removes the ldap results cached
int deleteNode(const string &path)
delete a node. The user must be an Admin on editor to remove the node In case of a WsDirNode...
Properties of a WsNode.
Used to compress data.
Definition: WsCompressor.h:24
const std::string receiveString()
receive a string after a request that returns a string
const std::string Pass
Definition: WsRequestType.h:22
int receiveIsLockedStatus(std::string uid)
const std::string & getEmail() const
return the email of the person
std::string m_surname
std::set< string > receiveAllGroups()
receive all the groups after a getAllGroups() request
Deserializes contents of a directory sent.
const std::string ModifyDate
Definition: WsRequestType.h:37
int createNode(const string &path, int type)
create a directory or File. If the node is a WsDirNode than it will be only accessible to the Admin a...
Used to decompress data.
int parse(const std::string &s)
parse the received Json from the fsdaemon
std::string m_rootPath
const std::string Email
Definition: WsRequestType.h:25
int putLock(const std::string &path)
Deserializes a tree serialized with WsTreeSerializer.
int getLock(const std::string &path)
const std::string NewPath
Definition: WsRequestType.h:31
const std::string Section
Definition: WsRequestType.h:29
std::string rawDataToString(zmq::message_t &msg)
Converts raw data received to string. This method should be used each time data is received from netw...
const std::string & getFirstName() const
return the name of the person
int saveProperty(const std::string &path, const std::string &section, const std::string &attr, const std::string &val)
sets one property of the node and save it on disk.
int load()
loads the user info
int saveProperties(WsNodeProperties *props, const std::string &path)
save the properties of the node on disk. The user must have access and edit rights for the node...
Represents a Result of a search.
Definition: WsResultItem.h:27
#define LOG
Definition: WsLogger.h:22
int deserialize()
deserialize the Json input
const int NotLogged
Json::Value getRoot()
Return the root of the Json tree.
boost::thread * m_updateThread
const std::string & getSurname() const
return the surname of the person
const std::string Size
Definition: WsRequestType.h:36
int receive(std::string &receivedData)
receive a string from the daemon.
#define INFO
Definition: WsLogger.h:32
Interacts with the menuTree and FsTree via the daemon.
const int NoAccess
WsGlobalProperties * m_conf
std::vector< std::string > getTemplatesList(const std::string &path)
std::string m_accessTreeStamp
NodePtr getMenuRoot()
returns the menu root
Deserializes an array.
long decompress(const char *data, size_t size, std::string &uncompressedData)
decompress the input data and store result in uncompressedData
vector< WsResultItem > getSearchResults(const std::string &terms)
search for all matching results of terms using WsSearch class
const std::string Type
Definition: WsRequestType.h:19
const std::string Uid
Definition: WsRequestType.h:20
long compress(const std::string &data, char **compressedData)
compress the input string (data) and puts it in compressedData.
Deserializes received contents on network.
std::string get(const std::string &section, const std::string &id, const std::string &def)
NodePtr getAccessRoot(const bool &forceUpdate=false)
return the root node of the access tree starting from the root
const std::string Value
Definition: WsRequestType.h:39
const std::string Ip
Definition: WsRequestType.h:21
const WsNodeProperties * getProperties(const std::string &p)
const std::string Body
Definition: WsRequestType.h:35
int receivePermissions()
receive the answer of a permission request
static WsGlobalProperties * instance()
const std::string Name
Definition: WsRequestType.h:23
zmq::socket_t * m_sock
bool receiveBoolean()
receive a Boolean after a request that returns a boolean
const std::string Key
Definition: WsRequestType.h:38
const std::string Failure
Definition: WsRequestType.h:33
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
int isLocked(const std::string &path, std::string &uid)
const std::string Property
Definition: WsRequestType.h:30
const int Success
Json::Reader m_reader
#define ERROR
Definition: WsLogger.h:42
int renameNode(const string &path, const string &newPath)
renames a node In case of a WsDirNode, all the contents of the directory and the directory will be mo...
vector< WsResultItem > receiveSearchResults()
receive the search results after a getSearchResults() request
int getPermissions(const std::string &p)
Load infos of the user.
const std::set< std::string > getContents()
returns the set serialized The method deserialize must be called prior to this method ...
const std::string Terms
Definition: WsRequestType.h:34