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.globalsight.smartbox.util.WebClientHelper.java

License:Apache License

/**
 * Download job/*w ww .  j  a  v a  2s  . co  m*/
 * 
 * @param jobInfo
 * @return
 * @throws Exception
 */
public static boolean jobDownload(JobInfo jobInfo, String baseDir, String server) {
    try {
        String fileXml = ambassador.getJobExportFiles(accessToken, jobInfo.getJobName());
        Document profileDoc = DocumentHelper.parseText(fileXml);
        Node node = profileDoc.selectSingleNode("/jobFiles");
        String root = node.selectSingleNode("root").getText();
        ArrayList<String> filePaths = new ArrayList<String>();
        List<Node> paths = node.selectNodes("paths");
        for (Node n : paths) {
            filePaths.add(n.getText());
        }

        root = replaceHostUrl(root, server);

        String rootNoCompany = root.substring(0, root.lastIndexOf("/"));
        boolean useHttps = root.startsWith("https:");
        boolean useHttp = root.startsWith("http:");

        String commonPath = ZipUtil.getCommonPath(getReplacedPath(jobInfo.getJobName(), filePaths), "");
        File targetFile = null;
        StringBuffer targetFiles = new StringBuffer();
        for (String path : filePaths) {
            int index = path.indexOf(commonPath);
            String savePath = path.substring(index + commonPath.length());
            String[] nodes = path.split("/");
            String locale = nodes[0];
            savePath = rootNoCompany + "/" + jobInfo.getJobName() + "/" + locale + savePath;

            String downloadUrl = root + "/" + path;

            if (useHttps) {
                targetFile = DownLoadHelper.downloadHttps(downloadUrl, baseDir, savePath);
            } else if (useHttp) {
                targetFile = DownLoadHelper.downloadHttp(downloadUrl, baseDir, savePath);
            }
            targetFiles.append(targetFile.getPath()).append("|");
        }
        if (targetFiles.length() > 0) {
            targetFiles.deleteCharAt(targetFiles.length() - 1);
        }
        jobInfo.setTargetFiles(targetFiles.toString());
    } catch (Exception e) {
        String message = "Failed to download job, Job Name:" + jobInfo.getJobName() + ", Job Id:"
                + jobInfo.getId();
        LogUtil.fail(message, e);
        return false;
    }
    return true;
}

From source file:com.globalsight.smartbox.util.WebClientHelper.java

License:Apache License

/**
 * Get File Profile Info from GS Server//  www  .  jav a2 s  . co m
 * 
 * @return
 * @throws Exception
 */
public static List<FileProfile> getFileProfileInfoFromGS() throws Exception {
    List<FileProfile> fileProfiles = new ArrayList<FileProfile>();
    String fileProfileInfo = ambassador.getFileProfileInfoEx(accessToken);

    Document profileDoc = DocumentHelper.parseText(fileProfileInfo);
    List<Element> profileList = profileDoc.selectNodes("/fileProfileInfo/fileProfile");
    for (Element node : profileList) {
        FileProfile fp = new FileProfile();
        fp.setId(node.selectSingleNode("id").getText());
        fp.setName(node.selectSingleNode("name").getText());

        List<Element> extensions = node.selectNodes("fileExtensionInfo/fileExtension");
        for (Element extension : extensions) {
            fp.addFileExtension(extension.getText());
        }

        String sourceLocale = node.selectSingleNode("localeInfo/sourceLocale").getText();
        fp.setSourceLocale(sourceLocale);

        List<Element> targetLocales = node.selectNodes("localeInfo/targetLocale");
        for (Element targetLocale : targetLocales) {
            fp.addTargetLocale(targetLocale.getText());
        }
        fileProfiles.add(fp);
    }
    return fileProfiles;
}

From source file:com.globalsight.smartbox.util.WebClientHelper.java

License:Apache License

/**
  * Check if importing/exporting is happening on server.
  * //ww  w . j  ava2  s . c  om
  * @return boolean
  */
