Spring Jackson Rest debug

If you try to POST/PUT data on an REST Endpoint and if you have a 400 error response from your Spring backEnd as the json is not well recognized by the server; go to the DispatcherServlet class and put a breakpoint on doDispatch or doRun something like this, you can use log4j and set the TRACE level to make it traced in the console logs.

Recursive function in javascript

This is an example to update a tree list object with nodes (the bonus is to set a flag for each element if there is something different between parent node and children nodes):

// Recursive function in order to update all nodes.
_updateSecuredBranchNodesState:function(ctx, pNode){
    return (function (ctx, pNode) {
        pNode.hasDifferentChildrenBranchCountries = false;
        _.each(pNode.nodes, function(cNode, index){
	    //only reset the flag at the beginning of the iteration
            if(index==0){cNode.hasDifferentChildrenBranchCountries = false;}
            ctx._updateSecuredBranchNodesState(ctx, cNode);
	    //don't treat the root branch
            if(pNode.id!= ctx.securedBranchesNodes.id){
                if(cNode.branch.countries.length!=pNode.branch.countries.length){
                    pNode.hasDifferentChildrenBranchCountries = true;
                    cNode.hasDifferentChildrenBranchCountries = true;
                } else {
                    for(var i=0; i<pNode.branch.countries.length;i++){
                        var pCountry = pNode.branch.countries[i];
                        var found = false;
                        _.each(cNode.branch.countries, function(cCountry){
                            if(pCountry.country.id== cCountry.country.id){
                                found = true;
                            }
                        });
                        if(!found) {
                            pNode.hasDifferentChildrenBranchCountries = true;
                            cNode.hasDifferentChildrenBranchCountries = true;
                            break;
                        }
                    }
                }
                if(cNode.hasDifferentChildrenBranchCountries){
		    // update the parent flag
                    pNode.hasDifferentChildrenBranchCountries = true;
                }
            }
        });
    })(ctx, pNode);
},