X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplc%2FsfaImport.py;h=9a5113e2f92a6b9de0c5b2c7b1ae419d7b9f4832;hb=b6194bb19fd83ac5d76946c541c789a01144fefd;hp=a749f3255bac30a9fa34bad7c1ebf09a20e59528;hpb=388315b1b7e94e09a1b717d38693a03be5e23058;p=sfa.git diff --git a/sfa/plc/sfaImport.py b/sfa/plc/sfaImport.py index a749f325..9a5113e2 100644 --- a/sfa/plc/sfaImport.py +++ b/sfa/plc/sfaImport.py @@ -68,18 +68,22 @@ class sfaImport: def create_top_level_auth_records(self, hrn): - # create the authority if it doesnt already exist AuthHierarchy = self.AuthHierarchy urn = hrn_to_urn(hrn, 'authority') - if not AuthHierarchy.auth_exists(urn): - trace("Import: creating top level authorites", self.logger) - AuthHierarchy.create_auth(urn) + # make sure parent exists parent_hrn = get_authority(hrn) if not parent_hrn: parent_hrn = hrn - auth_info = AuthHierarchy.get_auth_info(parent_hrn) + if not parent_hrn == hrn: + self.create_top_level_auth_records(parent_hrn) + + # create the authority if it doesnt already exist + if not AuthHierarchy.auth_exists(urn): + trace("Import: creating top level authorites", self.logger) + AuthHierarchy.create_auth(urn) # create the db record if it doesnt already exist + auth_info = AuthHierarchy.get_auth_info(hrn) table = SfaTable() auth_record = table.find({'type': 'authority', 'hrn': hrn})