public static boolean isServerImportingOrExporting() {
    try {
        String status = ambassador.getImportExportStatus(accessToken);
        Document dom = DocumentHelper.parseText(status);
        Element root = dom.getRootElement();
        String creatingNum = root.element("jobsCreating").getText();
        String exportingNum = root.element("localesExporting").getText();
        int cNum = Integer.valueOf(creatingNum);
        int eNum = Integer.valueOf(exportingNum);
        if (cNum > 0 || eNum > 0)
            return true;
    } catch (Exception e) {
        LogUtil.info("Exception when try to detect server importing/exporting status:" + e.getMessage());
    }

    return false;
}

From source file:com.globalsight.webservices.Ambassador.java

License:Apache License

/**
 * Edit job detail info./*from   ww w.j  a  v  a2 s .  c om*/
 * 
 * @param p_accessToken
 *            - The access token received from the login.
 * @param p_jobId
 *            - Job id is not empty and exist in GS server.
 * @param p_jobName
 *            - Job name can be empty.
 * @param p_estimatedDateXml
 *            - EstimatedDateXml can be empty. If not empty,example :
 *            <estimatedDates> <workflow> <targetLocale>zh_CN</targetLocale>
 *            <estimatedTranslateCompletionDate>yyyyMMdd
 *            HHmmss</estimatedTranslateCompletionDate>
 *            <estimatedWorkflowCompletionDate>yyyyMMdd
 *            HHmmss</estimatedWorkflowCompletionDate> </workflow>
 *            <workflow> ... ... </workflow> </estimatedDates>
 * @param p_priority
 *            Priority can be empty.If not empty,priority must be 1,2,3,4 or
 *            5;
 * */
