Judge: APA must pay farm's legal fees