Skip to content

Commit ad5437e

Browse files
committed
Merge branch '3.0.x' into 3.1.x
2 parents 5fde0d0 + dff4612 commit ad5437e

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/AbstractGrailsControllerUrlMappings.groovy

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,32 +133,58 @@ abstract class AbstractGrailsControllerUrlMappings implements UrlMappings{
133133
def namespace = hasUrlConverter ? urlConverter.toUrlElement( controller.namespace ) : controller.namespace
134134
def plugin = hasUrlConverter ? urlConverter.toUrlElement( controller.pluginName ) : controller.pluginName
135135
def controllerName = hasUrlConverter ? urlConverter.toUrlElement( controller.logicalPropertyName ) : controller.logicalPropertyName
136+
String pluginNameToRegister = plugin ? GrailsNameUtils.getPropertyNameForLowerCaseHyphenSeparatedName(plugin) : null
137+
final boolean hasNamespace = namespace == null
138+
if(!hasNamespace) {
139+
mappingsToGrailsControllerMap.put(new ControllerKey(namespace, controllerName, null, plugin), controller)
140+
if(plugin) {
141+
mappingsToGrailsControllerMap.put(new ControllerKey(namespace, controllerName, null, pluginNameToRegister), controller)
142+
def controllerKeyWithoutPlugin = new ControllerKey(namespace, controllerName, null, null)
143+
if(!mappingsToGrailsControllerMap.containsKey(controllerKeyWithoutPlugin)) {
144+
mappingsToGrailsControllerMap.put(controllerKeyWithoutPlugin, controller)
145+
}
146+
}
147+
}
136148

137-
mappingsToGrailsControllerMap.put(new ControllerKey(namespace, controllerName, null, plugin), controller)
138-
mappingsToGrailsControllerMap.put(new ControllerKey(null, controllerName, null, plugin), controller)
139149

140-
String pluginNameToRegister = plugin ? GrailsNameUtils.getPropertyNameForLowerCaseHyphenSeparatedName(plugin) : null
141-
if(plugin) {
142-
mappingsToGrailsControllerMap.put(new ControllerKey(namespace, controllerName, null, pluginNameToRegister), controller)
143-
def controllerKeyWithoutPlugin = new ControllerKey(namespace, controllerName, null, null)
144-
if(!mappingsToGrailsControllerMap.containsKey(controllerKeyWithoutPlugin)) {
145-
mappingsToGrailsControllerMap.put(controllerKeyWithoutPlugin, controller)
146-
mappingsToGrailsControllerMap.put(new ControllerKey(null, controllerName, null, null), controller)
150+
def noNamespaceNoPluginKey = new ControllerKey(null, controllerName, null, null)
151+
def noNamespaceDefaultActionKey = new ControllerKey(null, controllerName, null, plugin)
152+
153+
154+
if(hasNamespace) {
155+
mappingsToGrailsControllerMap.put(noNamespaceNoPluginKey, controller)
156+
mappingsToGrailsControllerMap.put(noNamespaceDefaultActionKey, controller)
157+
}
158+
else {
159+
if(!mappingsToGrailsControllerMap.containsKey(noNamespaceNoPluginKey)) {
160+
mappingsToGrailsControllerMap.put(noNamespaceNoPluginKey, controller)
161+
}
162+
if(!mappingsToGrailsControllerMap.containsKey(noNamespaceDefaultActionKey)) {
163+
mappingsToGrailsControllerMap.put(noNamespaceDefaultActionKey, controller)
147164
}
148165
}
149166

167+
168+
169+
170+
150171
for(action in controller.actions) {
151172
action = hasUrlConverter ? urlConverter.toUrlElement(action) : action
152173
def withPluginKey = new ControllerKey(namespace, controllerName, action, pluginNameToRegister)
153-
def withPluginKeyWithoutNamespaceKey = new ControllerKey(null, controllerName, action, pluginNameToRegister)
154174
def withoutPluginKey = new ControllerKey(namespace, controllerName, action, null)
175+
def withPluginKeyWithoutNamespaceKey = new ControllerKey(null, controllerName, action, pluginNameToRegister)
155176
def withoutPluginKeyWithoutNamespace = new ControllerKey(null, controllerName, action, null)
177+
156178
mappingsToGrailsControllerMap.put(withPluginKey, controller)
157-
mappingsToGrailsControllerMap.put(withPluginKeyWithoutNamespaceKey, controller)
179+
if(hasNamespace && !mappingsToGrailsControllerMap.containsKey(withPluginKeyWithoutNamespaceKey)) {
180+
mappingsToGrailsControllerMap.put(withPluginKeyWithoutNamespaceKey, controller)
181+
}
182+
158183
if(plugin != null && !mappingsToGrailsControllerMap.containsKey(withoutPluginKey)) {
159-
mappingsToGrailsControllerMap.put(new ControllerKey(namespace, controllerName, action, pluginNameToRegister), controller)
160184
mappingsToGrailsControllerMap.put(withoutPluginKey, controller)
161-
mappingsToGrailsControllerMap.put(withoutPluginKeyWithoutNamespace, controller)
185+
if(hasNamespace && !mappingsToGrailsControllerMap.containsKey(withoutPluginKeyWithoutNamespace)) {
186+
mappingsToGrailsControllerMap.put(withoutPluginKeyWithoutNamespace, controller)
187+
}
162188
}
163189
}
164190
}

0 commit comments

Comments
 (0)