public String editJobDetailInfo(String p_accessToken, String p_jobId, String p_jobName,
        String p_estimatedDateXml, String p_priority) throws WebServiceException {
    checkAccess(p_accessToken, EDIT_JOB_DETAIL_INFO);
    checkPermission(p_accessToken, Permission.JOBS_DETAILS);
    String userName = getUsernameFromSession(p_accessToken);
    Map<Object, Object> activityArgs = new HashMap<Object, Object>();
    activityArgs.put("loggedUserName", userName);
    activityArgs.put("jobId", p_jobId);
    activityArgs.put("jobName", p_jobName);
    activityArgs.put("estimatedDateXml", p_estimatedDateXml);
    activityArgs.put("priority", p_priority);
    WebServicesLog.Start activityStart = WebServicesLog.start(Ambassador.class,
            "editJobDetailInfo(p_accessToken,p_jobId,p_jobName,p_estimatedDateXml,p_priority)", activityArgs);

    Map<String, Object> paramter = new HashMap<String, Object>();
    try {
        if (!Assert.assertNotEmpty(p_jobId)) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Job id can not be empty");
        }
        Assert.assertIsInteger(p_jobId);
        if (StringUtil.isNotEmpty(p_priority)) {
            Assert.assertIsInteger(p_priority);

            int priority = Integer.parseInt(p_priority);
            if (priority != 1 && priority != 2 && priority != 3 && priority != 4 && priority != 5) {
                return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid priority: " + p_priority
                        + ", it should be limited in 1, 2, 3, 4, 5 or empty.");
            }
            paramter.put("priority", p_priority);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return makeErrorXml(EDIT_JOB_DETAIL_INFO, e.getMessage());
    }

    Job job = null;
    try {
        job = ServerProxy.getJobHandler().getJobById(Long.parseLong(p_jobId));
        if (job == null) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid job id: " + p_jobId);
        }

        if (!isInSameCompany(userName, String.valueOf(job.getCompanyId()))) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO,
                    "Invalid job id: " + p_jobId + ", current user is not in the same company with the job.");
        }

        if (!job.getDisplayState().equalsIgnoreCase("ready") && StringUtil.isNotEmpty(p_jobName)) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Only job in ready state is allowed to modify job name.");
        }

        paramter.put("jobId", p_jobId);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return makeErrorXml(EDIT_JOB_DETAIL_INFO, e.getMessage());
    }

    // get unique job name
    if (StringUtil.isNotEmpty(p_jobName)) {
        try {
            p_jobName = EditUtil.removeCRLF(p_jobName);
            if (p_jobName.length() > 120) {
                return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid job name: " + p_jobName
                        + ",  the max lenght for job name limits to 120 characters.");
            }
            Job checkJob = ServerProxy.getJobHandler().getJobByJobName(p_jobName);
            if (checkJob == null) {
                paramter.put("jobName", p_jobName);
            } else {
                if (checkJob.getId() == Long.parseLong(p_jobId)) {
                    return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid job name: " + p_jobName
                            + ", the modify name is identical to current one.");
                } else {
                    return makeErrorXml(EDIT_JOB_DETAIL_INFO,
                            "Invalid job name: " + p_jobName + ", job name already exists.");
                }
            }
        } catch (Exception e) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO, e.getMessage());
        }
    }

    if (StringUtil.isNotEmpty(p_estimatedDateXml)) {
        Document doc;
        SimpleDateFormat sfm = new SimpleDateFormat("yyyyMMdd HHmmss");
        String userId = UserUtil.getUserIdByName(userName);
        try {
            User user = ServerProxy.getUserManager().getUser(userId);
            TimeZone timeZone = ServerProxy.getCalendarManager().findUserTimeZone(userId);
            Timestamp ts = new Timestamp(Timestamp.DATE, timeZone);
            Locale uiLocale = new Locale(user.getDefaultUILocale());
            ts.setLocale(uiLocale);
            doc = DocumentHelper.parseText(p_estimatedDateXml);
            Element rootElt = doc.getRootElement();
            List elements = rootElt.elements();
            Map<Long, Map<String, Date>> workMap = new HashMap<Long, Map<String, Date>>();
            for (int i = 0; i < elements.size(); i++) {
                Element et = (Element) elements.get(i);
                Map<String, Date> dateMap = new HashMap<String, Date>();

                String targetLocale = null;
                String tranComDateStr = null;
                String workComDateStr = null;
                try {
                    targetLocale = et.element("targetLocale").getText();
                    tranComDateStr = et.element("estimatedTranslateCompletionDate").getText();
                    workComDateStr = et.element("estimatedWorkflowCompletionDate").getText();
                } catch (Exception e) {
                    return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid estimatedDateXml,xml spelling errors.");
                }

                if (StringUtil.isEmpty(targetLocale)) {
                    return makeErrorXml(EDIT_JOB_DETAIL_INFO,
                            "Invalid estimatedDateXml: target locale can not be empty.");
                }
                GlobalSightLocale targetGSLocale = null;
                try {
                    targetGSLocale = getLocaleByName(targetLocale);
                    if (targetGSLocale == null) {
                        return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid target locale: " + targetLocale);
                    }

                    long sameId = -1;
                    for (Workflow wf : job.getWorkflows()) {
                        if (targetGSLocale.getId() == wf.getTargetLocale().getId()) {
                            sameId = wf.getTargetLocale().getId();
                        }
                    }
                    if (sameId == -1) {
                        return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid target locale: " + targetLocale
                                + ", current job has no workflow with this target locale.");
                    }
                } catch (Exception e) {
                    return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid target locale: " + targetLocale);
                }

                if (StringUtil.isNotEmpty(tranComDateStr)) {
                    try {
                        Date tranComDate = sfm.parse(tranComDateStr);
                        ts.setDate(tranComDate);
                        dateMap.put("estimatedTranslateCompletionDate", ts.getDate());
                    } catch (ParseException e) {
                        return makeErrorXml(EDIT_JOB_DETAIL_INFO,
                                "Invalid estimatedTranslateCompletionDate: " + tranComDateStr);
                    }
                }

                if (StringUtil.isNotEmpty(workComDateStr)) {
                    try {
                        Date workComDate = sfm.parse(workComDateStr);
                        ts.setDate(workComDate);
                        dateMap.put("estimatedWorkflowCompletionDate", ts.getDate());
                    } catch (ParseException e) {
                        return makeErrorXml(EDIT_JOB_DETAIL_INFO,
                                "Invalid estimatedWorkflowCompletionDate: " + workComDateStr);
                    }
                }

                if (!dateMap.isEmpty() && !workMap.containsKey(targetGSLocale.getId())) {
                    workMap.put(targetGSLocale.getId(), dateMap);
                }
            }
            // put workflow date paramter
            paramter.put("estimatedDates", workMap);
        } catch (Exception e) {
            return makeErrorXml(EDIT_JOB_DETAIL_INFO, "Invalid estimatedDateXml: XML parse error.");
        }
    }

    String returnStr = updateJobDetailInfo(paramter);
    activityStart.end();
    return returnStr;
}

