From d60c98345b5f6bcee0d7fbeebd8aaaafd09ef62d Mon Sep 17 00:00:00 2001
From: "Ruben S. Montero" <rubensm@dacya.ucm.es>
Date: Sun, 3 Jul 2011 22:52:21 +0200
Subject: [PATCH] feature #687: DeleteRule returns the oid of the rule.
 AclManager initialized in constructor

---
 include/RequestManagerAcl.h | 15 +++++++++------
 src/rm/RequestManagerAcl.cc | 19 +++----------------
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/include/RequestManagerAcl.h b/include/RequestManagerAcl.h
index 364cd9ea08..fdb75e6539 100644
--- a/include/RequestManagerAcl.h
+++ b/include/RequestManagerAcl.h
@@ -36,6 +36,9 @@ protected:
     {
         auth_object = AuthRequest::ACL;
         auth_op     = AuthRequest::MANAGE;
+
+        Nebula& nd  = Nebula::instance();
+        aclm        = nd.get_aclm();
     };
 
     ~RequestManagerAcl(){};
@@ -57,8 +60,8 @@ class AclAddRule : public RequestManagerAcl
 public:
     AclAddRule():
         RequestManagerAcl("AclAddRule",
-                            "Adds a new ACL rule",
-                            "A:ssss")
+                          "Adds a new ACL rule",
+                          "A:ssss")
     {};
 
     ~AclAddRule(){};
@@ -74,8 +77,8 @@ class AclDelRule : public RequestManagerAcl
 public:
     AclDelRule():
         RequestManagerAcl("AclDelRule",
-                            "Deletes an existing ACL rule",
-                            "A:si")
+                          "Deletes an existing ACL rule",
+                          "A:si")
     {};
 
     ~AclDelRule(){};
@@ -91,8 +94,8 @@ class AclInfo: public RequestManagerAcl
 public:
     AclInfo():
         RequestManagerAcl("AclInfo",
-                            "Returns the ACL rule set",
-                            "A:s")
+                          "Returns the ACL rule set",
+                          "A:s")
     {};
 
     ~AclInfo(){};
diff --git a/src/rm/RequestManagerAcl.cc b/src/rm/RequestManagerAcl.cc
index 676d54ce89..827e841c7d 100644
--- a/src/rm/RequestManagerAcl.cc
+++ b/src/rm/RequestManagerAcl.cc
@@ -31,7 +31,6 @@ void AclAddRule::request_execute(xmlrpc_c::paramList const& paramList)
     resource  = xmlrpc_c::value_i8(paramList.getI8(2));
     rights    = xmlrpc_c::value_i8(paramList.getI8(3));
 */
-
     long long user;
     long long resource;
     long long rights;
@@ -49,10 +48,6 @@ void AclAddRule::request_execute(xmlrpc_c::paramList const& paramList)
     iss.str( xmlrpc_c::value_string(paramList.getString(3)) );
     iss >> hex >> rights;
 
-
-    Nebula& nd  = Nebula::instance();
-    aclm        = nd.get_aclm();
-
     string error_msg;
 
     if ( basic_authorization(-1) == false )
@@ -62,7 +57,6 @@ void AclAddRule::request_execute(xmlrpc_c::paramList const& paramList)
 
     int rc = aclm->add_rule(user, resource, rights, error_msg);
 
-
     if ( rc < 0 )
     {
         failure_response(INTERNAL, request_error(error_msg, ""));
@@ -79,11 +73,7 @@ void AclAddRule::request_execute(xmlrpc_c::paramList const& paramList)
 
 void AclDelRule::request_execute(xmlrpc_c::paramList const& paramList)
 {
-    int oid = xmlrpc_c::value_int(paramList.getInt(1));
-
-    Nebula& nd  = Nebula::instance();
-    aclm        = nd.get_aclm();
-
+    int    oid = xmlrpc_c::value_int(paramList.getInt(1));
     string error_msg;
 
     if ( basic_authorization(-1) == false )
@@ -99,7 +89,7 @@ void AclDelRule::request_execute(xmlrpc_c::paramList const& paramList)
         return;
     }
 
-    success_response("");
+    success_response(oid);
 
     return;
 }
@@ -109,9 +99,6 @@ void AclDelRule::request_execute(xmlrpc_c::paramList const& paramList)
 
 void AclInfo::request_execute(xmlrpc_c::paramList const& paramList)
 {
-    Nebula& nd  = Nebula::instance();
-    aclm        = nd.get_aclm();
-
     ostringstream oss;
     int rc;
 
@@ -128,7 +115,7 @@ void AclInfo::request_execute(xmlrpc_c::paramList const& paramList)
         return;
     }
 
-    success_response( oss.str() );
+    success_response(oss.str());
 
     return;
 }