From d55af70b93cf1bfa5c808ff2db4b4df77da21906 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Sat, 26 Apr 2025 12:15:25 +0530 Subject: [PATCH] Update SureopsService.java --- .../OpenAi/Services/SureopsService.java | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/SureopsService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/SureopsService.java index 2050ccb..ba186ab 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/SureopsService.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/OpenAi/Services/SureopsService.java @@ -36,36 +36,51 @@ public class SureopsService { String PRJ_NAME = list.get(0); int i = 0; + + String index = "\n" + "\n" + "\n" + " Welcome\n" + "\n" + + "\n" + "

Welcome to the Web App

\n" + " \n" + "\n" + ""; + + String filename = "index.html"; + createFile(projId, PRJ_NAME, filename, index); + for (Map.Entry entry : pageHtmlMap.entrySet()) { String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name String htmlContent = entry.getValue(); - String folderPath = projectPath + File.separator + projId + File.separator + "index" + File.separator - + PRJ_NAME; - File file = new File(folderPath + "/" + pageName + ".html"); - - // Ensure directory exists - File parentDir = file.getParentFile(); - if (!parentDir.exists()) { - - parentDir.mkdirs(); - } - - // Create new file - if (!file.exists()) { - file.createNewFile(); - } - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { - writer.write(htmlContent); - i++; - System.out.println(i + " file created "); - } - - System.out.println("✅ File created: " + file.getAbsolutePath()); + createFile(projId, PRJ_NAME, pageName, htmlContent); + i++; + System.out.println(i + " file created "); } } + public void createFile(Integer projId, String PRJ_NAME, String pageName, String htmlContent) throws IOException { + + String folderPath = projectPath + File.separator + projId + File.separator + "index" + File.separator + + PRJ_NAME; + File file = new File(folderPath + "/" + pageName + ".html"); + + // Ensure directory exists + File parentDir = file.getParentFile(); + if (!parentDir.exists()) { + + parentDir.mkdirs(); + } + + // Create new file + if (!file.exists()) { + file.createNewFile(); + } + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { + writer.write(htmlContent); + + } + + System.out.println("✅ File created: " + file.getAbsolutePath()); + + } + public ResponseEntity GET(String get) { RestTemplate restTemplate = new RestTemplate();