From source file:com.globalsight.webservices.Ambassador.java

License:Apache License

private String nextTm3Tus(ProjectTM ptm, GlobalSightLocale srcGSLocale, GlobalSightLocale trgGSLocale,
        long tuIdToStart, int size) throws WebServiceException {
    Connection conn = null;//from   w  w  w .java 2  s.c  o m
    try {
        conn = DbUtil.getConnection();

        String tuTable = "tm3_tu_shared_" + ptm.getCompanyId();
        String tuvTable = "tm3_tuv_shared_" + ptm.getCompanyId();

        StatementBuilder sb = new StatementBuilder();
        if (trgGSLocale != null) {
            sb.append("SELECT tuv.tuId FROM ").append(tuvTable).append(" tuv,");
            sb.append(" (SELECT id FROM ").append(tuTable).append(" tu ").append("WHERE tu.tmid = ? ")
                    .addValue(ptm.getTm3Id()).append(" AND tu.srcLocaleId = ? ").addValue(srcGSLocale.getId())
                    .append(" AND tu.id > ? ").addValue(tuIdToStart).append(" ORDER BY tu.id LIMIT 0, ")
                    .append(String.valueOf(10 * size)).append(") tuids ");
            sb.append(" WHERE tuv.tuId = tuids.id");
            sb.append(" AND tuv.localeId = ? ").addValue(trgGSLocale.getId());
            sb.append(" AND tuv.tmId = ? ").addValue(ptm.getTm3Id());
            sb.append(" ORDER BY tuv.tuId ");
            sb.append(" LIMIT 0, ").append(String.valueOf(size)).append(";");
        } else {
            sb.append("SELECT id FROM ").append(tuTable).append(" WHERE tmid = ? ").addValue(ptm.getTm3Id())
                    .append(" AND srcLocaleId = ? ").addValue(srcGSLocale.getId()).append(" AND id > ? ")
                    .addValue(tuIdToStart).append(" ORDER BY id ").append("LIMIT 0,").append(size + ";");
        }
        List<Long> tuIds = SQLUtil.execIdsQuery(conn, sb);
        if (tuIds == null || tuIds.size() == 0) {
            return null;
        }

        BaseTm tm = TM3Util.getBaseTm(ptm.getTm3Id());
        List<TM3Tu> tm3Tus = tm.getTu(tuIds);

        TM3Attribute typeAttr = TM3Util.getAttr(tm, TYPE);
        TM3Attribute formatAttr = TM3Util.getAttr(tm, FORMAT);
        TM3Attribute sidAttr = TM3Util.getAttr(tm, SID);
        TM3Attribute translatableAttr = TM3Util.getAttr(tm, TRANSLATABLE);
        TM3Attribute fromWsAttr = TM3Util.getAttr(tm, FROM_WORLDSERVER);
        TM3Attribute projectAttr = TM3Util.getAttr(tm, UPDATED_BY_PROJECT);
        List<SegmentTmTu> segTmTus = new ArrayList<SegmentTmTu>();
        for (TM3Tu tm3Tu : tm3Tus) {
            segTmTus.add(TM3Util.toSegmentTmTu(tm3Tu, ptm.getId(), formatAttr, typeAttr, sidAttr, fromWsAttr,
                    translatableAttr, projectAttr));
        }

        List<GlobalSightLocale> targetLocales = null;
        if (trgGSLocale != null) {
            targetLocales = new ArrayList<GlobalSightLocale>();
            targetLocales.add(trgGSLocale);
        }

        StringBuffer result = new StringBuffer();
        IExportManager exporter = null;
        String options = null;
        exporter = TmManagerLocal.getProjectTmExporter(ptm.getName());
        options = exporter.getExportOptions();
        Document doc = DocumentHelper.parseText(options);
        Element rootElt = doc.getRootElement();
        Iterator fileIter = rootElt.elementIterator("fileOptions");
        while (fileIter.hasNext()) {
            Element fileEle = (Element) fileIter.next();
            Element fileTypeElem = fileEle.element("fileType");
            fileTypeElem.setText("xml");
        }

        Iterator filterIter = rootElt.elementIterator("filterOptions");
        while (filterIter.hasNext()) {
            Element filterEle = (Element) filterIter.next();
            Element language = filterEle.element("language");
            if (trgGSLocale != null) {
                language.setText(trgGSLocale.getLanguage() + "_" + trgGSLocale.getCountry());
            }
        }

        options = doc.asXML().substring(doc.asXML().indexOf("<exportOptions>"));
        exporter.setExportOptions(options);

        Tmx tmx = new Tmx();
        tmx.setSourceLang(Tmx.DEFAULT_SOURCELANG);
        tmx.setDatatype(Tmx.DATATYPE_HTML);

        TmxWriter tmxWriter = new TmxWriter(exporter.getExportOptionsObject(), ptm, tmx);
        for (SegmentTmTu segTmTu : segTmTus) {
            result.append(tmxWriter.getSegmentTmForXml(segTmTu));
        }

        return result.toString();
    } catch (Exception e) {
        logger.error(e);
        throw new WebServiceException(e.getMessage());
    } finally {
        DbUtil.silentReturnConnection(conn);
    }
}

