diff --git a/backend/packagegroups/NuGet.props b/backend/packagegroups/NuGet.props index aa5606096ee..58b4297bd38 100644 --- a/backend/packagegroups/NuGet.props +++ b/backend/packagegroups/NuGet.props @@ -1,6 +1,7 @@ + @@ -20,6 +21,7 @@ + diff --git a/backend/src/Designer/Controllers/ApplicationMetadataController.cs b/backend/src/Designer/Controllers/ApplicationMetadataController.cs index e8612bd1ddb..d163f5b686f 100644 --- a/backend/src/Designer/Controllers/ApplicationMetadataController.cs +++ b/backend/src/Designer/Controllers/ApplicationMetadataController.cs @@ -1,6 +1,6 @@ using System.IO; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Altinn.Studio.Designer.Services.Interfaces; using Microsoft.AspNetCore.Authorization; @@ -37,7 +37,7 @@ public ApplicationMetadataController(IApplicationMetadataService applicationMeta [HttpGet] public async Task GetApplicationMetadata(string org, string app) { - Application application = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata application = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); if (application == null) { return NotFound(); @@ -54,10 +54,10 @@ public async Task GetApplicationMetadata(string org, string app) /// The application metadata /// The updated application metadata [HttpPut] - public async Task UpdateApplicationMetadata(string org, string app, [FromBody] Application applicationMetadata) + public async Task UpdateApplicationMetadata(string org, string app, [FromBody] ApplicationMetadata applicationMetadata) { await _applicationMetadataService.UpdateApplicationMetaDataLocally(org, app, applicationMetadata); - Application updatedApplicationMetadata = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata updatedApplicationMetadata = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); return Ok(updatedApplicationMetadata); } @@ -77,7 +77,7 @@ public async Task CreateApplicationMetadata(string org, string app } await _applicationMetadataService.CreateApplicationMetadata(org, app, app); - Application createdApplication = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata createdApplication = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); if (createdApplication == null) { return StatusCode(500); diff --git a/backend/src/Designer/Controllers/EnvironmentsController.cs b/backend/src/Designer/Controllers/EnvironmentsController.cs index 667b4ac225d..44824cfc939 100644 --- a/backend/src/Designer/Controllers/EnvironmentsController.cs +++ b/backend/src/Designer/Controllers/EnvironmentsController.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Altinn.Studio.Designer.Services.Implementation; using Altinn.Studio.Designer.Services.Interfaces; using Altinn.Studio.Designer.Services.Models; using Microsoft.AspNetCore.Authorization; diff --git a/backend/src/Designer/Controllers/PreviewController.cs b/backend/src/Designer/Controllers/PreviewController.cs index a230fae5036..d7a202a1d03 100644 --- a/backend/src/Designer/Controllers/PreviewController.cs +++ b/backend/src/Designer/Controllers/PreviewController.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using System.Web; +using Altinn.App.Core.Models; using Altinn.Platform.Profile.Models; using Altinn.Platform.Register.Enums; using Altinn.Platform.Register.Models; @@ -18,6 +19,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using ApplicationLanguage = Altinn.Studio.Designer.Models.ApplicationLanguage; +using LayoutSets = Altinn.Studio.Designer.Models.LayoutSets; namespace Altinn.Studio.Designer.Controllers { @@ -120,11 +123,11 @@ public FileStreamResult Image(string org, string app, string imageFilePath, Canc /// The application metadata for the app [HttpGet] [Route("api/v1/applicationmetadata")] - public async Task> ApplicationMetadata(string org, string app, CancellationToken cancellationToken) + public async Task> ApplicationMetadata(string org, string app, CancellationToken cancellationToken) { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer); - Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); + ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); return Ok(applicationMetadata); } @@ -141,7 +144,7 @@ public async Task> ApplicationSettings(string { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer); - Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); + ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); ApplicationSettings applicationSettings = new() { Id = applicationMetadata.Id, diff --git a/backend/src/Designer/Designer.csproj b/backend/src/Designer/Designer.csproj index 08dd310072a..7ae008fae42 100644 --- a/backend/src/Designer/Designer.csproj +++ b/backend/src/Designer/Designer.csproj @@ -18,13 +18,13 @@ + - - + diff --git a/backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs b/backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs index 40f2657707b..786f9498e8e 100644 --- a/backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs +++ b/backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs @@ -8,7 +8,7 @@ using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Altinn.Studio.Designer.Configuration; using Altinn.Studio.Designer.Helpers; using Altinn.Studio.Designer.Models; @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; using JsonSerializer = System.Text.Json.JsonSerializer; +using LayoutSets = Altinn.Studio.Designer.Models.LayoutSets; namespace Altinn.Studio.Designer.Infrastructure.GitRepository { @@ -74,12 +75,12 @@ public AltinnAppGitRepository(string org, string repository, string developer, s /// /// Gets the application metadata. /// - public async Task GetApplicationMetadata(CancellationToken cancellationToken = default) + public async Task GetApplicationMetadata(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); string appMetadataRelativeFilePath = Path.Combine(CONFIG_FOLDER_PATH, APP_METADATA_FILENAME); string fileContent = await ReadTextByRelativePathAsync(appMetadataRelativeFilePath, cancellationToken); - Application applicationMetaData = JsonSerializer.Deserialize(fileContent, _jsonOptions); + ApplicationMetadata applicationMetaData = JsonSerializer.Deserialize(fileContent, _jsonOptions); return applicationMetaData; } @@ -94,7 +95,7 @@ public bool ApplicationMetadataExists() /// Saves the application metadata file to disk. /// /// The updated application metadata to persist. - public async Task SaveApplicationMetadata(Application applicationMetadata) + public async Task SaveApplicationMetadata(ApplicationMetadata applicationMetadata) { string metadataAsJson = JsonSerializer.Serialize(applicationMetadata, _jsonOptions); string appMetadataRelativeFilePath = Path.Combine(CONFIG_FOLDER_PATH, APP_METADATA_FILENAME); diff --git a/backend/src/Designer/Services/Implementation/ApplicationInformationService.cs b/backend/src/Designer/Services/Implementation/ApplicationInformationService.cs index 5cafc48d9a6..12ba5dec1e1 100644 --- a/backend/src/Designer/Services/Implementation/ApplicationInformationService.cs +++ b/backend/src/Designer/Services/Implementation/ApplicationInformationService.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using Altinn.Studio.Designer.Services.Interfaces; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.Services.Implementation { diff --git a/backend/src/Designer/Services/Implementation/ApplicationMetadataService.cs b/backend/src/Designer/Services/Implementation/ApplicationMetadataService.cs index a144167c17f..d1e91cbb1ca 100644 --- a/backend/src/Designer/Services/Implementation/ApplicationMetadataService.cs +++ b/backend/src/Designer/Services/Implementation/ApplicationMetadataService.cs @@ -7,6 +7,7 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading.Tasks; +using Altinn.App.Core.Models; using Altinn.Platform.Storage.Interface.Models; using Altinn.Studio.Designer.Configuration; using Altinn.Studio.Designer.Helpers; @@ -58,7 +59,7 @@ public ApplicationMetadataService( /// public async Task UpdateAppTitleInAppMetadata(string org, string app, string languageId, string title) { - Application appMetadata = await GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata appMetadata = await GetApplicationMetadataFromRepository(org, app); Dictionary titles = appMetadata.Title; if (titles.ContainsKey(languageId)) @@ -76,7 +77,7 @@ public async Task UpdateAppTitleInAppMetadata(string org, string app, string lan } /// - public async Task UpdateApplicationMetaDataLocally(string org, string app, Application applicationMetadata) + public async Task UpdateApplicationMetaDataLocally(string org, string app, ApplicationMetadata applicationMetadata) { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer); @@ -117,9 +118,10 @@ public async Task UpdateAppMetadataConfigAsync(string org, string app, ServiceCo public async Task CreateApplicationMetadata(string org, string app, string appTitle) { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); - Application appMetadata = new() + string id = ApplicationHelper.GetFormattedApplicationId(org, app); + ApplicationMetadata appMetadata = new(id) { - Id = ApplicationHelper.GetFormattedApplicationId(org, app), + Id = id, VersionId = null, Org = org, Created = DateTime.UtcNow, @@ -145,7 +147,7 @@ public async Task CreateApplicationMetadata(string org, string app, string appTi public async Task AddMetadataForAttachment(string org, string app, string applicationMetadata) { DataType formMetadata = JsonConvert.DeserializeObject(applicationMetadata); - Application existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); existingApplicationMetadata.DataTypes.Add(formMetadata); await UpdateApplicationMetaDataLocally(org, app, existingApplicationMetadata); @@ -156,7 +158,7 @@ public async Task UpdateMetadataForAttachment(string org, string app, string app { dynamic attachmentMetadata = JsonConvert.DeserializeObject(applicationMetadata); string attachmentId = attachmentMetadata.GetValue("id").Value; - Application existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); DataType applicationForm = existingApplicationMetadata.DataTypes.FirstOrDefault(m => m.Id == attachmentId) ?? new DataType(); applicationForm.AllowedContentTypes = new List(); @@ -186,7 +188,7 @@ public async Task DeleteMetadataForAttachment(string org, string app, stri { try { - Application existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata existingApplicationMetadata = await GetApplicationMetadataFromRepository(org, app); if (existingApplicationMetadata.DataTypes != null) { @@ -208,8 +210,8 @@ public async Task DeleteMetadataForAttachment(string org, string app, stri public async Task UpdateApplicationMetadataInStorageAsync(string org, string app, string shortCommitId, string envName) { - Application applicationFromRepository = await GetApplicationMetadataFromSpecificReference(org, app, shortCommitId); - Application application = await GetApplicationMetadataFromStorage(org, app, envName); + ApplicationMetadata applicationFromRepository = await GetApplicationMetadataFromSpecificReference(org, app, shortCommitId); + ApplicationMetadata application = await GetApplicationMetadataFromStorage(org, app, envName); if (application == null) { await CreateApplicationMetadataInStorage(org, app, applicationFromRepository, envName, shortCommitId); @@ -219,11 +221,11 @@ public async Task UpdateApplicationMetadataInStorageAsync(string org, string app await UpdateApplicationMetadataInStorage(org, app, applicationFromRepository, envName, shortCommitId); } - public async Task GetApplicationMetadataFromRepository(string org, string app) + public async Task GetApplicationMetadataFromRepository(string org, string app) { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer); - Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(); + ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(); return applicationMetadata; } @@ -234,7 +236,7 @@ public async Task GetApplicationMetadataFromRepository(string org, /// Application identifier which is unique within an organisation. /// The name of the commit/branch/tag. Default the repository’s default branch /// The application metadata for an application. - private async Task GetApplicationMetadataFromSpecificReference(string org, string app, string referenceId) + private async Task GetApplicationMetadataFromSpecificReference(string org, string app, string referenceId) { var file = await _giteaApiWrapper.GetFileAsync(org, app, "App/config/applicationmetadata.json", referenceId); if (string.IsNullOrEmpty(file.Content)) @@ -245,7 +247,7 @@ private async Task GetApplicationMetadataFromSpecificReference(stri // It's used to avoid sensibility to BOM using var fileStream = new MemoryStream(Convert.FromBase64String(file.Content)); using StreamReader utf8Reader = new(fileStream, Encoding.UTF8); - return JsonSerializer.Deserialize(await utf8Reader.ReadToEndAsync(), + return JsonSerializer.Deserialize(await utf8Reader.ReadToEndAsync(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true, @@ -261,7 +263,7 @@ public bool ApplicationMetadataExistsInRepository(string org, string app) return altinnAppGitRepository.ApplicationMetadataExists(); } - private async Task GetApplicationMetadataFromStorage(string org, string app, string envName) + private async Task GetApplicationMetadataFromStorage(string org, string app, string envName) { try { @@ -282,7 +284,7 @@ private async Task GetApplicationMetadataFromStorage(string org, st } } - private async Task CreateApplicationMetadataInStorage(string org, string app, Application applicationFromRepository, string envName, string shortCommitId) + private async Task CreateApplicationMetadataInStorage(string org, string app, ApplicationMetadata applicationFromRepository, string envName, string shortCommitId) { applicationFromRepository.Id = $"{org}/{app}"; applicationFromRepository.VersionId = shortCommitId; @@ -290,7 +292,7 @@ private async Task CreateApplicationMetadataInStorage(string org, string app, Ap await _storageAppMetadataClient.CreateApplicationMetadata(org, app, applicationFromRepository, envName); } - private async Task UpdateApplicationMetadataInStorage(string org, string app, Application applicationFromRepository, string envName, string shortCommitId) + private async Task UpdateApplicationMetadataInStorage(string org, string app, ApplicationMetadata applicationFromRepository, string envName, string shortCommitId) { applicationFromRepository.VersionId = shortCommitId; diff --git a/backend/src/Designer/Services/Implementation/RepositorySI.cs b/backend/src/Designer/Services/Implementation/RepositorySI.cs index 5f6ed75e2b1..b1bce513892 100644 --- a/backend/src/Designer/Services/Implementation/RepositorySI.cs +++ b/backend/src/Designer/Services/Implementation/RepositorySI.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using System.Xml; +using Altinn.App.Core.Models; using Altinn.Authorization.ABAC.Utils; using Altinn.Authorization.ABAC.Xacml; using Altinn.Studio.DataModeling.Metamodel; @@ -312,7 +313,7 @@ private async Task CreateRepositorySettings(string org, string repository, strin await targetAppRepository.SearchAndReplaceInFile(".git/config", $"repos/{org}/{sourceRepository}.git", $"repos/{org}/{targetRepository}.git"); - PlatformStorageModels.Application appMetadata = await targetAppRepository.GetApplicationMetadata(); + ApplicationMetadata appMetadata = await targetAppRepository.GetApplicationMetadata(); appMetadata.Id = $"{org}/{targetRepository}"; appMetadata.CreatedBy = developer; appMetadata.LastChangedBy = developer; @@ -662,7 +663,7 @@ private FileSystemObject GetFileSystemObjectForDirectory(string path) private async Task GetModelName(string org, string app) { - PlatformStorageModels.Application application = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); + ApplicationMetadata application = await _applicationMetadataService.GetApplicationMetadataFromRepository(org, app); string dataTypeId = string.Empty; if (application == null) diff --git a/backend/src/Designer/Services/Implementation/SchemaModelService.cs b/backend/src/Designer/Services/Implementation/SchemaModelService.cs index 1d0267b71ca..4ca30bfbf3b 100644 --- a/backend/src/Designer/Services/Implementation/SchemaModelService.cs +++ b/backend/src/Designer/Services/Implementation/SchemaModelService.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using System.Xml.Schema; - +using Altinn.App.Core.Models; using Altinn.Platform.Storage.Interface.Models; using Altinn.Studio.DataModeling.Converter.Interfaces; using Altinn.Studio.DataModeling.Converter.Json.Strategy; @@ -291,7 +291,7 @@ private async Task UpdateCSharpClasses(AltinnAppGitRepository altinnAppGitReposi private static async Task UpdateApplicationMetadata(AltinnAppGitRepository altinnAppGitRepository, string schemaName, string typeName) { - Application application = await altinnAppGitRepository.GetApplicationMetadata(); + ApplicationMetadata application = await altinnAppGitRepository.GetApplicationMetadata(); UpdateApplicationWithAppLogicModel(application, schemaName, "Altinn.App.Models." + typeName); @@ -305,7 +305,7 @@ private static async Task UpdateApplicationMetadata(AltinnAppGitRepository altin /// The object to be updated. /// The id of the datatype to bed added. /// The C# class reference of the data type. - private static void UpdateApplicationWithAppLogicModel(Application application, string dataTypeId, string classRef) + private static void UpdateApplicationWithAppLogicModel(ApplicationMetadata application, string dataTypeId, string classRef) { if (application.DataTypes == null) { diff --git a/backend/src/Designer/Services/Interfaces/IApplicationInformationService.cs b/backend/src/Designer/Services/Interfaces/IApplicationInformationService.cs index 5ec2e8c872b..f83abf85198 100644 --- a/backend/src/Designer/Services/Interfaces/IApplicationInformationService.cs +++ b/backend/src/Designer/Services/Interfaces/IApplicationInformationService.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.Services.Interfaces { diff --git a/backend/src/Designer/Services/Interfaces/IApplicationMetadataService.cs b/backend/src/Designer/Services/Interfaces/IApplicationMetadataService.cs index 3567ab252b7..ed64f9eaa1d 100644 --- a/backend/src/Designer/Services/Interfaces/IApplicationMetadataService.cs +++ b/backend/src/Designer/Services/Interfaces/IApplicationMetadataService.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Altinn.Studio.Designer.Configuration; namespace Altinn.Studio.Designer.Services.Interfaces @@ -48,7 +48,7 @@ public interface IApplicationMetadataService /// Unique identifier of the organisation responsible for the app. /// Application identifier which is unique within an organisation. /// The application metadata to be updated - public Task UpdateApplicationMetaDataLocally(string org, string app, Application applicationMetadata); + public Task UpdateApplicationMetaDataLocally(string org, string app, ApplicationMetadata applicationMetadata); /// /// Returns the application metadata for an application. @@ -56,7 +56,7 @@ public interface IApplicationMetadataService /// Unique identifier of the organisation responsible for the app. /// Application identifier which is unique within an organisation. /// The application metadata for an application. - public Task GetApplicationMetadataFromRepository(string org, string app); + public Task GetApplicationMetadataFromRepository(string org, string app); /// /// Returns the application metadata exists in repo. diff --git a/backend/src/Designer/Services/Interfaces/IAuthorizationPolicyService.cs b/backend/src/Designer/Services/Interfaces/IAuthorizationPolicyService.cs index e264bcd63fc..bcb2f0da9a1 100644 --- a/backend/src/Designer/Services/Interfaces/IAuthorizationPolicyService.cs +++ b/backend/src/Designer/Services/Interfaces/IAuthorizationPolicyService.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.Services.Interfaces { diff --git a/backend/src/Designer/Services/Interfaces/ITextResourceService.cs b/backend/src/Designer/Services/Interfaces/ITextResourceService.cs index 879db5ee17b..9b9e18b5ebb 100644 --- a/backend/src/Designer/Services/Interfaces/ITextResourceService.cs +++ b/backend/src/Designer/Services/Interfaces/ITextResourceService.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.Services.Interfaces { diff --git a/backend/src/Designer/TypedHttpClients/AltinnAuthorization/IAltinnAuthorizationPolicyClient.cs b/backend/src/Designer/TypedHttpClients/AltinnAuthorization/IAltinnAuthorizationPolicyClient.cs index d35286eee87..a16741c636b 100644 --- a/backend/src/Designer/TypedHttpClients/AltinnAuthorization/IAltinnAuthorizationPolicyClient.cs +++ b/backend/src/Designer/TypedHttpClients/AltinnAuthorization/IAltinnAuthorizationPolicyClient.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.TypedHttpClients.AltinnAuthorization { diff --git a/backend/src/Designer/TypedHttpClients/AltinnStorage/AltinnStorageAppMetadataClient.cs b/backend/src/Designer/TypedHttpClients/AltinnStorage/AltinnStorageAppMetadataClient.cs index 6bdf5aadb9f..7904f96e401 100644 --- a/backend/src/Designer/TypedHttpClients/AltinnStorage/AltinnStorageAppMetadataClient.cs +++ b/backend/src/Designer/TypedHttpClients/AltinnStorage/AltinnStorageAppMetadataClient.cs @@ -3,7 +3,7 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Altinn.Studio.Designer.Configuration; using Altinn.Studio.Designer.Helpers; using Altinn.Studio.Designer.Services.Interfaces; @@ -41,7 +41,7 @@ public AltinnStorageAppMetadataClient( } /// - public async Task GetApplicationMetadata(string org, string app, string envName) + public async Task GetApplicationMetadata(string org, string app, string envName) { var storageUri = await CreateStorageUri(envName); Uri uri = new($"{storageUri}{org}/{app}"); @@ -54,14 +54,14 @@ public async Task GetApplicationMetadata(string org, string app, st using HttpRequestMessage request = new(HttpMethod.Get, uri); HttpResponseMessage response = await _httpClient.SendAsync(request); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(); } /// public async Task CreateApplicationMetadata( string org, string app, - Application applicationMetadata, + ApplicationMetadata applicationMetadata, string envName) { var storageUri = await CreateStorageUri(envName); @@ -84,7 +84,7 @@ public async Task CreateApplicationMetadata( public async Task UpdateApplicationMetadata( string org, string app, - Application applicationMetadata, + ApplicationMetadata applicationMetadata, string envName) { var storageUri = await CreateStorageUri(envName); diff --git a/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageAppMetadataClient.cs b/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageAppMetadataClient.cs index 95550d95ba8..7663f77a36e 100644 --- a/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageAppMetadataClient.cs +++ b/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageAppMetadataClient.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; -using Altinn.Studio.Designer.Services.Models; +using Altinn.App.Core.Models; namespace Altinn.Studio.Designer.TypedHttpClients.AltinnStorage { @@ -16,7 +15,7 @@ public interface IAltinnStorageAppMetadataClient /// Application /// Environment Name /// - Task GetApplicationMetadata(string org, string app, string envName); + Task GetApplicationMetadata(string org, string app, string envName); /// /// Creates application metadata for an application in Platform.Storage @@ -26,7 +25,7 @@ public interface IAltinnStorageAppMetadataClient /// Application /// Environment Name /// - Task CreateApplicationMetadata(string org, string app, Application applicationMetadata, string envName); + Task CreateApplicationMetadata(string org, string app, ApplicationMetadata applicationMetadata, string envName); /// /// Updates application metadata for an application in Platform.Storage @@ -36,6 +35,6 @@ public interface IAltinnStorageAppMetadataClient /// Application /// Environment Name /// - Task UpdateApplicationMetadata(string org, string app, Application applicationMetadata, string envName); + Task UpdateApplicationMetadata(string org, string app, ApplicationMetadata applicationMetadata, string envName); } } diff --git a/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageTextResourceClient.cs b/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageTextResourceClient.cs index 3418ba4a113..b0d77f690b1 100644 --- a/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageTextResourceClient.cs +++ b/backend/src/Designer/TypedHttpClients/AltinnStorage/IAltinnStorageTextResourceClient.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Altinn.Platform.Storage.Interface.Models; -using Altinn.Studio.Designer.Services.Models; namespace Altinn.Studio.Designer.TypedHttpClients.AltinnStorage { diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs index 68df3fabdf3..e0160d7b591 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/AddMetadataForAttachmentTests.cs @@ -7,6 +7,7 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; +using Altinn.App.Core.Models; using Altinn.Platform.Storage.Interface.Models; using Designer.Tests.Controllers.ApiTests; using Designer.Tests.Utils; @@ -39,7 +40,7 @@ public async Task AddMetadataForAttachment_WhenExists_ShouldReturnConflict(strin response.StatusCode.Should().Be(HttpStatusCode.OK); string applicationMetadataFile = await File.ReadAllTextAsync(Path.Combine(TestRepoPath, "App", "config", "applicationmetadata.json")); - var applicationMetadata = JsonSerializer.Deserialize(applicationMetadataFile, JsonSerializerOptions); + var applicationMetadata = JsonSerializer.Deserialize(applicationMetadataFile, JsonSerializerOptions); var attachmentDataType = applicationMetadata.DataTypes.Single(x => x.Id == payload.Id); attachmentDataType.MaxCount.Should().Be(payload.MaxCount); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs index b6adf009a01..33c628cf0a9 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/DeleteMetadataForAttachmentTests.cs @@ -4,7 +4,7 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Designer.Tests.Controllers.ApiTests; using Designer.Tests.Utils; using FluentAssertions; @@ -27,7 +27,7 @@ public async Task DeleteMetadataForAttachment_WhenExists_ShouldReturnOk(string o string targetRepository = TestDataHelper.GenerateTestRepoName(); await CopyRepositoryForTest(org, app, developer, targetRepository); string previousMetadata = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/applicationmetadata.json"); - Application applicationMetadataPreDelete = JsonSerializer.Deserialize(previousMetadata, JsonSerializerOptions); + ApplicationMetadata applicationMetadataPreDelete = JsonSerializer.Deserialize(previousMetadata, JsonSerializerOptions); Assert.Contains(applicationMetadataPreDelete.DataTypes, x => x.Id == attacmentIdToDelete); string url = $"{VersionPrefix(org, targetRepository)}/attachment-component"; @@ -38,7 +38,7 @@ public async Task DeleteMetadataForAttachment_WhenExists_ShouldReturnOk(string o response.StatusCode.Should().Be(HttpStatusCode.OK); string currentMetadata = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/applicationmetadata.json"); - Application applicationMetadataAfterDelete = JsonSerializer.Deserialize(currentMetadata, JsonSerializerOptions); + ApplicationMetadata applicationMetadataAfterDelete = JsonSerializer.Deserialize(currentMetadata, JsonSerializerOptions); Assert.DoesNotContain(applicationMetadataAfterDelete.DataTypes, x => x.Id == attacmentIdToDelete); } } diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs index 956ab916335..4aefc5c5336 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/GetApplicationMetadataTests.cs @@ -2,7 +2,7 @@ using System.Net; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Designer.Tests.Controllers.ApiTests; using Designer.Tests.Utils; using FluentAssertions; @@ -36,7 +36,7 @@ public async Task GetApplicationMetadata_ShouldReturnOK(string org, string app, response.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await response.Content.ReadAsStringAsync(); - string expectedJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(metadataFile, JsonSerializerOptions), JsonSerializerOptions); + string expectedJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(metadataFile, JsonSerializerOptions), JsonSerializerOptions); JsonUtils.DeepEquals(expectedJson, responseContent).Should().BeTrue(); } } diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs index a5d9c7f8479..d6a38f5dea0 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateApplicationMetadataTests.cs @@ -1,10 +1,11 @@ -using System.Net; +using System; +using System.Net; using System.Net.Http; using System.Net.Mime; using System.Text; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Designer.Tests.Controllers.ApiTests; using Designer.Tests.Utils; using FluentAssertions; @@ -29,7 +30,7 @@ public async Task UpdateApplicationMetadata_WhenExists_ShouldReturnConflict(stri await CopyRepositoryForTest(org, app, developer, targetRepository); string metadata = SharedResourcesHelper.LoadTestDataAsString(metadataToUpdate); - string expectedMetadataJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(metadata, JsonSerializerOptions), JsonSerializerOptions); + string expectedMetadataJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(metadata, JsonSerializerOptions), JsonSerializerOptions); string url = VersionPrefix(org, targetRepository); diff --git a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs index d9bf973552e..3f212304ff5 100644 --- a/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ApplicationMetadataController/UpdateMetadataForAttachmentTests.cs @@ -8,7 +8,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Designer.Tests.Controllers.ApiTests; using Designer.Tests.Utils; using FluentAssertions; @@ -46,7 +46,7 @@ public async Task UpdateMetadataForAttachment_WhenExists_ShouldReturnConflict(st response.StatusCode.Should().Be(HttpStatusCode.OK); string applicationMetadataFile = await File.ReadAllTextAsync(Path.Combine(TestRepoPath, "App", "config", "applicationmetadata.json")); - var applicationMetadata = JsonSerializer.Deserialize(applicationMetadataFile, _jsonSerializerOptions); + var applicationMetadata = JsonSerializer.Deserialize(applicationMetadataFile, _jsonSerializerOptions); var attachmentDataType = applicationMetadata.DataTypes.Single(x => x.Id == payloadNode!["id"]!.ToString()); attachmentDataType.MaxCount.Should().Be(payloadNode!["maxCount"]!.GetValue()); diff --git a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs index a1c143dbe3b..40be28dc247 100644 --- a/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/PreviewController/ApplicationMetadataTests.cs @@ -2,7 +2,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; -using Altinn.Platform.Storage.Interface.Models; +using Altinn.App.Core.Models; using Designer.Tests.Utils; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; @@ -30,7 +30,7 @@ public async Task Get_ApplicationMetadata_Ok() Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseBody = await response.Content.ReadAsStringAsync(); - string expectedJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(expectedApplicationMetadata, SerializerOptions), SerializerOptions); + string expectedJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(expectedApplicationMetadata, SerializerOptions), SerializerOptions); JsonUtils.DeepEquals(expectedJson, responseBody).Should().BeTrue(); } } diff --git a/backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs b/backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs index ffae4bb65ce..4192e51d2fc 100644 --- a/backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs +++ b/backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Text.Json.Nodes; using System.Threading.Tasks; +using Altinn.App.Core.Models; using Altinn.Platform.Storage.Interface.Models; using Altinn.Studio.Designer.Infrastructure.GitRepository; using Designer.Tests.Utils; @@ -37,7 +38,7 @@ public async Task GetApplicationMetadata_FileExists_ShouldHaveCorrectValues() string developer = "testUser"; AltinnAppGitRepository altinnAppGitRepository = PrepareRepositoryForTest(org, repository, developer); - Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(); + ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(); applicationMetadata.Id.Should().Be("yabbin/hvem-er-hvem"); applicationMetadata.Org.Should().Be("yabbin"); diff --git a/backend/tests/Designer.Tests/Services/TextResourceServiceTest.cs b/backend/tests/Designer.Tests/Services/TextResourceServiceTest.cs index 8c58729ba82..996c115693d 100644 --- a/backend/tests/Designer.Tests/Services/TextResourceServiceTest.cs +++ b/backend/tests/Designer.Tests/Services/TextResourceServiceTest.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Altinn.Studio.Designer.Services.Implementation; -using Altinn.Studio.Designer.Services.Models; using Altinn.Studio.Designer.TypedHttpClients.AltinnStorage; using AltinnCore.Authentication.Constants; diff --git a/testdata/App/config/applicationmetadata.json b/testdata/App/config/applicationmetadata.json index 3ccea793700..2a2eeb1b50f 100644 --- a/testdata/App/config/applicationmetadata.json +++ b/testdata/App/config/applicationmetadata.json @@ -1,5 +1,10 @@ { "id": "ttd/frontend-test", + "logo": { + "source": "resource", + "displayAppOwnerNameInHeader": false, + "size": "medium" + }, "org": "ttd", "title": { "nb": "frontend-test", @@ -163,9 +168,6 @@ "subUnit": false }, "autoDeleteOnProcessEnd": false, - "onEntry": { - "show": "select-instance" - }, "created": "2021-02-06T15:18:12.2060944Z", "createdBy": "jeeva", "lastChanged": "2021-02-06T15:18:12.2062288Z",