whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: dump LDAP request information on error
Date Wed, 15 Jun 2016 20:19:01 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  db9c743   dump LDAP request information on error
db9c743 is described below

commit db9c74359b8ca4a544b5ae1399cf129cb35aecec
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Wed Jun 15 16:17:54 2016 -0400

    dump LDAP request information on error
---
 lib/whimsy/asf/ldap.rb | 49 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 3c4fd51..16ac469 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -231,6 +231,33 @@ module ASF
       # write the configuration if there were any changes
       File.write(ldap_conf, content) unless content == File.read(ldap_conf)
     end
+
+    # dump more information on LDAP errors - modify
+    def self.modify(dn, list)
+      ASF::LDAP.modify(dn, list)
+    rescue LDAP::ResultError
+      Wunderbar.warn(list.inspect)
+      Wunderbar.warn(dn.to_s)
+      raise
+    end
+
+    # dump more information on LDAP errors - add
+    def self.add(dn, list)
+      ASF::LDAP.add(dn, list)
+    rescue LDAP::ResultError
+      Wunderbar.warn(list.inspect)
+      Wunderbar.warn(dn.to_s)
+      raise
+    end
+
+    # dump more information on LDAP errors - delete
+    def self.delete(dn, list)
+      ASF::LDAP.delete(dn, list)
+    rescue LDAP::ResultError
+      Wunderbar.warn(list.inspect)
+      Wunderbar.warn(dn.to_s)
+      raise
+    end
   end
 
   # public entry point for establishing a connection safely
@@ -549,7 +576,7 @@ module ASF
     end
 
     def modify(attr, value)
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_replace(attr.to_s, value)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_replace(attr.to_s, value)])
       attrs[attr.to_s] = value
     end
   end
@@ -605,7 +632,7 @@ module ASF
       @members = nil
       people = (Array(people) & members).map(&:id)
       return if people.empty?
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_delete('memberUid', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('memberUid', people)])
     ensure
       @members = nil
     end
@@ -615,7 +642,7 @@ module ASF
       @members = nil
       people = (Array(people) - members).map(&:id)
       return if people.empty?
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_add('memberUid', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('memberUid', people)])
     ensure
       @members = nil
     end
@@ -633,12 +660,12 @@ module ASF
         mod_add('memberUid', people.map(&:id))
       ]
 
-      ASF.ldap.add("cn=#{name},#{base}", entry)
+      ASF::LDAP.add("cn=#{name},#{base}", entry)
     end
 
     # remove a group
     def self.remove(name)
-      ASF.ldap.delete("cn=#{name},#{base}")
+      ASF::LDAP.delete("cn=#{name},#{base}")
     end
   end
 
@@ -683,7 +710,7 @@ module ASF
     def remove(people)
       @members = nil
       people = (Array(people) & members).map(&:dn)
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_delete('member', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('member', people)])
     ensure
       @members = nil
     end
@@ -692,7 +719,7 @@ module ASF
     def add(people)
       @members = nil
       people = (Array(people) - members).map(&:dn)
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_add('member', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('member', people)])
     ensure
       @members = nil
     end
@@ -705,12 +732,12 @@ module ASF
         mod_add('member', Array(people).map(&:dn))
       ]
 
-      ASF.ldap.add("cn=#{name},#{base}", entry)
+      ASF::LDAP.add("cn=#{name},#{base}", entry)
     end
 
     # remove a committee
     def self.remove(name)
-      ASF.ldap.delete("cn=#{name},#{base}")
+      ASF::LDAP.delete("cn=#{name},#{base}")
     end
   end
 
@@ -754,7 +781,7 @@ module ASF
     def remove(people)
       @members = nil
       people = Array(people - members).map(&:dn)
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_delete('member', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('member', people)])
     ensure
       @members = nil
     end
@@ -762,7 +789,7 @@ module ASF
     def add(people)
       @members = nil
       people = (Array(people) & members).map(&:dn)
-      ASF.ldap.modify(self.dn, [ASF::Base.mod_add('member', people)])
+      ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('member', people)])
     ensure
       @members = nil
     end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message