From source file:com.globalsight.webservices.Ambassador.java

License:Apache License

private String joinXml(String xml, String startDate, String finishDate, String fileType, String languages,
        String exportedFileName, String projectNames) throws WebServiceException {
    Document doc = null;/* w w w  .ja  v a  2  s .c o  m*/
    try {
        doc = DocumentHelper.parseText(xml);
        Element rootElt = doc.getRootElement();
        Iterator fileIter = rootElt.elementIterator("fileOptions");
        while (fileIter.hasNext()) {
            Element fileEle = (Element) fileIter.next();
            if (exportedFileName != null) {
                Element fileNameElem = fileEle.element("fileName");
                if (fileType.equals("xml")) {
                    fileNameElem.setText(exportedFileName + ".xml");
                } else if (fileType.equals("tmx2")) {
                    fileNameElem.setText(exportedFileName + ".tmx");
                }
            }
            Element fileTypeElem = fileEle.element("fileType");
            fileTypeElem.setText(fileType);
            Element fileEncodingElem = fileEle.element("fileEncoding");
            fileEncodingElem.setText("UTF-8");
        }

        Iterator selectIter = rootElt.elementIterator("selectOptions");
        while (selectIter.hasNext()) {
            Element selectEle = (Element) selectIter.next();
            Element selectModeElem = selectEle.element("selectMode");
            // Element selectLanguage = selectEle.element("selectLanguage");
            selectModeElem.setText(com.globalsight.everest.tm.exporter.ExportOptions.SELECT_ALL);
            // if (StringUtil.isEmpty(languages))
            // {
            // }
            // else
            // {
            // selectModeElem
            // .setText(com.globalsight.everest.tm.exporter.ExportOptions.SELECT_FILTERED);
            // selectLanguage.setText(languages);
            // }
        }

        Iterator filterIter = rootElt.elementIterator("filterOptions");
        while (filterIter.hasNext()) {
            Element filterEle = (Element) filterIter.next();
            Element createdafterElem = filterEle.element("createdafter");
            createdafterElem.setText(startDate);
            Element createdbeforeElem = filterEle.element("createdbefore");
            Element language = filterEle.element("language");
            Element projectName = filterEle.element("projectName");
            if (finishDate == null) {
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String nowDateStr = sdf.format(nowDate);
                createdbeforeElem.setText(nowDateStr);
            } else {
                createdbeforeElem.setText(finishDate);
            }

            if (StringUtil.isNotEmpty(languages)) {
                language.setText(languages);
            }

            if (StringUtil.isNotEmpty(projectNames)) {
                projectName.setText(projectNames);
            }
        }

        Iterator outputIter = rootElt.elementIterator("outputOptions");
        while (outputIter.hasNext()) {
            Element outputEle = (Element) outputIter.next();
            Element systemFields = outputEle.element("systemFields");
            systemFields.setText("true");
        }

        String xmlDoc = doc.asXML();
        return xmlDoc.substring(xmlDoc.indexOf("<exportOptions>"));
    } catch (DocumentException e) {
        throw new WebServiceException(e.getMessage());
    }
}

