Example usage for org.dom4j Element elementText

List of usage examples for org.dom4j Element elementText

Introduction

In this page you can find the example usage for org.dom4j Element elementText.

Prototype

String elementText(QName qname);

Source Link

Usage

From source file:com.google.jenkins.flakyTestHandler.junit.FlakySuiteResult.java

License:Open Source License

/**
 * @param xmlReport//  w  w  w . java 2 s .  c  om
 *      A JUnit XML report file whose top level element is 'testsuite'.
 * @param suite
 *      The parsed result of {@code xmlReport}
 */
private FlakySuiteResult(File xmlReport, Element suite, boolean keepLongStdio)
        throws DocumentException, IOException {
    this.file = xmlReport.getAbsolutePath();
    String name = suite.attributeValue("name");
    if (name == null)
        // some user reported that name is null in their environment.
        // see http://www.nabble.com/Unexpected-Null-Pointer-Exception-in-Hudson-1.131-tf4314802.html
        name = '(' + xmlReport.getName() + ')';
    else {
        String pkg = suite.attributeValue("package");
        if (pkg != null && pkg.length() > 0)
            name = pkg + '.' + name;
    }
    this.name = TestObject.safe(name);
    this.timestamp = suite.attributeValue("timestamp");
    this.id = suite.attributeValue("id");

    Element ex = suite.element("error");
    if (ex != null) {
        // according to junit-noframes.xsl l.229, this happens when the test class failed to load
        addCase(new FlakyCaseResult(this, suite, "<init>", keepLongStdio));
    }

    @SuppressWarnings("unchecked")
    List<Element> testCases = (List<Element>) suite.elements("testcase");
    for (Element e : testCases) {
        // https://issues.jenkins-ci.org/browse/JENKINS-1233 indicates that
        // when <testsuites> is present, we are better off using @classname on the
        // individual testcase class.

        // https://issues.jenkins-ci.org/browse/JENKINS-1463 indicates that
        // @classname may not exist in individual testcase elements. We now
        // also test if the testsuite element has a package name that can be used
        // as the class name instead of the file name which is default.
        String classname = e.attributeValue("classname");
        if (classname == null) {
            classname = suite.attributeValue("name");
        }

        // https://issues.jenkins-ci.org/browse/JENKINS-1233 and
        // http://www.nabble.com/difference-in-junit-publisher-and-ant-junitreport-tf4308604.html#a12265700
        // are at odds with each other --- when both are present,
        // one wants to use @name from <testsuite>,
        // the other wants to use @classname from <testcase>.

        addCase(new FlakyCaseResult(this, e, classname, keepLongStdio));
    }

    String stdout = FlakyCaseResult.possiblyTrimStdio(cases, keepLongStdio, suite.elementText("system-out"));
    String stderr = FlakyCaseResult.possiblyTrimStdio(cases, keepLongStdio, suite.elementText("system-err"));
    if (stdout == null && stderr == null) {
        // Surefire never puts stdout/stderr in the XML. Instead, it goes to a separate file (when ${maven.test.redirectTestOutputToFile}).
        Matcher m = SUREFIRE_FILENAME.matcher(xmlReport.getName());
        if (m.matches()) {
            // look for ***-output.txt from TEST-***.xml
            File mavenOutputFile = new File(xmlReport.getParentFile(), m.group(1) + "-output.txt");
            if (mavenOutputFile.exists()) {
                try {
                    stdout = FlakyCaseResult.possiblyTrimStdio(cases, keepLongStdio, mavenOutputFile);
                } catch (IOException e) {
                    throw new IOException("Failed to read " + mavenOutputFile, e);
                }
            }
        }
    }

    this.stdout = stdout;
    this.stderr = stderr;
}

From source file:com.hand.hemp.push.server.xmpp.handler.IQAuthHandler.java

License:Open Source License

/**
 * Handles the received IQ packet./*from   w ww. java  2 s .co  m*/
 * 
 * @param packet the packet
 * @return the response to send back
 * @throws UnauthorizedException if the user is not authorized
 */
public IQ handleIQ(IQ packet) throws UnauthorizedException {
    IQ reply = null;

    ClientSession session = sessionManager.getSession(packet.getFrom());
    if (session == null) {
        log.error("Session not found for key " + packet.getFrom());
        reply = IQ.createResultIQ(packet);
        reply.setChildElement(packet.getChildElement().createCopy());
        reply.setError(PacketError.Condition.internal_server_error);
        return reply;
    }

    try {
        Element iq = packet.getElement();
        Element query = iq.element("query");
        Element queryResponse = probeResponse.createCopy();

        if (IQ.Type.get == packet.getType()) { // get query
            String username = query.elementText("username");
            if (username != null) {
                queryResponse.element("username").setText(username);
            }
            reply = IQ.createResultIQ(packet);
            reply.setChildElement(queryResponse);
            if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
                reply.setTo((JID) null);
            }
        } else { // set query
            String resource = query.elementText("resource");
            String username = query.elementText("username");
            String password = query.elementText("password");
            String digest = null;
            if (query.element("digest") != null) {
                digest = query.elementText("digest").toLowerCase();
            }

            // Verify the resource
            if (resource != null) {
                try {
                    resource = JID.resourceprep(resource);
                } catch (StringprepException e) {
                    throw new UnauthorizedException("Invalid resource: " + resource, e);
                }
            } else {
                throw new IllegalArgumentException("Invalid resource (empty or null).");
            }

            // Verify the username
            if (username == null || username.trim().length() == 0) {
                throw new UnauthorizedException("Invalid username (empty or null).");
            }
            try {
                Stringprep.nodeprep(username);
            } catch (StringprepException e) {
                throw new UnauthorizedException("Invalid username: " + username, e);
            }
            username = username.toLowerCase();

            // Verify that username and password are correct
            AuthToken token = null;
            if (password != null && AuthManager.isPlainSupported()) {
                token = AuthManager.authenticate(username, password);
            } else if (digest != null && AuthManager.isDigestSupported()) {
                token = AuthManager.authenticate(username, session.getStreamID().toString(), digest);
            }

            if (token == null) {
                throw new UnauthenticatedException();
            }

            // Set the session authenticated successfully
            session.setAuthToken(token, resource);
            packet.setFrom(session.getAddress());
            reply = IQ.createResultIQ(packet);

            // update last login date
            if (username != null && !"".equals(username)) {
                HpnsClient client = clientService.getUserByUsername(username);
                log.debug("update client last login date with client: " + client);
                if (client != null) {
                    client.setLastLoginDate(new Date());
                    clientService.updateUser(client);
                }
            }
        }
    } catch (Exception ex) {
        log.error(ex);
        ex.printStackTrace();
        reply = IQ.createResultIQ(packet);
        reply.setChildElement(packet.getChildElement().createCopy());
        if (ex instanceof IllegalArgumentException) {
            reply.setError(PacketError.Condition.not_acceptable);
        } else if (ex instanceof UnauthorizedException) {
            reply.setError(PacketError.Condition.not_authorized);
        } else if (ex instanceof UnauthenticatedException) {
            reply.setError(PacketError.Condition.not_authorized);
        } else {
            reply.setError(PacketError.Condition.internal_server_error);
        }
    }

    // Send the response directly to the session
    if (reply != null) {
        session.process(reply);
    }
    return null;
}

