46 LOG(
DEBUG) <<
"WsFsDaemonClient::WsFsDaemonClient() : Context created";
56 LOG(
INFO) <<
"WsFsDaemonClient::~WsFsDaemonClient() : Sending Clear Cache request to Server";
59 LOG(
INFO) <<
"WsFsDaemonClient::~WsFsDaemonClient() : interrupting thread";
61 LOG(
INFO) <<
"WsFsDaemonClient::~WsFsDaemonClient() : joining thread";
63 LOG(
INFO) <<
"WsFsDaemonClient::~WsFsDaemonClient() : thread ended";
65 LOG(
INFO) <<
"WsFsDaemonClient::~WsFsDaemonClient() : thread deleted";
94 if (
m_conf->
get(
"global",
"enable_compression",
"true") ==
"true") {
102 }
catch (zmq::error_t e) {
103 LOG(
ERROR) <<
"WsFsDaemonClient::load() : Could not connect to host" << endl;
134 }
catch (zmq::error_t e) {
135 LOG(
ERROR) <<
"WsFsDaemonClient::receive() : Could not receive on socket" << endl;
157 if (memcpy ((
void*) reply.data (), data, r) == NULL) {
158 LOG(
ERROR) <<
"WsFsDaemonClient::send() : Could not memcpy in Server" << endl;
163 if (
m_sock->send (reply) < 0) {
164 LOG(
ERROR) <<
"WsFsDaemonClient::send() : Could not send on socket " << endl;
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;
176 if (
m_sock->send (reply) < 0) {
177 LOG(
ERROR) <<
"WsFsDaemonClient::send() : Could not send on socket " << endl;
183 }
catch (zmq::error_t e) {
184 LOG(
ERROR) <<
"WsFsDaemonClienti::send(): Could not send on socket" << endl;
188 }
catch (boost::thread_resource_error e) {
200 LOG(
ERROR) <<
"WsFsDaemon::receiveAuthAnswer() : Could not authenticate on server " <<
m_uid;
204 LOG(
ERROR) <<
"WsFsDaemon::receiveAuthAnswer() : Could not parse server response ";
208 if (v != Value::null)
209 m_uid = v.asString();
211 if (v != Value::null)
214 if (v != Value::null)
217 if (v != Value::null)
225 LOG(
ERROR) <<
"WsFsDaemonClient::parse() : Could not parse received input" << endl;
236 if (resp ==
"success")
337 LOG(
ERROR) <<
"WsFsDaemonClient::receiveAccessItems() : receiveMenuItems deserialize error " << endl;
353 if (resp ==
"notlogged")
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.";
373 if (!reader.parse(resp, root,
false))
395 vector<WsResultItem> l;
403 if (!reader.parse(resp, root,
false))
408 for (
int i = 0; i < root.size(); ++i) {
424 if (!reader.parse(resp, root,
false))
435 return set<string>();
439 return set<string>();
461 int ret = boost::lexical_cast<
int>(resp);
463 }
catch (boost::bad_lexical_cast&) {
464 LOG(
ERROR) <<
"WsFsDaemonClient::receiveInt() : Could not cast received data to int";
504 LOG(
DEBUG) <<
"WsAbstractProperties :: Could not send on socket";
521 LOG(
DEBUG) <<
"WsAbstractProperties::getProperty() : Could not send on socket";
550 vector<WsResultItem> l;
564 return set<string>();
613 LOG(
ERROR)<<
"WsFsDaemonClient::createNode() : Failure";
686 return vector<string>();
694 }
else ret = string( static_cast<char*>(msg.data()), msg.size());
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";
724 boost::this_thread::sleep(boost::posix_time::milliseconds(delay * 1000));
725 }
catch (std::exception& e) {
726 LOG(
ERROR) <<
"WsFsDaemonClient::threadUpdate :" << e.what();
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
WsDecompressor * m_decompressor
std::string getProperty(const std::string §ion, const std::string &p, const std::string &prop)
returns the properties of a node
int deserialize()
Deserialize contents serialized by WsArraySerialize::serialize.
NodePtr receiveAccessItems()
receive the access tree items after a getAccessRoot request
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 std::string NodeType
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...
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...
const std::string receiveString()
receive a string after a request that returns a string
int receiveIsLockedStatus(std::string uid)
const std::string & getEmail() const
return the email of the person
std::set< string > receiveAllGroups()
receive all the groups after a getAllGroups() request
Deserializes contents of a directory sent.
const std::string ModifyDate
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...
int parse(const std::string &s)
parse the received Json from the fsdaemon
int putLock(const std::string &path)
Deserializes a tree serialized with WsTreeSerializer.
int getLock(const std::string &path)
const std::string NewPath
const std::string Section
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 §ion, 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.
int deserialize()
deserialize the Json input
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
int receive(std::string &receivedData)
receive a string from the daemon.
Interacts with the menuTree and FsTree via the daemon.
WsGlobalProperties * m_conf
std::vector< std::string > getTemplatesList(const std::string &path)
std::string m_accessTreeStamp
NodePtr getMenuRoot()
returns the menu root
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
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 §ion, 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 WsNodeProperties * getProperties(const std::string &p)
int receivePermissions()
receive the answer of a permission request
static WsGlobalProperties * instance()
bool receiveBoolean()
receive a Boolean after a request that returns a boolean
const std::string Failure
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
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 ...