Example usage for org.dom4j DocumentHelper parseText

List of usage examples for org.dom4j DocumentHelper parseText

Introduction

In this page you can find the example usage for org.dom4j DocumentHelper parseText.

Prototype

public static Document parseText(String text) throws DocumentException 

Source Link

Document

parseText parses the given text as an XML document and returns the newly created Document.

Usage

From source file:com.wifi.util.msg.MessageBuilder.java

@SuppressWarnings("unchecked")
public AppMessage buildAppMessage() throws DocumentException {
    AppMessage msg = new AppMessage();
    try {//  w w  w . ja  v  a2  s. co  m
        Document document = DocumentHelper.parseText(this.xmlText);
        Element rootElt = document.getRootElement();
        if (!rootElt.getName().equals(AppMessage.MESSAGE_TAG)) {
            System.err.println("The xml message tag is incorrect!" + rootElt.getName());
            return null;
        }

        Element headElt = rootElt.element(AppMessage.HEADER_TAG);
        if (headElt == null) {
            System.err.println("The message content is incorrect [no message header]!");
            return null;
        }

        MessageHeader header = new MessageHeader();

        header.setDevMac(headElt.elementTextTrim(MessageHeader.DEV_MAC_TAG));
        header.setHwId(headElt.elementTextTrim(MessageHeader.HW_ID_TAG));
        header.setLicense(headElt.elementTextTrim(MessageHeader.LICENSE_TAG));
        header.setMagic(headElt.elementTextTrim(MessageHeader.MAGIC_TAG));
        header.setMsgId(headElt.elementTextTrim(MessageHeader.MSG_ID_TAG));
        header.setSrcIp(headElt.elementTextTrim(MessageHeader.SRC_IP_TAG));
        header.setTargetIp(headElt.elementTextTrim(MessageHeader.TARGET_IP_TAG));
        msg.setHeader(header);
        System.out.println(header);

        Element bodyElt = rootElt.element(AppMessage.BODY_TAG);
        if (bodyElt == null) {
            System.out.println("The message doesn't exists message body!");
        } else {
            MessageBody body = new MessageBody();
            Map<String, String> map = new HashMap<>();
            Iterator<Element> bdyIterator = bodyElt.elementIterator();
            while (bdyIterator.hasNext()) {
                Element element = bdyIterator.next();
                map.put(element.getName(), element.getTextTrim());
            }
            body.setItemsMap(map);
            msg.setBody(body);
            System.out.println(body);
        }

    } catch (Exception e) {
        System.err.println("parse error: " + e.getMessage());
        return null;
    }

    return msg;
}

From source file:com.wonders.stpt.metroIndicator.action.MetroIndicatorAction.java

License:Open Source License

/**
 * @author ycl//ww w .  j  av  a 2  s  .com
 * @updateDate 2012-4-10
 * @description ????
 */
public String metroExpressLatestEvents() {
    String tmpSize = StringUtil.getNotNullValueString(super.getServletRequest().getParameter("size"));
    int size = 4;
    if (!"".equals(tmpSize)) {
        size = Integer.parseInt(tmpSize);
    }
    String accidentLine = StringUtil
            .getNotNullValueString(super.getServletRequest().getParameter("accidentLine"));
    String accidentEmergency = StringUtil
            .getNotNullValueString(super.getServletRequest().getParameter("accidentEmergency"));
    //System.out.println(accidentEmergency+"--------------------------------");
    List<MetroExpress> list = this.metroExpressService.findLatestMetroExpressEvents(accidentLine,
            accidentEmergency, size);
    List<MetroExpressVo> voList = new ArrayList<MetroExpressVo>();
    if (list != null && list.size() > 0) {
        for (MetroExpress e : list) {
            MetroExpressVo vo = new MetroExpressVo();
            BeanUtils.copyProperties(e, vo);
            if (vo.getAccidentDetail().length() > 58) {
                vo.setDetailSimple(vo.getAccidentDetail().substring(0, 58) + "...");
            } else {
                vo.setDetailSimple(vo.getAccidentDetail());
            }

            //?
            Map<Integer, String> resultMap = new HashMap<Integer, String>();
            if (vo.getAccidentRemark() != null && !vo.getAccidentRemark().equals("")) {
                try {
                    Document document = DocumentHelper.parseText(vo.getAccidentRemark());
                    int id = -1;
                    int maxId = -1;
                    String value = null;
                    String remarkAll = "";
                    List<Element> idList = document.selectNodes("//item/id");
                    List<Element> valueList = document.selectNodes("//item/value");

                    if (idList.size() != 0 && valueList.size() != 0 && valueList.size() == idList.size()) {
                        maxId = -1;
                        for (int i = 0; i < idList.size(); i++) {
                            id = Integer.valueOf(idList.get(i).getText());
                            if (id > maxId) {
                                maxId = id;
                            }
                            value = valueList.get(i).getText();
                            resultMap.put(id, value);
                        }
                        remarkAll += "<ul>";
                        for (int j = valueList.size() - 1; j >= 0; j--) {
                            value = valueList.get(j).getText();
                            remarkAll += "<li style='width:95%;padding:0;background:none;'>" + value + "</li>";
                        }
                        remarkAll += "</ul>";
                        vo.setAccidentRemarkAll(remarkAll);
                    }

                    if (maxId != -1) {
                        vo.setAccidentRemark(resultMap.get(maxId));
                    }

                    if (vo.getAccidentRemark() != null && !vo.getAccidentRemark().equals("")
                            && vo.getAccidentRemark().length() > 58) {
                        vo.setRemarkSimple(vo.getAccidentRemark().substring(0, 58) + "...");
                    } else {
                        vo.setRemarkSimple(vo.getAccidentRemark());
                    }
                } catch (DocumentException de) {
                    System.out.println(
                            "-----------------????--------------");
                    vo.setAccidentRemark("");
                }
            }

            voList.add(vo);
        }
    }
    String json = VOUtils.getJsonDataFromCollection(voList);
    //this.servletRequest.setAttribute("lineMap", this.metroExpressService.findMetroLineConfigMap());
    //System.out.println(json+"--------------------------------");
    createJSonData(json);
    return AJAX;
}

