private void LoadMetadata() { if (this.metadata == null) { Logger.LogInfo("We have no existing in-memory metadata"); if (File.Exists(this.metadataFilepath)) { try { this.metadata = XmlFile.ReadFile<StorageMetadata>(this.metadataFilepath); Logger.LogInfo("Succesfully loaded metadata from file"); } catch (Exception ex) { Logger.LogError("Error loading metadata from file", ex); } } if (this.metadata == null) // still null. Not loaded from file, or something went wrong when loading from file { this.metadata = new StorageMetadata(); } } }
public void InitializeSystem(User dataOwner, Role dataOwnerRootRole) { this.metadata = new StorageMetadata(); this.metadata.DataOwnerUserId = dataOwner.Id; this.metadata.DataOwnerRoleId = dataOwnerRootRole.Id; CreateUser(dataOwner); CreateRole(dataOwnerRootRole); SaveMetadata(); }