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