First validate the object and permissions, then save the OSD, then set the metadata.