diff --git a/backend/src/Designer/Controllers/ProcessModelingController.cs b/backend/src/Designer/Controllers/ProcessModelingController.cs index a31a7c30d52..8a3e237ed13 100644 --- a/backend/src/Designer/Controllers/ProcessModelingController.cs +++ b/backend/src/Designer/Controllers/ProcessModelingController.cs @@ -128,30 +128,5 @@ await _processModelingService.SaveProcessDefinitionFromTemplateAsync(editingCont Stream processDefinitionStream = _processModelingService.GetProcessDefinitionStream(editingContext); return new FileStreamResult(processDefinitionStream, MediaTypeNames.Text.Plain); } - - [HttpPut("tasks/{taskId}/{taskName}")] - public async Task UpdateProcessTaskName(string org, string repo, string taskId, string taskName, - CancellationToken cancellationToken) - { - Guard.AssertArgumentNotNull(taskId, nameof(taskId)); - Guard.AssertArgumentNotNull(taskName, nameof(taskName)); - string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext); - var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, repo, developer); - try - { - Stream updatedProcessDefinitionStream = - await _processModelingService.UpdateProcessTaskNameAsync(editingContext, taskId, taskName, - cancellationToken); - return new FileStreamResult(updatedProcessDefinitionStream, MediaTypeNames.Text.Plain); - } - catch (InvalidOperationException) - { - return BadRequest("Could not deserialize process definition."); - } - catch (ArgumentException) - { - return BadRequest("Could not find task with given id."); - } - } } } diff --git a/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs b/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs index 71dc3035a61..708ca63d278 100644 --- a/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs +++ b/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs @@ -56,37 +56,6 @@ public Stream GetProcessDefinitionStream(AltinnRepoEditingContext altinnRepoEdit return altinnAppGitRepository.GetProcessDefinitionFile(); } - public async Task UpdateProcessTaskNameAsync(AltinnRepoEditingContext altinnRepoEditingContext, string taskId, string taskName, CancellationToken cancellationToken = default) - { - cancellationToken.ThrowIfCancellationRequested(); - AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer); - XmlSerializer serializer = new(typeof(Definitions)); - Definitions? definitions; - using (Stream processDefinitionStream = GetProcessDefinitionStream(altinnRepoEditingContext)) - { - definitions = (Definitions?)serializer.Deserialize(processDefinitionStream); - } - - if (definitions == null) - { - throw new InvalidOperationException("Could not deserialize process definition."); - } - - ProcessTask? processTask = (definitions.Process.Tasks?.FirstOrDefault(t => t.Id == taskId)) ?? throw new ArgumentException($"Could not find task with id {taskId}."); - processTask.Name = taskName; - - Stream processStream = new MemoryStream(); - serializer.Serialize(processStream, definitions); - - // Reset stream position to beginning after serialization - processStream.Seek(0, SeekOrigin.Begin); - await altinnAppGitRepository.SaveProcessDefinitionFileAsync(processStream, cancellationToken); - - // Reset stream position to beginning after saving - processStream.Seek(0, SeekOrigin.Begin); - return processStream; - } - private IEnumerable EnumerateTemplateResources(SemanticVersion version) { return typeof(ProcessModelingService).Assembly.GetManifestResourceNames() diff --git a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs index cc5e61db789..85d38e079cb 100644 --- a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs +++ b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs @@ -39,15 +39,5 @@ public interface IProcessModelingService /// An . /// A of a process definition file. Stream GetProcessDefinitionStream(AltinnRepoEditingContext altinnRepoEditingContext); - - /// - /// Updates the name of a task in the process definition file. - /// - /// n . - /// The ID of the task to update - /// The name to set for the task - /// A that observes if operation is cancelled. - /// - Task UpdateProcessTaskNameAsync(AltinnRepoEditingContext altinnRepoEditingContext, string taskId, string taskName, CancellationToken cancellationToken = default); } } diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/UpsertProcessDefinitionAndNotifyTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/UpsertProcessDefinitionAndNotifyTests.cs index 70351d8d431..b8e0122edbc 100644 --- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/UpsertProcessDefinitionAndNotifyTests.cs +++ b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/UpsertProcessDefinitionAndNotifyTests.cs @@ -38,7 +38,7 @@ public async Task UpsertProcessDefinition_ShouldReturnOk(string org, string app, string url = VersionPrefix(org, targetRepository); - var form = new MultipartFormDataContent(); + using var form = new MultipartFormDataContent(); string metadataString = JsonSerializer.Serialize(metadata, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); form.Add(new StreamContent(fileStream), "content", "process.bpmn"); diff --git a/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs b/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs index ec8a4ad5613..de0487719df 100644 --- a/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs +++ b/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs @@ -37,34 +37,6 @@ public void GetProcessDefinitionTemplates_GivenVersion_ReturnsListOfTemplates(st } } - [Theory] - [InlineData("ttd", "app-with-process", "testUser", "Task_1", "NewTaskName")] - public async void UpdateProcessTaskNameAsync_GivenTaskIdAndTaskName_UpdatesTaskName(string org, string repo, string developer, string taskId, string newTaskName) - { - // Arrange - string targetRepository = TestDataHelper.GenerateTestRepoName(); - var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, targetRepository, developer); - await TestDataHelper.CopyRepositoryForTest(org, repo, developer, targetRepository); - - try - { - var altinnGitRepositoryFactory = new AltinnGitRepositoryFactory(TestDataHelper.GetTestDataRepositoriesRootDirectory()); - IProcessModelingService processModelingService = new ProcessModelingService(altinnGitRepositoryFactory); - - // Act - using Stream result = await processModelingService.UpdateProcessTaskNameAsync(editingContext, taskId, newTaskName); - XmlSerializer serializer = new(typeof(Definitions)); - Definitions definitions = (Definitions)serializer.Deserialize(result); - - // Assert - definitions.Process.Tasks.First(t => t.Id == taskId).Name.Should().Be(newTaskName); - } - finally - { - TestDataHelper.DeleteAppRepository(org, targetRepository, developer); - } - } - public static IEnumerable TemplatesTestData => new List { new object[]