Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
WsFsDaemonClient Class Reference

Interface between the User class and the fsdaemon. More...

#include <WsFsDaemonClient.h>

Inheritance diagram for WsFsDaemonClient:
Inheritance graph
Collaboration diagram for WsFsDaemonClient:
Collaboration graph

Public Member Functions

 WsFsDaemonClient (const std::string &id, const std::string &pass, const std::string &ip)
 constructor More...
 
 ~WsFsDaemonClient ()
 destructor More...
 
int clearServerCache ()
 clears the server cache (removes the ldap results cached More...
 
int load ()
 loads the user info More...
 
int getPermissions (const std::string &p)
 Load infos of the user. More...
 
const WsNodePropertiesgetProperties (const std::string &p)
 
std::string getProperty (const std::string &section, const std::string &p, const std::string &prop)
 returns the properties of a node More...
 
const std::string & getSurname () const
 return the surname of the person More...
 
const std::string & getFirstName () const
 return the name of the person More...
 
const std::string & getEmail () const
 return the email of the person More...
 
int getLock (const std::string &path)
 
int putLock (const std::string &path)
 
int isLocked (const std::string &path, std::string &uid)
 
NodePtr getAccessRoot (const bool &forceUpdate=false)
 return the root node of the access tree starting from the root More...
 
vector< WsResultItemgetSearchResults (const std::string &terms)
 search for all matching results of terms using WsSearch class More...
 
std::set< string > getAllGroups ()
 
const std::string getRootPath ()
 return the root path of the filesystem tree, example : /var/www/demo_site More...
 
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. More...
 
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 and the editor who created the node More...
 
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, all the contents of the directory and the directory will be deleted More...
 
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 moved More...
 
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. More...
 
bool isEditor ()
 
bool isAdministrator ()
 
std::vector< std::string > getTemplatesList (const std::string &path)
 

Private Member Functions

int authentify ()
 authenticate user. Sends an auth request to the daemon More...
 
int send (const std::string &message)
 sends a string to the daemon More...
 
int receive (std::string &receivedData)
 receive a string from the daemon. More...
 
int receiveAuthAnswer ()
 receive the answer after performing an Auth request to the daemon More...
 
int receiveSuccessCode ()
 receive the success code after a request that returns a SUCCESS or FAILURE answer only More...
 
int receivePermissions ()
 receive the answer of a permission request More...
 
bool receiveBoolean ()
 receive a Boolean after a request that returns a boolean More...
 
int receiveInt ()
 receive an int after a request that returns an int More...
 
const std::string receiveString ()
 receive a string after a request that returns a string More...
 
const WsNodePropertiesreceiveProperties ()
 receive the properties after a getProperties request More...
 
const std::string receiveProperty ()
 receive a property after a getProperty request More...
 
NodePtr receiveAccessItems ()
 receive the access tree items after a getAccessRoot request More...
 
vector< WsResultItemreceiveSearchResults ()
 receive the search results after a getSearchResults() request More...
 
int receiveIsLockedStatus (std::string uid)
 
std::set< string > receiveAllGroups ()
 receive all the groups after a getAllGroups() request More...
 
std::string rawDataToString (zmq::message_t &msg)
 Converts raw data received to string. This method should be used each time data is received from network to decode it and be sure everything has been read. More...
 
int parse (const std::string &s)
 parse the received Json from the fsdaemon More...
 
int threadUpdate ()
 Launch the routine that will retrieve new AccessTree from fsdaemon This method should be called in a different thread. More...
 

Private Attributes

std::string m_uid
 
std::string m_pass
 
std::string m_ip
 
std::string m_email
 
std::string m_name
 
std::string m_surname
 
std::string m_host
 
std::string m_port
 
std::string m_proto
 
WsGlobalPropertiesm_conf
 
Json::Reader m_reader
 
Json::Value m_root
 
bool m_compress
 
NodePtr m_accessRoot
 
NodePtr m_menuRoot
 
std::string m_accessTreeStamp
 
std::string m_menuTreeStamp
 
std::string m_rootPath
 
int m_isAdmin
 
int m_isEditor
 
bool m_listen
 
zmq::socket_t * m_sock
 
WsCompressorm_compressor
 
WsDecompressorm_decompressor
 
boost::mutex * m_sendMutex
 
boost::thread * m_updateThread
 

Static Private Attributes

static zmq::context_t * m_context = 0
 

Detailed Description

Interface between the User class and the fsdaemon.

Used dynamcally when using FsDaemon

Definition at line 33 of file WsFsDaemonClient.h.

Constructor & Destructor Documentation

WsFsDaemonClient::WsFsDaemonClient ( const std::string &  id,
const std::string &  pass,
const std::string &  ip 
)

constructor

Parameters
idthe user id

Definition at line 28 of file WsFsDaemonClient.cpp.

WsFsDaemonClient::~WsFsDaemonClient ( )

destructor

Definition at line 53 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Member Function Documentation

int WsFsDaemonClient::authentify ( )
private

authenticate user. Sends an auth request to the daemon

Returns
SUCCESS if user has been authenticated, FAILURE otherwise

Definition at line 113 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::clearServerCache ( )

clears the server cache (removes the ldap results cached

Definition at line 242 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::createNode ( const string &  path,
int  type 
)
virtual

create a directory or File. If the node is a WsDirNode than it will be only accessible to the Admin and the editor who created the node

Parameters
paththe relative path starting from root
typea NodeType enum { File, Directory }
Returns
ErrorCode::Success if ok, ErrorCode::NotFound if path is not found, ErrorCode::NoAccess if access denied and ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 598 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::deleteNode ( const string &  path)
virtual

delete a node. The user must be an Admin on editor to remove the node In case of a WsDirNode, all the contents of the directory and the directory will be deleted

Parameters
paththe path to the node
Returns
ErrorCode::Success if ok, ErrorCode::NotFound if path is not found, ErrorCode::NoAccess if access denied and ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 617 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

NodePtr WsFsDaemonClient::getAccessRoot ( const bool &  forceUpdate = false)
virtual

return the root node of the access tree starting from the root

Returns
NULL if the path is incorrect or if the user does not have access rights to it otherwise a NodePtr to the rootNode is returned

Implements WsAbstractFsClient.

Definition at line 295 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

set< string > WsFsDaemonClient::getAllGroups ( )
virtual

Implements WsAbstractFsClient.

Definition at line 556 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

const string & WsFsDaemonClient::getEmail ( ) const
virtual

return the email of the person

Returns
the email or an empty string if not found

Implements WsAbstractFsClient.

Definition at line 537 of file WsFsDaemonClient.cpp.

const string & WsFsDaemonClient::getFirstName ( ) const
virtual

return the name of the person

Returns
the name or an empty string if not found

Implements WsAbstractFsClient.

Definition at line 532 of file WsFsDaemonClient.cpp.

int WsFsDaemonClient::getLock ( const std::string &  path)
virtual

Implements WsAbstractFsClient.

Definition at line 256 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::getPermissions ( const std::string &  p)
virtual

Load infos of the user.

Loads the name, surname, email, groups ..

Returns
ErrorCode::Success if load is completed successfully, ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 482 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

const WsNodeProperties * WsFsDaemonClient::getProperties ( const std::string &  p)
virtual

Implements WsAbstractFsClient.

Definition at line 495 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

string WsFsDaemonClient::getProperty ( const std::string &  section,
const std::string &  p,
const std::string &  prop 
)
virtual

returns the properties of a node

Parameters
pthe path to the node
Returns
a NodePtr containing a WsAbstractNode

Implements WsAbstractFsClient.

Definition at line 510 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

const string WsFsDaemonClient::getRootPath ( )
virtual

return the root path of the filesystem tree, example : /var/www/demo_site

Implements WsAbstractFsClient.

Definition at line 310 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

vector< WsResultItem > WsFsDaemonClient::getSearchResults ( const std::string &  terms)
virtual

search for all matching results of terms using WsSearch class

Parameters
termsthe terms to match results where found or if an error occured during the process.
Returns
a vector containing the results as WsResultItem or an empty vector if no results found

Implements WsAbstractFsClient.

Definition at line 542 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

const string & WsFsDaemonClient::getSurname ( ) const
virtual

return the surname of the person

Returns
the surname or an empty string if not found

Implements WsAbstractFsClient.

Definition at line 527 of file WsFsDaemonClient.cpp.

vector< string > WsFsDaemonClient::getTemplatesList ( const std::string &  path)
virtual

Implements WsAbstractFsClient.

Definition at line 683 of file WsFsDaemonClient.cpp.

bool WsFsDaemonClient::isAdministrator ( )
virtual

Returns
true if the actual user is an admin

Implements WsAbstractFsClient.

Definition at line 667 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

bool WsFsDaemonClient::isEditor ( )
virtual

Returns
true if actual user is an editor

Implements WsAbstractFsClient.

Definition at line 651 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::isLocked ( const std::string &  path,
std::string &  uid 
)
virtual

Implements WsAbstractFsClient.

Definition at line 269 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::load ( )
virtual

loads the user info

Implements WsAbstractFsClient.

Definition at line 84 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::parse ( const std::string &  s)
private

parse the received Json from the fsdaemon

Parameters
sthe received string from the fsdaemon
Returns
SUCCESS if parsed succeeded, FAILURE otherwise

Definition at line 222 of file WsFsDaemonClient.cpp.

Here is the caller graph for this function:

int WsFsDaemonClient::putLock ( const std::string &  path)
virtual

Implements WsAbstractFsClient.

Definition at line 282 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

string WsFsDaemonClient::rawDataToString ( zmq::message_t &  msg)
private

Converts raw data received to string. This method should be used each time data is received from network to decode it and be sure everything has been read.

Parameters
msgthe zmq::message_t receveived from the network
Returns
the string decoded

Definition at line 689 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receive ( std::string &  receivedData)
private

receive a string from the daemon.

Returns
SUCCESS or FAILURE
Parameters
receivedDataa string where will be stored the received input

Definition at line 129 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NodePtr WsFsDaemonClient::receiveAccessItems ( )
private

receive the access tree items after a getAccessRoot request

See Also
WsAbstractFsClient::getAccessRoot()

Definition at line 326 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

set< string > WsFsDaemonClient::receiveAllGroups ( )
private

receive all the groups after a getAllGroups() request

See Also
WsAbstractFsClient::getAllGroups()
Returns
a set of gids or an empty set if no groups or failure

Definition at line 431 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receiveAuthAnswer ( )
private

receive the answer after performing an Auth request to the daemon

Returns
SUCCESS or FAILURE if user cannot be authenticated (due to network failure, software failure or if his not in the DB

Definition at line 194 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool WsFsDaemonClient::receiveBoolean ( )
private

receive a Boolean after a request that returns a boolean

Returns
true or false depending on the answer received

Definition at line 443 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receiveInt ( )
private

receive an int after a request that returns an int

Returns
an int

Definition at line 454 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receiveIsLockedStatus ( std::string  uid)
private

Definition at line 418 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receivePermissions ( )
private

receive the answer of a permission request

See Also
WsFsDaemonClient::getPermissions()
Returns
SUCCESS or FAILURE

Definition at line 346 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const WsNodeProperties * WsFsDaemonClient::receiveProperties ( )
private

receive the properties after a getProperties request

See Also
WsAbstractFsClient::getProperties().get().get()
Returns
a WsNodeProperties object with the properties or a NULL object if failure

Definition at line 364 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const string WsFsDaemonClient::receiveProperty ( )
private

receive a property after a getProperty request

See Also
WsAbstractFsClient::getProperty()
Returns
the received property as a string or an empty string if failure

Definition at line 380 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

vector< WsResultItem > WsFsDaemonClient::receiveSearchResults ( )
private

receive the search results after a getSearchResults() request

See Also
WsAbstractFsClient::getSearchResults()
Returns
a vector of result items or empty vector if no results

Definition at line 392 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const string WsFsDaemonClient::receiveString ( )
private

receive a string after a request that returns a string

Returns
the received string or an empty string if failure

Definition at line 469 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::receiveSuccessCode ( )
private

receive the success code after a request that returns a SUCCESS or FAILURE answer only

Returns
SUCCESS or FAILURE

Definition at line 231 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::renameNode ( const string &  path,
const string &  newPath 
)
virtual

renames a node In case of a WsDirNode, all the contents of the directory and the directory will be moved

Parameters
paththe path to the node from the root
newPathnew path from the root
Returns
ErrorCode::Success if ok, ErrorCode::NotFound if path is not found, ErrorCode::NoAccess if access denied and ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 634 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::saveProperties ( WsNodeProperties props,
const std::string &  path 
)
virtual

save the properties of the node on disk. The user must have access and edit rights for the node.

Parameters
propsthe properties to save
paththe path to the node (relative path)
Returns
ErrorCode::Success if ok, ErrorCode::NotFound if path is not found, ErrorCode::NoAccess if access denied and ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 568 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::saveProperty ( const std::string &  path,
const std::string &  section,
const std::string &  attr,
const std::string &  val 
)
virtual

sets one property of the node and save it on disk.

Parameters
paththe path to the node (relative path)
sectionthe section of the property
attrthe key of the property
valthe value to set
Returns
ErrorCode::Success if ok, ErrorCode::NotFound if path is not found, ErrorCode::NoAccess if access denied and ErrorCode::Failure otherwise

Implements WsAbstractFsClient.

Definition at line 582 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

int WsFsDaemonClient::send ( const std::string &  message)
private

sends a string to the daemon

Returns
SUCCESS if send succeeded, FAILURE otherwise
Parameters
messagethe string to send

Definition at line 144 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsFsDaemonClient::threadUpdate ( )
private

Launch the routine that will retrieve new AccessTree from fsdaemon This method should be called in a different thread.

Definition at line 698 of file WsFsDaemonClient.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

NodePtr WsFsDaemonClient::m_accessRoot
private

Definition at line 292 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_accessTreeStamp
private

Definition at line 294 of file WsFsDaemonClient.h.

bool WsFsDaemonClient::m_compress
private

Definition at line 291 of file WsFsDaemonClient.h.

WsCompressor* WsFsDaemonClient::m_compressor
private

Definition at line 302 of file WsFsDaemonClient.h.

WsGlobalProperties* WsFsDaemonClient::m_conf
private

Definition at line 287 of file WsFsDaemonClient.h.

zmq::context_t * WsFsDaemonClient::m_context = 0
staticprivate

Definition at line 304 of file WsFsDaemonClient.h.

WsDecompressor* WsFsDaemonClient::m_decompressor
private

Definition at line 303 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_email
private

Definition at line 280 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_host
private

Definition at line 284 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_ip
private

Definition at line 279 of file WsFsDaemonClient.h.

int WsFsDaemonClient::m_isAdmin
private

Definition at line 297 of file WsFsDaemonClient.h.

int WsFsDaemonClient::m_isEditor
private

Definition at line 298 of file WsFsDaemonClient.h.

bool WsFsDaemonClient::m_listen
private

Definition at line 300 of file WsFsDaemonClient.h.

NodePtr WsFsDaemonClient::m_menuRoot
private

Definition at line 293 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_menuTreeStamp
private

Definition at line 295 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_name
private

Definition at line 281 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_pass
private

Definition at line 278 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_port
private

Definition at line 285 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_proto
private

Definition at line 286 of file WsFsDaemonClient.h.

Json::Reader WsFsDaemonClient::m_reader
private

Definition at line 288 of file WsFsDaemonClient.h.

Json::Value WsFsDaemonClient::m_root
private

Definition at line 289 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_rootPath
private

Definition at line 296 of file WsFsDaemonClient.h.

boost::mutex* WsFsDaemonClient::m_sendMutex
private

Definition at line 305 of file WsFsDaemonClient.h.

zmq::socket_t* WsFsDaemonClient::m_sock
private

Definition at line 301 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_surname
private

Definition at line 282 of file WsFsDaemonClient.h.

std::string WsFsDaemonClient::m_uid
private

Definition at line 277 of file WsFsDaemonClient.h.

boost::thread* WsFsDaemonClient::m_updateThread
private

Definition at line 306 of file WsFsDaemonClient.h.


The documentation for this class was generated from the following files: