Merge branch 'master' of https://git.dirt.kz/igor/Metadata_PHP
# Conflicts: # metadata/dbms/DBMSRecords.java
This commit is contained in:
+45
-145
@@ -1,4 +1,4 @@
|
|||||||
package dbms;
|
package dbms; //package com.geovizor.monitoring; //Главная 2
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@@ -8,10 +8,8 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -48,13 +46,11 @@ import javax.xml.xpath.XPathFactory;
|
|||||||
//import org.apache.commons.fileupload.FileItem;
|
//import org.apache.commons.fileupload.FileItem;
|
||||||
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
//import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
//import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
import jakarta.servlet.ServletContext;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -111,11 +107,10 @@ public class DBMSRecords implements ServletContextAware {
|
|||||||
//Документация по @RequestBody http://javastudy.ru/spring-mvc/json-xml/ application/xml
|
//Документация по @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"
|
@RequestMapping(value = "/api/dbms/records.xyz",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
|
||||||
@ResponseBody
|
@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();
|
final HttpHeaders httpHeaders= new HttpHeaders();
|
||||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
|
||||||
if(language_id!=null && !language_id.equals(""))
|
if(language_id!=null && !language_id.equals(""))
|
||||||
user.language_id=language_id;
|
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);
|
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());
|
//response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||||
//Thread.sleep(5000); // sleep 5 seconds
|
//Thread.sleep(5000); // sleep 5 seconds
|
||||||
//String metadata_file = "";
|
String db_url="";
|
||||||
String db_url = "";
|
String db_login="";
|
||||||
String db_login = "";
|
String db_password="";
|
||||||
String db_password = "";
|
|
||||||
String data_dir = "";
|
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_host = "";
|
||||||
String mail_port = "";
|
String mail_port = "";
|
||||||
String mail_login = "";
|
String mail_login = "";
|
||||||
String mail_password = "";
|
String mail_password = "";
|
||||||
//Load DB configuration from "config.xml"
|
Properties prop = new Properties();
|
||||||
/*try {
|
try {
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
db_url = prop.getProperty("spring.datasource.url");
|
||||||
//Document doc = dBuilder.parse(fXmlFile);
|
db_login = prop.getProperty("spring.datasource.username");
|
||||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
db_password = prop.getProperty("spring.datasource.password");
|
||||||
Element nMain = doc.getDocumentElement();
|
data_dir = prop.getProperty("data.dir");
|
||||||
NodeList nl = nMain.getChildNodes();
|
mail_host = prop.getProperty("mail.host");
|
||||||
for (int i = 0; i < nl.getLength(); i++) {
|
mail_port = prop.getProperty("mail.port");
|
||||||
if (nl.item(i).getNodeName().equals("mail-host"))
|
mail_login = prop.getProperty("mail.login");
|
||||||
mail_host = nl.item(i).getTextContent();
|
mail_password = prop.getProperty("mail.password");
|
||||||
if (nl.item(i).getNodeName().equals("mail-port"))
|
} catch (Exception e) {
|
||||||
mail_port = nl.item(i).getTextContent();
|
e.printStackTrace();
|
||||||
if (nl.item(i).getNodeName().equals("mail-login"))
|
logger.error("Error load application.properties",e);
|
||||||
mail_login = nl.item(i).getTextContent();
|
|
||||||
if (nl.item(i).getNodeName().equals("mail-password"))
|
|
||||||
mail_password = nl.item(i).getTextContent();
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.info(ex.getMessage());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
String jspPath = context.getRealPath("/");
|
String jspPath = context.getRealPath("/");
|
||||||
|
|
||||||
@@ -1918,11 +1880,6 @@ public class DBMSRecords implements ServletContextAware {
|
|||||||
return new ResponseEntity<String>(result, httpHeaders, HttpStatus.OK);
|
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
|
* 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) {
|
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 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_url="";
|
||||||
String db_login="";
|
String db_login="";
|
||||||
String db_password="";
|
String db_password="";
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
InputStream input = null;
|
|
||||||
try {
|
try {
|
||||||
prop.load(new FileInputStream("monitoring.properties")); // load a properties file
|
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||||
//Читаю настройки базы
|
db_url = prop.getProperty("spring.datasource.url");
|
||||||
db_url = prop.getProperty("db.url");
|
db_login = prop.getProperty("spring.datasource.username");
|
||||||
System.out.println("db.url = " + db_url);
|
db_password = prop.getProperty("spring.datasource.password");
|
||||||
//dbSchema = prop.getProperty("db.schema");
|
} catch (Exception e) {
|
||||||
//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) {
|
|
||||||
e.printStackTrace();
|
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) {
|
public String uploadFile(HttpServletResponse response,@RequestParam(required=false,name="file") MultipartFile file) {
|
||||||
|
|
||||||
String result="";
|
String result="";
|
||||||
String data_dir="";
|
|
||||||
|
|
||||||
|
String data_dir = "";
|
||||||
|
Properties prop = new Properties();
|
||||||
try {
|
try {
|
||||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||||
//File fXmlFile = new File(fullPath);
|
data_dir = prop.getProperty("data.dir");
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
} catch (Exception e) {
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
e.printStackTrace();
|
||||||
//Document doc = dBuilder.parse(fXmlFile);
|
logger.error("Error load application.properties",e);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2188,25 +2093,16 @@ public class DBMSRecords implements ServletContextAware {
|
|||||||
@RequestMapping(value = "/reports",method = RequestMethod.GET, produces = "application/octet-stream")
|
@RequestMapping(value = "/reports",method = RequestMethod.GET, produces = "application/octet-stream")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public FileSystemResource sendReport(HttpServletResponse response,@RequestParam(required=true,name="file") String fileName) {
|
public FileSystemResource sendReport(HttpServletResponse response,@RequestParam(required=true,name="file") String fileName) {
|
||||||
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("data-dir"))
|
|
||||||
data_dir = nl.item(i).getTextContent();
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.info(ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
String data_dir = "";
|
||||||
|
Properties prop = new Properties();
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
File file = new File(data_dir + "temp" + File.separator + fileName);
|
File file = new File(data_dir + "temp" + File.separator + fileName);
|
||||||
if(file.exists())
|
if(file.exists())
|
||||||
@@ -2440,4 +2336,8 @@ public class DBMSRecords implements ServletContextAware {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setServletContext(ServletContext servletContext) {
|
||||||
|
this.context=servletContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+13
-23
@@ -2,12 +2,14 @@ package kz.goodssales.GoodsSales.dbms;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
@@ -66,30 +68,18 @@ public class DBMSTree implements ServletContextAware {
|
|||||||
String result="<metadata fn=\"-1\"><![CDATA[Request not processed!]]></metadata>";
|
String result="<metadata fn=\"-1\"><![CDATA[Request not processed!]]></metadata>";
|
||||||
|
|
||||||
String jspPath = context.getRealPath("/");
|
String jspPath = context.getRealPath("/");
|
||||||
String db_url = "";
|
String db_url="";
|
||||||
String db_login = "";
|
String db_login="";
|
||||||
String db_password = "";
|
String db_password="";
|
||||||
|
Properties prop = new Properties();
|
||||||
//Load DB configuration from "config.xml"
|
|
||||||
try {
|
try {
|
||||||
//String fullPath = context.getRealPath("/WEB-INF/config.xml");
|
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||||
//File fXmlFile = new File(fullPath);
|
db_url = prop.getProperty("spring.datasource.url");
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
db_login = prop.getProperty("spring.datasource.username");
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
db_password = prop.getProperty("spring.datasource.password");
|
||||||
//Document doc = dBuilder.parse(fXmlFile);
|
} catch (Exception e) {
|
||||||
Document doc = dBuilder.parse(new ClassPathResource("config.xml").getInputStream());
|
e.printStackTrace();
|
||||||
Element nMain = doc.getDocumentElement();
|
logger.error("Error load application.properties",e);
|
||||||
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();
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.info(ex.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//var ScriptName='../records'; //POST
|
//var ScriptName='../api/dbms/records.xyz'; //POST
|
||||||
//var ScriptDName='../download';
|
//var ScriptDName='../download';
|
||||||
//var ScriptUName='../upload';
|
//var ScriptUName='../upload';
|
||||||
//var ScriptRName='../reports'; //GET For download reports (?file=name)
|
//var ScriptRName='../reports'; //GET For download reports (?file=name)
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ function postJsonData(url,data,fun){
|
|||||||
//Вывести текст поверх окон с кнопочкой OK
|
//Вывести текст поверх окон с кнопочкой OK
|
||||||
function alert2(title,smallText,fullText,okFunc=null)
|
function alert2(title,smallText,fullText,okFunc=null)
|
||||||
{
|
{
|
||||||
|
if(fullText === undefined) fullText='';
|
||||||
if(smallText === undefined || smallText==''){
|
if(smallText === undefined || smallText==''){
|
||||||
smallText=fullText;
|
smallText=fullText;
|
||||||
fullText='';
|
fullText='';
|
||||||
|
|||||||
Reference in New Issue
Block a user