From source file:com.hand.hemp.push.server.xmpp.handler.IQRegisterHandler.java

License:Open Source License

/**
 * Handles the received IQ packet.//w w  w. j  a  v a2 s.c o  m
 *
 * @param packet the packet
 * @return the response to send back
 * @throws UnauthorizedException if the client is not authorized
 */
public IQ handleIQ(IQ packet) throws UnauthorizedException {
    IQ reply = null;

    ClientSession session = sessionManager.getSession(packet.getFrom());
    if (session == null) {
        log.error("Session not found for key " + packet.getFrom());
        reply = IQ.createResultIQ(packet);
        reply.setChildElement(packet.getChildElement().createCopy());
        reply.setError(PacketError.Condition.internal_server_error);
        return reply;
    }

    if (IQ.Type.get.equals(packet.getType())) {
        reply = IQ.createResultIQ(packet);
        if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
            // TODO
        } else {
            reply.setTo((JID) null);
            reply.setChildElement(probeResponse.createCopy());
        }
    } else if (IQ.Type.set.equals(packet.getType())) {
        try {
            Element query = packet.getChildElement();
            if (query.element("remove") != null) {
                if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
                    // TODO
                } else {
                    throw new UnauthorizedException();
                }
            } else {
                // generate username from server side
                //String username = query.elementText("username");
                String username = null;
                String password = query.elementText("password");
                String email = query.elementText("email");
                String name = query.elementText("name");
                String androidId = query.elementText("androidId");
                String resourceName = query.elementText("resourceName");

                // Deny registration if androidId is null or resourceName is null
                if (androidId == null || "".equals(androidId) || resourceName == null
                        || "".equals(resourceName)) {
                    reply = IQ.createResultIQ(packet);
                    reply.setChildElement(packet.getChildElement().createCopy());
                    reply.setError(PacketError.Condition.not_acceptable);
                    return reply;
                } else {
                    username = IQRegisterHandler.genUsername(androidId, resourceName);
                    log.debug("generated username: " + username);
                }

                // removed because username generate on server
                if (username != null) {
                    Stringprep.nodeprep(username);
                }

                // Deny registration of users with no password
                if (password == null || password.trim().length() == 0) {
                    reply = IQ.createResultIQ(packet);
                    reply.setChildElement(packet.getChildElement().createCopy());
                    reply.setError(PacketError.Condition.not_acceptable);
                    return reply;
                }

                if (email != null && email.matches("\\s*")) {
                    email = null;
                }

                if (name != null && name.matches("\\s*")) {
                    name = null;
                }

                HpnsClient client;
                boolean updateHpnsClient = false;
                if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
                    client = clientService.getUser(Long.valueOf(session.getUsername()));
                    updateHpnsClient = true;
                } else {
                    try {
                        client = clientService.getUserByUsername(username);
                        log.debug("update exist client");
                        updateHpnsClient = true;
                    } catch (UserNotFoundException unfe) {
                        log.debug("create new client: " + unfe.getMessage());
                        client = new HpnsClient();
                    }
                }
                client.setPassword(password);
                client.setEmail(email);
                client.setName(name);
                client.setAndroidId(androidId);
                client.setResourceName(resourceName);
                if (updateHpnsClient) {
                    client.setLastUpdatedBy("system");
                    client.setLastUpdateDate(new Date());
                    clientService.updateUser(client);
                } else {
                    client.setUsername(username);
                    client.setCreatedBy("system");
                    client.setRegDate(new Date());
                    clientService.saveUser(client);
                }

                //                    HpnsClient hpnsClient;
                //                    if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
                //                        hpnsClient = hpnsClientFacade.getClientByUsername(session.getUsername());
                //                    } else {
                //                        hpnsClient = new HpnsClient();
                //                    }
                //                    hpnsClient.setUsername(username);
                //                    hpnsClient.setPassword(password);
                //                    hpnsClient.setEmail(email);
                //                    hpnsClient.setName(name);
                //                    hpnsClientFacade.create(hpnsClient);
                reply = IQ.createResultIQ(packet);
                DOMElement queryEle = new DOMElement("query", Namespace.get("jabber:iq:register"));
                DOMElement usernameEle = new DOMElement("username", Namespace.get("jabber:iq:register"));
                usernameEle.setText(username);
                queryEle.add(usernameEle);
                reply.setChildElement(queryEle);
            }
        } catch (Exception ex) {
            log.error(ex);
            reply = IQ.createResultIQ(packet);
            reply.setChildElement(packet.getChildElement().createCopy());
            if (ex instanceof UserExistsException) {
                reply.setError(PacketError.Condition.conflict);
            } else if (ex instanceof UserNotFoundException) {
                reply.setError(PacketError.Condition.bad_request);
            } else if (ex instanceof StringprepException) {
                reply.setError(PacketError.Condition.jid_malformed);
            } else if (ex instanceof IllegalArgumentException) {
                reply.setError(PacketError.Condition.not_acceptable);
            } else {
                reply.setError(PacketError.Condition.internal_server_error);
            }
        }
    }

    // Send the response directly to the session
    if (reply != null) {
        session.process(reply);
    }
    return null;
}

