|
|
|
|
@ -18,17 +18,19 @@ import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.Statement;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
//import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
import java.util.zip.CRC32;
|
|
|
|
|
import java.util.zip.Checksum;
|
|
|
|
|
|
|
|
|
|
import io.jsonwebtoken.Claims;
|
|
|
|
|
import io.jsonwebtoken.Jws;
|
|
|
|
|
import io.jsonwebtoken.Jwts;
|
|
|
|
|
import jakarta.servlet.ServletContext;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import javax.crypto.SecretKey;
|
|
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
|
import javax.xml.transform.OutputKeys;
|
|
|
|
|
@ -78,6 +80,7 @@ import org.xml.sax.InputSource;
|
|
|
|
|
|
|
|
|
|
import tctable.Tools;
|
|
|
|
|
import tools.EmailUtility;
|
|
|
|
|
import tools.Translation;
|
|
|
|
|
import tools.User;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -105,9 +108,10 @@ 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"
|
|
|
|
|
@RequestMapping(value = "/api/dbms/v09/records.xyz",method = {RequestMethod.POST,RequestMethod.GET}) //,produces = "text/plain; charset=utf-8"
|
|
|
|
|
@ResponseBody
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
@ -187,13 +191,11 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
logger.info("Connect is OK!");
|
|
|
|
|
} else {
|
|
|
|
|
error=true;
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[An error occurred while connecting to the database!]]></metadata>";
|
|
|
|
|
result=sendError(1,"An error occurred while connecting to the database!");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[An error occurred while connecting to the database!]]></metadata>";
|
|
|
|
|
result=sendError(1,"An error occurred while connecting to the database!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -205,7 +207,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[An set TYPE_SCROLL_SENSITIVE!]]></metadata>";
|
|
|
|
|
result=sendError(1,"An set TYPE_SCROLL_SENSITIVE!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -296,7 +297,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage() + " SQL=" + sql_query);
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
}finally {
|
|
|
|
|
@ -324,7 +324,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
}finally {
|
|
|
|
|
@ -352,7 +351,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
}finally {
|
|
|
|
|
@ -380,7 +378,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
}finally {
|
|
|
|
|
@ -395,7 +392,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
xml += "<metadata fn=\"0\"></metadata>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result=getText(conn,xml,user);
|
|
|
|
|
result=trts(conn,xml,user);
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
|
|
|
|
|
} else if (fn != null && fn.equals("1")) {
|
|
|
|
|
@ -500,7 +497,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
result=xmlstring;
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
//logger.info("xmlstring = " + xmlstring);
|
|
|
|
|
}
|
|
|
|
|
stt.close();
|
|
|
|
|
rs.close();
|
|
|
|
|
@ -508,7 +504,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
rs=null;
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -616,13 +611,11 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
result=xmlstring;
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
//logger.info("xmlstring = " + xmlstring);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stt.close();
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -708,13 +701,11 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
result=xmlstring;
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
//logger.info("xmlstring = " + xmlstring);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stt.close();
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -822,7 +813,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -967,8 +957,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result=json.toString();
|
|
|
|
|
//logger.info("json = " + json);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rs.close();
|
|
|
|
|
stmt.close();
|
|
|
|
|
rs=null;
|
|
|
|
|
@ -977,7 +966,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -1066,7 +1054,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
result=xmlstring;
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
//logger.info("xmlstring = " + xmlstring);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stt.close();
|
|
|
|
|
@ -1074,7 +1061,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
stt=null;
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -1203,7 +1189,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
result=xmlstring;
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
//logger.info("xmlstring = " + xmlstring);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stt.close();
|
|
|
|
|
@ -1211,7 +1196,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
stt=null;
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage()+"\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -1219,7 +1203,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Could not find the requested node!]]></metadata>";
|
|
|
|
|
result=sendError(1,"Could not find the requested node!");
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -1552,7 +1535,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
|
|
|
|
|
} else if (fn != null && fn.equals("8")) {
|
|
|
|
|
//Select information about the current user
|
|
|
|
|
//Select information about the current user for generated report
|
|
|
|
|
String uName = "<br>";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -1573,7 +1556,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
stt=null;
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -1721,7 +1703,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
expr = xpath.compile("objects-list/@d");
|
|
|
|
|
|
|
|
|
|
writer.write(" <table border=\"1\" cellspacing=\"0\">\n");
|
|
|
|
|
writer.write(" <caption><b>" + getText(conn,"" + expr.evaluate(nTypeS, XPathConstants.STRING),user) + "</b></caption>\n");
|
|
|
|
|
writer.write(" <caption><b>" + trts(conn,"" + expr.evaluate(nTypeS, XPathConstants.STRING),user) + "</b></caption>\n");
|
|
|
|
|
writer.write(" <thead>\n");
|
|
|
|
|
writer.write(" <tr>");
|
|
|
|
|
|
|
|
|
|
@ -1729,7 +1711,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
Object exprResult = expr.evaluate(nTypeS, XPathConstants.NODESET);
|
|
|
|
|
nodeList = (NodeList) exprResult;
|
|
|
|
|
for (int i = 0; i < nodeList.getLength(); i++) {
|
|
|
|
|
writer.write("<td bgcolor=\"#d1d1d1\" width=\"" + nodeList.item(i).getAttributes().getNamedItem("width").getNodeValue() + "px\"><b>" + getText(conn,nodeList.item(i).getAttributes().getNamedItem("d").getNodeValue(),user)
|
|
|
|
|
writer.write("<td bgcolor=\"#d1d1d1\" width=\"" + nodeList.item(i).getAttributes().getNamedItem("width").getNodeValue() + "px\"><b>" + trts(conn,nodeList.item(i).getAttributes().getNamedItem("d").getNodeValue(),user)
|
|
|
|
|
+ "</b></td>");
|
|
|
|
|
}
|
|
|
|
|
writer.write(" </tr>\n");
|
|
|
|
|
@ -1755,7 +1737,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage());
|
|
|
|
|
error=true;
|
|
|
|
|
} finally {
|
|
|
|
|
@ -1764,8 +1745,9 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Отправляем название файла на сервер
|
|
|
|
|
//Отправляем название файла клиенту
|
|
|
|
|
result="<metadata fn=\"8\"><file><![CDATA[" + tmpName + "]]></file></metadata>";
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_XML);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stt.close();
|
|
|
|
|
@ -1773,7 +1755,6 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
stt=null;
|
|
|
|
|
} catch (SQLException ex) {
|
|
|
|
|
logger.info(ex.getMessage());
|
|
|
|
|
//result="<metadata fn=\"-1\"><![CDATA[Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query + "]]></metadata>";
|
|
|
|
|
result=sendError(1,"Error: " + ex.getMessage() + "\n\nSQL query: " + sql_query);
|
|
|
|
|
error=true;
|
|
|
|
|
}
|
|
|
|
|
@ -2265,7 +2246,7 @@ public class DBMSRecords implements ServletContextAware {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Translate text by patterns
|
|
|
|
|
public String getText(Connection conn,String text,User user) {
|
|
|
|
|
public String trts(Connection conn,String text,User user) {
|
|
|
|
|
int pos1 = 0;
|
|
|
|
|
while (true) {
|
|
|
|
|
pos1 = text.indexOf("trt('", pos1);
|
|
|
|
|
|