whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Bazley <s...@apache.org>
Subject [whimsy.git] [1/1] Commit 5918af1: Add services json file
Date Wed, 27 Jan 2016 22:43:26 GMT
Commit 5918af1935b2e95f896146309df7a22e2aa2ea64:
    Add services json file


Branch: refs/heads/master
Author: Sebb <sebb@apache.org>
Committer: Sebb <sebb@apache.org>
Pusher: sebb <sebb@apache.org>

------------------------------------------------------------
www/roster/public_ldap_services.rb                           | +++++++++++++ 
------------------------------------------------------------
49 changes: 49 additions, 0 deletions.
------------------------------------------------------------


diff --git a/www/roster/public_ldap_services.rb b/www/roster/public_ldap_services.rb
new file mode 100644
index 0000000..edf12c4
--- /dev/null
+++ b/www/roster/public_ldap_services.rb
@@ -0,0 +1,49 @@
+# Creates JSON output with the following format:
+#
+# {
+#   "lastTimestamp": "20160119171152Z", // most recent modifyTimestamp
+#   "services": {
+#     "svnadmins": {
+#       "modifyTimestamp": "20111204095436Z",
+#       "roster": ["uid",
+#       ...
+#       ]
+#     },
+#     ...
+#   },
+# }
+#
+
+require 'bundler/setup'
+
+require_relative 'public_json_common'
+
+require 'whimsy/asf'
+
+ldap = ASF.init_ldap
+exit 1 unless ldap
+
+# gather unix group info
+entries = {}
+
+groups = ASF::Service.preload # for performance
+
+lastStamp = ''
+groups.keys.sort_by {|a| a.name}.each do |entry|
+    m = []
+    entry.members.sort_by {|a| a.name}.each do |e|
+        m << e.name
+    end
+    lastStamp = entry.modifyTimestamp if entry.modifyTimestamp > lastStamp
+    entries[entry.name] = {
+        modifyTimestamp: entry.modifyTimestamp,
+        roster: m 
+    }
+end
+
+info = {
+  lastTimestamp: lastStamp,
+  services: entries,
+}
+
+public_json_output(info)

Mime
View raw message