From source file:com.xdtech.report.controller.ReadReportController.java

License:Apache License

@RequestMapping(params = "configReportPage")
public ModelAndView configReportPage(HttpServletRequest request, Long configId) throws Exception {
    String title = "";
    if (configId != null) {
        ConfigItem configItem = configService.loadConfigItem(configId);
        title = configItem.getName();/*  w w w. j a va2s.  co  m*/
        request.setAttribute("configItem", configItem);
        SAXReader reader = new SAXReader(); // User.hbm.xml??xml 
        //         Document doc = reader.read(new File("G:/my-dev/git/xdtech-shop/src/test/java/pageTemplate.xml"));
        // ??xml 
        Document doc = DocumentHelper.parseText(configItem.getXml()); // XML 
        Element rootElement = doc.getRootElement();
        Element subGridDataElement = rootElement.element("datagrid");// ?datagrid
        //??title
        if (null != subGridDataElement.elementText("title")) {
            title = subGridDataElement.elementText("title");
        }
        //??
        Element columnsElement = subGridDataElement.element("columns");
        if (null != columnsElement && !columnsElement.isRootElement()) {
            List<Element> columnList = columnsElement.elements();
            JSONArray columnsArray = new JSONArray();
            JSONObject columnJson = null;
            for (Element element : columnList) {
                columnJson = new JSONObject();
                columnJson.put("field", element.attributeValue("field"));
                columnJson.put("title", element.attributeValue("title"));
                columnsArray.add(columnJson);
            }
            //            System.out.println(columnsArray.toString());
            request.setAttribute("columns", columnsArray.toString());
        }
    }
    request.setAttribute("showReportGridId", UUID.randomUUID().toString() + "_grid");
    request.setAttribute("title", title);
    return new ModelAndView("report/read/showReportGrid_ftl");
}

From source file:com.xebialabs.overthere.cifs.winrm.connector.JdkHttpConnector.java

License:Open Source License

