A proposed EU directive aimed at protecting food businesses from counterfeit brands has been undermined by a ruling from the European Court of Justice.