From source file:com.googlecode.starflow.engine.xml.XmlFormat.java

License:Apache License

/**
 * dom4j?XML'pretty'?.//ww w.ja  va2  s  .c  o  m
 * 
 * @param xml
 *            ??XML.
 * @param encoding
 *            ??.
 * @return ??XML.null,???.
 */
public static String getPrettyString(String xml, String encoding) throws DocumentException {
    if (xml == null || xml.trim().length() < 1) {
        return xml;
    }

    Document doc = DocumentHelper.parseText(xml);
    return getPrettyString(doc, encoding);
}

From source file:com.greenline.guahao.biz.manager.payment.util.AlipayCore.java

License:Open Source License

/**
 * ?????token/*from   ww w  . j  a v  a2s . com*/
 * 
 * @param text ??
 * @return ?
 * @throws Exception
 */
public static String getRequestToken(String text) throws Exception {
    String request_token = "";
    // &?
    String[] strSplitText = text.split("&");
    // ??????
    Map<String, String> paraText = new HashMap<String, String>();
    for (int i = 0; i < strSplitText.length; i++) {
        // =?
        int nPos = strSplitText[i].indexOf("=");
        // 
        int nLen = strSplitText[i].length();
        // ????
        String strKey = strSplitText[i].substring(0, nPos);
        // 
        String strValue = strSplitText[i].substring(nPos + 1, nLen);
        // MAP
        paraText.put(strKey, strValue);
    }
    if (paraText.get("res_data") != null) {
        String res_data = paraText.get("res_data");
        // tokenres_data??res_data??token
        Document document = DocumentHelper.parseText(res_data);
        request_token = document.selectSingleNode("//direct_trade_create_res/request_token").getText();
    }
    return request_token;
}

From source file:com.greenline.guahao.biz.manager.payment.util.AlipayCore.java

License:Open Source License

/**
 * ?????????// w w  w.  j  av  a 2  s .  c  om
 * 
 * @param params ??
 * @return ?
 */
public static boolean verifyNotify(Map<String, String> params) throws Exception {

    // ???????
    String responseTxt = "true";
    try {
        // XML?notify_data??notify_id
        Document document = DocumentHelper.parseText(params.get("notify_data"));
        String notify_id = document.selectSingleNode("//notify/notify_id").getText();
        responseTxt = verifyResponse(notify_id);
    } catch (Exception e) {
        responseTxt = e.toString();
    }

    // ????
    String sign = "";
    if (params.get("sign") != null) {
        sign = params.get("sign");
    }
    boolean isSign = getSignVeryfy(params, sign, false);

    if (isSign && "true".equals(responseTxt)) {
        return true;
    } else {
        return false;
    }
}

From source file:com.greenline.guahao.web.module.home.controllers.mobile.reservation.MobilePaymentController.java

License:Open Source License

