Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsFsDaemon.h
Go to the documentation of this file.
1 
14 #ifndef WS_FSDAEMON_H__
15 #define WS_FSDAEMON_H__
19 #include <Auth/WsAuthenticator.h>
23 
24 #include "WsUserSession.h"
25 
26 #include <json/json.h>
27 #include <json/reader.h>
28 #include <json/writer.h>
29 #include <json/value.h>
30 
31 #include <boost/lexical_cast.hpp>
32 
33 #include <zmq.hpp>
34 
35 #include <iostream>
36 #include <set>
37 #include <vector>
38 
44 class WsFsDaemon {
45 public:
46 
47  enum DaemonStatus {
52  };
58 
62  ~WsFsDaemon();
63 
68  DaemonStatus bind(unsigned int numWorkers = 1);
69 
71 
72 private:
73 
80  DaemonStatus send(zmq::socket_t& sock, const std::string& s);
81 
88  DaemonStatus receive(zmq::socket_t& sock, std::string& receivedData);
89 
95  DaemonStatus parse(const std::string& s, Json::Value& root);
96 
102  DaemonStatus handleRequest(zmq::socket_t& sock, Json::Value& root);
103 
109  DaemonStatus handleAuthRequest(zmq::socket_t& sock, Json::Value& root);
110 
116  DaemonStatus handleGetLockRequest(zmq::socket_t& sock, Json::Value& root);
117 
123  DaemonStatus handlePutLockRequest(zmq::socket_t& sock, Json::Value& root);
124 
130  DaemonStatus handleIsLockedRequest(zmq::socket_t& sock, Json::Value& root);
131 
137  DaemonStatus handleAccessTreeRequest(zmq::socket_t& sock, Json::Value& root);
138 
144  DaemonStatus handlePermRequest(zmq::socket_t& sock, Json::Value& root);
145 
151  DaemonStatus handlePropRequest(zmq::socket_t& sock, Json::Value& root);
152 
158  DaemonStatus handleAllGroupsRequest(zmq::socket_t& sock, Json::Value& root);
159 
165  DaemonStatus handlePropsRequest(zmq::socket_t& sock, Json::Value& root);
166 
172  DaemonStatus handleSearchRequest(zmq::socket_t& sock, Json::Value& root);
173 
179  DaemonStatus handleClearCache(zmq::socket_t& sock, Json::Value& root);
180 
186  DaemonStatus handleIsAdminRequest(zmq::socket_t& sock, Json::Value& root);
187 
193  DaemonStatus handleIsEditorRequest(zmq::socket_t& sock, Json::Value& root);
194 
200  DaemonStatus handleSavePropertiesRequest(zmq::socket_t& sock, Json::Value& root);
201 
207  DaemonStatus handleSavePropertyRequest(zmq::socket_t& sock, Json::Value& root);
208 
214  DaemonStatus handleCreateNodeRequest(zmq::socket_t& sock, Json::Value& root);
215 
221  DaemonStatus handleRenameNodeRequest(zmq::socket_t& sock, Json::Value& root);
222 
228  DaemonStatus handleDeleteNodeRequest(zmq::socket_t& sock, Json::Value& root);
229 
235  DaemonStatus handleRootPathRequest(zmq::socket_t& sock, Json::Value& root);
236 
242  DaemonStatus handleGetTreeVersion(zmq::socket_t& sock, Json::Value& root);
243 
249  string rawDataToString(zmq::message_t& msg);
250 
256  bool isActiveSession(const std::string& uid, const std::string& pass, const std::string& ip);
257 
262 
267 
272 
276  map<string, WsUserSession* > m_userMap;
277 
281  set<string> m_allGroups;
282 
287 
292 
297 
298  zmq::context_t* m_context;
299 };
300 
301 #endif
Global properties.
DaemonStatus handlePermRequest(zmq::socket_t &sock, Json::Value &root)
sends the permissions of a path to the client
Definition: WsFsDaemon.cpp:333
DaemonStatus bind(unsigned int numWorkers=1)
start listening on the port
Definition: WsFsDaemon.cpp:83
WsGlobalProperties * m_conf
Definition: WsFsDaemon.h:261
map< string, WsUserSession * > m_userMap
Definition: WsFsDaemon.h:276
DaemonStatus handleRenameNodeRequest(zmq::socket_t &sock, Json::Value &root)
rename a node
Definition: WsFsDaemon.cpp:505
Global properties class.
string rawDataToString(zmq::message_t &msg)
converts raw data received on the socket to string
Definition: WsFsDaemon.cpp:574
DaemonStatus parse(const std::string &s, Json::Value &root)
Parses the received data (json)
Definition: WsFsDaemon.cpp:177
DaemonStatus handleCreateNodeRequest(zmq::socket_t &sock, Json::Value &root)
create a node requested by the client
Definition: WsFsDaemon.cpp:478
bool isActiveSession(const std::string &uid, const std::string &pass, const std::string &ip)
returns true or false whether the section of a user is still active or not
Definition: WsFsDaemon.cpp:583
WsDecompressor * m_decompressor
Definition: WsFsDaemon.h:296
~WsFsDaemon()
destructor
Definition: WsFsDaemon.cpp:40
Redirect operations to adequate class.
DaemonStatus handleSavePropertiesRequest(zmq::socket_t &sock, Json::Value &root)
saves the properties received by the client for a node
Definition: WsFsDaemon.cpp:448
Used to compress data.
Definition: WsCompressor.h:24
DaemonStatus receive(zmq::socket_t &sock, std::string &receivedData)
read data from the socket
Definition: WsFsDaemon.cpp:160
WsFsTreeOperations * m_operation
Definition: WsFsDaemon.h:271
bool m_listening
Definition: WsFsDaemon.h:266
DaemonStatus handleIsLockedRequest(zmq::socket_t &sock, Json::Value &root)
checks the lock for the path
Definition: WsFsDaemon.cpp:543
Used to decompress data.
Main class of the FsDaemon.
Definition: WsFsDaemon.h:44
zmq::context_t * m_context
Definition: WsFsDaemon.h:298
DaemonStatus send(zmq::socket_t &sock, const std::string &s)
Sends data on the socket.
Definition: WsFsDaemon.cpp:120
DaemonStatus handleSavePropertyRequest(zmq::socket_t &sock, Json::Value &root)
saves one property received by a client for a node
Definition: WsFsDaemon.cpp:461
DaemonStatus handlePropsRequest(zmq::socket_t &sock, Json::Value &root)
sends all the properties of a node
Definition: WsFsDaemon.cpp:358
DaemonStatus handleGetTreeVersion(zmq::socket_t &sock, Json::Value &root)
sends the last tree version to the client
Definition: WsFsDaemon.cpp:566
DaemonStatus handlePutLockRequest(zmq::socket_t &sock, Json::Value &root)
releases the lock for the path
Definition: WsFsDaemon.cpp:531
WsFsDaemon(WsGlobalProperties *props)
constructor for the server
Definition: WsFsDaemon.cpp:28
const std::string Value
Definition: WsRequestType.h:39
DaemonStatus handleGetLockRequest(zmq::socket_t &sock, Json::Value &root)
Acquires the lock for the path.
Definition: WsFsDaemon.cpp:519
DaemonStatus handlePropRequest(zmq::socket_t &sock, Json::Value &root)
sends a property of a node to the client
Definition: WsFsDaemon.cpp:374
WsCompressor * m_compressor
Definition: WsFsDaemon.h:291
DaemonStatus handleAuthRequest(zmq::socket_t &sock, Json::Value &root)
Authenticate user on server Loads the groups which the user belongs to, uid, email, etc..
Definition: WsFsDaemon.cpp:274
set< string > m_allGroups
Definition: WsFsDaemon.h:281
DaemonStatus handleAccessTreeRequest(zmq::socket_t &sock, Json::Value &root)
Sends the accesstree to the client.
Definition: WsFsDaemon.cpp:316
Structure representing all the fs tree from the root.
DaemonStatus handleRootPathRequest(zmq::socket_t &sock, Json::Value &root)
send the rootPath to the client
Definition: WsFsDaemon.cpp:557
DaemonStatus workerRoutine()
Definition: WsFsDaemon.cpp:48
Updates the tree and takes care of unconsistencies with the user.
DaemonStatus handleIsAdminRequest(zmq::socket_t &sock, Json::Value &root)
sends the result of an admin request so that the client can know if he is an admin or not ...
Definition: WsFsDaemon.cpp:435
DaemonStatus handleClearCache(zmq::socket_t &sock, Json::Value &root)
clears the user from the cache
Definition: WsFsDaemon.cpp:412
bool m_compress
Definition: WsFsDaemon.h:286
DaemonStatus handleSearchRequest(zmq::socket_t &sock, Json::Value &root)
sends the result of a search request to the client. Only nodes where the user has access are returned...
Definition: WsFsDaemon.cpp:389
DaemonStatus handleAllGroupsRequest(zmq::socket_t &sock, Json::Value &root)
sends all the groups available to the client
Definition: WsFsDaemon.cpp:347
DaemonStatus handleRequest(zmq::socket_t &sock, Json::Value &root)
Handle received request and redirect to correct method.
Definition: WsFsDaemon.cpp:189
DaemonStatus handleIsEditorRequest(zmq::socket_t &sock, Json::Value &root)
sends the result of an editor request so that the client can know if he is an editor or not ...
Definition: WsFsDaemon.cpp:422
DaemonStatus handleDeleteNodeRequest(zmq::socket_t &sock, Json::Value &root)
delete a node requested by the client
Definition: WsFsDaemon.cpp:492