Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed some nasty parameter mapping edge cases

  • Loading branch information...
commit 45b1300b994909489d0612831705820db565afaf 1 parent 9cddeff
@wfaler wfaler authored
View
8 core/src/main/scala/org/bowlerframework/http/BowlerHttpApplicationRouter.scala
@@ -14,16 +14,16 @@ trait BowlerHttpApplicationRouter extends ApplicationRouter {
val map = new HashMap[String, Any]
params.foreach(f => {
- map += f._1 -> f._2
+ map += f._1.replace("[]", "") -> f._2
})
val nameEnum = request.getParameterNames
while (nameEnum.hasMoreElements) {
val name = nameEnum.nextElement.asInstanceOf[String]
val reqParams = request.getParameterValues(name)
if (reqParams.length == 1) {
- map += name -> reqParams(0)
+ map += name.replace("[]", "") -> reqParams(0)
} else {
- map += name -> reqParams.toList
+ map += name.replace("[]", "") -> reqParams.toList
}
}
@@ -34,7 +34,7 @@ trait BowlerHttpApplicationRouter extends ApplicationRouter {
try {
fileParams.foreach(f => {
- map += f._1 -> f._2
+ map += f._1.replace("[]", "") -> f._2
})
} catch {
case e: Exception => {}
View
32 core/src/main/scala/org/bowlerframework/model/DefaultRequestMapper.scala
@@ -142,19 +142,39 @@ class DefaultRequestMapper extends RequestMapper {
private def valueList(parent: GenericTypeDefinition, typeDef: GenericTypeDefinition, request: HashMap[String, Any], nameHint: String): MutableList[Any] = {
val values = new MutableList[Any]
var list: List[Any] = null
- if (nameHint != null)
- list = request(nameHint).asInstanceOf[List[_]]
- else {
+ if (nameHint != null){
+ try{
+ list = request(nameHint).asInstanceOf[List[_]]
+ }catch{
+ case e: ClassCastException => {
+ list = List(request(nameHint))
+ }
+ }
+ }else {
val alias = AliasRegistry(parent)
request.iterator.foreach(f => {
- if (list == null && f._2.isInstanceOf[AnyRef] && classOf[List[_ <: Any]].isAssignableFrom(f._2.asInstanceOf[AnyRef].getClass) && f._1.startsWith(alias))
- list = f._2.asInstanceOf[List[_]]
+ if (list == null && f._2.isInstanceOf[AnyRef] && classOf[List[_ <: Any]].isAssignableFrom(f._2.asInstanceOf[AnyRef].getClass) && f._1.startsWith(alias)){
+ try{
+ list = f._2.asInstanceOf[List[_]]
+ }catch{
+ case e: ClassCastException => {
+ list = List(f._2)
+ }
+ }
+ }
})
if (list == null) {
request.iterator.foreach(f => {
- if (list == null && f._2.isInstanceOf[AnyRef] && classOf[List[_ <: Any]].isAssignableFrom(f._2.asInstanceOf[AnyRef].getClass))
+ if (list == null && f._2.isInstanceOf[AnyRef] && classOf[List[_ <: Any]].isAssignableFrom(f._2.asInstanceOf[AnyRef].getClass)){
+ try{
list = f._2.asInstanceOf[List[_]]
+ }catch{
+ case e: ClassCastException => {
+ list = List(f._2)
+ }
+ }
+ }
})
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.