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