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

Interface that provides differents methods for accessing the FsTree as well as other features. More...

#include <WsUser.h>

Collaboration diagram for WsUser:
Collaboration graph

Public Types

enum  NodeType { File, Directory }
 

Public Member Functions

 WsUser (const std::string &strUid, const std::string &pass="", const std::string &ip="")
 Constructor. More...
 
 ~WsUser ()
 Destructor. More...
 
int load ()
 Load infos of the user. More...
 
const std::string getHomePage ()
 return the home page More...
 
NodePtr getAccessRoot ()
 return the root node of the access tree starting from the root More...
 
const std::string getRootPath ()
 return the root path of the filesystem tree, example : /var/www/demo_site 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...
 
const std::string & getUid () const
 
int getLock (const std::string &path)
 tries to acquire the lock for the path. @ return ErrorCode::Locked if the lock cannot be aquired because is detented by someone else. ErrorCode::Failure if an error occured. ErrorCode::NotFound if the path does not exist and a positive value with the duration in seconds of the lock is returned otherwise. More...
 
int putLock (const std::string &path)
 releases the lock for the path. More...
 
int isLocked (const std::string &path, std::string &uid)
 check is the path is already locked More...
 
int getPermissions (const std::string &p)
 return the permissions on specific node More...
 
const WsNodePropertiesgetProperties (const std::string &p)
 returns the properties of a node More...
 
std::string getProperty (const std::string &path, const std::string &section, const string &attr, const std::string &def)
 returns one property of a node If the property does not exist, a empty string is returned. More...
 
std::vector< WsResultItemgetSearchResults (const std::string &terms)
 search for all matching results of terms using WsSearch class More...
 
std::set< std::string > getAllGroups ()
 
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 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...
 
