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.sf.integration.warehouse.service.SFService.java

/**
 * ?//  ww w .  j a v a  2 s.c o m
 * @author sven
 * @param request
 * @param response
 * @return
 */
public static String SFInventoryPush(HttpServletRequest request, HttpServletResponse response) {
    String logistics_interface = (String) request.getParameter("logistics_interface");
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");

    Document responseDoc = (Document) DocumentHelper.createDocument();
    Element responseElement = responseDoc.addElement("Response");
    responseElement.addAttribute("service", "INVENTORY_BALANCE_SERVICE");
    responseElement.addAttribute("lang", "zh-CN");
    responseElement.addElement("Head").addText("OK");
    Element InventoryBalanceResponse = responseElement.addElement("Body")
            .addElement("InventoryBalanceResponse");

    try {
        Document doc = (Document) DocumentHelper.parseText(logistics_interface);
        Element ResponseElement = doc.getRootElement();
        Element BodyElement = ResponseElement.element("Body");
        Element InventoryBalanceRequest = BodyElement.element("InventoryBalanceRequest");
        Element InventoryBalances = InventoryBalanceRequest.element("InventoryBalances");
        Element Status = InventoryBalanceRequest.element("Status");
        // ?1?
        if (UtilValidate.isEmpty(InventoryBalances) || "1".equals(Status.getText())) {
            setResponseMsg(InventoryBalanceResponse, "1", "");
            responseToShunfeng(request, response, responseDoc.getRootElement().asXML());
            return "success";
        }
        List<Element> inventoryBalanceList = InventoryBalances.elements("InventoryBalance");
        for (Element inventoryBalance : inventoryBalanceList) {
            Element SkuNo = inventoryBalance.element("SkuNo");
            Element Qty = inventoryBalance.element("Qty");
            Element InventoryStatus = inventoryBalance.element("InventoryStatus");

            GenericValue invTemp = delegator.makeValue("ShunfengInventoryTemp");
            invTemp.put("baseId", delegator.getNextSeqId("ShunfengInventoryTemp"));
            invTemp.put("productId", SkuNo.getText());
            invTemp.put("availableToPromiseTotal", new BigDecimal(Qty.getText()));
            invTemp.put("quantityOnHandTotal", new BigDecimal(Qty.getText()));
            invTemp.put("inventoryStatus", InventoryStatus.getText());
            invTemp.put("pushDateTime", UtilDateTime.nowTimestamp());
            invTemp.create();
        }
        setResponseMsg(InventoryBalanceResponse, "1", "");
        responseToShunfeng(request, response, responseDoc.getRootElement().asXML());
    } catch (DocumentException e) {
        setResponseMsg(InventoryBalanceResponse, "2", e.getMessage());
        responseToShunfeng(request, response, responseDoc.getRootElement().asXML());
        e.printStackTrace();
    } catch (GenericEntityException e) {
        setResponseMsg(InventoryBalanceResponse, "2", e.getMessage());
        responseToShunfeng(request, response, responseDoc.getRootElement().asXML());
        e.printStackTrace();
    }
    return "success";
}

From source file:com.sf.integration.warehouse.service.SFService.java

/**
 * ??/*  ww  w.  j a  v  a 2  s  . c o  m*/
 * @author sven
 * @param request
 * @param response
 * @return
 */
