From 7cb9a25a7e32bcf141a5ad8f8ab1af0ed6064a99 Mon Sep 17 00:00:00 2001 From: BharathS24 Date: Mon, 20 Aug 2018 17:47:05 +0530 Subject: Modified snmpmapper Now snmpmapper is using DB(postgres) to save mapping file Issue-ID: DCAEGEN2-338 Change-Id: Ifdf173f7b405463005a96f76dee2558a291548e6 Signed-off-by: BharathS24 --- .../org/onap/dcae/mapper/FileUploadController.java | 128 -------------------- .../onap/dcae/mapper/SnmpmapperApplication.java | 46 -------- .../mapper/storage/FileSystemStorageService.java | 130 --------------------- .../onap/dcae/mapper/storage/StorageException.java | 32 ----- .../storage/StorageFileNotFoundException.java | 32 ----- .../dcae/mapper/storage/StorageProperties.java | 44 ------- .../onap/dcae/mapper/storage/StorageService.java | 43 ------- .../java/org/onap/dcae/servicedb/Mapping_file.java | 77 ++++++++++++ .../java/org/onap/dcae/snmpmapperApplication.java | 12 ++ .../java/org/onap/dcae/snmpmapperController.java | 124 ++++++++++++++++++++ .../src/main/resources/application.properties | 13 ++- .../src/main/resources/templates/success.html | 34 ++++++ .../src/main/resources/templates/uploadForm.html | 53 ++++++--- .../src/main/resources/templates/uploadform.html | 36 ++++++ 14 files changed, 329 insertions(+), 475 deletions(-) delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/FileUploadController.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/SnmpmapperApplication.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/storage/FileSystemStorageService.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageException.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageFileNotFoundException.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageProperties.java delete mode 100644 snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageService.java create mode 100644 snmpmapper/src/main/java/org/onap/dcae/servicedb/Mapping_file.java create mode 100644 snmpmapper/src/main/java/org/onap/dcae/snmpmapperApplication.java create mode 100644 snmpmapper/src/main/java/org/onap/dcae/snmpmapperController.java create mode 100644 snmpmapper/src/main/resources/templates/success.html create mode 100644 snmpmapper/src/main/resources/templates/uploadform.html (limited to 'snmpmapper/src/main') diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/FileUploadController.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/FileUploadController.java deleted file mode 100644 index fce8dfa..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/FileUploadController.java +++ /dev/null @@ -1,128 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper; - -import java.io.IOException; -import java.net.URL; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.Resource; -import org.springframework.http.HttpHeaders; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; - -import org.onap.dcae.mapper.storage.StorageFileNotFoundException; -import org.onap.dcae.mapper.storage.StorageService; - -/** - * @author BS00493532 This Controller shifts control according to the uri - * accessed by the user. Accordingly control shifts to get and post - * methods. - * - */ -@Controller -public class FileUploadController { - - private final StorageService storageService; - - @Autowired - public FileUploadController(StorageService storageService) { - this.storageService = storageService; - } - - @GetMapping("/") - public String listUploadedFiles(Model model) throws IOException { - - model.addAttribute("files", - storageService.loadAll() - .map(path -> MvcUriComponentsBuilder - .fromMethodName(FileUploadController.class, "serveFile", path.getFileName().toString()) - .build().toString()) - .collect(Collectors.toList())); - - return "uploadForm"; - - /** - * @author BS00493532 - * - * Returns the upload form like a html page - */ - - } - - @GetMapping("/files/{filename:.+}") - @ResponseBody - public ResponseEntity serveFile(@PathVariable String filename) { - - Resource file = storageService.loadAsResource(filename); - return ResponseEntity.ok() - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFilename() + "\"") - .body(file); - } - - @GetMapping("/fileAsString/{filename:.+}") - @ResponseBody - public String serveFileAsString(@PathVariable String filename) { - - Resource file = storageService.loadAsResource(filename); - // URL url = Resources.getResource(file. getFilename());// - // getResource(file.getURL()); - String fileContent = null; - try { - fileContent = Resources.toString(file.getURL(), Charsets.UTF_8); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return fileContent; - } - - @PostMapping("/") - public String handleFileUpload(@RequestParam("file") MultipartFile file, RedirectAttributes redirectAttributes) { - System.out.println("1"); - - storageService.store(file); - redirectAttributes.addFlashAttribute("message", - "You successfully uploaded " + file.getOriginalFilename() + "!"); - - return "redirect:/"; - } - - @ExceptionHandler(StorageFileNotFoundException.class) - public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException exc) { - return ResponseEntity.notFound().build(); - } - -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/SnmpmapperApplication.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/SnmpmapperApplication.java deleted file mode 100644 index 4893a2a..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/SnmpmapperApplication.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper; - -import org.onap.dcae.mapper.storage.StorageProperties; -import org.onap.dcae.mapper.storage.StorageService; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -@EnableConfigurationProperties(StorageProperties.class) -public class SnmpmapperApplication { - - public static void main(String[] args) { - SpringApplication.run(SnmpmapperApplication.class, args); - } - - @Bean - CommandLineRunner init(StorageService storageService) { - return (args) -> { - // storageService.deleteAll(); - storageService.init(); - }; - } -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/FileSystemStorageService.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/FileSystemStorageService.java deleted file mode 100644 index 5cee706..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/FileSystemStorageService.java +++ /dev/null @@ -1,130 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper.storage; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.stream.Stream; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.Resource; -import org.springframework.core.io.UrlResource; -import org.springframework.stereotype.Service; -import org.springframework.util.FileSystemUtils; -import org.springframework.util.StringUtils; -import org.springframework.web.multipart.MultipartFile; - -@Service -public class FileSystemStorageService implements StorageService { - - private final Path rootLocation; - - @Autowired - public FileSystemStorageService(StorageProperties properties) { - this.rootLocation = Paths.get(properties.getLocation()); - } - - @Override - public void store(MultipartFile file) { - String filename = StringUtils.cleanPath(file.getOriginalFilename()); - try { - if (file.isEmpty()) { - throw new StorageException("Failed to store empty file " + filename); - } - - /** - * @author BS00493532 Checks the contents of the file. If empty, throws - * exception - */ - if (filename.contains("..")) { - // This is a security check - throw new StorageException( - "Cannot store file with relative path outside current directory " + filename); - } - Files.copy(file.getInputStream(), this.rootLocation.resolve(filename), StandardCopyOption.REPLACE_EXISTING); - } catch (IOException e) { - throw new StorageException("Failed to store file " + filename, e); - } - } - - @Override - public Stream loadAll() { - try { - return Files.walk(this.rootLocation, 1).filter(path -> !path.equals(this.rootLocation)) - .map(path -> this.rootLocation.relativize(path)); - } - - /** - * @author BS00493532 Loads all the files in the given path - * - */ - - catch (IOException e) { - throw new StorageException("Failed to read stored files", e); - } - - } - - @Override - public Path load(String filename) { - return rootLocation.resolve(filename); - } - - @Override - public Resource loadAsResource(String filename) { - try { - Path file = load(filename); - Resource resource = new UrlResource(file.toUri()); - if (resource.exists() || resource.isReadable()) { - return resource; - } else { - throw new StorageFileNotFoundException("Could not read file: " + filename); - - } - } catch (MalformedURLException e) { - throw new StorageFileNotFoundException("Could not read file: " + filename, e); - } - } - - /* - * @Override public void deleteAll() { - * FileSystemUtils.deleteRecursively(rootLocation.toFile()); } - */ - - @Override - public void init() { - try { - Files.createDirectories(rootLocation); - } - - /** - * @author BS00493532 Initializes Storage - */ - - catch (IOException e) { - throw new StorageException("Could not initialize storage", e); - } - } -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageException.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageException.java deleted file mode 100644 index dd2675d..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper.storage; - -public class StorageException extends RuntimeException { - - public StorageException(String message) { - super(message); - } - - public StorageException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageFileNotFoundException.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageFileNotFoundException.java deleted file mode 100644 index ef88087..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageFileNotFoundException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper.storage; - -public class StorageFileNotFoundException extends StorageException { - - public StorageFileNotFoundException(String message) { - super(message); - } - - public StorageFileNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} \ No newline at end of file diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageProperties.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageProperties.java deleted file mode 100644 index a2f5396..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageProperties.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper.storage; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties("storage") -public class StorageProperties { - - /** - * Folder location for storing files - */ - // private String location = "upload-dir"; - @Value("${fileService.rootPath}") - private String location; - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageService.java b/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageService.java deleted file mode 100644 index cb278f2..0000000 --- a/snmpmapper/src/main/java/org/onap/dcae/mapper/storage/StorageService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ - -package org.onap.dcae.mapper.storage; - -import java.nio.file.Path; -import java.util.stream.Stream; - -import org.springframework.core.io.Resource; -import org.springframework.web.multipart.MultipartFile; - -public interface StorageService { - - void init(); - - void store(MultipartFile file); - - Stream loadAll(); - - Path load(String filename); - - Resource loadAsResource(String filename); - - // void deleteAll(); - -} diff --git a/snmpmapper/src/main/java/org/onap/dcae/servicedb/Mapping_file.java b/snmpmapper/src/main/java/org/onap/dcae/servicedb/Mapping_file.java new file mode 100644 index 0000000..a4669da --- /dev/null +++ b/snmpmapper/src/main/java/org/onap/dcae/servicedb/Mapping_file.java @@ -0,0 +1,77 @@ +package org.onap.dcae.servicedb; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Table; + +@Entity +@Table(name = "mapping_file") +public class Mapping_file { + + @Id + @Column(name = "EnterpriseID") + public String Enterprise_ID; + + @Column(name = "File_Name") + public String name; + + + @Column(name = "mimetype") + private String mimetype; + + + @Column(name = "mappingfilecontents") + private byte[] Mapping_File; + + + + public Mapping_file() { + super(); + } + + public Mapping_file(String enterprise_ID, String name, String mimetype, byte[] mapping_File) { + super(); + Enterprise_ID = enterprise_ID; + this.name = name; + this.mimetype = mimetype; + Mapping_File = mapping_File; + } + + public String getEnterprise_ID() { + return Enterprise_ID; + } + + public void setEnterprise_ID(String enterprise_ID) { + Enterprise_ID = enterprise_ID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMimetype() { + return mimetype; + } + + public void setMimetype(String mimetype) { + this.mimetype = mimetype; + } + + public byte[] getMapping_File() { + return Mapping_File; + } + + public void setMapping_File(byte[] mapping_File) { + Mapping_File = mapping_File; + } + + + + +} diff --git a/snmpmapper/src/main/java/org/onap/dcae/snmpmapperApplication.java b/snmpmapper/src/main/java/org/onap/dcae/snmpmapperApplication.java new file mode 100644 index 0000000..5354f86 --- /dev/null +++ b/snmpmapper/src/main/java/org/onap/dcae/snmpmapperApplication.java @@ -0,0 +1,12 @@ +package org.onap.dcae; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class snmpmapperApplication { + + public static void main(String[] args) { + SpringApplication.run(snmpmapperApplication.class, args); + } +} diff --git a/snmpmapper/src/main/java/org/onap/dcae/snmpmapperController.java b/snmpmapper/src/main/java/org/onap/dcae/snmpmapperController.java new file mode 100644 index 0000000..94eca54 --- /dev/null +++ b/snmpmapper/src/main/java/org/onap/dcae/snmpmapperController.java @@ -0,0 +1,124 @@ +package org.onap.dcae; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.catalina.startup.ClassLoaderFactory.Repository; +import org.onap.dcae.servicedb.Mapping_file; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class snmpmapperController { + + /*@Autowired + private UploadPageSample1Service upss;*/ + + @Value("${spring.datasource.url}") + String url; + @Value("${spring.datasource.username}") + String user; + @Value("${spring.datasource.password}") + String pwd; + + static String enterpriseid; + static Mapping_file mapping; + + @GetMapping("/") + public String index() { + return "uploadform.html"; + } + + + // This Method Is Used To Get Or Retrieve The Uploaded File And Save It In The Db + @RequestMapping(value = "uploadFile", method = RequestMethod.POST) + public String saveUploadedFileInDatabase(HttpServletRequest request, final @RequestParam MultipartFile[] mapper) throws IllegalStateException, IOException, SQLException { + + // Reading File Upload Form Input Parameters + enterpriseid = request.getParameter("eid"); + + // Logging The Input Parameter (i.e. File Description) For The Debugging Purpose + System.out.println("\nEnterPrise ID Is = " + enterpriseid + "\n"); + + // Determine If There Is An File Upload. If Yes, Attach It To The Client Email + if ((mapper != null) && (mapper.length > 0) && (!mapper.equals(""))) { + for (MultipartFile aFile : mapper) { + if(aFile.isEmpty()) { + continue; + } else { + System.out.println("MappingFile Name = " + aFile.getOriginalFilename() + "\n"); + if (!aFile.getOriginalFilename().equals("")) { + mapping = new Mapping_file(); + mapping.setEnterprise_ID(enterpriseid); + mapping.setMapping_File(aFile.getBytes()); + mapping.setMimetype(aFile.getContentType()); + mapping.setName(aFile.getOriginalFilename()); + + + + /*InputStream inputStream = new BufferedInputStream(aFile.getInputStream());*/ + + System.out.println("1"); + try (Connection con = DriverManager.getConnection(url, user, pwd)) { + + System.out.println("2"); + /*CopyManager cm = new CopyManager((BaseConnection) con);*/ + PreparedStatement pstmt=con.prepareStatement("INSERT INTO mapping_file(enterpriseid, mappingfilecontents, mimetype, File_Name) VALUES (?, ?, ?, ?)"); + pstmt.setString(1, enterpriseid); + System.out.println("3"); + pstmt.setBytes(2, aFile.getBytes()); + pstmt.setString(3, aFile.getContentType()); + pstmt.setString(4, aFile.getOriginalFilename()); + + + System.out.println("4"); + pstmt.executeUpdate(); + + + + + + + /*String fileName = "D:\\configFiles\\TestFile.txt";*/ + + /*try (FileInputStream fis = new FileInputStream(fileName); + InputStreamReader isr = new InputStreamReader(fis, + StandardCharsets.UTF_8)) {*/ + + + + + } + + + + } + } + System.out.println("File Is Successfully Uploaded & Saved In The Database\n"); + } + } else { + // Do Nothing + } + + return "success.html"; + } + +} diff --git a/snmpmapper/src/main/resources/application.properties b/snmpmapper/src/main/resources/application.properties index bee02d9..cf4f33c 100644 --- a/snmpmapper/src/main/resources/application.properties +++ b/snmpmapper/src/main/resources/application.properties @@ -1,2 +1,11 @@ -fileService.rootPath=D:/configFiles -server.port=8888 \ No newline at end of file +server.port=9090 +spring.datasource.url=jdbc:postgresql://10.49.16.19:5432/dummy +spring.datasource.username=postgres +spring.datasource.password=root +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false +spring.servlet.multipart.enabled=true +spring.servlet.multipart.max-file-size=1MB +spring.servlet.multipart.max-request-size=10MB +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect + diff --git a/snmpmapper/src/main/resources/templates/success.html b/snmpmapper/src/main/resources/templates/success.html new file mode 100644 index 0000000..c5a0d34 --- /dev/null +++ b/snmpmapper/src/main/resources/templates/success.html @@ -0,0 +1,34 @@ + + + + + Mapping File + + + +
+

Uploaded Mapping File

+
+
+ Successfully Uploaded Mapping File + Submit another mapping file +
+ + + \ No newline at end of file diff --git a/snmpmapper/src/main/resources/templates/uploadForm.html b/snmpmapper/src/main/resources/templates/uploadForm.html index 22ffc68..89ef4c2 100644 --- a/snmpmapper/src/main/resources/templates/uploadForm.html +++ b/snmpmapper/src/main/resources/templates/uploadForm.html @@ -1,19 +1,36 @@ - + + + + Mapping File + + + + + + + + - -
-

-

- -
-
- - - -
File to upload:
-
-
- - - - +
+

Upload Mapping File

+
+ + + + + + + + + + + + +
Enterprise ID:
Mapping file: + + Please Upload A File! +
+
+
+ + \ No newline at end of file diff --git a/snmpmapper/src/main/resources/templates/uploadform.html b/snmpmapper/src/main/resources/templates/uploadform.html new file mode 100644 index 0000000..89ef4c2 --- /dev/null +++ b/snmpmapper/src/main/resources/templates/uploadform.html @@ -0,0 +1,36 @@ + + + + Mapping File + + + + + + + + + +
+

Upload Mapping File

+
+ + + + + + + + + + + + +
Enterprise ID:
Mapping file: + + Please Upload A File! +
+
+
+ + \ No newline at end of file -- cgit 1.2.3-korg