@@ -99,36 +99,26 @@ internal fun <T : Any> parseJson(urlStr: String): T {
9999
100100/* * Retrieves the project name, for example `Polaris` using the lower-case project ID. */
101101internal fun fetchAsfProjectName (apacheId : String ): String {
102- val projectsAll: Map <String , Map <String , Any >> =
103- parseJson(" https://whimsy.apache.org/public/public_ldap_projects.json" )
104- val projects = unsafeCast<Map <String , Map <String , Any >>>(projectsAll[" projects" ])
105- val project =
106- projects[apacheId]
107- ? : throw IllegalArgumentException (
108- " No project '$apacheId ' found in https://whimsy.apache.org/public/public_ldap_projects.json"
109- )
102+ val project = projectMap(apacheId)
110103 val isPodlingCurrent = project.containsKey(" podling" ) && project[" podling" ] == " current"
111104 if (isPodlingCurrent) {
112- val podlingsAll: Map <String , Map <String , Any >> =
113- parseJson(" https://whimsy.apache.org/public/public_podlings.json" )
114- val podlings = unsafeCast<Map <String , Map <String , Any >>>(podlingsAll[" podling" ])
115- val podling =
116- podlings[apacheId]
117- ? : throw IllegalArgumentException (
118- " No podling '$apacheId ' found in https://whimsy.apache.org/public/public_podlings.json"
119- )
105+ val podling = podlingMap(apacheId)
120106 return podling[" name" ] as String
121107 } else {
122108 // top-level-project
123- val committeesAll: Map <String , Map <String , Any >> =
124- parseJson(" https://whimsy.apache.org/public/committee-info.json" )
125- val committees = unsafeCast<Map <String , Map <String , Any >>>(committeesAll[" committees" ])
126- val committee = unsafeCast<Map <String , Any >>(committees[apacheId])
109+ val committee = projectCommitteeMap(apacheId)
127110 return committee[" display_name" ] as String
128111 }
129112}
130113
131- internal fun fetchProjectPeople (apacheId : String ): ProjectPeople {
114+ internal fun projectCommitteeMap (apacheId : String ): Map <String , Any > {
115+ val committeesAll: Map <String , Map <String , Any >> =
116+ parseJson(" https://whimsy.apache.org/public/committee-info.json" )
117+ val committees = unsafeCast<Map <String , Map <String , Any >>>(committeesAll[" committees" ])
118+ return unsafeCast(committees[apacheId])
119+ }
120+
121+ internal fun projectMap (apacheId : String ): Map <String , Any > {
132122 val projectsAll: Map <String , Map <String , Any >> =
133123 parseJson(" https://whimsy.apache.org/public/public_ldap_projects.json" )
134124 val projects = unsafeCast<Map <String , Map <String , Any >>>(projectsAll[" projects" ])
@@ -137,19 +127,26 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
137127 ? : throw IllegalArgumentException (
138128 " No project '$apacheId ' found in https://whimsy.apache.org/public/public_ldap_projects.json"
139129 )
140- val isPodlingCurrent = project.containsKey(" podling" ) && project[" podling" ] == " current"
130+ return project
131+ }
141132
142- val inceptionYear = (project[" createTimestamp" ] as String ).subSequence(0 , 4 ).toString().toInt()
133+ internal fun podlingMap (apacheId : String ): Map <String , Any > {
134+ val podlingsAll: Map <String , Map <String , Any >> =
135+ parseJson(" https://whimsy.apache.org/public/public_podlings.json" )
136+ val podlings = unsafeCast<Map <String , Map <String , Any >>>(podlingsAll[" podling" ])
137+ val podling =
138+ podlings[apacheId]
139+ ? : throw IllegalArgumentException (
140+ " No podling '$apacheId ' found in https://whimsy.apache.org/public/public_podlings.json"
141+ )
142+ return podling
143+ }
143144
144- // Committers
145- val peopleProjectRoles: MutableMap <String , MutableList <String >> = mutableMapOf ()
146- val members = unsafeCast(project[" members" ]) as List <String >
147- members.forEach { member -> peopleProjectRoles.put(member, mutableListOf (" Committer" )) }
145+ internal fun fetchProjectInformation (apacheId : String ): ProjectInformation {
146+ val project = projectMap(apacheId)
147+ val isPodlingCurrent = project.containsKey(" podling" ) && project[" podling" ] == " current"
148148
149- // (P)PMC Members
150- val pmcRoleName = if (isPodlingCurrent) " PPMC member" else " PMC member"
151- val owners = unsafeCast(project[" owners" ]) as List <String >
152- owners.forEach { member -> peopleProjectRoles[member]!! .add(pmcRoleName) }
149+ val inceptionYear = (project[" createTimestamp" ] as String ).subSequence(0 , 4 ).toString().toInt()
153150
154151 val projectName: String
155152 val description: String
@@ -158,14 +155,7 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
158155 val licenseUrl: String
159156 val bugDatabase: String
160157 if (isPodlingCurrent) {
161- val podlingsAll: Map <String , Map <String , Any >> =
162- parseJson(" https://whimsy.apache.org/public/public_podlings.json" )
163- val podlings = unsafeCast<Map <String , Map <String , Any >>>(podlingsAll[" podling" ])
164- val podling =
165- podlings[apacheId]
166- ? : throw IllegalArgumentException (
167- " No podling '$apacheId ' found in https://whimsy.apache.org/public/public_podlings.json"
168- )
158+ val podling = podlingMap(apacheId)
169159 projectName = podling[" name" ] as String
170160 description = podling[" description" ] as String
171161 val podlingStatus = unsafeCast(podling[" podlingStatus" ]) as Map <String , Any >
@@ -174,12 +164,6 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
174164 repository = " https://github.com/apache/$apacheId .git"
175165 bugDatabase = " https://github.com/apache/$apacheId /issues"
176166 licenseUrl = " https://www.apache.org/licenses/LICENSE-2.0.txt"
177-
178- val champion = podling[" champion" ] as String
179- peopleProjectRoles[champion]!! .add(" Champion" )
180-
181- val mentors = unsafeCast(podling[" mentors" ]) as List <String >
182- mentors.forEach { member -> peopleProjectRoles[member]!! .add(" Mentor" ) }
183167 } else {
184168 // top-level-project
185169 val tlpPrj: Map <String , Any > =
@@ -189,33 +173,12 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
189173 bugDatabase = tlpPrj[" bug-database" ] as String
190174 licenseUrl = tlpPrj[" license" ] as String
191175
192- val committeesAll: Map <String , Map <String , Any >> =
193- parseJson(" https://whimsy.apache.org/public/committee-info.json" )
194- val committees = unsafeCast<Map <String , Map <String , Any >>>(committeesAll[" committees" ])
195- val committee = unsafeCast<Map <String , Any >>(committees[apacheId])
196- val pmcChair = unsafeCast<Map <String , Map <String , Any >>>(committee[" chair" ])
176+ val committee = projectCommitteeMap(apacheId)
197177 projectName = committee[" display_name" ] as String
198178 description = committee[" description" ] as String
199- pmcChair.keys.forEach { chair -> peopleProjectRoles[chair]!! .add(" PMC Chair" ) }
200179 }
201180
202- val peopleNames: Map <String , Map <String , Any >> =
203- parseJson(" https://whimsy.apache.org/public/public_ldap_people.json" )
204- val people: Map <String , Map <String , Any >> =
205- unsafeCast(peopleNames[" people" ]) as Map <String , Map <String , Any >>
206- val peopleList =
207- peopleProjectRoles.entries
208- .map { entry ->
209- val person =
210- people[entry.key]
211- ? : throw IllegalStateException (
212- " No person '${entry.key} ' found in https://whimsy.apache.org/public/public_ldap_people.json"
213- )
214- ProjectMember (entry.key, person[" name" ]!! as String , entry.value)
215- }
216- .sortedBy { it.name }
217-
218- return ProjectPeople (
181+ return ProjectInformation (
219182 apacheId,
220183 projectName,
221184 description,
@@ -224,11 +187,10 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
224187 licenseUrl,
225188 bugDatabase,
226189 inceptionYear,
227- peopleList,
228190 )
229191}
230192
231- internal class ProjectPeople (
193+ internal class ProjectInformation (
232194 val apacheId : String ,
233195 val name : String ,
234196 val description : String ,
@@ -237,7 +199,4 @@ internal class ProjectPeople(
237199 val licenseUrl : String ,
238200 val bugDatabase : String ,
239201 val inceptionYear : Int ,
240- val people : List <ProjectMember >,
241202)
242-
243- internal class ProjectMember (val apacheId : String , val name : String , val roles : List <String >)
0 commit comments