/**
 * ?url// w w  w .  ja v a  2s  .c  o m
 * 
 * @param model
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
@MethodRemark(value = "remark=?url,method=POST")
@RequestMapping(value = MobileConstants.M_PAYMENT_NOTIFY_PATH, method = RequestMethod.POST)
public void paymentNofity(ModelMap model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    log.info("html5?...");
    Map<String, String> params = new HashMap<String, String>();
    Map requestParams = request.getParameterMap();
    for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
        String name = (String) iter.next();
        String[] values = (String[]) requestParams.get(name);
        String valueStr = "";
        for (int i = 0; i < values.length; i++) {
            valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
        }
        params.put(name, valueStr);
    }
    String sign = request.getParameter("sign");
    log.info("sign:" + sign);
    ;
    String sec_id = request.getParameter("sec_id");
    log.info("sec_id:" + sec_id);
    String notify_data = request.getParameter("notify_data");// ?
    log.info("notify_data:" + notify_data);
    Document doc_notify_data = DocumentHelper.parseText(notify_data);
    String payment_type = doc_notify_data.selectSingleNode("//notify/payment_type").getText();
    log.info("payment_type:" + payment_type);
    String subject = doc_notify_data.selectSingleNode("//notify/subject").getText();
    log.info("subject:" + subject);
    String trade_no = doc_notify_data.selectSingleNode("//notify/trade_no").getText();
    log.info("trade_no:" + trade_no);
    String buyer_email = doc_notify_data.selectSingleNode("//notify/buyer_email").getText();
    log.info("buyer_email:" + buyer_email);
    String gmt_create = doc_notify_data.selectSingleNode("//notify/gmt_create").getText();
    log.info("gmt_create:" + gmt_create);
    String notify_type = doc_notify_data.selectSingleNode("//notify/notify_type").getText();
    log.info("notify_type:" + notify_type);
    String quantity = doc_notify_data.selectSingleNode("//notify/quantity").getText();
    log.info("quantity:" + quantity);
    String out_trade_no = doc_notify_data.selectSingleNode("//notify/out_trade_no").getText();
    log.info("out_trade_no:" + out_trade_no);
    String notify_time = doc_notify_data.selectSingleNode("//notify/notify_time").getText();
    log.info("notify_time:" + notify_time);
    String seller_id = doc_notify_data.selectSingleNode("//notify/seller_id").getText();
    log.info("seller_id:" + seller_id);
    String trade_status = doc_notify_data.selectSingleNode("//notify/trade_status").getText();
    log.info("trade_status:" + trade_status);
    String is_total_fee_adjust = doc_notify_data.selectSingleNode("//notify/is_total_fee_adjust").getText();
    log.info("is_total_fee_adjust:" + is_total_fee_adjust);
    String total_fee = doc_notify_data.selectSingleNode("//notify/total_fee").getText();
    log.info("total_fee:" + total_fee);
    String gmt_payment = "";
    if (doc_notify_data.selectSingleNode("//notify/gmt_payment") != null) {
        gmt_payment = doc_notify_data.selectSingleNode("//notify/gmt_payment").getText();
    }
    log.info("gmt_payment:" + gmt_payment);
    String seller_email = doc_notify_data.selectSingleNode("//notify/seller_email").getText();
    log.info("seller_email:" + seller_email);
    String price = doc_notify_data.selectSingleNode("//notify/price").getText();
    log.info("price:" + price);
    String buyer_id = doc_notify_data.selectSingleNode("//notify/buyer_id").getText();
    log.info("buyer_id:" + buyer_id);
    String notify_id = doc_notify_data.selectSingleNode("//notify/notify_id").getText();
    log.info("notify_id:" + notify_id);
    String use_coupon = doc_notify_data.selectSingleNode("//notify/use_coupon").getText();
    log.info("use_coupon:" + use_coupon);
    // 1????url
    // 2????
    AlipayParamDTO param = new AlipayParamDTO();
    param.setBuyerEmail(buyer_email);
    param.setBuyerId(buyer_id);
    param.setSallerEmail(seller_email);
    param.setSallerId(seller_id);
    param.setChannelType("directPay");
    param.setOrderId(out_trade_no);
    param.setTradeNo(trade_no);
    param.setTradeStatus(trade_status);
    param.setGmtPayment(gmt_payment);
    param.setGmtTradeCreate(gmt_create);
    param.setOrderTitle(subject);
    param.setOrderId(out_trade_no);
    param.setPayType(1);
    ResponseDTO<ConfirmResultDTO> pdt = paymentManager.aliPaySucConfirm(param);
    if (pdt == null) {
        log.error("hession??:?null");
        return;
    }
    try {
        if (ResponseCode.isSuccess(pdt.getCode())) {
            log.info("??");
            response.getWriter().print("success");

        } else {
            log.error("?:" + pdt.getMessage());
        }
    } catch (IOException e) {
        log.error("hession??", e);
    }

}