The work gained Ofili the kind of notoriety which contemporary art embraces when the then mayor of New York took umbrage at the painting when it was shown at an exhibition in the city , and took his case to court .