Luxury clothing brands can prevent authorised agents on-selling lines to another retailer if it could damage their reputation, the European Court of Justice (ECJ) has ruled.