@Override
public Document sendMessage(Document requestDocument, SoapAction soapAction) {
    Document responseDocument = null;
    try {//w  w  w.j a va  2 s  .  c  o m
        final URLConnection urlConnection = targetURL.openConnection();
        HttpURLConnection con = (HttpURLConnection) urlConnection;

        con.setDoInput(true);
        con.setDoOutput(true);
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8");

        final String authToken = tokenGenerator.generateToken();
        if (authToken != null)
            con.addRequestProperty("Authorization", authToken);

        if (soapAction != null) {
            con.setRequestProperty("SOAPAction", soapAction.getValue());
        }

        final String requestDocAsString = toString(requestDocument);
        logger.debug("send message to {}:request {}", targetURL, requestDocAsString);
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
        bw.write(requestDocAsString, 0, requestDocAsString.length());
        bw.flush();
        bw.close();

        InputStream is;
        if (con.getResponseCode() >= 400) {
            /* Read error response */
            is = httpConn.getErrorStream();
        } else {
            is = httpConn.getInputStream();
        }

        Writer writer = new StringWriter();
        try {
            int n;
            char[] buffer = new char[1024];
            Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            while ((n = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }
        } finally {
            Closeables.closeQuietly(is);
        }

        if (logger.isDebugEnabled()) {
            for (int i = 0; i < con.getHeaderFields().size(); i++) {
                logger.debug("Header {} --> {}", con.getHeaderFieldKey(i), con.getHeaderField(i));
            }
        }

        final String text = writer.toString();
        logger.debug("send message:response {}", text);
        responseDocument = DocumentHelper.parseText(text);
        return responseDocument;

    } catch (BlankValueRuntimeException bvrte) {
        throw bvrte;
    } catch (InvalidFilePathRuntimeException ifprte) {
        throw ifprte;
    } catch (Exception e) {
        throw new WinRMRuntimeIOException("send message on " + targetURL + " error ", requestDocument,
                responseDocument, e);
    }
}

From source file:com.xebialabs.overthere.winrm.WinRmClient.java

License:Open Source License

/**
 * Internal sendRequest, performs the HTTP request and returns the result document.
 *///from  ww  w.ja v a2s  .  co  m
private Document doSendRequest(final Document requestDocument, final SoapAction soapAction) {
    final HttpClientBuilder client = HttpClientBuilder.create();
    HttpClientConnectionManager connectionManager = getHttpClientConnectionManager();
    try {
        configureHttpClient(client);
        try (CloseableHttpClient httpClient = client.build()) {
            final HttpContext context = new BasicHttpContext();
            final HttpPost request = new HttpPost(targetURL.toURI());

            if (soapAction != null) {
                request.setHeader("SOAPAction", soapAction.getValue());
            }

            final String requestBody = toString(requestDocument);
            logger.trace("Request:\nPOST {}\n{}", targetURL, requestBody);

            final HttpEntity entity = createEntity(requestBody);
            request.setEntity(entity);

            final HttpResponse response = httpClient.execute(request, context);

            logResponseHeaders(response);

            Document responseDocument = null;
            try {
                final String responseBody = handleResponse(response, context);
                responseDocument = DocumentHelper.parseText(responseBody);
                logDocument("Response body:", responseDocument);
            } catch (WinRmRuntimeIOException e) {
                if (response.getStatusLine().getStatusCode() == 200) {
                    throw e;
                }
            }

            if (response.getStatusLine().getStatusCode() != 200) {
                throw new WinRmRuntimeIOException(String.format("Unexpected HTTP response on %s:  %s (%s)",
                        targetURL, response.getStatusLine().getReasonPhrase(),
                        response.getStatusLine().getStatusCode()));
            }

            return responseDocument;
        } finally {
            connectionManager.shutdown();
        }
    } catch (WinRmRuntimeIOException exc) {
        throw exc;
    } catch (Exception exc) {
        throw new WinRmRuntimeIOException("Error when sending request to " + targetURL, requestDocument, null,
                exc);
    }
}

From source file:com.xia.ssm.tools.ocr.CheckPic.java

/**
 * ?//  w  ww.  ja va2  s.c  o m
 * @Title: sendPicToWt
 * @param thPhoneDTO
 * @return  
 * @createDate 20161026;?3:26:55
 * @author xjf
 */
public static ClaimPhoneDTO sendPicToWt(ClaimPhoneDTO thPhoneDTO) {
    String result = "";
    String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//?
    long beginTime = System.currentTimeMillis();
    try {
        log.info("file======" + file);
        result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK,
                WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl());
        log.info("result======" + result);
    } catch (Exception e) {
        // TODO: handle exception
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }

    String[] encData = result.split("==@@");
    long times = System.currentTimeMillis() - beginTime;
    log.info("" + times);
    String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", "");
    Document doc;
    String insertString = "";
    try {
        doc = DocumentHelper.parseText(dataString);
        String status = doc.selectSingleNode("/data/message/status").getText();
        String value = doc.selectSingleNode("/data/message/value").getText();
        StringBuffer sql = new StringBuffer();
        if ("?".equals(value)) {
            List list = doc.selectNodes("/data/cardsinfo/card/item");
            StringBuffer json = new StringBuffer();
            for (int j = 1; j < list.size() - 1; j++) {
                Element term = (Element) list.get(j);
                String returString = term.getText();
                insertString += "'" + returString + "'" + ",";
                String name = term.attribute("desc").getText();

                if ("???".equals(name)) {
                    thPhoneDTO.setPlateNo(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setVehicleType(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setCustomerName(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setAddress(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setVehicleModels(returString);
                }
                if ("?".equals(name)) {
                    thPhoneDTO.setVin(returString);
                }
                if ("???".equals(name)) {
                    thPhoneDTO.setEngineNo(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setRegisterDate(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setIssueDate(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setUseType(returString);
                }
                thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
                thPhoneDTO.setState(value);
                thPhoneDTO.setStatus(status);
            }
        } else {
            thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
            thPhoneDTO.setState(value);
            thPhoneDTO.setStatus(status);
            thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        }
    } catch (Exception e) {
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }
    return thPhoneDTO;
}

From source file:com.xia.ssm.tools.ocr.CheckPic.java

/**
 * /*from   w ww  . ja  v a  2  s.  c  o m*/
 * @Title: sendPlateNoPicToWt
 * @param thPhoneDTO
 * @return  
 * @createDate 20161026;?3:31:45
 * @author luy
 */
public static ClaimPhoneDTO sendPlateNoPicToWt(ClaimPhoneDTO thPhoneDTO) {
    String result = "";
    String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//?
    long beginTime = System.currentTimeMillis();
    try {
        log.info("file======" + file);
        result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK,
                WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl());
        log.info("result======" + result);
    } catch (Exception e) {
        // TODO: handle exception
        thPhoneDTO.setResponseCode(ExceptionClaimCode.PLATENO_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }

    String[] encData = result.split("==@@");
    long times = System.currentTimeMillis() - beginTime;
    log.info("" + times);
    String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", "");
    Document doc;
    String insertString = "";
    try {
        doc = DocumentHelper.parseText(dataString);
        String status = doc.selectSingleNode("/data/message/status").getText();
        String value = doc.selectSingleNode("/data/message/value").getText();
        if ("?".equals(value)) {
            List list = doc.selectNodes("/data/cardsinfo/card/item");
            for (int j = 0; j < list.size(); j++) {
                Element term = (Element) list.get(j);
                String returString = term.getText();
                insertString += "'" + returString + "'" + ",";
                String name = term.attribute("desc").getText();
                if ("?".equals(name)) {
                    thPhoneDTO.setPlateNo(returString);
                }
                thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
                thPhoneDTO.setState(value);
                thPhoneDTO.setStatus(status);
            }
        } else {
            thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
            thPhoneDTO.setState(value);
            thPhoneDTO.setStatus(status);
            thPhoneDTO.setResponseCode(ExceptionClaimCode.PLATENO_FAILED);
        }
    } catch (Exception e) {
        thPhoneDTO.setResponseCode(ExceptionClaimCode.PLATENO_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }
    return thPhoneDTO;
}

From source file:com.xia.ssm.tools.ocr.CheckPic.java

/**
 * ?// www.  jav a 2 s.c o m
 * @Title: sendIdCardToWt
 * @param thPhoneDTO
 * @return  
 * @createDate 20161026;?3:32:41
 * @author xjf
 */
public static ClaimPhoneDTO sendIdCardToWt(ClaimPhoneDTO thPhoneDTO) {
    String result = "";
    String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//?
    long beginTime = System.currentTimeMillis();
    try {
        log.info("file======" + file);
        result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK,
                WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl());
        log.info("result======" + result);
    } catch (Exception e) {
        // TODO: handle exception
        thPhoneDTO.setResponseCode(ExceptionClaimCode.IDCARD_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }

    String[] encData = result.split("==@@");
    long times = System.currentTimeMillis() - beginTime;
    log.info("" + times);
    String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", "");
    Document doc;
    String insertString = "";
    try {
        doc = DocumentHelper.parseText(dataString);
        String status = doc.selectSingleNode("/data/message/status").getText();
        String value = doc.selectSingleNode("/data/message/value").getText();
        if ("?".equals(value)) {
            List list = doc.selectNodes("/data/cardsinfo/card/item");
            for (int j = 1; j < list.size() - 1; j++) {
                Element term = (Element) list.get(j);
                String returString = term.getText();
                insertString += "'" + returString + "'" + ",";
                String name = term.attribute("desc").getText();

                if ("??".equals(name)) {
                    thPhoneDTO.setUserName(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setSex(returString);
                }
                if ("?".equals(name)) {
                    thPhoneDTO.setNation(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setBirthday(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setAddress(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setIdCardNo(returString);
                }
                if ("?".equals(name)) {
                    thPhoneDTO.setIdCardPhoto(returString);
                }
                thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
                thPhoneDTO.setState(value);
                thPhoneDTO.setStatus(status);
            }
        } else {
            thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
            thPhoneDTO.setState(value);
            thPhoneDTO.setStatus(status);
            thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        }
    } catch (Exception e) {
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }
    return thPhoneDTO;
}

From source file:com.xia.ssm.tools.ocr.CheckPic.java

/**
 * ?//from w  w w.ja va2  s  .c  om
 * @Title: sendDriverToWt
 * @param thPhoneDTO
 * @return  
 * @createDate 20161026;?3:33:28
 * @author luy
 */
public static ClaimPhoneDTO sendDriverToWt(ClaimPhoneDTO thPhoneDTO) {
    String result = "";
    String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//?
    long beginTime = System.currentTimeMillis();
    try {
        log.info("file======" + file);
        result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK,
                WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl());
        log.info("result======" + result);
    } catch (Exception e) {
        // TODO: handle exception
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVER_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }

    String[] encData = result.split("==@@");
    long times = System.currentTimeMillis() - beginTime;
    log.info("" + times);
    String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", "");
    Document doc;
    String insertString = "";
    try {
        doc = DocumentHelper.parseText(dataString);
        String status = doc.selectSingleNode("/data/message/status").getText();
        String value = doc.selectSingleNode("/data/message/value").getText();
        if ("?".equals(value)) {
            List list = doc.selectNodes("/data/cardsinfo/card/item");
            for (int j = 1; j < list.size() - 1; j++) {
                Element term = (Element) list.get(j);
                String returString = term.getText();
                insertString += "'" + returString + "'" + ",";
                String name = term.attribute("desc").getText();

                if ("??".equals(name)) {
                    thPhoneDTO.setCardNo(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setUserName(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setSex(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setAddress(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setBirthday(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setRegisterTime(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setDrivingType(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setStartTime(returString);
                }
                if ("?".equals(name)) {
                    thPhoneDTO.setLimitTime(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setEndTime(returString);
                }
                thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
                thPhoneDTO.setState(value);
                thPhoneDTO.setStatus(status);
            }
        } else {
            thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
            thPhoneDTO.setState(value);
            thPhoneDTO.setStatus(status);
            thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        }
    } catch (Exception e) {
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }
    return thPhoneDTO;
}

From source file:com.xia.ssm.tools.ocr.CheckPic.java

/**
 * ?//from  w  ww  .  j a  v  a 2s.  c  o  m
 * @Title: sendBankToWt
 * @param thPhoneDTO
 * @return  
 * @createDate 20161026;?6:39:23
 * @author luy
 */
public static ClaimPhoneDTO sendBankToWt(ClaimPhoneDTO thPhoneDTO) {
    String result = "";
    String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//?
    long beginTime = System.currentTimeMillis();
    try {
        log.info("file======" + file);
        result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK,
                WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl());
        log.info("result======" + result);
    } catch (Exception e) {
        // TODO: handle exception
        thPhoneDTO.setResponseCode(ExceptionClaimCode.BANK_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }

    String[] encData = result.split("==@@");
    long times = System.currentTimeMillis() - beginTime;
    log.info("" + times);
    String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", "");
    Document doc;
    String insertString = "";
    try {
        doc = DocumentHelper.parseText(dataString);
        String status = doc.selectSingleNode("/data/message/status").getText();
        String value = doc.selectSingleNode("/data/message/value").getText();
        if ("?".equals(value)) {
            List list = doc.selectNodes("/data/cardsinfo/card/item");
            for (int j = 1; j < list.size() - 1; j++) {
                Element term = (Element) list.get(j);
                String returString = term.getText();
                insertString += "'" + returString + "'" + ",";
                String name = term.attribute("desc").getText();

                if ("???".equals(name)) {
                    thPhoneDTO.setPlateNo(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setVehicleType(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setCustomerName(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setAddress(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setVehicleModels(returString);
                }
                if ("?".equals(name)) {
                    thPhoneDTO.setVin(returString);
                }
                if ("???".equals(name)) {
                    thPhoneDTO.setEngineNo(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setRegisterDate(returString);
                }
                if ("??".equals(name)) {
                    thPhoneDTO.setIssueDate(returString);
                }
                if ("".equals(name)) {
                    thPhoneDTO.setUseType(returString);
                }
                thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
                thPhoneDTO.setState(value);
                thPhoneDTO.setStatus(status);
            }
        } else {
            thPhoneDTO.setConsumeTime("" + String.valueOf(times) + "");
            thPhoneDTO.setState(value);
            thPhoneDTO.setStatus(status);
            thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        }
    } catch (Exception e) {
        thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED);
        ErrorsLogPrintUtil.printToLog4j(log, e);
    }
    return thPhoneDTO;
}