From source file:com.haulmont.cuba.desktop.sys.DesktopExternalUIComponentsSource.java

License:Apache License

@SuppressWarnings("unchecked")
protected void _registerComponent(InputStream is) throws ClassNotFoundException {
    ClassLoader classLoader = App.class.getClassLoader();

    Element rootElement = Dom4j.readDocument(is).getRootElement();
    List<Element> components = rootElement.elements("component");
    for (Element component : components) {
        String name = trimToEmpty(component.elementText("name"));
        String componentClassName = trimToEmpty(component.elementText("class"));

        String componentLoaderClassName = trimToEmpty(component.elementText("componentLoader"));
        String tag = trimToEmpty(component.elementText("tag"));
        if (StringUtils.isEmpty(tag)) {
            tag = name;/*from ww w  . j  a  va  2  s .c  o m*/
        }

        if (StringUtils.isEmpty(name) && StringUtils.isEmpty(tag)) {
            log.warn("You have to provide name or tag for custom component");
            // skip this <component> element
            continue;
        }

        if (StringUtils.isEmpty(componentLoaderClassName) && StringUtils.isEmpty(componentClassName)) {
            log.warn("You have to provide at least <class> or <componentLoader> for custom component {} / <{}>",
                    name, tag);
            // skip this <component> element
            continue;
        }

        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(componentClassName)) {
            Class<?> componentClass = classLoader.loadClass(componentClassName);

            if (Component.class.isAssignableFrom(componentClass)) {
                log.trace("Register component {} class {}", name, componentClass.getCanonicalName());

                DesktopComponentsFactory.registerComponent(name, (Class<? extends Component>) componentClass);
            } else {
                log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component",
                        componentClassName);
            }
        }

        if (StringUtils.isNotEmpty(tag) && StringUtils.isNotEmpty(componentLoaderClassName)) {
            Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);

            if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
                log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());

                LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
            } else {
                log.warn(
                        "Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
                        componentLoaderClassName);
            }
        }
    }

    _loadWindowLoaders(rootElement);
}

From source file:com.haulmont.cuba.web.sys.ExternalUIComponentsManager.java

License:Apache License

protected void _registerComponents(String componentDescriptorPath) throws IOException, ClassNotFoundException {
    Enumeration<URL> resources = ExternalUIComponentsManager.class.getClassLoader()
            .getResources(componentDescriptorPath);
    while (resources.hasMoreElements()) {
        URL url = resources.nextElement();
        try (InputStream is = url.openStream()) {
            Document document = Dom4j.readDocument(is);
            List<Element> components = document.getRootElement().elements("component");
            for (Element component : components) {
                String name = component.elementText("name");
                String componentLoaderClassName = component.elementText("componentLoader");
                String componentClassName = component.elementText("class");

                Class<?> componentLoaderClass = Class.forName(componentLoaderClassName);
                Class<?> componentClass = Class.forName(componentClassName);

                if (Component.class.isAssignableFrom(componentClass)) {
                    WebComponentsFactory.registerComponent(name, (Class<? extends Component>) componentClass);
                } else {
                    log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component",
                            componentClassName);
                }//from w  w  w  . ja v a2s .  c  om

                if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
                    LayoutLoaderConfig.registerLoader(name,
                            (Class<? extends ComponentLoader>) componentLoaderClass);
                } else {
                    log.warn(
                            "Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
                            componentLoaderClassName);
                }
            }
        }
    }
}

From source file:com.haulmont.cuba.web.sys.WebExternalUIComponentsSource.java

License:Apache License

@SuppressWarnings("unchecked")
protected void _registerComponent(InputStream is) throws ClassNotFoundException {
    ClassLoader classLoader = App.class.getClassLoader();

    Element rootElement = Dom4j.readDocument(is).getRootElement();
    List<Element> components = rootElement.elements("component");
    for (Element component : components) {
        String name = trimToEmpty(component.elementText("name"));
        String componentClassName = trimToEmpty(component.elementText("class"));

        String componentLoaderClassName = trimToEmpty(component.elementText("componentLoader"));
        String tag = trimToEmpty(component.elementText("tag"));
        if (StringUtils.isEmpty(tag)) {
            tag = name;/*from   w  w  w. j  a v  a 2s .  co  m*/
        }

        if (StringUtils.isEmpty(name) && StringUtils.isEmpty(tag)) {
            log.warn("You have to provide name or tag for custom component");
            // skip this <component> element
            continue;
        }

        if (StringUtils.isEmpty(componentLoaderClassName) && StringUtils.isEmpty(componentClassName)) {
            log.warn("You have to provide at least <class> or <componentLoader> for custom component {} / <{}>",
                    name, tag);
            // skip this <component> element
            continue;
        }

        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(componentClassName)) {
            Class<?> componentClass = classLoader.loadClass(componentClassName);

            if (Component.class.isAssignableFrom(componentClass)) {
                log.trace("Register component {} class {}", name, componentClass.getCanonicalName());

                webComponentsFactory.register(name, (Class<? extends Component>) componentClass);
            } else {
                log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component",
                        componentClassName);
            }
        }

        if (StringUtils.isNotEmpty(tag) && StringUtils.isNotEmpty(componentLoaderClassName)) {
            Class<?> componentLoaderClass = classLoader.loadClass(componentLoaderClassName);

            if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
                log.trace("Register tag {} loader {}", tag, componentLoaderClass.getCanonicalName());

                LayoutLoaderConfig.registerLoader(tag, (Class<? extends ComponentLoader>) componentLoaderClass);
            } else {
                log.warn(
                        "Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
                        componentLoaderClassName);
            }
        }
    }

    _loadWindowLoaders(rootElement);
}

From source file:com.haulmont.restapi.config.RestQueriesConfiguration.java

License:Apache License

