/// <summary> /// Gets the settings for this repository. This is the same as what can be found in .altinnstudio\settings.json /// </summary> public async Task <AltinnStudioSettings> GetAltinnStudioSettings() { if (_altinnStudioSettings != null) { return(_altinnStudioSettings); } // AltinnStudioSettings doesn't always exists (earlier versions of the app template), so // need some reasonable defaults. if (!FileExistsByRelativePath(STUDIO_SETTINGS_FILEPATH)) { _altinnStudioSettings = await CreateNewAltinnStudioSettings(); } else { (AltinnStudioSettings altinnStudioSettings, bool needsSaving) = await MigrateExistingAltinnStudioSettings(); if (needsSaving) { await WriteObjectByRelativePathAsync(STUDIO_SETTINGS_FILEPATH, altinnStudioSettings); } _altinnStudioSettings = altinnStudioSettings; } return(_altinnStudioSettings); }
public async Task <ActionResult> Put(string org, string repository, [FromBody] AltinnStudioSettings settings) { var developer = AuthenticationHelper.GetDeveloperUserName(HttpContext); if (ModelState.IsValid) { var altinnGitRepository = _altinnGitRepositoryFactory.GetAltinnGitRepository(org, repository, developer); await altinnGitRepository.SaveAltinnStudioSettings(settings); return(Ok(settings)); } else { return(BadRequest(ModelState)); } }
private async Task <AltinnStudioSettings> CreateNewAltinnStudioSettings() { AltinnStudioSettings newAltinnStudioSettings; if (IsDatamodelsRepo()) { newAltinnStudioSettings = new AltinnStudioSettings() { RepoType = AltinnRepositoryType.Datamodels, DatamodellingPreference = DatamodellingPreference.JsonSchema }; } else { newAltinnStudioSettings = new AltinnStudioSettings() { RepoType = AltinnRepositoryType.App, DatamodellingPreference = DatamodellingPreference.Xsd }; } await WriteObjectByRelativePathAsync(STUDIO_SETTINGS_FILEPATH, newAltinnStudioSettings, true); return(newAltinnStudioSettings); }
/// <summary> /// Saves the AltinnStudioSettings to disk. /// </summary> /// <param name="altinnStudioSettings">The <see cref="AltinnStudioSettings"/> object to save. This will overwrite the existing file.</param> public async Task SaveAltinnStudioSettings(AltinnStudioSettings altinnStudioSettings) { await WriteObjectByRelativePathAsync(STUDIO_SETTINGS_FILEPATH, altinnStudioSettings, true); }