-
Notifications
You must be signed in to change notification settings - Fork 0
Code formatting while saving #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ | |
| import org.frankframework.flow.project.ProjectDTO; | ||
| import org.frankframework.flow.project.ProjectNotFoundException; | ||
| import org.frankframework.flow.project.ProjectService; | ||
| import org.frankframework.flow.xml.XmlDTO; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
|
|
@@ -39,20 +38,17 @@ public ResponseEntity<ConfigurationDTO> getConfigurationByPath(@RequestBody Conf | |
| } | ||
|
|
||
| @PutMapping("/{projectName}/configuration") | ||
| public ResponseEntity<XmlDTO> updateConfiguration( | ||
| public ResponseEntity<Void> updateConfiguration( | ||
| @RequestBody ConfigurationDTO configurationDTO) | ||
| throws ConfigurationNotFoundException, IOException, ParserConfigurationException, | ||
| SAXException, TransformerException { | ||
| String updatedContent = configurationService.updateConfiguration( | ||
| configurationDTO.filepath(), configurationDTO.content()); | ||
| XmlDTO xmlDTO = new XmlDTO(updatedContent); | ||
| return ResponseEntity.ok(xmlDTO); | ||
| throws ConfigurationNotFoundException, IOException { | ||
| configurationService.updateConfiguration(configurationDTO.filepath(), configurationDTO.content()); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
|
|
||
| @PostMapping("/{projectName}/configurations/{configName}") | ||
| public ResponseEntity<ProjectDTO> addConfiguration( | ||
| @PathVariable String projectName, @PathVariable String configName) | ||
| throws ProjectNotFoundException, IOException { | ||
| throws ProjectNotFoundException, IOException, ParserConfigurationException, TransformerException, SAXException { | ||
|
Comment on lines
49
to
+51
|
||
| Project project = configurationService.addConfiguration(projectName, configName); | ||
|
Comment on lines
48
to
52
|
||
| return ResponseEntity.ok(projectService.toDto(project)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,8 @@ public String getConfigurationContent(String filepath) throws IOException, Confi | |
| return fileSystemStorage.readFile(filePath.toString()); | ||
| } | ||
|
|
||
| public String updateConfiguration(String filepath, String content) | ||
| throws IOException, ConfigurationNotFoundException, ParserConfigurationException, SAXException, | ||
| TransformerException { | ||
| public boolean updateConfiguration(String filepath, String content) | ||
| throws IOException, ConfigurationNotFoundException { | ||
| Path absolutePath = fileSystemStorage.toAbsolutePath(filepath); | ||
|
|
||
| if (!Files.exists(absolutePath)) { | ||
|
|
@@ -56,16 +55,13 @@ public String updateConfiguration(String filepath, String content) | |
| if (Files.isDirectory(absolutePath)) { | ||
| throw new ConfigurationNotFoundException("Invalid file path: " + filepath); | ||
| } | ||
| Document updatedDocument = XmlConfigurationUtils.insertFlowNamespace(content); | ||
| String updatedContent = XmlConfigurationUtils.convertNodeToString(updatedDocument); | ||
|
|
||
| // Just write to the disk. ProjectService reads directly from disk now! | ||
| fileSystemStorage.writeFile(absolutePath.toString(), updatedContent); | ||
| return updatedContent; | ||
| fileSystemStorage.writeFile(absolutePath.toString(), content); | ||
| return true; | ||
|
Comment on lines
47
to
+60
|
||
| } | ||
|
|
||
| public Project addConfiguration(String projectName, String configurationName) | ||
| throws ProjectNotFoundException, IOException { | ||
| throws ProjectNotFoundException, IOException, TransformerException, ParserConfigurationException, SAXException { | ||
| Project project = projectService.getProject(projectName); | ||
|
Comment on lines
63
to
65
|
||
|
|
||
| Path absProjectPath = fileSystemStorage.toAbsolutePath(project.getRootPath()); | ||
|
|
@@ -81,14 +77,16 @@ public Project addConfiguration(String projectName, String configurationName) | |
| } | ||
|
|
||
| String defaultXml = loadDefaultConfigurationXml(); | ||
| fileSystemStorage.writeFile(filePath.toString(), defaultXml); | ||
| Document updatedDocument = XmlConfigurationUtils.insertFlowNamespace(defaultXml); | ||
| String updatedContent = XmlConfigurationUtils.convertNodeToString(updatedDocument); | ||
| fileSystemStorage.writeFile(filePath.toString(), updatedContent); | ||
|
|
||
| // Returning the project handles everything, as 'toDto' will pick up the new file | ||
| return project; | ||
| } | ||
|
|
||
| public Project addConfigurationToFolder(String projectName, String configurationName, String folderPath) | ||
| throws IOException, ApiException { | ||
| throws IOException, ApiException, ParserConfigurationException, SAXException, TransformerException { | ||
| Project project = projectService.getProject(projectName); | ||
|
Comment on lines
88
to
90
|
||
|
|
||
| Path absProjectPath = fileSystemStorage.toAbsolutePath(project.getRootPath()); | ||
|
|
@@ -112,7 +110,9 @@ public Project addConfigurationToFolder(String projectName, String configuration | |
| } | ||
|
|
||
| String defaultXml = loadDefaultConfigurationXml(); | ||
| fileSystemStorage.writeFile(filePath.toString(), defaultXml); | ||
| Document updatedDocument = XmlConfigurationUtils.insertFlowNamespace(defaultXml); | ||
| String updatedContent = XmlConfigurationUtils.convertNodeToString(updatedDocument); | ||
| fileSystemStorage.writeFile(filePath.toString(), updatedContent); | ||
|
|
||
| return project; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchConfigurationCacheduses the module-levelconfigCache, butsaveConfigurationdoesn't update or invalidate that cache. After saving, other screens that rely onfetchConfigurationCachedcan read stale XML until a manual cache clear happens. Consider updatingconfigCachefor the saved key (set it tocontent) or deleting that key once the PUT succeeds.