if( parentResources.isEmpty() ) {
urlDefiningMode = false;
}
args = args != null && args.length > 0 ? args : new Object[]{Collections.EMPTY_MAP};
if (args[0] instanceof Closure) {
UrlMappingData urlData = createUrlMappingData(mappedURI, isResponseCode);
Closure callable = (Closure) args[0];
if (delegate != null) {
callable.setDelegate(delegate);
}
callable.call();
if (binding != null) {
mappingInfo.setController(variables.get(GrailsControllerClass.CONTROLLER));
mappingInfo.setAction(variables.get(GrailsControllerClass.ACTION));
mappingInfo.setView(variables.get(GrailsControllerClass.VIEW));
mappingInfo.setUri(variables.get(UrlMapping.URI));
mappingInfo.setPlugin(variables.get(UrlMapping.PLUGIN));
mappingInfo.setNamespace(variables.get(UrlMapping.NAMESPACE));
if (variables.containsKey(UrlMapping.HTTP_METHOD)) {
mappingInfo.setHttpMethod(variables.get(UrlMapping.HTTP_METHOD).toString());
}
}
ConstrainedProperty[] constraints = currentConstraints.toArray(new ConstrainedProperty[currentConstraints.size()]);
UrlMapping urlMapping;
if (mappingInfo.getUri() != null) {
try {
urlMapping = new RegexUrlMapping(urlData, new URI(mappingInfo.getUri().toString()), constraints, sc);
} catch (URISyntaxException e) {
throw new UrlMappingException("Cannot map to invalid URI: " + e.getMessage(), e);
}
} else {
urlMapping = createURLMapping(urlData, isResponseCode, mappingInfo.getRedirectInfo(), mappingInfo.getController(), mappingInfo.getAction(), mappingInfo.getNamespace(), mappingInfo.getPlugin(), mappingInfo.getView(), mappingInfo.getHttpMethod(), null, constraints);
}
if (binding != null) {
Map bindingVariables = variables;
Object parse = getParseRequest(Collections.EMPTY_MAP, bindingVariables);
if (parse instanceof Boolean) {
urlMapping.setParseRequest((Boolean) parse);
}
}
configureUrlMapping(urlMapping);
return urlMapping;
}
if (args[0] instanceof Map) {
Map namedArguments = (Map) args[0];
String uri = mappedURI;
String version = null;
if (namedArguments.containsKey(UrlMapping.VERSION)) {
version = namedArguments.get(UrlMapping.VERSION).toString();
}
if (namedArguments.containsKey(UrlMapping.NAMESPACE)) {
mappingInfo.setNamespace(namedArguments.get(UrlMapping.NAMESPACE).toString());
}
if (namedArguments.containsKey(UrlMapping.PLUGIN)) {
mappingInfo.setPlugin(namedArguments.get(UrlMapping.PLUGIN).toString());
}
UrlMappingData urlData = createUrlMappingData(uri, isResponseCode);
if (namedArguments.containsKey(RESOURCE)) {
Object controller = namedArguments.get(RESOURCE);
String controllerName = controller.toString();
mappingInfo.setController(controllerName);