public static String SFOutboundListPush(HttpServletRequest request, HttpServletResponse response) {
    String logistics_interface = (String) request.getParameter("logistics_interface");

    Debug.log("====== logistics_interface SFOutboundListPush ? :" + logistics_interface);
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    StringBuffer errorOrderBody = new StringBuffer();
    List<Map<String, Object>> orderList = FastList.newInstance();
    List<Map<String, Object>> shipmentList = FastList.newInstance();

    Document responseDoc = (Document) DocumentHelper.createDocument();
    Element responseElement = responseDoc.addElement("Response");
    responseElement.addAttribute("service", "SALE_ORDER_OUTBOUND_DETAIL_SERVICE");
    responseElement.addAttribute("lang", "zh-CN");
    responseElement.addElement("Head").addText("OK");
    Element PurchaseOrderInboundResponse = responseElement.addElement("Body")
            .addElement("SaleOrderOutboundDetailResponse");

    try {
        GenericValue userLogin = delegator.findOne("UserLogin", true, UtilMisc.toMap("userLoginId", "system"));
        Document doc = (Document) DocumentHelper.parseText(logistics_interface);
        Element ResponseElement = doc.getRootElement();
        Element BodyElement = ResponseElement.element("Body");
        Element PurchaseOrderInboundRequest = BodyElement.element("SaleOrderOutboundDetailRequest");
        List<Element> salesOrders = PurchaseOrderInboundRequest.elements("SaleOrders");
        for (Element salesOrder : salesOrders) {
            String sfShipmentId = salesOrder.element("SaleOrder").element("ShipmentId").getText();
            String trackingIdNumber = salesOrder.element("SaleOrder").element("WayBillNo").getText();
            String status = salesOrder.element("SaleOrder").element("DataStatus").getText();
            if (!"2900".equals(status) && !"3900".equals(status)) {
                errorOrderBody.append("SFOutboundListPush:ErpOrder[" + sfShipmentId + "],status[" + status
                        + "] ???<br/>");
                continue;
            }
            // ReceiptId ???
            GenericValue sfOrderAssoc = EntityUtil.getFirst(
                    delegator.findByAnd("SFOrderAssoc", UtilMisc.toMap("SFCallBackId", sfShipmentId)));
            if (UtilValidate.isEmpty(sfOrderAssoc)) {
                errorOrderBody.append("SFOutboundListPush:sfShipmentId not found<br/>");
                continue;
            }
            if ("SHIPMENT_OUT".equals(sfOrderAssoc.getString("localOrderTypeId"))) {
                //ofbizshipment?
                Map<String, Object> shipmentMap = UtilMisc.toMap("shipmentId",
                        sfOrderAssoc.getString("shipmentId"), "trackingIdNumber", trackingIdNumber);
                shipmentList.add(shipmentMap);
            } else if ("ORDER_OUT".equals(sfOrderAssoc.getString("localOrderTypeId"))) {
                Map<String, Object> orderMap = UtilMisc.toMap("orderId", sfOrderAssoc.getString("orderId"),
                        "orderItemShipGroupId", sfOrderAssoc.getString("shipGroupSeqId"), "trackingIdNumber",
                        trackingIdNumber);
                orderList.add(orderMap);
            }
        }

        if (UtilValidate.isNotEmpty(errorOrderBody)) {
            //?
            ApiUtil.messageEmailNotification(dispatcher, delegator, "SFShipmentPushError",
                    errorOrderBody.toString(), null);
            //return "error";
        }
        if (UtilValidate.isNotEmpty(orderList)) {
            //???
            dispatcher.runSync("OMSOrderShipComplete",
                    UtilMisc.toMap("orderList", orderList, "userLogin", userLogin));
        }

        if (UtilValidate.isNotEmpty(shipmentList)) {
            //shipment??
            dispatcher.runSync("sendShipmentFromShunfeng",
                    UtilMisc.toMap("shipmentList", shipmentList, "userLogin", userLogin));
        }

        setResponseMsg(PurchaseOrderInboundResponse, "1", "");
        responseToShunfeng(request, response, responseDoc.asXML());
    } catch (DocumentException e) {
        ApiUtil.messageEmailNotification(dispatcher, delegator, "SFShipmentPushError", e.getMessage(), null);
        setResponseMsg(PurchaseOrderInboundResponse, "2", e.getMessage());
        responseToShunfeng(request, response, responseDoc.asXML());
        e.printStackTrace();
    } catch (GenericEntityException e) {
        ApiUtil.messageEmailNotification(dispatcher, delegator, "SFShipmentPushError", e.getMessage(), null);
        setResponseMsg(PurchaseOrderInboundResponse, "2", e.getMessage());
        responseToShunfeng(request, response, responseDoc.asXML());
        e.printStackTrace();
    } catch (GenericServiceException e) {
        ApiUtil.messageEmailNotification(dispatcher, delegator, "SFShipmentPushError", e.getMessage(), null);
        setResponseMsg(PurchaseOrderInboundResponse, "2", e.getMessage());
        responseToShunfeng(request, response, responseDoc.asXML());
        e.printStackTrace();
    }
    return "success";
}

From source file:com.shlaunch.weixin.local.web.WeixinController.java

License:Open Source License

/**
 * parse?,map/*from   ww w. j  a  v  a  2  s  .  c om*/
 *
 * @param request
 * @return
 * @throws IOException
 * @throws DocumentException
 */
