Source code: org/acs/damsel/client/config/PopulateConfigAction.java
1 package org.acs.damsel.client.config;
2
3 import org.apache.struts.action.*;
4 import javax.servlet.http.*;
5 import java.io.*;
6
7 import org.acs.damsel.srvr.Config;
8 import org.acs.damsel.srvr.user.*;
9
10
11 public class PopulateConfigAction extends Action {
12 public ActionForward execute(ActionMapping actionMapping,
13 ActionForm actionForm,
14 HttpServletRequest httpServletRequest,
15 HttpServletResponse httpServletResponse) {
16 ConfigServerForm configServerForm = (ConfigServerForm) actionForm;
17
18 File file = new File("config.xml");
19 Config configFile = Config.instance(file);
20 configServerForm.setDbName(configFile.getAssetDBUserName());
21
22 // Extract the IP address and dbName from the connection string
23 String ipAddress = configFile.getAssetDBConnection();
24 String dbName = new String();
25 int start = ipAddress.indexOf("//") + 2;
26 ipAddress = ipAddress.substring(start);
27 int end = ipAddress.indexOf("/");
28 dbName = ipAddress.substring(end + 1);
29 ipAddress = ipAddress.substring(0, end);
30
31 configServerForm.setDbName(dbName);
32 configServerForm.setIpAddress(ipAddress);
33 configServerForm.setUserName(configFile.getAssetDBUserName());
34 configServerForm.setPassword(configFile.getAssetDBPassword());
35 httpServletRequest.getSession().setAttribute("configServerForm", configServerForm);
36
37 return actionMapping.findForward("success");
38 }
39 }