class ASF::Project
Ultimately, this will include both PMCs and PPMCs, and enable separate updating of owners and members. For now this is only used for PPMCs and owners and members are kept in sync.
Attributes
Date this committee was initially created in LDAP
.
Date this committee was last modified in LDAP
.
Public Class Methods
Source
# File lib/whimsy/asf/ldap.rb, line 1232 def self.[](name) project = super project.dn ? project : nil end
return project only if it actually exits
ASF::Base::[]
Source
# File lib/whimsy/asf/ldap.rb, line 1222 def self.list(filter='cn=*') ASF.search_one(base, filter, 'cn').flatten.map {|cn| Project.find(cn)} end
obtain a list of projects from LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1227 def self.listids(filter='cn=*') ASF.search_one(base, filter, 'cn').flatten end
obtain a list of projectids from LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1239 def self.preload Hash[ASF.search_one(base, 'cn=*', %w(dn member owner modifyTimestamp createTimestamp)).map do |results| cn = results['dn'].first[/^cn=(.*?),/, 1] project = self.find(cn) project.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an array of 1 entry project.createTimestamp = results['createTimestamp'].first # it is returned as an array of 1 entry members = results['member'] || [] owners = results['owner'] || [] # TODO members and owners are duplicated in the project object and the returned hash project.members = members project.owners = owners [project, [members, owners]] # TODO is this correct? it seems to work... end] end
fetch dn
, member
, modifyTimestamp
, and createTimestamp
for all projects in LDAP
.
Public Instance Methods
Source
# File lib/whimsy/asf/ldap.rb, line 1354 def add(people) add_owners(people) add_members(people) end
add people to a project as members and owners in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1372 def add_members(people) # Addition fails if the id is present @members = nil # force fresh LDAP search additions = (Array(people) - members).map(&:dn) unless additions.empty? ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('member', additions)]) end ensure @members = nil end
add people as members of a project in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1360 def add_owners(people) # Addition fails if the id is present @owners = nil # force fresh LDAP search additions = (Array(people) - owners).map(&:dn) unless additions.empty? ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('owner', additions)]) end ensure @owners = nil end
add people as owners of a project in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1266 def create(owners, committers=nil) committers = Array(committers || owners).map(&:dn) owners = Array(owners).map(&:dn) entry = [ ASF::Base.mod_add('objectClass', ['groupOfNames', 'top']), ASF::Base.mod_add('cn', name), ASF::Base.mod_add('owner', owners), ASF::Base.mod_add('member', committers), ] ASF::LDAP.add("cn=#{name},#{base}", entry) self.owners = owners self.members = committers end
create an LDAP
group for this project
Source
# File lib/whimsy/asf/ldap.rb, line 1261 def dn @dn ||= ASF.search_one(base, "cn=#{name}", 'dn').first.first rescue nil end
Designated Name from LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1302 def memberids members = weakref(:members) do ASF.search_one(base, "cn=#{name}", 'member').flatten end members.map {|uid| uid[/uid=(.*?),/, 1]} end
list of member ids in the project
Source
# File lib/whimsy/asf/ldap.rb, line 1297 def members memberids.map {|id| Person.find id} end
list of committers on this project. Stored in LDAP
as a member
attribute.
Source
# File lib/whimsy/asf/ldap.rb, line 1285 def members=(members) @members = WeakRef.new(members) end
setter for members, should only be called by preload. N.B. Do not dereference @members directly; use weakref(:members) instead
Source
# File lib/whimsy/asf/ldap.rb, line 1316 def ownerids owners = weakref(:owners) do ASF.search_one(base, "cn=#{name}", 'owner').flatten end owners.map {|uid| uid[/uid=(.*?),/, 1]} end
list of owner ids in the project
Source
# File lib/whimsy/asf/ldap.rb, line 1311 def owners ownerids.map {|id| Person.find id} end
list of owners on this project. Stored in LDAP
as a owners
attribute.
Source
# File lib/whimsy/asf/ldap.rb, line 1291 def owners=(owners) @owners = WeakRef.new(owners) end
setter for owners, should only be called by preload. N.B. Do not dereference @owners directly; use weakref(:owners) instead
Source
# File lib/whimsy/asf/ldap.rb, line 1324 def remove(people) remove_owners(people) remove_members(people) end
remove people from a project as owners and members in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1342 def remove_members(people) # Removal fails if the id is not present @members = nil # force fresh LDAP search removals = (Array(people) & members).map(&:dn) unless removals.empty? ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('member', removals)]) end ensure @members = nil end
remove people as members of a project in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1330 def remove_owners(people) # Removal fails if the id is not present @owners = nil # force fresh LDAP search removals = (Array(people) & owners).map(&:dn) unless removals.empty? ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('owner', removals)]) end ensure @owners = nil end
remove people as owners of a project in LDAP