Skip to content

Commit

Permalink
[JENKINS-28298] Saves enabled / disabled configuration to the disk.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedam committed Jul 1, 2015
1 parent 4bc59e0 commit 369cb10
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -25,6 +25,7 @@
package org.jenkinsci.plugins.authorizeproject;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -61,8 +62,8 @@ public ProjectQueueItemAuthenticator() {
this(Collections.<String, Boolean>emptyMap());
}

public ProjectQueueItemAuthenticator(Map<String,Boolean> strategyEnableMap) {
this.strategyEnabledMap = strategyEnableMap;
public ProjectQueueItemAuthenticator(Map<String,Boolean> strategyEnabledMap) {
this.strategyEnabledMap = strategyEnabledMap;
}

public Object readResolve() {
Expand Down Expand Up @@ -146,16 +147,24 @@ public List<Descriptor<AuthorizeProjectStrategy>> getAvailableDescriptorList() {
public ProjectQueueItemAuthenticator newInstance(StaplerRequest req, JSONObject formData)
throws FormException
{
ProjectQueueItemAuthenticator r = (ProjectQueueItemAuthenticator)super.newInstance(req, formData);
Map<String,Boolean> strategyEnabledMap = new HashMap<String, Boolean>();

for (AuthorizeProjectStrategyDescriptor d : getDescriptorsForGlobalSecurityConfigPage()) {
for (Descriptor<AuthorizeProjectStrategy> d : getAvailableDescriptorList()) {
String name = d.getJsonSafeClassName();
if (formData.has(name)) {
d.configureFromGlobalSecurity(req, formData.getJSONObject(name));
strategyEnabledMap.put(d.getId(), true);
if (
d instanceof AuthorizeProjectStrategyDescriptor
&& ((AuthorizeProjectStrategyDescriptor)d).getGlobalSecurityConfigPage() != null
) {
((AuthorizeProjectStrategyDescriptor)d).configureFromGlobalSecurity(req, formData.getJSONObject(name));
}
} else {
strategyEnabledMap.put(d.getId(), false);
}
}

return r;
return new ProjectQueueItemAuthenticator(strategyEnabledMap);
}
}

Expand Down

0 comments on commit 369cb10

Please sign in to comment.