01: package com.opensymphony.webwork.config_browser;
02:
03: import com.opensymphony.xwork.ActionSupport;
04: import com.opensymphony.xwork.config.entities.ActionConfig;
05: import com.opensymphony.webwork.config.Configuration;
06: import com.opensymphony.webwork.WebWorkConstants;
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09:
10: import java.util.Set;
11: import java.util.TreeSet;
12:
13: /**
14: * ActionNamesAction
15: *
16: * @author Jason Carreira Created Aug 11, 2003 9:35:15 PM
17: * @author Rainer Hermanns
18: */
19: public class ActionNamesAction extends ActionSupport {
20: private Set actionNames;
21: private String namespace = "";
22: private Set namespaces;
23: private String extension;
24: private static Log log = LogFactory.getLog(ActionNamesAction.class);
25:
26: public Set getActionNames() {
27: return actionNames;
28: }
29:
30: public String getNamespace() {
31: return namespace;
32: }
33:
34: public void setNamespace(String namespace) {
35: this .namespace = namespace;
36: }
37:
38: public ActionConfig getConfig(String actionName) {
39: return ConfigurationHelper.getActionConfig(namespace,
40: actionName);
41: }
42:
43: public Set getNamespaces() {
44: return namespaces;
45: }
46:
47: public String getExtension() {
48: if (extension == null) {
49: String ext = (String) Configuration
50: .get(WebWorkConstants.WEBWORK_ACTION_EXTENSION);
51: if (ext == null || ext.equals("")) {
52: extension = "action";
53: } else {
54: extension = ext;
55: }
56: }
57: return extension;
58: }
59:
60: public String execute() throws Exception {
61: namespaces = ConfigurationHelper.getNamespaces();
62: if (namespaces.size() == 0) {
63: addActionError("There are no namespaces in this configuration");
64: return ERROR;
65: }
66: if (namespace == null) {
67: namespace = "";
68: }
69: actionNames = new TreeSet(ConfigurationHelper
70: .getActionNames(namespace));
71: return SUCCESS;
72: }
73: }
|