private Map<String, Object> parseInputStream(HttpServletRequest request) throws IOException, DocumentException {
    Map<String, Object> elementMap = null;
    ServletInputStream inputStream = request.getInputStream();

    if (null != inputStream) {

        String postStr = this.readStreamParameter(inputStream);

        Document document = null;
        try {
            document = DocumentHelper.parseText(postStr);
        } catch (Exception e) {
            logger.debug(e);
            e.printStackTrace();
        }
        if (null != document) {
            elementMap = new HashMap<String, Object>();
            Element rootElm = document.getRootElement();

            for (Iterator<Element> iterator = rootElm.elementIterator(); iterator.hasNext();) {
                Element element = iterator.next();
                String name = element.getName();
                Object data = element.getData();
                elementMap.put(name, data);
            }
        }
    }
    return elementMap;
}

From source file:com.smartmarmot.dbforbix.config.Config.java

License:Open Source License

public void buildItems() {

    //result for hosts:
    // hostid=[11082], host=[APISQL], nameFC=[APISQL], status=[0]
    //result for items:
    //status=[0, 0], 
    //type=[11, 11], value_type=[4, 3],
    //hostid=[11082, 11082], itemid=[143587, 143588],  
    //key_=[db.odbc.discovery[sessions,{$DSN}], db.odbc.select[sessions,{$DSN}]], 
    //params=[select machine, count(1) N from v$session, sessions], 
    //delay=[120, 120],

    Collection<ZServer> zServers = null;
    try {/*  w ww .  j  a  v a 2s .co  m*/
        zServers = getZabbixServers();
    } catch (Exception ex) {
        LOG.error("Error getting Zabbix servers collection - " + ex.getLocalizedMessage());
    }

    for (ZServer zs : zServers) {
        for (Entry<String, Map<String, String>> ic : zs.getItemConfigs().entrySet()) {
            LOG.debug("buildItems: " + zs + " --> " + ic.getKey());
            try {
                String param = ic.getValue().get("param");
                param = "<!DOCTYPE parms SYSTEM \"" + getBasedir() + "/items/param.dtd\">" + param;
                Document doc = DocumentHelper.parseText(param);
                Element root = doc.getRootElement();
                String prefix = root.attributeValue("prefix");
                for (Object srv : root.elements("server")) {
                    if (srv instanceof Element)
                        buildItemsAndSchedulers((Element) srv, ic.getValue(), prefix, zs);
                }
                //            for (Object db: root.elements("database")) {
                //               if (db instanceof Element) buildDatabaseElements((Element) db, itemGroupName, prefix);
                //            }
            } catch (Exception ex) {
                LOG.error("Error while loading config item " + ic, ex);
                LOG.error("Skipping " + ic);
            }
        }
    }
}

From source file:com.stardon.carassistant.Activity.BusinessRecordFunctionList_Activity.java

/**
 * @: request08Q12/*from w ww  .  ja va  2 s.c om*/
 * @: 08Q12 <br/>
 *         <br/>
 *        Toastmessage <br/>
 *         <br/>
 *           <br/>
 *         <br/>
 *         <br/>
 * @: null
 * @: void
 * @ IOException:
 * @ NullPointerException:
 */
