Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ class RestCallAction(

/**
* Make sure that the path params are resolved to the same concrete values of "other".
* Note: "this" can be just an ancestor of "other"
* Note: "this" can be just an ancestor of "other".
* This function takes care when path elements are dynamically handled based on
* results of previous calls (eg a POST creating a resource). *
*
**/
fun bindToSamePathResolution(other: RestCallAction) {
Expand All @@ -189,11 +191,38 @@ class RestCallAction(
g.forceNewTaints()
}
}
if(this.path.isEquivalent(other.path)) {
//if pointing to the same resource, make sure to handle dynamic resource creation
//TODO does it make sense to do it even for ancestor paths??? likely not... but not 100% sure
this.usePreviousLocationId = other.usePreviousLocationId
this.weakReference = other.weakReference
}
}

fun usingSameResolvedPath(other: RestCallAction) =
//FIXME this does not consider dynamic fields?
this.resolvedOnlyPath() == other.resolvedOnlyPath()
/**
* Check if the resulting path of this action is the same of [other], taking into account dynamic info
*/
fun usingSameResolvedPath(other: RestCallAction) : Boolean{
if(this.path.levels() != other.path.levels()){
return false
}

/*
TODO Is this really correct? what about cases of
1) /items/{id}/foo
2) /items/{id}/bar
???
TODO we need to handle the possible non-shared suffix
*/
if(this.usePreviousLocationId != null && this.usePreviousLocationId == other.usePreviousLocationId){
return true
}
if(this.weakReference != null && this.weakReference == other.weakReference){
return true
}

return this.resolvedOnlyPath() == other.resolvedOnlyPath()
}

/**
* When the URL path of this endpoint is resolved, would it be a (strict) parent from the other action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class RestPath(path: String) {
return false
}

return (0 until this.elements.size).none { other.elements[it] != this.elements[it] }
return this.elements.indices.none { other.elements[it] != this.elements[it] }
}


Expand Down
Loading