2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcaegen2.services.mapper.snmpmapper.controller;
22 import java.io.BufferedInputStream;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.nio.charset.StandardCharsets;
28 import java.sql.Connection;
29 import java.sql.DriverManager;
30 import java.sql.PreparedStatement;
31 import java.sql.SQLException;
33 import javax.servlet.http.HttpServletRequest;
35 import org.apache.catalina.startup.ClassLoaderFactory.Repository;
36 import org.onap.dcaegen2.services.mapper.snmpmapper.entity.MappingFile;
37 import org.onap.dcaegen2.services.mapper.snmpmapper.service.MappingFileService;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.beans.factory.annotation.Value;
40 import org.springframework.stereotype.Controller;
41 import org.springframework.web.bind.annotation.GetMapping;
42 import org.springframework.web.bind.annotation.RequestMapping;
43 import org.springframework.web.bind.annotation.RequestMethod;
44 import org.springframework.web.bind.annotation.RequestParam;
45 import org.springframework.web.multipart.MultipartFile;
46 import org.springframework.web.multipart.commons.CommonsMultipartFile;
47 import org.springframework.web.servlet.ModelAndView;
51 public class SnmpmapperController {
54 MappingFileService mappingFileService;
57 public String index() {
58 return "uploadform.html";
65 * Method to upload Mapping file in the postgresql db
71 @RequestMapping(value = "uploadFile", method = RequestMethod.POST)
72 public String saveUploadedFileInDatabase(HttpServletRequest request, final @RequestParam MultipartFile[] mapper){
73 String result=mappingFileService.saveUploadedFileInDatabase(request, mapper);
74 if(result.equals("success")) {
75 return "success.html";