Gravitating solitons and hairy black holes