View Javadoc

    1   /*
    2    * $Id: ActionNamesAction.java 474191 2006-11-13 08:30:40Z mrdon $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    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  }