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);
parentResources.push(new ParentResource(controllerName, uri, true));
try {
invokeLastArgumentIfClosure(args);
} finally {
parentResources.pop();
}
if (controller != null) {
createSingleResourceRestfulMappings(controllerName, mappingInfo.getPlugin(), mappingInfo.getNamespace(), version, urlData, currentConstraints, calculateIncludes(namedArguments, DEFAULT_RESOURCE_INCLUDES));
}
} else if (namedArguments.containsKey(RESOURCES)) {
Object controller = namedArguments.get(RESOURCES);
String controllerName = controller.toString();
mappingInfo.setController(controllerName);
parentResources.push(new ParentResource(controllerName, uri, false));
try {
invokeLastArgumentIfClosure(args);
} finally {
parentResources.pop();
}
if (controller != null) {
createResourceRestfulMappings(controllerName, mappingInfo.getPlugin(), mappingInfo.getNamespace(), version,urlData, currentConstraints, calculateIncludes(namedArguments, DEFAULT_RESOURCES_INCLUDES));
}
} else {
invokeLastArgumentIfClosure(args);
UrlMapping urlMapping = getURLMappingForNamedArgs(namedArguments, urlData, mappedURI, isResponseCode, currentConstraints);
configureUrlMapping(urlMapping);
return urlMapping;
}
}
return null;