namespace = "";
}
Map<String, ResultTypeConfig> resultsByExtension = conventionsService.getResultTypesByExtension(parentPackage);
String pathPrefix = determinePath(null, namespace);
ActionConfig actionConfig = null;
// Try /idx/action.jsp if actionName is not empty, otherwise it will just be /.jsp
if (!actionName.equals("")) {
Resource resource = findResource(resultsByExtension, pathPrefix, actionName);
if (resource != null) {
actionConfig = buildActionConfig(resource.path, resultsByExtension.get(resource.ext));
}
}
if (actionConfig == null) {
Resource resource = findResource(resultsByExtension, pathPrefix, actionName, "/index");
// If the URL is /foo and there is an action we can redirect to, send the redirect to /foo/.
// However, if that action is not in the same namespace, it is the default, so I'm not going
// to return that.
if (!actionName.equals("") && redirectToSlash) {
ResultTypeConfig redirectResultTypeConfig = parentPackage.getAllResultTypeConfigs().get("redirect");
String redirectNamespace = namespace + "/" + actionName;
if (LOG.isTraceEnabled()) {
LOG.trace("Checking if there is an action named index in the namespace [#0]",
redirectNamespace);
}
actionConfig = configuration.getRuntimeConfiguration().getActionConfig(redirectNamespace, "index");
if (actionConfig != null) {
if (LOG.isTraceEnabled())
LOG.trace("Found action config");
PackageConfig packageConfig = configuration.getPackageConfig(actionConfig.getPackageName());
if (redirectNamespace.equals(packageConfig.getNamespace())) {
if (LOG.isTraceEnabled())
LOG.trace("Action is not a default - redirecting");
return buildActionConfig(redirectNamespace + "/", redirectResultTypeConfig);
}