protected void loadConfig(Element rootElem) {
    for (Element queryElem : Dom4j.elements(rootElem, "query")) {
        String queryName = queryElem.attributeValue("name");
        if (ALL_ENTITIES_QUERY_NAME.equalsIgnoreCase(queryName)) {
            log.error("{} is a predefined query name. It can not be used.", queryName);
            continue;
        }/*from   w w  w .j  a  va2 s  .co m*/
        String entityName = queryElem.attributeValue("entity");
        String viewName = queryElem.attributeValue("view");
        String jpql = queryElem.elementText("jpql");

        if (Strings.isNullOrEmpty(queryName)) {
            log.error("queryName attribute is not defined");
            continue;
        }
        if (Strings.isNullOrEmpty(entityName)) {
            log.error("entityName attribute is not defined");
            continue;
        }
        if (Strings.isNullOrEmpty(viewName)) {
            log.error("viewName attribute is not defined");
            continue;
        }
        if (Strings.isNullOrEmpty(jpql)) {
            log.error("Query jpql is not defined");
            continue;
        }

        QueryInfo queryInfo = new QueryInfo();
        queryInfo.setName(queryName);
        queryInfo.setEntityName(entityName);
        queryInfo.setViewName(viewName);
        queryInfo.setJpql(jpql);

        Element paramsEl = queryElem.element("params");
        if (paramsEl != null) {
            for (Element paramElem : Dom4j.elements(paramsEl, "param")) {
                String paramName = paramElem.attributeValue("name");
                String paramType = paramElem.attributeValue("type");
                QueryParamInfo param = new QueryParamInfo(paramName, paramType);
                queryInfo.getParams().add(param);
            }
        }

        queries.add(queryInfo);
    }
}

From source file:com.haulmont.restapi.query.RestQueriesManager.java

License:Apache License

protected void loadConfig(Element rootElem) {
    for (Element queryElem : Dom4j.elements(rootElem, "query")) {
        String queryName = queryElem.attributeValue("name");
        String entityName = queryElem.attributeValue("entity");
        String viewName = queryElem.attributeValue("view");
        String jpql = queryElem.elementText("jpql");

        QueryInfo queryInfo = new QueryInfo();
        queryInfo.setName(queryName);//w  w  w. ja v a 2  s. com
        queryInfo.setEntityName(entityName);
        queryInfo.setViewName(viewName);
        queryInfo.setJpql(jpql);

        Element paramsEl = queryElem.element("params");
        for (Element paramElem : Dom4j.elements(paramsEl, "param")) {
            String paramName = paramElem.attributeValue("name");
            String paramType = paramElem.attributeValue("type");
            QueryParamInfo param = new QueryParamInfo(paramName, paramType);
            queryInfo.getParams().add(param);
        }

        queries.add(queryInfo);
    }
}

From source file:com.hrbb.loan.pos.biz.backstage.inter.impl.PoliceAndAICConnectBizImpl.java

