1 37 package net.sourceforge.cruisecontrol.servlet; 38 39 import java.util.Iterator ; 40 import java.util.Map ; 41 42 import net.sourceforge.cruisecontrol.Configuration; 43 import net.sourceforge.cruisecontrol.PluginConfiguration; 44 import net.sourceforge.cruisecontrol.interceptor.ConfigurationAware; 45 import net.sourceforge.cruisecontrol.interceptor.DetailsAware; 46 47 import com.opensymphony.webwork.interceptor.ParameterAware; 48 import com.opensymphony.xwork.ActionSupport; 49 50 53 public class PluginDetailsServlet extends ActionSupport implements 54 ConfigurationAware, DetailsAware, ParameterAware { 55 private Configuration configuration; 56 private Map parameters; 57 private PluginConfiguration pluginConfiguration; 58 59 public String execute() throws Exception { 60 setDetails(); 61 configuration.updatePluginConfiguration(pluginConfiguration); 62 addActionMessage("Updated configuration."); 63 return SUCCESS; 64 } 65 66 public String load() { 67 return INPUT; 68 } 69 70 public String getName() { 71 return this.pluginConfiguration.getName(); 72 } 73 74 public String getType() { 75 return this.pluginConfiguration.getType(); 76 } 77 78 public Map getDetails() { 79 return this.pluginConfiguration.getDetails(); 80 } 81 82 public void setConfiguration(Configuration configuration) { 83 this.configuration = configuration; 84 } 85 86 public void setDetails(PluginConfiguration pluginConfiguration) { 87 this.pluginConfiguration = pluginConfiguration; 88 } 89 90 private void setDetails() { 91 for (Iterator i = parameters.entrySet().iterator(); i.hasNext();) { 92 Map.Entry entry = (Map.Entry ) i.next(); 93 this.pluginConfiguration.setDetail((String ) entry.getKey(), 94 ((String []) entry.getValue())[0]); 95 } 96 } 97 98 public void setParameters(Map parameters) { 99 this.parameters = parameters; 100 } 101 } 102 | Popular Tags |