List of usage examples for org.dom4j DocumentHelper parseText
public static Document parseText(String text) throws DocumentException
parseText
parses the given text as an XML document and returns the newly created Document.
From source file:cn.com.sunjiesh.wechat.service.AbstractWechatMessageReceiveService.java
/** * ??/*from w w w .ja v a 2 s . c om*/ * * @param message ? * @param queryParams querystring? * @return * @throws ServiceException ServiceException * @throws AesException AesException */ public String messageReceive(String message, Map<String, String> queryParams) throws ServiceException, AesException { try { // ??XML Document doc4j = DocumentHelper.parseText(message); Node encryptEle = doc4j.selectSingleNode("/xml/Encrypt"); if (encryptEle != null) { LOGGER.debug("???"); String token = WeChatProperties.getProperty(WeChatProperties.TOKEN); String encodingAesKey = WeChatProperties.getProperty(WeChatProperties.ENCODING_AES_KEY); String appId = WeChatProperties.getProperty(WeChatProperties.APPID); String timeStamp = queryParams.get("timestamp"); String nonce = queryParams.get("nonce"); String msgSignature = queryParams.get("msg_signature"); WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); String format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>"; String fromXML = String.format(format, encryptEle.getText()); String decryptStr = pc.decryptMsg(msgSignature, timeStamp, nonce, fromXML); LOGGER.debug("" + decryptStr); Document decryptDoc = DocumentHelper.parseText(decryptStr); Document resultDoc = messageReceive(decryptDoc); String resultStr = resultDoc.asXML(); String encryptResultStr = pc.encryptMsg(resultStr, timeStamp, nonce); return encryptResultStr; } Document resultDoc = messageReceive(doc4j); if (resultDoc == null) { //???Success return "success"; } return resultDoc.asXML(); } catch (DocumentException ex) { throw new ServiceException("?XML", ex); } }
From source file:cn.myloveqian.utils.XmlUtils.java
License:Open Source License
/** * is xml//w w w . jav a 2 s . c o m * * @param value * @return */ public static boolean isXml(String value) { try { DocumentHelper.parseText(value); } catch (DocumentException e) { return false; } return true; }
From source file:cn.myloveqian.utils.XmlUtils.java
License:Open Source License
/** * @param message// ww w. j a va 2s . c o m * @return * @throws DocumentException */ public static Document getDocument(String message) throws DocumentException { return DocumentHelper.parseText(message); }
From source file:com.adobe.ac.pmd.metrics.engine.AbstractMetrics.java
License:Apache License
public void execute(final File outputFile) throws DocumentException, IOException { final String builtReport = buildReport(loadMetrics()); final Document document = DocumentHelper.parseText(builtReport); final OutputFormat format = OutputFormat.createPrettyPrint(); if (!outputFile.exists()) { if (outputFile.createNewFile() == false) { LOGGER.warning("Could not create a new output file"); }/*from www. j av a 2 s.com*/ } final XMLWriter writer = new XMLWriter(new FileOutputStream(outputFile), format); writer.write(document); writer.close(); }
From source file:com.aesirteam.smep.adc.message.CorpBindReq.java
@SuppressWarnings("unchecked") public CorpBindReq(String msg) throws Exception { MsgRequest request = new MsgRequest(msg); //??//from w ww . j a v a 2 s.c om this.header = request.getHeader(); //?? String bodyText; if (null == (bodyText = request.getBody())) { throw new Exception("CorpBindReq??"); } try { Document document = DocumentHelper.parseText(bodyText); Element root = document.getRootElement(); this.corpName = root.element("CORPNAME").getTextTrim(); this.corpAccount = root.element("CORPACCOUNT").getTextTrim(); this.license = root.element("LICENSE").getTextTrim(); this.optype = root.element("OPTYPE").getTextTrim(); this.opnote = root.element("OPNOTE").getTextTrim(); //PARAMMAP paramMap = new HashMap<String, String>(); if (null != root.element("PARAMLIST").element("PARAMMAP")) { for (Iterator<Element> it = root.element("PARAMLIST").elementIterator("PARAMMAP"); it.hasNext();) { Element e = it.next(); String name = e.element("PARAMNAME").getTextTrim(); String value = e.element("PARAMVALUE").getTextTrim(); if (0 < name.length() && 0 < value.length()) paramMap.put(name, value); } } //CORPINFOMAP corpInfoMap = new HashMap<String, String>(); if (null != root.element("CORPINFOLIST").element("CORPINFOMAP")) { for (Iterator<Element> it = root.element("CORPINFOLIST").elementIterator("CORPINFOMAP"); it .hasNext();) { Element e = it.next(); String name = e.element("CORPINFONAME").getTextTrim(); String value = e.element("CORPINFOVALUE").getTextTrim(); if (0 < name.length() && 0 < value.length()) { corpInfoMap.put(name, value); if ("CORP_SHORTNAME".equals(name)) this.corpShortName = value; else if ("CORP_LINKMAN".equals(name)) this.corpLinkMan = value; else if ("CORP_LINKPHONE".equals(name)) this.corpLinkPhone = value; else if ("CORP_LINKMOBILE".equals(name)) this.corpLinkMobile = value; } } } //ORDERPOINTMAP orderPointMap = new HashMap<String, String>(); int count = 1; if (null != root.element("POINTLIST").element("ORDERPOINTMAP")) { for (Iterator<Element> it = root.element("POINTLIST").elementIterator("ORDERPOINTMAP"); it .hasNext();) { Element e = it.next(); String name = e.element("POINTNAME").getTextTrim(); String value = e.element("POINTVALUE").getTextTrim(); if (0 < name.length() && 0 < value.length()) { orderPointMap.put(name, value); this.point = (count == 1) ? name : String.format("%s,%s", point, name); count++; } } } } catch (Exception ex) { throw new Exception(ex.getMessage()); } }
From source file:com.ai.tools.generator.util.XMLFormatter.java
License:Open Source License
public static String toString(String xml, String indent) throws DocumentException, IOException { SAXReader reader = new SAXReader(); Document doc = DocumentHelper.parseText(xml); // Document doc = reader.read(new StringReader(xml)); return toString(doc, indent); }
From source file:com.aisino2.icksystem.action.KongJianDiaoYongAction.java
public void kongJianDiaoYong() { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); try {//from w w w. j av a 2s .c o m if (isUserStr(type) && "verifycardid".equals(type)) { // ??? // --- if (isUserStr(cardid)) { // modify on 2010-08-13 by mds begin //cardid = cardid.replace("-", ""); // ?? - ? // modify on 2010-08-13 by mds end Icksl icksl = new Icksl(); icksl.setIckh(cardid); String isDxr = ickslService.sfDxr(icksl); if (isUserStr(isDxr)) { renderText(response, isDxr); } } else { renderText(response, "FALSE"); // } renderText(response, ""); } // ???? - OK if (isUserStr(type) && "islogout".equals(type)) { if (isUserStr(cardid)) { // modify on 2010-08-13 by mds begin //cardid = cardid.replace("-", ""); // ?? - ? // modify on 2010-08-13 by mds end Icksl icksl = new Icksl(); icksl.setIckh(cardid); icksl = ickslService.getIcksl(icksl); // ?? ?? if ("7".equals(icksl.getZkztbs()) || "8".equals(icksl.getZkztbs()) || "9".equals(icksl.getZkztbs())) { renderText(response, "TRUE"); } } else { renderText(response, ""); // 09.06.09 ?? ? } renderText(response, ""); } // ?? - OK if (isUserStr(type) && "offlineversion".equals(type)) { Globalpar globalpar = new Globalpar(); Globalpar temp = null; // globalpar.setGlobalparcode("offline-bbhtest"); // globalpar.setGlobalparcode("offline-bbh"); List globList = CacheManager.getCacheGlobalpar(globalpar); if (globList != null && globList.size() > 0) { temp = (Globalpar) globList.get(0); } String OfflineVersion = temp.getGlobalparvalue().trim().replaceAll(",", "").substring(0, 4); renderText(response, OfflineVersion); } // prjwebcontrol.ocx - OK if (isUserStr(type) && "prjwebcontrol".equals(type)) { // String httpHead = request.getScheme() + "://" // + request.getServerName() + ":" // + request.getServerPort() + request.getContextPath() // + "/"; // String prjWebControlPatch = httpHead // + "active/prjWebControl.ocx"; String activePatch = "";// active? activePatch = QjblUtil.queryQjblVal("active-url"); String prjWebControlPatch = activePatch + "prjWebControl.ocx"; String exeDataString = ""; try { URL fileurl = new URL(prjWebControlPatch); exeDataString = fileToBase64(fileurl); } catch (Exception e) { e.printStackTrace(); } if (exeDataString == null) { exeDataString = ""; } renderText(response, exeDataString); } // - OK if (isUserStr(type) && "offline".equals(type)) { // String httpHead = request.getScheme() + "://" // + request.getServerName() + ":" // + request.getServerPort() + request.getContextPath() // + "/"; // String offlineExePatch = httpHead + "active/offline.exe"; String activePatch = "";// active? activePatch = QjblUtil.queryQjblVal("active-url"); String offlineExePatch = activePatch + "offline.exe"; String exeDataString = ""; try { URL fileurl = new URL(offlineExePatch); exeDataString = fileToBase64(fileurl); } catch (Exception e) { e.printStackTrace(); } if (exeDataString == null) { exeDataString = ""; } renderText(response, exeDataString); } // prjupdate.exe - OK if (isUserStr(type) && "prjupdate".equals(type)) { // String httpHead = request.getScheme() + "://" // + request.getServerName() + ":" // + request.getServerPort() + request.getContextPath() // + "/"; // String offlineExePatch = httpHead + "active/prjupdate.exe"; String activePatch = "";// active? activePatch = QjblUtil.queryQjblVal("active-url"); String prjupdateExePatch = activePatch + "prjupdate.exe"; String exeDataString = ""; try { URL fileurl = new URL(prjupdateExePatch); exeDataString = fileToBase64(fileurl); } catch (Exception e) { e.printStackTrace(); } if (exeDataString == null) { exeDataString = ""; } renderText(response, exeDataString); } // ?? - ?? ?? - OK if (isUserStr(type) && "upload".equals(type)) { //? Icksl icksl = null; Date sksjDates = null; String yjFlag = ""; // 0 1 2?? 3 ? String yjyy = ""; // String dwlb = ""; //?? ? String dwlbdm = ""; //??? ? Dict_item dict_item = new Dict_item(); dict_item.setDict_code("dm_ickyjyy"); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); if (isUserStr(value)) { value = value.replace('_', '+'); value = value.replace('$', '='); value = getFromBASE64(value); String[] valueArray = value.split("%"); String skzdzc = QjblUtil.queryQjblVal("skzdzc");//? 0-? 1- for (int index = 0; index < valueArray.length; index++) { yjFlag = "";// ? yjyy = "";// ? icksl = null;// ? sksjDates = null;// ? String dantiaoString = valueArray[index]; dantiaoString = dantiaoString.replace("$", "%"); String[] dantiaoArray = dantiaoString.split("%"); // String eg = // "CHN$??$J024103030004000253$$$$$$20090615155236$2048070716$?$J023200000003$"; // String eg = // "CHN$$J014103020003090001$310106197709090823$2$$$20090619134629$690744610$$J044101050005$"; String qybm = String.valueOf(dantiaoArray[11]); //qybm=qybm.substring(1, 12); Qyjbxx qyjbxx = new Qyjbxx(); if (qybm.startsWith("N")) { qyjbxx.setQybm(qybm.substring(1, 12)); } else { qyjbxx.setQybm(qybm); } qyjbxx = qyjbxxService.getQyjbxx(qyjbxx); Date sxsj = null;// ? ,? Integer ryid = null; // ,? String kh = null; String sksj = String.valueOf(dantiaoArray[8]); sksj = sksj.substring(0, 4) + "-" + sksj.substring(4, 6) + "-" + sksj.substring(6, 8) + " " + sksj.substring(8, 10) + ":" + sksj.substring(10, 12) + ":" + sksj.substring(12, 14); sksjDates = stringToDate(sksj, "yyyy-MM-dd HH:mm:ss"); String ickh = String.valueOf(dantiaoArray[9]); String cyrybh = dantiaoArray[2]; String zjhm = dantiaoArray[3]; int qyryid = 0; //?? 20100903?? if (skzdzc == null || "".equals(skzdzc) || "1".equals(skzdzc)) { if (qyjbxx != null) { int qyid = qyjbxx.getQyid(); Qyryxx qyryxx = new Qyryxx(); //?14????????? 20110131 mds if (StringUtil.isNotEmpty(cyrybh) && cyrybh.length() == 14) qyryxx.setZjhm(zjhm); else qyryxx.setCyrybh(cyrybh); qyryxx = qyryxxService.getQyryxx(qyryxx); if (qyryxx != null) { qyryid = qyryxx.getRyid(); int qyrrxxQyid = qyryxx.getQyid(); dwlb = qyryxx.getCylb(); dwlbdm = qyryxx.getCylbdm(); //? if (Integer.parseInt(qyryxx.getZt()) < 90 && qyrrxxQyid != qyid) { qyryxx.setQyid(qyid); Date rzrq = modifyCyryRzrq(qyryxx, sksjDates); qyryxx.setRzrq(rzrq); qyryxx.setCyryzt(""); qyryxx.setCyryztdm("11"); qyryxx.setKh(ickh); ickslService.updateIckslByryzc(qyryxx);//t_icksl } else if (Integer.parseInt(qyryxx.getZt()) < 90 && qyrrxxQyid == qyid) { if (qyryxx.getRzrq() == null) { Date rzrq = modifyCyryRzrq(qyryxx, sksjDates); qyryxx.setRzrq(rzrq); qyryxx.setCzlx(""); qyryxx.setCzr(qyryxx.getQybm()); qyryxxService.updateQyryxxOnly(qyryxx); } } } } } else { if (qyjbxx != null) { int qyid = qyjbxx.getQyid(); Qyryxx qyryxx = new Qyryxx(); //?14????????? 20110131 mds if (StringUtil.isNotEmpty(cyrybh) && cyrybh.length() == 14) qyryxx.setZjhm(zjhm); else qyryxx.setCyrybh(cyrybh); qyryxx = qyryxxService.getQyryxx(qyryxx); if (qyryxx != null) { qyryid = qyryxx.getRyid(); int qyrrxxQyid = qyryxx.getQyid(); dwlb = qyryxx.getCylb(); dwlbdm = qyryxx.getCylbdm(); if (Integer.parseInt(qyryxx.getZt()) < 90 && qyryxx.getRzrq() == null) { Date rzrq = modifyCyryRzrq(qyryxx, sksjDates); qyryxx.setRzrq(rzrq); qyryxx.setCzlx(""); qyryxx.setCzr(qyryxx.getQybm()); qyryxxService.updateQyryxxOnly(qyryxx); } } } } // ????14??,?ICKH? --modify at 20100610 /* 20100817????????????IC?????? if (cyrybh != null && cyrybh.length() == 14) { // service?ickh?? icksl = new Icksl(); icksl.setIckh(ickh); icksl = ickslService.getIckslCyrybh(icksl); if (icksl != null) { cyrybh = icksl.getCyrybh(); kh = icksl.getKh(); icksllsh = icksl.getIckslid(); } }*/ /** * ?20100817?IC??????? * ?? ---start--- */ int icksllsh = 0; // service?ickh?? icksl = new Icksl(); icksl.setIckh(ickh); icksl = ickslService.getIckslCyrybh(icksl); if (icksl != null) { cyrybh = icksl.getCyrybh(); kh = icksl.getKh(); icksllsh = icksl.getIckslid(); } /** * IC????????? * 2010-08-16 mds */ else { Icksl ickslTemp = new Icksl(); ickslTemp.setIckh(ickh); ickslService.updateIckslIckh(ickslTemp); } /** * ?20100817?IC??????? * ?? ---end--- */ if (dantiaoArray.length > 12) { kh = dantiaoArray[12]; } // String jczt =dantiaoArray[dantiaoArray.length]; if (qyjbxx != null) { int qyid = qyjbxx.getQyid(); Qyryskjl qyryskjl = new Qyryskjl(); qyryskjl.setQyid(qyid); qyryskjl.setIckh(ickh); // ?? - ? , qyryskjl.setSksj(sksjDates); qyryskjl.setScsj(new Date()); qyryskjl.setCyrybh(cyrybh); if (dantiaoArray.length > 12) { qyryskjl.setKh(dantiaoArray[12]); } // 102025start qyryskjl.setQybm(qyjbxx.getQybm()); qyryskjl.setHylb(qyjbxx.getHylb()); qyryskjl.setHylbdm(qyjbxx.getHylbdm()); // end // --modify on 20100610 if (icksl != null) { qyryskjl.setKh(kh); qyryskjl.setIcksllsh(icksllsh); } // --modify on 20100610 if ("N".equals(qyjbxx.getHylbdm())) { qyryskjl.setJczt(dantiaoArray[dantiaoArray.length - 1]); qyryskjl.setDwlb(dwlb); qyryskjl.setDwlbdm(dwlbdm); qyryskjl = qyryskjlService.insertQyryskjl(qyryskjl); Qyskfbxx qyskfbxx = new Qyskfbxx(); qyryskjl.setRyid(qyryid); qyryskjl.setGxdwbm(qyjbxx.getGxdwbm()); qyryskjl.setGxdwmc(qyjbxx.getGxdwmc()); qyryskjl.setQymc(qyjbxx.getQymc()); qyskfbxx.insertqyskfb(qyryskjl); } else { qyryskjl = qyryskjlService.insertQyryskjl(qyryskjl); } // ?? Integer ickslid = null; String ickslslh = null;// ?? Icksl ickslOne = new Icksl(); // modify on 2010-08-13 by mds begin //ickslOne.setIckh(String.valueOf(dantiaoArray[9]).replace("-", "")); ickslOne.setIckh(String.valueOf(dantiaoArray[9])); // modify on 2010-08-13 by mds end List list = ickslService.getListIcksl(ickslOne); if (list == null || list.size() == 0) { yjFlag = "2";// ? ?? //?? } else { icksl = new Icksl(); // modify on 2010-08-13 by mds begin //icksl.setIckh(String.valueOf(dantiaoArray[9]).replace("-", "")); // ?? - ? icksl.setIckh(String.valueOf(dantiaoArray[9])); // modify on 2010-08-13 by mds end icksl.setCyrybh(dantiaoArray[2]); icksl = ickslService.getIckslyj(icksl); if (icksl == null) { yjFlag = "2"; } // ? ?? //?? else { ickslid = icksl.getIckslid(); // sxsj = icksl.getIckzxsj(); // ickslh = icksl.getIckslh(); ryid = icksl.getRyid(); Qyryxx qyryxx = new Qyryxx(); qyryxx.setRyid(ryid); qyryxx.setScbz(0); qyryxx = qyryxxService.getQyryxx(qyryxx); if (kh == null) { kh = icksl.getKh(); } if ("7".equals(icksl.getZkztbs()) || "8".equals(icksl.getZkztbs()) || "9".equals(icksl.getZkztbs())) { if ("9".equals(icksl.getZkztbs())) { yjFlag = "3"; // ? sxsj = icksl.getYxqhzrq(); } else { yjFlag = "0"; // ? sxsj = icksl.getIckzxsj(); } } else if (!"7".equals(icksl.getZkztbs()) && !"8".equals(icksl.getZkztbs()) && !"9".equals(icksl.getZkztbs())) { String sksjtemp = sksj.substring(0, 10); Date sksjDate = stringToDate(sksjtemp, "yyyy-MM-dd"); if (sksjDate.compareTo(icksl.getYxqhzrq()) >= 0) { yjFlag = "1"; // ? sxsj = icksl.getYxqhzrq(); } } else if ("1".endsWith(qyryxx.getYjbz())) { yjFlag = "4"; // ?? sxsj = qyryxx.getYjsj(); } // ???icksl??qyryskjl if (qyryskjl.getKh() == null) { qyryskjl.setKh(kh); } qyryskjl.setIcksllsh(ickslid); qyryskjlService.updateQyryskjl(qyryskjl); } } } else { yjFlag = "2"; // ? //?? } if (!"".equals(yjFlag)) { // ? Ickyj tempIckyj = new Ickyj(); // Qyryxx cyryxx = new Qyryxx(); Wgcyryxx wgcyryxx = new Wgcyryxx(); if (icksl != null) { cyryxx.setRyid(icksl.getRyid()); cyryxx = qyryxxService.getQyryxx(cyryxx); tempIckyj.setIckh(icksl.getIckh()); } if ("2".equals(yjFlag)) { // ?? cyryxx.setCyrybh(dantiaoArray[2]); cyryxx = qyryxxService.getQyryxx(cyryxx); tempIckyj.setCyrybh(dantiaoArray[2]); // modify on 2010-08-13 by mds begin //tempIckyj.setIckh(String.valueOf(dantiaoArray[9]).replace("-", "")); // ??- ? tempIckyj.setIckh(String.valueOf(dantiaoArray[9])); // modify on 2010-08-13 by mds end } if (cyryxx != null) { tempIckyj.setXmpy(cyryxx.getXm()); tempIckyj.setXb(cyryxx.getXb()); tempIckyj.setCyzj(cyryxx.getCyzj()); tempIckyj.setZjhm(cyryxx.getZjhm()); tempIckyj.setCylb(cyryxx.getCylb()); tempIckyj.setCylbdm(cyryxx.getCylbdm()); tempIckyj.setXmpy(cyryxx.getXmpy()); tempIckyj.setCyrybh(cyryxx.getCyrybh()); tempIckyj.setXm(cyryxx.getXm()); tempIckyj.setCyzjdm(cyryxx.getCyzjdm()); ryid = cyryxx.getRyid(); wgcyryxx.setRyid(cyryxx.getRyid()); wgcyryxx = wgcyryxxService.getWgcyryxx(wgcyryxx); if (wgcyryxx != null) { tempIckyj.setYwm(wgcyryxx.getYwm()); tempIckyj.setYwx(wgcyryxx.getYwx()); tempIckyj.setWgrjyxkz(wgcyryxx.getWgrjyxkz()); } } qybm = "?"; String qymc = "?"; String gxdwdm = "?"; String gxdwmc = "?"; String dsjgdm = "?"; String fxjdm = "?"; String dsjgmc = "?"; String fxjmc = "?"; if (qyjbxx != null) { qybm = qyjbxx.getQybm(); qymc = qyjbxx.getQymc(); gxdwdm = qyjbxx.getGxdwbm(); gxdwmc = qyjbxx.getGxdwmc(); String qybmTemp = qybm.substring(3, qybm.length()); dsjgdm = qybmTemp.substring(0, 4) + "00000000"; fxjdm = qybmTemp.substring(0, 6) + "000000"; dsjgmc = ""; fxjmc = ""; // ? ? >>> ??? = N; // N?4?+80=??N?6?+60=?(6.19?) Department userDepartment = new Department(); userDepartment.setDepartcode(dsjgdm); // userDepartment = departmentService.getDepartment(userDepartment); dsjgmc = (userDepartment != null) ? userDepartment.getDepartname() : "?"; userDepartment = new Department(); userDepartment.setDepartcode(fxjdm); // userDepartment = departmentService.getDepartment(userDepartment); fxjmc = (userDepartment != null) ? userDepartment.getDepartname() : "?"; tempIckyj.setQyid(qyjbxx.getQyid()); } // ??? tempIckyj.setQybm(qybm); tempIckyj.setQymc(qymc); tempIckyj.setGxdwdm(gxdwdm); tempIckyj.setGxdwmc(gxdwmc); tempIckyj.setDsjgdm(dsjgdm); tempIckyj.setDsjgmc(dsjgmc); tempIckyj.setFxjdm(fxjdm); tempIckyj.setFxjmc(fxjmc); if (!"".equals(yjFlag)) { // dict_item.setFact_value(yjFlag); List list = CacheManager.getCacheDictitem(dict_item); if (list != null && list.size() > 0) { yjyy = ((Dict_item) list.get(0)).getDisplay_name(); } } tempIckyj.setSksj(sksjDates); tempIckyj.setYjyy(yjyy); tempIckyj.setSxsj(sxsj); tempIckyj.setRyid(ryid); tempIckyj.setKh(kh); ickyjService.insertIckyj(tempIckyj); tempIckyj = null; } } } renderText(response, "OK"); } // - OK if (isUserStr(type) && "reg".equals(type)) { Qyjbxx qyjbxx = new Qyjbxx(); qyjbxx.setQybm(id); qyjbxx = qyjbxxService.getQyjbxx(qyjbxx); if (qyjbxx != null) { int qyid = qyjbxx.getQyid(); Qyryxx qyryxx = new Qyryxx(); Icksl icksl = new Icksl(); //?14????????? 20110131 mds if (StringUtil.isNotEmpty(cyrybh) && cyrybh.length() == 14) qyryxx.setZjhm(gmsfhm); else qyryxx.setCyrybh(cyrybh); try { qyryxx = qyryxxService.getQyryxx(qyryxx); icksl.setRyid(qyryxx.getRyid()); icksl.setIckh(cardid); icksl.setZxbz("0"); icksl = ickslService.getIckslyj(icksl); if (icksl != null) { if (qyryxx != null) { int qyrrxxQyid = qyryxx.getQyid(); // ??? 20100914 if (90 > Integer.parseInt(qyryxx.getZt())) { if (qyrrxxQyid == qyid) { renderText(response, ""); } else { qyryxx.setQyid(qyid); qyryxx.setRzrq(new Date()); ickslService.updateIckslByryzc(qyryxx);// t_icksl, renderText(response, "?"); } } else { renderText(response, "???"); } } else { renderText(response, "?"); } } else { renderText(response, "????"); } } catch (Exception e) { renderText(response, "??"); } } else { renderText(response, "?"); } } // ? - ? - OK if (isUserStr(type) && "message".equals(type)) { Map map = new HashMap(); map.put("jsdwbm", id); // ? - jsdwbm map.put("csck", "0"); // / map.put("gqbs", "0"); Page page = xctbService.getcsListForPage(map, 1, 10, null, null); if (page.getData().size() > 0) { renderText(response, "TRUE"); } else { renderText(response, "FALSE"); } } // IC? 20?? - OK if (isUserStr(type) && "history".equals(type)) { String skkssj1 = RespDateByDay(-20); Date sksjf = stringToDate(skkssj1, "yyyy-MM-dd"); Date sksjt = new Date(); Qyjbxx qyjbxx = new Qyjbxx(); qyjbxx.setQybm(id); qyjbxx = qyjbxxService.getQyjbxx(qyjbxx); if (qyjbxx == null) { renderText(response, "<CSMC></CSMC>", 1); } else { /** ****************modify on 20100721********************* */ /* * int csid = qyjbxx.getQyid(); Map map = new HashMap(); * map.put("qybm", id); map.put("cyrybh", cyrybh); * map.put("sksjf", sksjf); map.put("sksjt", sksjt); Page * page = qyryskjlService.getListForPage(map, 1, 10, null, * null); int total = page.getTotalRows(); page = * qyryskjlService .getListForPage(map, 1, total, null, * null); List list = page.getData(); */ Qyryskjl setQyryskjl = new Qyryskjl(); setQyryskjl.setQybm(id); setQyryskjl.setCyrybh(cyrybh); setQyryskjl.setSksjf(sksjf); setQyryskjl.setSksjt(sksjt); List list = qyryskjlService.getListQyryskjl(setQyryskjl); /** ****************modify on 20100721********************* */ String fanhuiString = "<CSMC></CSMC>"; if (list != null && list.size() > 0) { fanhuiString = "<CSMC>" + qyjbxx.getQymc() + "</CSMC>"; for (int index = 0; index < list.size(); index++) { Qyryskjl qyryskjl = (Qyryskjl) list.get(index); fanhuiString += "<RECORD>" + dateToString(qyryskjl.getSksj(), "yyyy-MM-dd HH:mm:ss") + kongGe(6) + qyryskjl.getCyrybh() + kongGe(6) + qyryskjl.getXm() + "</RECORD>"; } } renderText(response, fanhuiString, 1); } } // ? - OK if (isUserStr(type) && "connect".equals(type)) { renderText(response, "OK"); } // ?? -OK if (isUserStr(type) && "date".equals(type)) { try { String fanhuiString = dateToString(new Date(), "yyyyMMddHHmmss"); Globalpar globalpar = new Globalpar(); Globalpar temp = null; // globalpar.setGlobalparcode("offline-bbhtest"); // globalpar.setGlobalparcode("offline-bbh"); // List globList = CacheManager.getCacheGlobalpar(globalpar); if (globList != null && globList.size() > 0) { temp = (Globalpar) globList.get(0); } fanhuiString += "$" + temp.getGlobalparvalue().replaceAll(",", ""); // globalpar.setGlobalparcode("prjweb-bbhtest"); globalpar.setGlobalparcode("prjweb-bbh"); globList = CacheManager.getCacheGlobalpar(globalpar); if (globList != null && globList.size() > 0) { temp = (Globalpar) globList.get(0); } fanhuiString += "$" + temp.getGlobalparvalue().replaceAll(",", ""); globalpar.setGlobalparcode("gsweb-bbh"); globList = CacheManager.getCacheGlobalpar(globalpar); if (globList != null && globList.size() > 0) { temp = (Globalpar) globList.get(0); } fanhuiString += "$" + temp.getGlobalparvalue().replaceAll(",", ""); renderText(response, fanhuiString); } catch (Exception e) { e.printStackTrace(); response.getWriter().write(""); } } // 13 - login 14 - login2 - OK if ((isUserStr(type) && "login".equals(type)) || (isUserStr(type) && "login2".equals(type))) { String userType = ""; if ("login".equals(type)) { userType = "13"; } if ("login2".equals(type)) { userType = "14"; } User user = new User(); user.setUseraccount(id); user = userService.checkUser(user); if (user != null) { String password = user.getPassword(); String type = user.getUsertype(); if (password.equals(EncryptUtil.getMD5Code(pwd))) { // ? if (type.contains(userType)) { // ? if ("13".equals(type)) { String qykfkg = QjblUtil.queryQjblVal("qykf-kg"); if ("1".equals(qykfkg)) { // ? try { String content = wsdlResult(user.getUseraccount()); Document doc = DocumentHelper.parseText(content); Element root = doc.getRootElement(); String isright = root.element("ISVERIFY").getText(); if ("1".equals(isright)) { renderText(response, "OK"); } else { renderText(response, "ERROR??"); } } catch (Exception e) { e.printStackTrace(); renderText(response, "ERROR???"); } } else { renderText(response, "OK"); } } else { renderText(response, "OK"); } } else { // ?? renderText(response, "NOTOK"); } } else { renderText(response, "FALSE"); } } else { renderText(response, "FALSE"); } } // 2009-12-11 add // type=verify&id=&devicetype= // <OUTPUT>TRUE</OUTPUT><OUTPUT></OUTPUT> // ????<OUTPUT>TRUE???</OUTPUT> // ???????? if (isUserStr(type) && "verify".equals(type)) { User user = new User(); user.setUseraccount(id); try { user = userService.checkUser(user); } catch (Exception e) { e.printStackTrace(); renderText(response, ""); } if (user != null) { String qykfkg = QjblUtil.queryQjblVal("qykf-kg"); String sksblx = QjblUtil.queryQjblVal("deviceType");// ? if (!sksblx.equals(devicetype)) { renderText(response, "?"); } else { if ("1".equals(qykfkg)) { // ? try { String content = wsdlResult(user.getUseraccount()); Document doc = DocumentHelper.parseText(content); Element root = doc.getRootElement(); String isright = root.element("ISVERIFY").getText(); String endDate = root.element("ENDDATE").getText(); if ("1".equals(isright)) { int difday = difDay(endDate); if (difday < 31) { renderText(response, "TRUE???"); } else { renderText(response, "TRUE"); } } else { renderText(response, "??"); } } catch (Exception e) { e.printStackTrace(); renderText(response, "???"); } } else { renderText(response, "TRUE"); } } } else { renderText(response, "???"); } } // ??- OK if (isUserStr(type) && "coding".equals(type)) { StringBuffer condingString = new StringBuffer("<output>"); Dict dict = new Dict(); dict.setKongjianDicts("'dm_mz','dm_gj(lgy)','dm_xzqh'"); List list = dictService.getListDict(dict); if (list != null && list.size() > 0) { for (int index = 0; index < list.size(); index++) { dict = (Dict) list.get(index); // 15342003,???,DICTIONARY,DI_SN,DI_CVALUE,DI_SELNO,DI_MNEMONIC,DI_PROMPT,DI_DFID=1330,,,,WLGLZT,,1 condingString.append(nullCheck(String.valueOf(dict.getDict_id())) + "," + nullCheck(dict.getDict_name()) + "," + nullCheck(dict.getDict_itemtablename()) + "," + "DI_SN" + "," + "DI_CVALUE" + "," + "DI_SELNO" + "," + "DI_MNEMONIC" + "," + "DI_PROMPT" + "," + "DI_DFID=" + dict.getDict_id() + "," + "" + "," + "" + "," + "" + "," + nullCheck(dict.getDict_simplepin()) + "," + "" + "," + nullCheck(dict.getDict_versionid() + "\r\n")); } } condingString.append("</output>"); renderText(response, condingString.toString(), 1); } // ????- OK if (isUserStr(type) && "dict".equals(type)) { Dict dict = new Dict(); dict.setDict_id(Integer.parseInt(coid)); List list = dict_itemService.getOfflineDict_item(dict); StringBuffer returnString = new StringBuffer("<output>"); if (list != null && list.size() > 0) { for (int index = 0; index < list.size(); index++) { Dict_item dict_item = (Dict_item) list.get(index); returnString.append(nullCheck(String.valueOf(dict_item.getItem_id())) + "," + nullCheck(dict_item.getDisplay_name()) + "," + nullCheck(dict_item.getItem_simplepin()) + "," + nullCheck(dict_item.getFact_value()) + "," + coid + "\r\n"); } } returnString.append("</output>"); renderText(response, returnString.toString(), 1); } // ??config?? if (isUserStr(type) && "password".equals(type)) { String password = QjblUtil.queryQjblVal("offline-config-password"); renderText(response, password); } // ?offline?(0??1??) if (isUserStr(type) && "logintype".equals(type)) { String logintype = QjblUtil.queryQjblVal("login-type"); renderText(response, logintype); } //?? if (isUserStr(type) && "policecardlogin".equals(type) || "culturecardlogin".equals(type)) { Map map = new HashMap(); map.put("tableName", "t_mjjczsl"); map.put("zkztbs", "5"); map.put("mjjczbh", jcz); map.put("xgbz", "0"); boolean jczexit = systemService.isExit(map); if (jczexit) { String deptJcz = StringUtil.trimEven0(gajg); Qyjbxx qyjbxx = new Qyjbxx(); qyjbxx.setQybm(id); qyjbxx = qyjbxxService.getQyjbxx(qyjbxx); String deptQyxx = qyjbxx.getGxdwbm(); String mjjcqxms = QjblUtil.queryQjblVal("mjjcqxms"); String kzxljcqk = QjblUtil.queryQjblVal("kzxljcqk"); if (mjjcqxms.equals("2")) { if (deptQyxx.indexOf(deptJcz) == 0) { if ("0".equals(url)) { renderText(response, "OK"); } else { if ("1".equals(kzxljcqk)) { renderText(response, "URL=basic/jfglsystem/JcqkAdd-offline.jsp"); } else { renderText(response, "URL=basic/mjjczsystem/RcjcMjjczSk.jsp"); } } } else { renderText(response, "???"); } } else { if ("0".equals(url)) { renderText(response, "OK"); } else { if ("1".equals(kzxljcqk)) { renderText(response, "URL=basic/jfglsystem/JcqkAdd-offline.jsp"); } else { renderText(response, "URL=basic/mjjczsystem/RcjcMjjczSk.jsp"); } } } } else { if ("policecardlogin".equals(type)) { renderText(response, "??"); } else { renderText(response, "??"); } } } //???? if (isUserStr(type) && "unioncardlogin".equals(type)) { Map map = new HashMap(); map.put("tableName", "t_mjjczsl"); map.put("zkztbs", "5"); map.put("mjjczbh", jcz); map.put("xgbz", "0"); boolean jczexit = systemService.isExit(map); if (jczexit) { String deptJcz = StringUtil.trimEven0(gajg); Qyjbxx qyjbxx = new Qyjbxx(); qyjbxx.setQybm(id); qyjbxx = qyjbxxService.getQyjbxx(qyjbxx); String deptQyxx = qyjbxx.getGxdwbm(); String mjjcqxms = QjblUtil.queryQjblVal("mjjcqxms"); String kzxljcqk = QjblUtil.queryQjblVal("kzxljcqk"); if (mjjcqxms.equals("2")) { if (deptQyxx.indexOf(deptJcz) == 0) { if ("1".equals(url)) { renderText(response, "UNION=basic/jfglsystem/JcqkUnionAdd-offline.jsp"); } else { renderText(response, "OK"); } } else { renderText(response, "???"); } } else { if ("1".equals(url)) { renderText(response, "UNION=basic/jfglsystem/JcqkUnionAdd-offline.jsp"); } else { renderText(response, "OK"); } } } else { renderText(response, "??"); } } //?offline?connect?config??offline? if (isUserStr(type) && "para".equals(type)) { //?connect? String timeControl = QjblUtil.queryQjblVal("offline-config-timeControl"); //?config?? String password = QjblUtil.queryQjblVal("offline-config-password"); //?offline? String logintype = QjblUtil.queryQjblVal("login-type"); StringBuffer returnString = new StringBuffer("<OUTPUT>"); returnString.append(timeControl); returnString.append("$"); returnString.append(password); returnString.append("$"); returnString.append(logintype); returnString.append("</OUTPUT>"); renderText(response, returnString.toString(), 1); } } catch (Exception e) { e.printStackTrace(); renderText(response, "??"); } }
From source file:com.aisino2.sysadmin.action.LoginAction.java
/** * ? ?/*from w w w . ja va 2 s . c om*/ * @param logUser * @return */ public boolean kefuValidater(User logUser, HttpSession session) { boolean res = true; String userType = logUser.getUsertype(); String qykfkg = QjblUtil.queryQjblVal("qykf-kg"); Map mapUse = queryKfsqUserType("qysqUserType"); //??UserType Map mapTg = queryKfsqUserType("qysqTiaoGuoUserType"); //?UserType if ("1".equals(qykfkg) && !isContentsUserType(mapTg, userType) && isContentsUserType(mapUse, userType)) { //? try { String content = wsdlResult(queryQybm(logUser).getSsdwbm()); Document doc = DocumentHelper.parseText(content); Element root = doc.getRootElement(); String isright = root.element("ISVERIFY").getText(); String endDate = root.element("ENDDATE").getText(); if ("1".equals(isright)) { long difday = difDay(endDate); if (difday < 31) { session.setAttribute("shouquanEndDate", "?:" + endDate + " " + QjblUtil.queryQjblVal("qykf-xxtxbc")); } } else { result = "?"; res = false; } } catch (Exception e) { e.printStackTrace(); result = "??"; res = false; } } return res; }
From source file:com.alibaba.intl.bcds.goldroom.remote.DoubanBookInfoFetcher.java
License:Open Source License
private BookInfo parserBookInfo(String xml) { if (logger.isDebugEnabled()) { logger.debug("the bookinfo xml is \n" + xml + "\n"); }/*w w w .jav a 2s.com*/ logger.debug(xml); BookInfo info = new BookInfo(); try { Document document = DocumentHelper.parseText(xml); info.setAuthor(queryByXpath("/entry/s:author/s:name", document)); String desc = queryByXpath("/entry/s:summary", document); if (desc != null) { desc = desc.replaceAll("\n", "<br/>"); } info.setDescription(desc); info.setName(queryByXpath("/entry/s:title", document)); info.setIsbn10(queryByXpath("/entry/db:attribute[@name='isbn10']", document)); info.setIsbn13(queryByXpath("/entry/db:attribute[@name='isbn13']", document)); info.setIsbn(info.getIsbn13()); info.setPages(NumberUtils.toInt(queryByXpath("/entry/db:attribute[@name='pages']", document))); info.setPublisher(queryByXpath("/entry/db:attribute[@name='publisher']", document)); info.setTranslator(queryByXpath("/entry/db:attribute[@name='translator']", document)); info.setPublishTime( dateConverter.conver(queryByXpath("/entry/db:attribute[@name='pubdate']", document))); info.setTags(formatTag(queryByXpathForList("/entry/db:tag", "@name", document))); String imageUrl = createXpath("/entry/s:link[@rel='image']").selectSingleNode(document) .valueOf("@href"); info.setImgUrl(saveImage(info.getIsbn(), imageUrl)); return info; } catch (DocumentException e) { logger.error("parse bookinfo from xml{" + xml + "} error", e); } return null; }
From source file:com.alibaba.intl.goldroom.remote.DoubanBookInfoFetcher.java
License:Open Source License
private BookInfo parserBookInfo(String xml) { if (logger.isDebugEnabled()) { logger.debug("the bookinfo xml is \n" + xml + "\n"); }/*from ww w.j a v a 2 s. com*/ logger.debug(xml); BookInfo info = new BookInfo(); try { Document document = DocumentHelper.parseText(xml); info.setAuthor(queryByXpath("/entry/s:author/s:name", document)); info.setDescription(queryByXpath("/entry/s:summary", document)); info.setName(queryByXpath("/entry/s:title", document)); info.setIsbn10(queryByXpath("/entry/db:attribute[@name='isbn10']", document)); info.setIsbn13(queryByXpath("/entry/db:attribute[@name='isbn13']", document)); info.setIsbn(info.getIsbn13()); info.setPages(NumberUtils.toInt(queryByXpath("/entry/db:attribute[@name='pages']", document))); info.setPublisher(queryByXpath("/entry/db:attribute[@name='publisher']", document)); info.setTranslator(queryByXpath("/entry/db:attribute[@name='translator']", document)); info.setPublishTime( dateConverter.conver(queryByXpath("/entry/db:attribute[@name='pubdate']", document))); String imageUrl = createXpath("/entry/s:link[@rel='image']").selectSingleNode(document) .valueOf("@href"); info.setImgUrl(saveImage(info.getIsbn(), imageUrl)); return info; } catch (DocumentException e) { logger.error("parse bookinfo from xml{" + xml + "} error", e); } return null; }