@SuppressWarnings("unchecked")
@Override/*from w  w  w  .  j av  a2 s.  co m*/
public Map<String, String> getAICInfo(Map<String, String> reqMap) throws Exception {
    // ? 0, 1
    String queryTime = reqMap.get("queryTime");
    int flag = 0;
    String posCustId = reqMap.get("posCustId");
    String posCustName = reqMap.get("posCustName");
    String resXmlBefore = reqMap.get("resXml");
    String keyString = resXmlBefore.substring(resXmlBefore.indexOf("<KEY>"), resXmlBefore.indexOf("</KEY>"))
            .replaceAll("<KEY>", "").trim();
    String valueString = resXmlBefore.substring(resXmlBefore.indexOf("<VALUE>"), resXmlBefore.indexOf("/VALUE"))
            .replaceAll("<VALUE>", "").trim();
    // RSA
    String desDecryptKey = RSAEncryption.PublicDecrypt(keyString);
    logger.debug("RSA?:" + desDecryptKey);
    // des
    String resXml = new Authcode().AuthcodeDecode(valueString, desDecryptKey);
    resXml = URLDecoder.decode(resXml, "UTF-8");
    logger.debug("des?:" + resXml);
    if (StringUtil.isEmpty(resXml)) {
        Map<String, String> resMap = Maps.newHashMap();
        resMap.put("resCode", "01");
        resMap.put("resMsg", "");
        return resMap;
    } else {
        // 
        if (resXml.indexOf("ERRORCODE") >= 0) {
            logger.error(".resCode:"
                    + resXml.substring(resXml.indexOf("<ERRORCODE>"), resXml.indexOf("</ERRORCODE>"))
                            .replace("<ERRORCODE>", "")
                    + "resMsg:" + resXml.substring(resXml.indexOf("<ERRORMSG>"), resXml.indexOf("</ERRORMSG>"))
                            .replace("<ERRORMSG>", ""));
            Map<String, String> resMap = Maps.newHashMap();
            resMap.put("resCode", "01");
            resMap.put("resMsg", resXml.substring(resXml.indexOf("<ERRORMSG>"), resXml.indexOf("</ERRORMSG>"))
                    .replace("<ERRORMSG>", ""));
            return resMap;
        }
        Document document = Dom4jUtil.getDocumentFromText(resXml);
        Element root = Dom4jUtil.getRootElement(document);
        String orderNo = "";
        if (root.element("ORDERLIST") != null && root.element("ORDERLIST").element("ITEM") != null) {
            Element orderListEle = root.element("ORDERLIST").element("ITEM");
            // orderList?
            Map<String, Object> orderListMap = Maps.newHashMap();
            orderNo = orderListEle.element("ORDERNO").getText();
            orderListMap.put("queryUid", orderListEle.element("UID").getText());
            orderListMap.put("orderNo", orderNo);
            orderListMap.put("posCustId", posCustId);
            orderListMap.put("posCustName", posCustName);
            orderListMap.put("keyName", orderListEle.elementText("KEY"));
            orderListMap.put("keyType", orderListEle.element("KEYTYPE").getText());
            orderListMap.put("status", orderListEle.element("STATUS").getText());
            orderListMap.put("finishTime", orderListEle.elementText("FINISHTIME"));
            orderListMap.put("queryTime", queryTime);
            policeAndAICConnectService.insertAICOrderlistInfo(orderListMap);
        }
        // ???
        if (root.element("BASIC") != null && root.element("BASIC").element("ITEM") != null) {
            Element basicEle = root.element("BASIC").element("ITEM");
            Map<String, Object> basicMap = Maps.newHashMap();
            basicMap.put("posCustId", posCustId);
            basicMap.put("orderNo", orderNo);
            basicMap.put("entName", basicEle.elementText("ENTNAME"));
            basicMap.put("frName", basicEle.elementText("FRNAME"));
            basicMap.put("regNo", basicEle.elementText("REGNO"));
            basicMap.put("oriRegNo", basicEle.elementText("ORIREGNO"));
            basicMap.put("orgCodes", basicEle.elementText("ORGCODES"));
            basicMap.put("regCap", basicEle.elementText("REGCAP"));
            basicMap.put("recCap", basicEle.elementText("RECCAP"));
            basicMap.put("regCapCur", basicEle.elementText("REGCAPCUR"));
            basicMap.put("entStatus", basicEle.elementText("ENTSTATUS"));
            basicMap.put("entType", basicEle.elementText("ENTTYPE"));
            basicMap.put("esDate", basicEle.elementText("ESDATE"));
            basicMap.put("opFrom", basicEle.elementText("OPFROM"));
            basicMap.put("opTo", basicEle.elementText("OPTO"));
            basicMap.put("addr", basicEle.elementText("DOM"));
            basicMap.put("regOrg", basicEle.elementText("REGORG"));
            basicMap.put("abuiTem", basicEle.elementText("ABUITEM"));
            basicMap.put("cbuiTem", basicEle.elementText("CBUITEM"));
            basicMap.put("opScope", basicEle.elementText("OPSCOPE"));
            basicMap.put("opScoAndForm", basicEle.elementText("OPSCOANDFORM"));
            basicMap.put("anCheYear", basicEle.elementText("ANCHEYEAR"));
            basicMap.put("canDate", basicEle.elementText("CANDATE"));
            basicMap.put("revDate", basicEle.elementText("REVDATE"));
            basicMap.put("anCheDate", basicEle.elementText("ANCHEDATE"));
            basicMap.put("industryPhyCode", basicEle.elementText("INDUSTRYPHYCODE"));
            basicMap.put("industryCoCode", basicEle.elementText("INDUSTRYCOCODE"));
            basicMap.put("cdId", basicEle.elementText("CDID"));
            logger.debug(posCustName + "??");
            policeAndAICConnectService.insertAICBasicInfo(basicMap);
            logger.debug(posCustName + "???");
            logger.debug(posCustName + "?");
            Map<String, Object> posCustUpMap = Maps.newHashMap();
            logger.debug("?:" + posCustId);
            posCustUpMap.put("posCustId", posCustId);
            posCustUpMap.put("legalPersonName", basicEle.elementText("FRNAME"));
            posCustUpMap.put("regCapital",
                    new BigDecimal(
                            basicEle.elementText("REGCAP") == null ? "0" : basicEle.elementText("REGCAP"))
                                    .multiply(new BigDecimal("10000")).toString());
            posCustUpMap.put("industryTypeId",
                    (basicEle.elementText("INDUSTRYPHYCODE") == null ? ""
                            : basicEle.elementText("INDUSTRYPHYCODE"))
                            + (basicEle.elementText("INDUSTRYCOCODE") == null ? ""
                                    : basicEle.elementText("INDUSTRYCOCODE")));
            posCustUpMap.put("registDate", basicEle.elementText("ESDATE"));
            loanPosCreditApplyService.updatePosCustByPrimaryKeySelectiveMap(posCustUpMap);
            logger.debug(posCustName + "??");

        }
        if (root.element("SHAREHOLDER") != null && root.element("SHAREHOLDER").elements("ITEM") != null) {
            // ?
            List<Element> shareHolderEle = root.element("SHAREHOLDER").elements("ITEM");
            for (Element element : shareHolderEle) {

                Map<String, Object> shareHolderMap = Maps.newHashMap();
                shareHolderMap.put("posCustId", posCustId);
                shareHolderMap.put("orderNo", orderNo);
                shareHolderMap.put("shaName", element.elementText("SHANAME"));
                shareHolderMap.put("subConAm", element.elementText("SUBCONAM"));
                shareHolderMap.put("regCapCur", element.elementText("REGCAPCUR"));
                shareHolderMap.put("funDedRatio", element.elementText("FUNDEDRATIO"));
                shareHolderMap.put("conDate", element.elementText("CONDATE"));
                shareHolderMap.put("cdId", element.elementText("CDID"));
                policeAndAICConnectService.insertAICShareHolder(shareHolderMap);

            }
        }
        // ????
        if (root.element("PERSON") != null && root.element("PERSON").elements("ITEM") != null) {
            List<Element> personEle = root.element("PERSON").elements("ITEM");
            for (Element element : personEle) {

                Map<String, Object> personMap = Maps.newHashMap();
                personMap.put("posCustId", posCustId);
                personMap.put("orderNo", orderNo);
                personMap.put("perName", element.elementText("PERNAME"));
                personMap.put("position", element.elementText("POSITION"));
                personMap.put("cdId", element.elementText("CDID"));
                policeAndAICConnectService.insertAICPersonInfo(personMap);

            }
        }

        // ??
        if (root.element("FRINV") != null && root.element("FRINV").elements("ITEM") != null) {
            List<Element> frinvEle = root.element("FRINV").elements("ITEM");
            for (Element element : frinvEle) {

                Map<String, Object> frinvMap = Maps.newHashMap();
                frinvMap.put("posCustId", posCustId);
                frinvMap.put("orderNo", orderNo);
                frinvMap.put("name", element.elementText("NAME"));
                frinvMap.put("entName", element.elementText("ENTNAME"));
                frinvMap.put("regNo", element.elementText("REGNO"));
                frinvMap.put("entType", element.elementText("ENTTYPE"));
                frinvMap.put("regCap", element.elementText("REGCAP"));
                frinvMap.put("regCapCur", element.elementText("REGCAPCUR"));
                frinvMap.put("entStatus", element.elementText("ENTSTATUS"));
                frinvMap.put("canDate", element.elementText("CANDATE"));
                frinvMap.put("revDate", element.elementText("REVDATE"));
                frinvMap.put("regOrg", element.elementText("REGORG"));
                frinvMap.put("subConAm", element.elementText("SUBCONAM"));
                frinvMap.put("currency", element.elementText("CURRENCY"));
                frinvMap.put("funDedRatio", element.elementText("FUNDEDRATIO"));
                frinvMap.put("esDate", element.elementText("ESDATE"));
                policeAndAICConnectService.insertAICFrinvInfo(frinvMap);

            }

        }

        if (root.element("FRPOSITION") != null && root.element("FRPOSITION").elements("ITEM") != null) {
            // ????

            List<Element> frpositionEle = root.element("FRPOSITION").elements("ITEM");
            for (Element element : frpositionEle) {

                Map<String, Object> frpositionMap = Maps.newHashMap();
                frpositionMap.put("posCustId", posCustId);
                frpositionMap.put("orderNo", orderNo);
                frpositionMap.put("name", element.elementText("NAME"));
                frpositionMap.put("entName", element.elementText("ENTNAME"));
                frpositionMap.put("regNo", element.elementText("REGNO"));
                frpositionMap.put("entType", element.elementText("ENTTYPE"));
                frpositionMap.put("regCap", element.elementText("REGCAP"));
                frpositionMap.put("regCapCur", element.elementText("REGCAPCUR"));
                frpositionMap.put("entStatus", element.elementText("ENTSTATUS"));
                frpositionMap.put("canDate", element.elementText("CANDATE"));
                frpositionMap.put("revDate", element.elementText("REVDATE"));
                frpositionMap.put("regOrg", element.elementText("REGORG"));
                frpositionMap.put("position", element.elementText("POSITION"));
                frpositionMap.put("lerepSign", element.elementText("LEREPSIGN"));
                frpositionMap.put("esDate", element.elementText("ESDATE"));
                policeAndAICConnectService.insertAICFrpositionInfo(frpositionMap);

            }
        }

        // ??
        if (root.element("ENTINV") != null && root.element("ENTINV").elements("ITEM") != null) {
            List<Element> entinvEle = root.element("ENTINV").elements("ITEM");
            for (Element element : entinvEle) {

                Map<String, Object> entinvMap = Maps.newHashMap();
                entinvMap.put("posCustId", posCustId);
                entinvMap.put("orderNo", orderNo);
                entinvMap.put("entName", element.elementText("ENTNAME"));
                entinvMap.put("regNo", element.elementText("REGNO"));
                entinvMap.put("entType", element.elementText("ENTTYPE"));
                entinvMap.put("regCap", element.elementText("REGCAP"));
                entinvMap.put("regCapCur", element.elementText("REGCAPCUR"));
                entinvMap.put("entStatus", element.elementText("ENTSTATUS"));
                entinvMap.put("canDate", element.elementText("CANDATE"));
                entinvMap.put("revDate", element.elementText("REVDATE"));
                entinvMap.put("regOrg", element.elementText("REGORG"));
                entinvMap.put("subConAm", element.elementText("SUBCONAM"));
                entinvMap.put("congroCur", element.elementText("CONGROCUR"));
                entinvMap.put("funDedRatio", element.elementText("FUNDEDRATIO"));
                entinvMap.put("esDate", element.elementText("ESDATE"));
                policeAndAICConnectService.insertAICEntinvInfo(entinvMap);

            }
        }

        // ??

        // ?
        if (root.element("PUNISHBREAK") != null && root.element("PUNISHBREAK").elements("ITEM") != null) {

            List<Element> punishBreakEle = root.element("PUNISHBREAK").elements("ITEM");
            for (Element element : punishBreakEle) {

                Map<String, Object> punishBreakMap = Maps.newHashMap();
                punishBreakMap.put("posCustId", posCustId);
                punishBreakMap.put("orderNo", orderNo);
                punishBreakMap.put("caseCode", element.elementText("CASECODE"));
                punishBreakMap.put("iNameClean", element.elementText("INAMECLEAN"));
                punishBreakMap.put("type", element.elementText("TYPE"));
                punishBreakMap.put("sexyClean", element.elementText("SEXYCLEAN"));
                punishBreakMap.put("ageClean", element.elementText("AGECLEAN"));
                punishBreakMap.put("cardNum", element.elementText("CARDNUM"));
                punishBreakMap.put("ysFzd", element.elementText("YSFZD"));
                punishBreakMap.put("businessEntity", element.elementText("BUSINESSENTITY"));
                punishBreakMap.put("regDateClean", element.elementText("REGDATECLEAN"));
                punishBreakMap.put("publishDateClean", element.elementText("PUBLISHDATECLEAN"));
                punishBreakMap.put("courtName", element.elementText("COURTNAME"));
                punishBreakMap.put("areaNameClean", element.elementText("AREANAMECLEAN"));
                punishBreakMap.put("gistId", element.elementText("GISTID"));
                punishBreakMap.put("gistUnit", element.elementText("GISTUNIT"));
                punishBreakMap.put("duty", element.elementText("DUTY"));
                punishBreakMap.put("disruptTypeName", element.elementText("DISRUPTTYPENAME"));
                punishBreakMap.put("performance", element.elementText("PERFORMANCE"));
                punishBreakMap.put("performedPart", element.elementText("PERFORMEDPART"));
                punishBreakMap.put("unperformPart", element.elementText("UNPERFORMPART"));
                punishBreakMap.put("focusNumber", element.elementText("FOCUSNUMBER"));
                punishBreakMap.put("exitDate", element.elementText("EXITDATE"));
                policeAndAICConnectService.insertAICPunishBreakInfo(punishBreakMap);

            }
        }

        if (root.element("PUNISHED") != null && root.element("PUNISHED").elements("ITEM") != null) {
            // ?
            List<Element> punishedEle = root.element("PUNISHED").elements("ITEM");
            for (Element element : punishedEle) {

                Map<String, Object> punishedMap = Maps.newHashMap();
                punishedMap.put("posCustId", posCustId);
                punishedMap.put("orderNo", orderNo);
                punishedMap.put("caseCode", element.elementText("CASECODE"));
                punishedMap.put("iNameClean", element.elementText("INAMECLEAN"));
                punishedMap.put("cardNumClean", element.elementText("CARDNUMCLEAN"));
                punishedMap.put("sexyClean", element.elementText("SEXYCLEAN"));
                punishedMap.put("ageClean", element.elementText("AGECLEAN"));
                punishedMap.put("areaNameClean", element.elementText("AREANAMECLEAN"));
                punishedMap.put("ysFzd", element.elementText("YSFZD"));
                punishedMap.put("courtName", element.elementText("COURTNAME"));
                punishedMap.put("regDateClean", element.elementText("REGDATECLEAN"));
                punishedMap.put("caseState", element.elementText("CASESTATE"));
                punishedMap.put("execMoney", element.element("EXECMONEY"));
                punishedMap.put("focusNumber", element.element("FOCUSNUMBER"));
                policeAndAICConnectService.insertAICPunishedInfo(punishedMap);

            }
        }

        if (root.element("ALIDEBT") != null && root.element("ALIDEBT").elements("ITEM") != null) {
            // ?
            List<Element> aliDebtEle = root.element("ALIDEBT").elements("ITEM");
            for (Element element : aliDebtEle) {

                Map<String, Object> aliDebtMap = Maps.newHashMap();
                aliDebtMap.put("posCustId", posCustId);
                aliDebtMap.put("orderNo", orderNo);
                aliDebtMap.put("sexyClean", element.elementText("SEXYCLEAN"));
                aliDebtMap.put("ageClean", element.elementText("AGECLEAN"));
                aliDebtMap.put("areaNameClean", element.elementText("AREANAMECLEAN"));
                aliDebtMap.put("ysFzd", element.elementText("YSFZD"));
                aliDebtMap.put("qked", element.elementText("QKED"));
                aliDebtMap.put("wyqk", element.elementText("WYQK"));
                aliDebtMap.put("dkdqsj", element.elementText("DKDQSJ"));
                aliDebtMap.put("tbzh", element.elementText("TBZH"));
                aliDebtMap.put("legalPerson", element.elementText("LEGALPERSON"));
                aliDebtMap.put("dkqx", element.elementText("DKQX"));
                policeAndAICConnectService.insertAICAlidebtInfo(aliDebtMap);

            }
        }
        // ?
        if (root.element("CASEINFO") != null && root.element("CASEINFO").elements("ITEM") != null) {

            List<Element> caseInfoEle = root.element("CASEINFO").elements("ITEM");
            for (Element element : caseInfoEle) {

                Map<String, Object> caseInfoMap = Maps.newHashMap();
                caseInfoMap.put("posCustId", posCustId);
                caseInfoMap.put("orderNo", orderNo);
                caseInfoMap.put("caseTime", element.elementText("CASETIME"));
                caseInfoMap.put("caseReason", element.elementText("CASEREASON"));
                caseInfoMap.put("caseVal", element.elementText("CASEVAL"));
                caseInfoMap.put("caseType", element.elementText("CASETYPE"));
                caseInfoMap.put("exeSort", element.elementText("EXESORT"));
                caseInfoMap.put("caseResult", element.elementText("CASERESULT"));
                caseInfoMap.put("pendecNo", element.elementText("PENDECNO"));
                caseInfoMap.put("pendecissDate", element.elementText("PENDECISSDATE"));
                caseInfoMap.put("penAuth", element.elementText("PENAUTH"));
                caseInfoMap.put("illegFact", element.elementText("ILLEGFACT"));
                caseInfoMap.put("penBasis", element.elementText("PENBASIS"));
                caseInfoMap.put("penType", element.elementText("PENTYPE"));
                caseInfoMap.put("penResult", element.elementText("PENRESULT"));
                caseInfoMap.put("penAm", element.elementText("PENAM"));
                caseInfoMap.put("penExest", element.elementText("PENEXEST"));
                policeAndAICConnectService.insertAICCaseInfo(caseInfoMap);

            }
        }

        // ??
        if (root.element("ALTER") != null && root.element("ALTER").elements("ITEM") != null) {
            List<Element> alterInfos = root.element("ALTER").elements("ITEM");
            for (Element element : alterInfos) {
                TAICAlterInfo alterInfo = new TAICAlterInfo();
                alterInfo.setOrderNo(orderNo);
                alterInfo.setPosCustId(posCustId);
                alterInfo.setAltItem(element.elementText("ALTITEM"));
                alterInfo.setAltDate(element.elementText("ALTDATE"));
                alterInfo.setAltAf(element.elementText("ALTAF"));
                alterInfo.setAltBe(element.elementText("ALTBE"));
                policeAndAICConnectService.insetAlterInfo(alterInfo);
            }
        }

        // ??
        if (root.element("SHARESIMPAWN") != null && root.element("SHARESIMPAWN").elements("ITEM") != null) {
            List<Element> shareSimpawns = root.element("SHARESIMPAWN").elements("ITEM");
            for (Element ele : shareSimpawns) {
                TAICSharesimpawnInfo taicSharesimpawnInfo = new TAICSharesimpawnInfo();
                taicSharesimpawnInfo.setOrderNo(orderNo);
                taicSharesimpawnInfo.setPosCustId(posCustId);
                taicSharesimpawnInfo.setImpAm(ele.elementText("IMPAM"));
                taicSharesimpawnInfo.setImpExAeep(ele.elementText("IMPEXAEEP"));
                taicSharesimpawnInfo.setImpOnRecDate(ele.elementText("IMPONRECDATE"));
                taicSharesimpawnInfo.setImpOrg(ele.elementText("IMPORG"));
                taicSharesimpawnInfo.setImpOrgType(ele.elementText("IMPORGTYPE"));
                taicSharesimpawnInfo.setImpSanDate(ele.elementText("IMPSANDATE"));
                taicSharesimpawnInfo.setImpTo(ele.elementText("IMPTO"));
                policeAndAICConnectService.insertSharesimpaw(taicSharesimpawnInfo);
            }
        }

        // ?
        if (root.element("MORDETAIL") != null && root.element("MORDETAIL").element("ITEM") != null) {
            List<Element> mordetails = root.element("MORDETAIL").elements("ITEM");
            for (Element element : mordetails) {
                TAICMordetailInfo taicMordetailInfo = new TAICMordetailInfo();
                taicMordetailInfo.setAppRegRea(element.elementText("APPREGREA"));
                taicMordetailInfo.setCanDate(element.elementText("CANDATE"));
                taicMordetailInfo.setOrderNo(orderNo);
                taicMordetailInfo.setPosCustId(posCustId);
                taicMordetailInfo.setMore(element.elementText("MORE"));
                taicMordetailInfo.setMorRegcNo(element.elementText("MORREGCNO"));
                taicMordetailInfo.setMortGagor(element.elementText("MORTGAGOR"));
                taicMordetailInfo.setMorRegId(element.elementText("MORREGID"));
                taicMordetailInfo.setMorType(element.elementText("MORTYPE"));
                taicMordetailInfo.setPefPerForm(element.elementText("PEFPERFORM"));
                taicMordetailInfo.setPefPerTo(element.elementText("PEFPERTO"));
                taicMordetailInfo.setPriClasecAm(element.elementText("PRICLASECAM"));
                taicMordetailInfo.setPriClasecKind(element.elementText("PRICLASECKIND"));
                taicMordetailInfo.setRegiDate(element.elementText("REGIDATE"));
                taicMordetailInfo.setRegOrg(element.elementText("REGORG"));
                policeAndAICConnectService.insertMordetail(taicMordetailInfo);

            }
        }

        // ?
        if (root.element("MORGUAINFO") != null && root.element("MORGUAINFO").elements("ITEM") != null) {
            List<Element> morguaiInfos = root.element("MORGUAINFO").elements("ITEM");
            for (Element ele : morguaiInfos) {
                TAICMorguaInfo taicMorguaInfo = new TAICMorguaInfo();
                taicMorguaInfo.setOrderNo(orderNo);
                taicMorguaInfo.setPosCustId(posCustId);
                taicMorguaInfo.setGuaName(ele.elementText("GUANAME"));
                taicMorguaInfo.setMorRegId(ele.elementText("MORREGID"));
                taicMorguaInfo.setQuan(ele.elementText("QUAN"));
                taicMorguaInfo.setValue(ele.elementText("VALUE"));
                policeAndAICConnectService.insertMorguaInfo(taicMorguaInfo);
            }
        }

        // ??
        if (root.element("SHARESFROST") != null && root.element("SHARESFROST").elements("ITEM") != null) {
            List<Element> sharesFrosts = root.element("SHARESFROST").elements("ITEM");
            for (Element ele : sharesFrosts) {
                TAICSharesFrostInfo taicSharesFrostInfo = new TAICSharesFrostInfo();
                taicSharesFrostInfo.setOrderNo(orderNo);
                taicSharesFrostInfo.setPosCustId(posCustId);
                taicSharesFrostInfo.setFroAm(ele.elementText("FROAM"));
                taicSharesFrostInfo.setFroAuth(ele.elementText("FROAUTH"));
                taicSharesFrostInfo.setFroDocNo(ele.elementText("FRODOCNO"));
                taicSharesFrostInfo.setFroFrom(ele.elementText("FROFROM"));
                taicSharesFrostInfo.setFroTo(ele.elementText("FROTO"));
                taicSharesFrostInfo.setThawAuth(ele.elementText("THAWAUTH"));
                taicSharesFrostInfo.setThawComment(ele.elementText("THAWCOMMENT"));
                taicSharesFrostInfo.setThawDate(ele.elementText("THAWDATE"));
                taicSharesFrostInfo.setThawDocNo(ele.elementText("THAWDOCNO"));
                policeAndAICConnectService.insertShareFrost(taicSharesFrostInfo);
            }
        }

        // ?
        if (root.element("LIQUIDATION") != null && root.element("LIQUIDATION").elements("ITEM") != null) {
            List<Element> liquidations = root.element("LIQUIDATION").elements("ITEM");
            for (Element ele : liquidations) {
                TAICLiguidationInfo taicLiguidationInfo = new TAICLiguidationInfo();
                taicLiguidationInfo.setOrderNo(orderNo);
                taicLiguidationInfo.setPosCustId(posCustId);
                taicLiguidationInfo.setClaimTranee(ele.elementText("CLAIMTRANEE"));
                taicLiguidationInfo.setDebtTranee(ele.elementText("DEBTTRANEE"));
                taicLiguidationInfo.setLigEndDate(ele.elementText("LIGENDDATE"));
                taicLiguidationInfo.setLigEntity(ele.elementText("LIGENTITY"));
                taicLiguidationInfo.setLigPrincipal(ele.elementText("LIGPRINCIPAL"));
                taicLiguidationInfo.setLigSt(ele.elementText("LIGST"));
                taicLiguidationInfo.setLiqMen(ele.elementText("LIQMEN"));
                policeAndAICConnectService.insertLiquidationInfo(taicLiguidationInfo);
            }
        }
        logger.debug(posCustName + "??");

    }
    // 
    Map<String, String> resMap = Maps.newHashMap();
    logger.debug("??");
    resMap.put("resCode", "00");
    resMap.put("respMsg", "??");
    return resMap;
}

From source file:com.jfinal.ext.weixin.msg.InMsgParaser.java

License:Apache License

/**
 * ?// w  ww.j ava 2s.  co m
 * 1text ?
 * 2image ?
 * 3voice ?
 * 4video ?
 * 5location ???
 * 6link ?
 * 7event 
 */
private static InMsg doParse(String xml) throws DocumentException {
    Document doc = DocumentHelper.parseText(xml);
    Element root = doc.getRootElement();
    String toUserName = root.elementText("ToUserName");
    String fromUserName = root.elementText("FromUserName");
    Integer createTime = Integer.parseInt(root.elementText("CreateTime"));
    String msgType = root.elementText("MsgType");
    if ("text".equals(msgType))
        return parseInTextMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("image".equals(msgType))
        return parseInImageMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("voice".equals(msgType))
        return parseInVoiceMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("video".equals(msgType))
        return parseInVideoMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("location".equals(msgType))
        return parseInLocationMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("link".equals(msgType))
        return parseInLinkMsg(root, toUserName, fromUserName, createTime, msgType);
    if ("event".equals(msgType))
        return parseInEvent(root, toUserName, fromUserName, createTime, msgType);
    throw new RuntimeException("???");
}