private void request08Q12() {
    String jkid = "08Q12";
    StringBuilder xmlData = new StringBuilder();
    xmlData.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
    xmlData.append("<root>");
    xmlData.append("<QueryCondition>");
    xmlData.append("<orgcode>" + orgcode + "</orgcode>");
    xmlData.append("</QueryCondition>");
    xmlData.append("</root>");
    doRequest(METHOD_QUERY, jkid, xmlData.toString(), new VolleyInterface() {

        @Override
        public void onMySuccess(JSONObject result) {

        }

        @Override
        public void onMySuccess(String result) {
            Document doc = null;
            try {
                doc = DocumentHelper.parseText(result);
                Element root = doc.getRootElement();
                Element head = root.element("head");
                String code = head.elementTextTrim("code");
                String message = head.elementTextTrim("message");
                if (!"1".equals(code)) {// 1.
                    MyToast.showButtom(getContext(), message);
                    return;
                }
                {
                    XStream xstream = new XStream(new DomDriver());
                    xstream.ignoreUnknownElements();
                    xstream.alias("root", ResponseRootVo.class);
                    xstream.alias("head", BaseResponseMsgVO.class);
                    xstream.alias("body", BaseResponseBodyVO.class);
                    xstream.aliasField("vehispara", BaseResponseBodyVO.class, "bean08Q12");// 
                    xstream.alias("vehispara", Bean08Q12.class);// 
                    ResponseRootVo b = (ResponseRootVo) xstream.fromXML(result);
                    bean08Q12 = b.getBody().getBean08Q12();
                }
                Element body = root.element("body");
                List<Element> elementList = body.element("vehispara").elements();
                data08Q12 = new HashMap<String, String>();
                for (Element element : elementList) {
                    data08Q12.put(element.getName(), element.getTextTrim());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                user.setOrgrecoedstate(data08Q12.get("reviewstate"));
                dao.saveUser(user);
                reviewstate = data08Q12.get("reviewstate");
                code = data08Q12.get("code");
                ishavephoto = data08Q12.get("ishavephoto");
                pic = data08Q12.get("pic");
                zzpic = data08Q12.get("zzpic");
                refreshStauts();
            } catch (Exception e) {
            }
        }

        @Override
        public void onMyError(VolleyError result) {
        }
    });
}

From source file:com.stardon.carassistant.Activity.BusinessRecordFunctionList_Activity.java

/**
 * @: request08W11//from  w  ww .  java 2s  .com
 * @: 08W11 <br/>
 *        Toast <br/>
 *        Toastmessage <br/>
 * @: null
 * @: void
 * @ IOException:
 * @ NullPointerException:
 */
private void request08W11() {
    String jkid = "08W11";
    StringBuilder xmlData = new StringBuilder();
    xmlData.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
    xmlData.append("<root>");
    xmlData.append("<vehispara>");
    xmlData.append("<orgcode>" + orgcode + "</orgcode>");
    xmlData.append("</vehispara>");
    xmlData.append("</root>");
    doRequest(METHOD_WRITE, jkid, xmlData.toString(), new VolleyInterface() {

        @Override
        public void onMySuccess(JSONObject result) {

        }

        @Override
        public void onMySuccess(String result) {
            Document doc = null;
            try {
                doc = DocumentHelper.parseText(result);
                Element root = doc.getRootElement();
                Element head = root.element("head");
                String code = head.elementTextTrim("code");
                String message = head.elementTextTrim("message");
                MyToast.showButtom(getContext(), message);
                if (!"1".equals(code)) {// 1.
                    return;
                }
                user.setOrgrecoedstate("1");
                dao.saveUser(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
            // 
            itemButton.setVisibility(View.GONE);
            itemMessage.setVisibility(View.VISIBLE);
            statusItem.setText(R.string.function_list_confirmed);
        }

        @Override
        public void onMyError(VolleyError result) {

        }
    });
}

From source file:com.taobao.datax.engine.conf.ParseXMLUtil.java

License:Open Source License

/**
 * Parse dataX job configuration file.//  w ww  . j a  v a2 s . com
 * 
 * @param filename
 *            Job configure filename.
 * 
 * @return a JobConf instance which describes this Job configuration file.
 * 
 * */
@SuppressWarnings("unchecked")
public static JobConf loadJobConfig(String filename) {
    JobConf job = new JobConf();
    Document document;
    try {
        String xml = FileUtils.readFileToString(new File(filename), "UTF-8");
        document = DocumentHelper.parseText(xml);
    } catch (DocumentException e) {
        LOG.error("DataX Can not find " + filename + " .");
        throw new DataExchangeException(e.getCause());
    } catch (IOException e) {
        LOG.error(String.format("DataX read config file %s failed .", filename));
        throw new DataExchangeException(e.getCause());
    }

    String xpath = "/jobs/job";
    Element jobE = (Element) document.selectSingleNode(xpath);
    job.setId(jobE.attributeValue("id") == null ? "DataX_is_still_a_virgin" : jobE.attributeValue("id").trim());

    JobPluginConf readerJobConf = new JobPluginConf();
    Element readerE = (Element) document.selectSingleNode(xpath + "/loader");
    if (null == readerE)
        readerE = (Element) document.selectSingleNode(xpath + "/reader");

    String readerId = readerE.attributeValue("id");
    readerJobConf.setId(readerId == null ? "virgin-reader" : readerId.trim());
    Element readerPluinE = (Element) readerE.selectSingleNode("plugin");
    readerJobConf.setName(readerPluinE.getStringValue().trim().replace("loader", "reader").toLowerCase());

    Map<String, String> readerParamMap = new HashMap<String, String>();

    /*
     * for historic reason, we need to check concurrency node first add by
     * bazhen.csy
     */
    if (readerE.selectSingleNode("concurrency") != null) {
        Element readerConcurrencyE = (Element) readerE.selectSingleNode("concurrency");
        readerParamMap.put("concurrency", StrUtils.replaceString(readerConcurrencyE.attributeValue("core")));
    }

    List<Element> readerParamE = (List<Element>) readerE.selectNodes("param");
    for (Element e : readerParamE) {
        readerParamMap.put(e.attributeValue("key").toLowerCase(),
                StrUtils.replaceString(e.attributeValue("value").trim()));
    }

    PluginParam readerPluginParam = new DefaultPluginParam(readerParamMap);

    //      if (!readerPluginParam.hasValue("concurrency")
    //            || readerPluginParam.getIntValue("concurrency", 1) < 0) {
    //         throw new IllegalArgumentException(
    //               "Reader option [concurrency] error !");
    //      }

    readerJobConf.setPluginParams(readerPluginParam);

    List<JobPluginConf> writerJobConfs = new ArrayList<JobPluginConf>();
    List<Element> writerEs = (List<Element>) document.selectNodes(xpath + "/dumper");
    if (null == writerEs || 0 == writerEs.size())
        writerEs = (List<Element>) document.selectNodes(xpath + "/writer");

    for (Element writerE : writerEs) {
        JobPluginConf writerPluginConf = new JobPluginConf();

        String writerId = writerE.attributeValue("id");
        writerPluginConf.setId(writerId == null ? "virgin-writer" : writerId.trim());

        String destructLimit = writerE.attributeValue("destructlimit");
        if (destructLimit != null) {
            writerPluginConf.setDestructLimit(Integer.valueOf(destructLimit));
        }

        Element writerPluginE = (Element) writerE.selectSingleNode("plugin");
        writerPluginConf
                .setName(writerPluginE.getStringValue().trim().replace("dumper", "writer").toLowerCase());

        Map<String, String> writerParamMap = new HashMap<String, String>();

        /*
         * for historic reason, we need to check concurrency node add by
         * bazhen.csy
         */
        if (writerE.selectSingleNode("concurrency") != null) {
            Element writerConcurrencyE = (Element) writerE.selectSingleNode("concurrency");
            writerParamMap.put("concurrency",
                    StrUtils.replaceString(writerConcurrencyE.attributeValue("core")));
        }

        List<Element> writerParamE = (List<Element>) writerE.selectNodes("param");
        for (Element e : writerParamE) {
            writerParamMap.put(e.attributeValue("key").toLowerCase(),
                    StrUtils.replaceString(e.attributeValue("value").trim()));
        }

        PluginParam writerPluginParam = new DefaultPluginParam(writerParamMap);

        writerPluginConf.setPluginParams(writerPluginParam);
        writerJobConfs.add(writerPluginConf);
    }

    job.setReaderConf(readerJobConf);
    job.setWriterConfs(writerJobConfs);

    return job;
}

From source file:com.thinkberg.webdav.data.DavResource.java

License:Apache License

/**
 * Add the value for a given property to the result document. If the value
 * is missing or can not be added for some reason it will return false to
 * indicate a missing property./*from  w w  w .  ja  va  2s . com*/
 *
 * @param root         the root element for the result document fragment
 * @param propertyName the property name to query
 * @return true for successful addition and false for missing data
 */
protected boolean getPropertyValue(Element root, String propertyName, boolean ignoreValue) {
    LogFactory.getLog(getClass()).debug(String.format("[%s].get('%s')", object.getName(), propertyName));
    if (PROP_CREATION_DATE.equals(propertyName)) {
        return addCreationDateProperty(root, ignoreValue);
    } else if (PROP_DISPLAY_NAME.equals(propertyName)) {
        return addGetDisplayNameProperty(root, ignoreValue);
    } else if (PROP_GET_CONTENT_LANGUAGE.equals(propertyName)) {
        return addGetContentLanguageProperty(root, ignoreValue);
    } else if (PROP_GET_CONTENT_LENGTH.equals(propertyName)) {
        return addGetContentLengthProperty(root, ignoreValue);
    } else if (PROP_GET_CONTENT_TYPE.equals(propertyName)) {
        return addGetContentTypeProperty(root, ignoreValue);
    } else if (PROP_GET_ETAG.equals(propertyName)) {
        return addGetETagProperty(root, ignoreValue);
    } else if (PROP_GET_LAST_MODIFIED.equals(propertyName)) {
        return addGetLastModifiedProperty(root, ignoreValue);
    } else if (PROP_LOCK_DISCOVERY.equals(propertyName)) {
        return addLockDiscoveryProperty(root, ignoreValue);
    } else if (PROP_RESOURCETYPE.equals(propertyName)) {
        return addResourceTypeProperty(root, ignoreValue);
    } else if (PROP_SOURCE.equals(propertyName)) {
        return addSourceProperty(root, ignoreValue);
    } else if (PROP_SUPPORTED_LOCK.equals(propertyName)) {
        return addSupportedLockProperty(root, ignoreValue);
    } else {
        // handle non-standard properties (keep a little separate)
        if (PROP_QUOTA.equals(propertyName)) {
            return addQuotaProperty(root, ignoreValue);
        } else if (PROP_QUOTA_USED.equals(propertyName)) {
            return addQuotaUsedProperty(root, ignoreValue);
        } else if (PROP_QUOTA_AVAILABLE_BYTES.equals(propertyName)) {
            return addQuotaAvailableBytesProperty(root, ignoreValue);
        } else if (PROP_QUOTA_USED_BYTES.equals(propertyName)) {
            return addQuotaUsedBytesProperty(root, ignoreValue);
        } else {
            try {
                Object propertyValue = object.getContent().getAttribute(propertyName);
                if (null != propertyValue) {
                    if (((String) propertyValue).startsWith("<")) {
                        try {
                            Document property = DocumentHelper.parseText((String) propertyValue);
                            if (ignoreValue) {
                                property.clearContent();
                            }
                            root.add(property.getRootElement().detach());
                            return true;
                        } catch (DocumentException e) {
                            LogFactory.getLog(getClass()).error("property value unparsable", e);
                            return false;
                        }
                    } else {
                        Element el = root.addElement(propertyName);
                        if (!ignoreValue) {
                            el.addText((String) propertyValue);
                        }
                        return true;
                    }

                }
            } catch (FileSystemException e) {
                LogFactory.getLog(this.getClass())
                        .error(String.format("property '%s' is not supported", propertyName), e);
            }
        }
    }

    return false;
}

From source file:com.thoughtworks.go.helper.ConfigFileFixture.java

License:Apache License

public static String addLicense(String config, String user, String license) {
    try {//from   w w  w.  j  a va 2 s .  c om
        Document document = DocumentHelper.parseText(config);
        return addLicense(document, user, license);
    } catch (DocumentException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.topsec.tsm.common.message.CommandHandlerUtil.java

public static Serializable handleChildUpgrade(Serializable obj, NodeMgrFacade nodeMgrFacade) {
    // TODO Auto-generated method stub
    Map<String, String> args = (Map<String, String>) obj;
    try {/*from  w  ww  . j a v a  2  s  .c om*/
        Node node = nodeMgrFacade.getParentNode();
        if (node == null)
            node = nodeMgrFacade.getKernelAuditor(false);
        String path = "https://" + node.getIp() + "/resteasy/upgrade/queryPatch";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("version", args.get("version").toString());
        String receviveInfo = HttpUtil.doPostWithSSLByMap(path, params, null, "UTF-8");
        if (StringUtil.isNotBlank(receviveInfo)) {
            Document document = DocumentHelper.parseText(receviveInfo);
            Element root = document.getRootElement();
            int port = Integer.parseInt(root.attributeValue("port"));
            String host = root.attributeValue("host");
            String user = root.attributeValue("user");
            String password = root.attributeValue("password");
            String home = root.attributeValue("home");
            String patch = root.attributeValue("patch");
            String encoding = root.attributeValue("encoding");

            //make patch directory   
            FileUtils.forceMkdir(new File(SystemDefinition.DEFAULT_INSTALL_DIR, "patch"));
            String patchDir = new File(SystemDefinition.DEFAULT_INSTALL_DIR, "patch").getAbsolutePath();
            //download patch file
            FtpUploadUtil.downFile(host, port, user, password, encoding, home, patch, patchDir);

            //??(auditor\service\reportserv\smp)
            restartAllNode(nodeMgrFacade);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}