Wittyshare
0.2
|
Interface that provides differents methods for accessing the FsTree as well as other features. More...
#include <WsUser.h>
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 WsNodeProperties * | getProperties (const std::string &p) |
returns the properties of a node More... | |
std::string | getProperty (const std::string &path, const std::string §ion, 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< WsResultItem > | getSearchResults (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 §ion, 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 | |
WsAbstractFsClient * | m_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 |
WsGlobalProperties * | m_conf |
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)
enum WsUser::NodeType |
WsUser::WsUser | ( | const std::string & | strUid, |
const std::string & | pass = "" , |
||
const std::string & | ip = "" |
||
) |
Constructor.
strUid | the uid of the user |
pass | the password of the user |
ip | the ip of the user |
Definition at line 7 of file WsUser.cpp.
WsUser::~WsUser | ( | ) |
Destructor.
Definition at line 14 of file WsUser.cpp.
|
private |
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
path | the relative path starting from root |
type | a NodeType enum { File, Directory } |
Definition at line 105 of file WsUser.cpp.
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
path | the path to the node |
Definition at line 115 of file WsUser.cpp.
NodePtr WsUser::getAccessRoot | ( | ) |
return the root node of the access tree starting from the root
Definition at line 50 of file WsUser.cpp.
set< string > WsUser::getAllGroups | ( | ) |
const string & WsUser::getEmail | ( | ) | const |
return the email of the person
Definition at line 71 of file WsUser.cpp.
const string & WsUser::getFirstName | ( | ) | const |
return the name of the person
Definition at line 66 of file WsUser.cpp.
const string WsUser::getHomePage | ( | ) |
return the home page
Definition at line 140 of file WsUser.cpp.
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.
int WsUser::getPermissions | ( | const std::string & | p | ) |
return the permissions on specific node
p | the node path (relative) |
Definition at line 81 of file WsUser.cpp.
const WsNodeProperties * WsUser::getProperties | ( | const std::string & | p | ) |
returns the properties of a node
p | the path to the node |
Definition at line 86 of file WsUser.cpp.
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.
section | the section of the property in the Json tree |
attr | the key of the property to retrieve |
path | the path to the node (relative path) |
def | the default value returned if not found |
Definition at line 91 of file WsUser.cpp.
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.
vector< WsResultItem > WsUser::getSearchResults | ( | const std::string & | terms | ) |
search for all matching results of terms using WsSearch class
terms | the terms to match results where found or if an error occured during the process. |
Definition at line 146 of file WsUser.cpp.
const string & WsUser::getSurname | ( | ) | const |
return the surname of the person
Definition at line 61 of file WsUser.cpp.
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.
const string & WsUser::getUid | ( | ) | const |
bool WsUser::isAdministrator | ( | ) |
Definition at line 184 of file WsUser.cpp.
bool WsUser::isEditor | ( | ) |
Definition at line 179 of file WsUser.cpp.
int WsUser::isLocked | ( | const std::string & | path, |
std::string & | uid | ||
) |
check is the path is already locked
Definition at line 135 of file WsUser.cpp.
int WsUser::load | ( | ) |
Load infos of the user.
Loads the name, surname, email, groups ..
Definition at line 22 of file WsUser.cpp.
int WsUser::putLock | ( | const std::string & | path | ) |
releases the lock for the path.
Definition at line 130 of file WsUser.cpp.
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
path | the path to the node from the root |
newPath | new path from the root |
Definition at line 120 of file WsUser.cpp.
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.
props | the properties to save |
path | the path to the node (relative path) |
Definition at line 156 of file WsUser.cpp.
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.
path | the path to the node (relative path) |
section | the section of the property |
attr | the key of the property |
val | the value to set |
Definition at line 99 of file WsUser.cpp.
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.
path | the relative path to the node |
text | the text to write |
Definition at line 161 of file WsUser.cpp.
|
private |
this will be an instance of WsFsTreeClient if not using daemon or WsFsDaemonClient if using daemon
|
private |