Update SureopsService.java
This commit is contained in:
		
							parent
							
								
									5b0d2742bc
								
							
						
					
					
						commit
						d55af70b93
					
				@ -36,10 +36,26 @@ public class SureopsService {
 | 
				
			|||||||
		String PRJ_NAME = list.get(0);
 | 
							String PRJ_NAME = list.get(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		int i = 0;
 | 
							int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String index = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "  <title>Welcome</title>\n" + "</head>\n"
 | 
				
			||||||
 | 
									+ "<body>\n" + "  <h1>Welcome to the Web App</h1>\n" + "  <ul>\n"
 | 
				
			||||||
 | 
									+ "    <li><a href=\"Home.html\">Home Page</a></li>\n" + "  </ul>\n" + "</body>\n" + "</html>";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String filename = "index.html";
 | 
				
			||||||
 | 
							createFile(projId, PRJ_NAME, filename, index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
 | 
							for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
 | 
				
			||||||
			String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
 | 
								String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
 | 
				
			||||||
			String htmlContent = entry.getValue();
 | 
								String htmlContent = entry.getValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								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
 | 
							String folderPath = projectPath + File.separator + projId + File.separator + "index" + File.separator
 | 
				
			||||||
				+ PRJ_NAME;
 | 
									+ PRJ_NAME;
 | 
				
			||||||
		File file = new File(folderPath + "/" + pageName + ".html");
 | 
							File file = new File(folderPath + "/" + pageName + ".html");
 | 
				
			||||||
@ -58,12 +74,11 @@ public class SureopsService {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
 | 
							try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
 | 
				
			||||||
			writer.write(htmlContent);
 | 
								writer.write(htmlContent);
 | 
				
			||||||
				i++;
 | 
					
 | 
				
			||||||
				System.out.println(i + " file created ");
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		System.out.println("✅ File created: " + file.getAbsolutePath());
 | 
							System.out.println("✅ File created: " + file.getAbsolutePath());
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public ResponseEntity<Object> GET(String get) {
 | 
						public ResponseEntity<Object> GET(String get) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user