1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.config_browser;
23
24 import java.util.Set;
25 import java.util.TreeSet;
26
27 import org.apache.struts2.StrutsConstants;
28
29 import com.opensymphony.xwork2.ActionSupport;
30 import com.opensymphony.xwork2.ObjectFactory;
31 import com.opensymphony.xwork2.config.Configuration;
32 import com.opensymphony.xwork2.config.entities.ActionConfig;
33 import com.opensymphony.xwork2.inject.Inject;
34
35 /***
36 * ActionNamesAction
37 *
38 */
39 public class ActionNamesAction extends ActionSupport {
40
41 private static final long serialVersionUID = -5389385242431387840L;
42
43 private Set actionNames;
44 private String namespace = "";
45 private Set namespaces;
46 private String extension;
47
48 protected ConfigurationHelper configHelper;
49
50 @Inject
51 public void setConfigurationHelper(ConfigurationHelper cfg) {
52 this.configHelper = cfg;
53 }
54
55 public Set getActionNames() {
56 return actionNames;
57 }
58
59 public String getNamespace() {
60 return namespace;
61 }
62
63 public void setNamespace(String namespace) {
64 this.namespace = namespace;
65 }
66
67 @Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
68 public void setExtension(String ext) {
69 this.extension = ext;
70 }
71
72 public ActionConfig getConfig(String actionName) {
73 return configHelper.getActionConfig(namespace, actionName);
74 }
75
76 public Set getNamespaces() {
77 return namespaces;
78 }
79
80 public String getExtension() {
81 if ( extension == null) {
82 extension = "action";
83 }
84 return extension;
85 }
86
87 public String execute() throws Exception {
88 namespaces = configHelper.getNamespaces();
89 if (namespaces.size() == 0) {
90 addActionError("There are no namespaces in this configuration");
91 return ERROR;
92 }
93 if (namespace == null) {
94 namespace = "";
95 }
96 actionNames =
97 new TreeSet(configHelper.getActionNames(namespace));
98 return SUCCESS;
99 }
100 }