We introduce the family of law-invariant convex risk functionals, which includes a wide majority of practically used convex risk measures and deviation measures. We obtain a unified representation theorem for this family of functionals. Two related optimization problems are studied. In the first...