int createNode (const string &path, NodeType 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 writeFile (const std::string path, const std::string &text)
 writes the text to the file More...
 
bool isAdministrator ()
 
bool isEditor ()
 
std::vector< std::string > getTemplatesList (const std::string &path)
 return all the templates contained in a directory and parents If two templates have the same name, the template stored in the deepest node will appear More...
 

Private Member Functions

std::string cleanPath (const std::string &path)
 

Private Attributes

WsAbstractFsClientm_client
 this will be an instance of WsFsTreeClient if not using daemon or WsFsDaemonClient if using daemon More...
 
int m_isDaemon
 Use daemon or no. More...
 
std::string m_uid
 
std::string m_pass
 
std::string m_ip
 
WsGlobalPropertiesm_conf
 

Detailed Description

Interface that provides differents methods for accessing the FsTree as well as other features.

If the daemon is used it will instanciate a WsFsDaemonClient otherwise it will instanciate a WsFsTreeClient. All methods filter data accroding to user right before returning any data. (The test is not done in this class but in the instanciated class of WsAbstractFsClient)

Definition at line 33 of file WsUser.h.

Member Enumeration Documentation

Enumerator
File 
Directory 

Definition at line 35 of file WsUser.h.

Constructor & Destructor Documentation

WsUser::WsUser ( const std::string &  strUid,
const std::string &  pass = "",
const std::string &  ip = "" 
)

Constructor.

Parameters
strUidthe uid of the user
passthe password of the user
ipthe ip of the user

Definition at line 7 of file WsUser.cpp.

WsUser::~WsUser ( )

Destructor.

Definition at line 14 of file WsUser.cpp.

Member Function Documentation

std::string WsUser::cleanPath ( const std::string &  path)
private

Definition at line 194 of file WsUser.cpp.

Here is the caller graph for this function:

int WsUser::createNode ( const string &  path,
NodeType  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

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

Definition at line 105 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::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

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

Definition at line 115 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NodePtr WsUser::getAccessRoot ( )

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

Definition at line 50 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

set< string > WsUser::getAllGroups ( )

Definition at line 151 of file WsUser.cpp.

Here is the call graph for this function:

const string & WsUser::getEmail ( ) const

return the email of the person

Returns
the email or an empty string if not found

Definition at line 71 of file WsUser.cpp.

Here is the call graph for this function:

const string & WsUser::getFirstName ( ) const

return the name of the person

Returns
the name or an empty string if not found

Definition at line 66 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const string WsUser::getHomePage ( )

return the home page

Definition at line 140 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::getLock ( const std::string &  path)

tries to acquire the lock for the path. @ return ErrorCode::Locked if the lock cannot be aquired because is detented by someone else. ErrorCode::Failure if an error occured. ErrorCode::NotFound if the path does not exist and a positive value with the duration in seconds of the lock is returned otherwise.

Definition at line 125 of file WsUser.cpp.

Here is the call graph for this function:

int WsUser::getPermissions ( const std::string &  p)

return the permissions on specific node

Parameters
pthe node path (relative)
Returns
GlobalConfig::Read if only read GlobalConfig::ReadWrite if read write perm or ErrorCode::NoAccess
ErrorCode::NotFound if path not found

Definition at line 81 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const WsNodeProperties * WsUser::getProperties ( const std::string &  p)

returns the properties of a node

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

Definition at line 86 of file WsUser.cpp.

Here is the call graph for this function:

string WsUser::getProperty ( const std::string &  path,
const std::string &  section,
const string &  attr,
const std::string &  def 
)

returns one property of a node If the property does not exist, a empty string is returned.

Parameters
sectionthe section of the property in the Json tree
attrthe key of the property to retrieve
paththe path to the node (relative path)
defthe default value returned if not found
Returns
a string containing the property of a empty string if access is denied or path non existent

Definition at line 91 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const string WsUser::getRootPath ( )

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

Definition at line 55 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 146 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const string & WsUser::getSurname ( ) const

return the surname of the person

Returns
the surname or an empty string if not found

Definition at line 61 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

return all the templates contained in a directory and parents If two templates have the same name, the template stored in the deepest node will appear

Definition at line 189 of file WsUser.cpp.

Here is the call graph for this function:

const string & WsUser::getUid ( ) const

Definition at line 76 of file WsUser.cpp.

Here is the caller graph for this function:

bool WsUser::isAdministrator ( )
Returns
true if the actual user is an admin

Definition at line 184 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool WsUser::isEditor ( )
Returns
true if actual user is an editor

Definition at line 179 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

check is the path is already locked

Returns
1 if the path is unlocked
ErrorCode::Locked if the file is locked and the uid of the user who locked it will be stored in uid
ErrorCode::NotFound if the path does not exist
ErrorCode::Failure if an error occured

Definition at line 135 of file WsUser.cpp.

Here is the call graph for this function:

int WsUser::load ( )

Load infos of the user.

Loads the name, surname, email, groups ..

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

Definition at line 22 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::putLock ( const std::string &  path)

releases the lock for the path.

Returns
ErrorCode::Locked if path cannot be unlocked, ErrorCode::Failure if error. ErrorCode::NotFound if the path does not exist and ErrorCode::Success if unlock successful

Definition at line 130 of file WsUser.cpp.

Here is the call graph for this function:

int WsUser::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

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

Definition at line 120 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::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.

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

Definition at line 156 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::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.

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

Definition at line 99 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WsUser::writeFile ( const std::string  path,
const std::string &  text 
)

writes the text to the file

If the file does not exist, it is created. If the file already exists it is overwritten.

Parameters
paththe relative path to the node
textthe text to write
Returns
ErrorCode::Success, or ErrorCode::NoAccess or ErrorCode::Failure

Definition at line 161 of file WsUser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

WsAbstractFsClient* WsUser::m_client
private

this will be an instance of WsFsTreeClient if not using daemon or WsFsDaemonClient if using daemon

Definition at line 233 of file WsUser.h.

WsGlobalProperties* WsUser::m_conf
private

Definition at line 242 of file WsUser.h.

std::string WsUser::m_ip
private

Definition at line 241 of file WsUser.h.

int WsUser::m_isDaemon
private

Use daemon or no.

Definition at line 238 of file WsUser.h.

std::string WsUser::m_pass
private

Definition at line 240 of file WsUser.h.

std::string WsUser::m_uid
private

Definition at line 239 of file WsUser.h.


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