01: /*
02: * Created on Jan 23, 2004
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.vfny.geoserver.action.validation;
08:
09: import org.apache.struts.action.ActionForm;
10: import org.apache.struts.action.ActionForward;
11: import org.apache.struts.action.ActionMapping;
12: import org.vfny.geoserver.action.ConfigAction;
13: import org.vfny.geoserver.config.validation.PlugInConfig;
14: import org.vfny.geoserver.config.validation.TestConfig;
15: import org.vfny.geoserver.config.validation.TestSuiteConfig;
16: import org.vfny.geoserver.config.validation.ValidationConfig;
17: import org.vfny.geoserver.form.validation.ValidationTestNewForm;
18: import org.vfny.geoserver.global.UserContainer;
19: import java.util.HashMap;
20: import javax.servlet.ServletContext;
21: import javax.servlet.http.HttpServletRequest;
22: import javax.servlet.http.HttpServletResponse;
23:
24: /**
25: * ValidationTestNewAction purpose.
26: * <p>
27: * Description of ValidationTestNewAction ...
28: * </p>
29: *
30: * <p>
31: * Capabilities:
32: * </p>
33: * <ul>
34: * <li>
35: * Feature: description
36: * </li>
37: * </ul>
38: * <p>
39: * Example Use:
40: * </p>
41: * <pre><code>
42: * ValidationTestNewAction x = new ValidationTestNewAction(...);
43: * </code></pre>
44: *
45: * @author User, Refractions Research, Inc.
46: * @author $Author: dmzwiers $ (last modification)
47: * @version $Id: ValidationTestNewAction.java 6177 2007-02-19 10:11:27Z aaime $
48: */
49: public class ValidationTestNewAction extends ConfigAction {
50: public ActionForward execute(ActionMapping mapping,
51: ActionForm incomingForm, UserContainer user,
52: HttpServletRequest request, HttpServletResponse response) {
53: ServletContext context = this .getServlet().getServletContext();
54: ValidationConfig validationConfig = (ValidationConfig) context
55: .getAttribute(ValidationConfig.CONFIG_KEY);
56:
57: ValidationTestNewForm form = (ValidationTestNewForm) incomingForm;
58:
59: String newName = form.getNewName();
60: String selectedPlugIn = form.getSelectedPlugIn();
61:
62: PlugInConfig plugIn = validationConfig
63: .getPlugIn(selectedPlugIn);
64:
65: TestConfig testConfig = new TestConfig();
66: testConfig.setName(newName);
67: testConfig.setPlugIn(plugIn);
68: testConfig.setArgs(new HashMap());
69:
70: TestSuiteConfig suiteConfig = (TestSuiteConfig) request
71: .getSession().getAttribute(
72: TestSuiteConfig.CURRENTLY_SELECTED_KEY);
73: suiteConfig.addTest(testConfig);
74: getApplicationState().notifyConfigChanged();
75:
76: request.getSession().setAttribute(
77: TestConfig.CURRENTLY_SELECTED_KEY, testConfig);
78:
79: return mapping.findForward("validationTestEditor");
80: }
81: }
|