Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/acs/damsel/client/config/ConfigServerAction.java


1   package org.acs.damsel.client.config;
2   
3   import org.apache.struts.action.*;
4   import org.apache.struts.upload.*;
5   import javax.servlet.http.*;
6   import java.io.*;
7   
8   import org.acs.damsel.srvr.Config;
9   import org.acs.damsel.srvr.user.*;
10  import org.apache.log4j.*;
11  
12  public class ConfigServerAction extends Action {
13  
14    private Logger log = Logger.getLogger(ConfigServerAction.class);
15  
16    public ActionForward execute(ActionMapping actionMapping,
17                                 ActionForm actionForm,
18                                 HttpServletRequest httpServletRequest,
19                                 HttpServletResponse httpServletResponse) {
20      ConfigServerForm configServerForm = (ConfigServerForm) actionForm;
21  
22      Config config = Config.instance();
23      config.setAssetDBConnection("jdbc:mysql://" + configServerForm.getIpAddress()
24                                  + "/" + configServerForm.getDbName());
25      config.setAssetDBPassword(configServerForm.getPassword());
26      config.setAssetDBUserName(configServerForm.getUserName());
27      if (configServerForm.getRegistration().equals("admin")){
28      config.setAllowRegistration(false);
29      }
30      else config.setAllowRegistration(true);
31      try {
32        File file = new File(config.getPrefix() + "config.xml");
33        config.save(file);
34      }
35      catch (IOException ex) {
36        log.warn((config.getPrefix() + "config.xml not found."));
37      }
38  
39      return actionMapping.findForward("success");
40    }
41  }