Не знаю почему не последняя версия
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package com.geovizor.monitoring; //Главная 2
|
||||
package dbms; //package com.geovizor.monitoring; //Главная 2
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
@ -8,10 +8,8 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.sql.Connection;
|
||||
@ -48,13 +46,11 @@ import javax.xml.xpath.XPathFactory;
|
||||
//import org.apache.commons.fileupload.FileItem;
|
||||
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -111,12 +107,11 @@ public class DBMSRecords implements ServletContextAware {
|
||||
//Документация по @RequestBody http://javastudy.ru/spring-mvc/json-xml/ application/xml
|
||||
@RequestMapping(value = "/api/dbms/records.xyz",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> ajaxTamer(@ModelAttribute User user, @RequestBody(required = false) byte[] reqData, @RequestParam(required=false,name="lng") String language_id) {
|
||||
public ResponseEntity<String> ajaxRecords(@ModelAttribute User user, @RequestBody(required = false) byte[] reqData, @RequestParam(required=false,name="lng") String language_id) {
|
||||
final HttpHeaders httpHeaders= new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
|
||||
if(language_id!=null && !language_id.equals(""))
|
||||
if(language_id!=null && !language_id.equals(""))
|
||||
user.language_id=language_id;
|
||||
logger.info("user.id="+user.id+" user.name="+user.name+" user.language_id="+user.language_id+" user.country_id="+user.country_id);
|
||||
|
||||
@ -129,62 +124,29 @@ public class DBMSRecords implements ServletContextAware {
|
||||
|
||||
//response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
//Thread.sleep(5000); // sleep 5 seconds
|
||||
//String metadata_file = "";
|
||||
String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
try {
|
||||
prop.load(new FileInputStream("monitoring.properties")); // load a properties file
|
||||
//Читаю настройки базы
|
||||
db_url = prop.getProperty("db.url");
|
||||
System.out.println("db.url = " + db_url);
|
||||
//dbSchema = prop.getProperty("db.schema");
|
||||
//System.out.println("db.schema = " + dbSchema);
|
||||
db_login = prop.getProperty("db.login");
|
||||
System.out.println("db.login = " + db_login);
|
||||
db_password = prop.getProperty("db.password");
|
||||
//System.out.println("db.password = " + db_password);
|
||||
data_dir = prop.getProperty("data-dir");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
/*if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
String mail_host = "";
|
||||
String mail_port = "";
|
||||
String mail_login = "";
|
||||
String mail_password = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
/*try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("mail-host"))
|
||||
mail_host = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-port"))
|
||||
mail_port = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-login"))
|
||||
mail_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("mail-password"))
|
||||
mail_password = nl.item(i).getTextContent();
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
mail_host = prop.getProperty("mail.host");
|
||||
mail_port = prop.getProperty("mail.port");
|
||||
mail_login = prop.getProperty("mail.login");
|
||||
mail_password = prop.getProperty("mail.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load application.properties",e);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}*/
|
||||
|
||||
String jspPath = context.getRealPath("/");
|
||||
|
||||
@ -1918,11 +1880,6 @@ public class DBMSRecords implements ServletContextAware {
|
||||
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Example request: http://localhost:8080/CCALM/download?t=FrmLocust&f=image_name1&i=1298
|
||||
*/
|
||||
@ -1931,63 +1888,19 @@ public class DBMSRecords implements ServletContextAware {
|
||||
public FileSystemResource home(HttpServletResponse response,@ModelAttribute User user,@RequestParam(required=false,name="t") String typename,@RequestParam(required=false,name="f") String field,@RequestParam(required=false,name="i") String id) {
|
||||
|
||||
String metadata_file = "";
|
||||
/*String db_url = "";
|
||||
String db_login = "";
|
||||
String db_password = "";
|
||||
//String data_dir = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("db-url"))
|
||||
db_url = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-login"))
|
||||
db_login = nl.item(i).getTextContent();
|
||||
if (nl.item(i).getNodeName().equals("db-password"))
|
||||
db_password = nl.item(i).getTextContent();
|
||||
|
||||
if (nl.item(i).getNodeName().equals("metadata"))
|
||||
metadata_file = nl.item(i).getTextContent();
|
||||
|
||||
//if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
// data_dir = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}*/
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
try {
|
||||
prop.load(new FileInputStream("monitoring.properties")); // load a properties file
|
||||
//Читаю настройки базы
|
||||
db_url = prop.getProperty("db.url");
|
||||
System.out.println("db.url = " + db_url);
|
||||
//dbSchema = prop.getProperty("db.schema");
|
||||
//System.out.println("db.schema = " + dbSchema);
|
||||
db_login = prop.getProperty("db.login");
|
||||
System.out.println("db.login = " + db_login);
|
||||
db_password = prop.getProperty("db.password");
|
||||
//System.out.println("db.password = " + db_password);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
/*if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
logger.error("Error load application.properties",e);
|
||||
}
|
||||
|
||||
|
||||
@ -2101,23 +2014,15 @@ public class DBMSRecords implements ServletContextAware {
|
||||
public String uploadFile(HttpServletResponse response,@RequestParam(required=false,name="file") MultipartFile file) {
|
||||
|
||||
String result="";
|
||||
String data_dir="";
|
||||
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
data_dir = nl.item(i).getTextContent();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load application.properties",e);
|
||||
}
|
||||
|
||||
|
||||
@ -2188,25 +2093,16 @@ public class DBMSRecords implements ServletContextAware {
|
||||
@RequestMapping(value = "/reports",method = RequestMethod.GET, produces = "application/octet-stream")
|
||||
@ResponseBody
|
||||
public FileSystemResource sendReport(HttpServletResponse response,@RequestParam(required=true,name="file") String fileName) {
|
||||
|
||||
String data_dir = "";
|
||||
//Load DB configuration from "config.xml"
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
||||
//File fXmlFile = new File(fullPath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
//Document doc = dBuilder.parse(fXmlFile);
|
||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
||||
Element nMain = doc.getDocumentElement();
|
||||
NodeList nl = nMain.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals("data-dir"))
|
||||
data_dir = nl.item(i).getTextContent();
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load application.properties",e);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.info(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
File file = new File(data_dir + "temp" + File.separator + fileName);
|
||||
if(file.exists())
|
||||
@ -2440,4 +2336,8 @@ public class DBMSRecords implements ServletContextAware {
|
||||
return doc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user