diff --git a/include/AclRule.h b/include/AclRule.h
index 507e30b3da..ed6d402bf3 100644
--- a/include/AclRule.h
+++ b/include/AclRule.h
@@ -37,7 +37,9 @@ public:
AclRule(long long _user, long long _resource, long long _rights):
user(_user), resource(_resource), rights(_rights)
- {};
+ {
+ build_str();
+ };
bool operator ==(const AclRule& other) const
{
@@ -51,8 +53,10 @@ public:
*
* @return a human readable string for this rule
*/
- string to_str() const;
-
+ const string& to_str() const
+ {
+ return str;
+ };
/**
* Function to print the object into a string in XML format
@@ -124,6 +128,13 @@ private:
* 64 bit integer containing the rights flags
*/
long long rights;
+
+ /**
+ * Human readable representation
+ */
+ string str;
+
+ void build_str();
};
#endif /*ACL_RULE_H*/
diff --git a/src/acl/AclRule.cc b/src/acl/AclRule.cc
index fb20d3aa9f..de9e3686ca 100644
--- a/src/acl/AclRule.cc
+++ b/src/acl/AclRule.cc
@@ -27,11 +27,10 @@ const long long AclRule::ALL_ID = 0x400000000LL;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
-string AclRule::to_str() const
+void AclRule::build_str()
{
ostringstream oss;
- oss << "USER:";
if ( (user & GROUP_ID) != 0 )
{
oss << "@" << user_id();
@@ -45,7 +44,7 @@ string AclRule::to_str() const
oss << "*";
}
- oss << " RESOURCE:";
+ oss << " ";
AuthRequest::Object objects[] = {
AuthRequest::VM,
@@ -89,7 +88,7 @@ string AclRule::to_str() const
oss << "*";
}
- oss << " OPERATION:";
+ oss << " ";
AuthRequest::Operation operations[] = {
@@ -120,7 +119,7 @@ string AclRule::to_str() const
}
}
- return oss.str();
+ str = oss.str();
}
/* -------------------------------------------------------------------------- */
@@ -135,9 +134,7 @@ string& AclRule::to_xml(string& xml) const
"" << hex << user << "" <<
"" << hex << resource << "" <<
"" << hex << rights << "" <<
-
- // TODO: Element DEBUG contains a human friendly string
- "" << to_str() << "" <<
+ "" << str << "" <<
"";
xml = oss.str();