set the layer public for the purpose of WCS link creation

This is a fix for #973, but I'd like you devs to discuss it before pulling.
The problem is that in order to create the WCS links the resource has to be public. This is a very similar problem we had for the printing of private layers that we solved with the optional middleware (in fact the code is almost a duplicate, sorry mr DRY).

At this point I think that this code could be more general than a middleware so that can be reused.
If we pull this now then I will open a ticket against this for the 2.1.

Thanks for comments.