⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxprocessactionfactory.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                      thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("action"))                            actionValue = STAXUtil.parseAndCompileForPython(                                          thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                      thisChild.getNodeName() + ": " +                                       thisAttr.getNodeName());                    }                    process.setDisabledauth(actionValue, ifValue);                }                else if (thisChild.getNodeName().equals("statichandlename"))                {                    process.setStatichandlename(handleChild(thisChild),                                                handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("stdin"))                {                    process.setStdin(handleChild(thisChild),                                     handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("stdout"))                {                    String ifValue = new String();                    String modeValue = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                      thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("mode"))                            modeValue = STAXUtil.parseAndCompileForPython(                                        thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                      thisChild.getNodeName() + ": " +                                       thisAttr.getNodeName());                    }                    process.setStdout(handleChild(thisChild),                                      modeValue, ifValue);                }                else if (thisChild.getNodeName().equals("stderr"))                {                    String ifValue = new String();                    String modeValue = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                      thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("mode"))                            modeValue = STAXUtil.parseAndCompileForPython(                                        thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                      thisChild.getNodeName() + ": " +                                       thisAttr.getNodeName());                    }                    process.setStderr(handleChild(thisChild),                                      modeValue, ifValue);                }                else if (thisChild.getNodeName().equals("returnstdout"))                {                    process.setReturnStdout("returnstdout",                                            handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("returnstderr"))                {                    process.setReturnStderr("returnstderr",                                            handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("returnfile"))                                {                    process.setReturnFiles(handleChild(thisChild),                                           handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("returnfiles"))                                {                    process.setReturnFiles(handleChild(thisChild),                                           handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("other"))                {                    process.setOther(handleChild(thisChild),                                     handleIfAttribute(thisChild));                }                else if (thisChild.getNodeName().equals("process-action"))                {                    String ifValue = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                                                String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                      thisAttr.getNodeValue(), errorInfo);                                                else                            throw new STAXInvalidXMLAttributeException(                                      thisChild.getNodeName() + ": " +                                       thisAttr.getNodeName());                    }                                    NodeList processActionChildren = thisChild.getChildNodes();                    STAXAction processAction = null;                    for (int j = 0; j < processActionChildren.getLength(); ++j)                    {                        Node processActionChild =                             processActionChildren.item(j);                        if (processActionChild.getNodeType() ==                             Node.COMMENT_NODE)                        {                            /* Do nothing */                        }                        else if (processActionChild.getNodeType() ==                             Node.ELEMENT_NODE)                        {                            if (processAction != null)                            {                                throw new STAXInvalidXMLElementCountException(                                          thisChild.getNodeName());                            }                                                    STAXActionFactory factory =                                 staxService.getActionFactory(                                processActionChild.getNodeName());                            if (factory == null)                            {                                throw new STAXInvalidXMLElementException(                                          processActionChild.getNodeName());                            }                            processAction = factory.parseAction(staxService,                                 job, processActionChild);                        }                    }                                            process.setProcessAction(processAction, ifValue);                }            }            else            {                throw new STAXInvalidXMLNodeTypeException(                          Integer.toString(thisChild.getNodeType()));            }        }        return process;    }    private String handleIfAttribute(Node thisChild) throws STAXException    {        String ifValue = new String();        NamedNodeMap attrs = thisChild.getAttributes();        for (int i = 0; i < attrs.getLength(); ++i)        {            Node thisAttr = attrs.item(i);            String errorInfo = "\n  Element: " +                thisChild.getNodeName() + "  Attribute: " +                thisAttr.getNodeName();            if (thisAttr.getNodeName().equals("if"))                ifValue = STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo);            else                throw new STAXInvalidXMLAttributeException(                          thisChild.getNodeName() + ": " +                           thisAttr.getNodeName());        }        return ifValue;    }      private String handleChild(Node root) throws STAXException    {        NodeList children = root.getChildNodes();        for (int i = 0; i < children.getLength(); ++i)        {            Node thisChild = children.item(i);            // XXX: Should I be able to have a COMMENT_NODE here?            if (thisChild.getNodeType() == Node.COMMENT_NODE)            {                /* Do nothing */            }            else if (thisChild.getNodeType() == Node.TEXT_NODE)            {                String errorInfo = "\n  Element: " + root.getNodeName();                return STAXUtil.parseAndCompileForPython(                    thisChild.getNodeValue(), errorInfo);            }            else if (thisChild.getNodeType() == Node.CDATA_SECTION_NODE)            {                /* Do nothing */            }            else            {                throw new STAXInvalidXMLNodeTypeException(                          Integer.toString(thisChild.getNodeType()));            }        }        return new String();    }    // STAXSTAFQueueListener methods    public void handleQueueMessage(STAXSTAFMessage message, STAXJob job)    {        // XXX: How to make sure that the machine they registered        //      with is the machine on the queue (long vs. short        //      names)?  Maybe try        //          a.startsWith(b) || b.startsWith(a)        String machine = message.getMachine();        int handle = message.getProcessHandle();                String key = "";                if (!message.getProcessKey().equals(""))        {            key = message.getProcessKey();        }        else        {            // XXX Does lower casing the machine name cause any other problems?            key = (machine + "/" + handle).toLowerCase();        }        HashMap processMap = (HashMap)job.getData("processMap");        synchronized (processMap)        {            STAXProcessCompleteListener listener =                 (STAXProcessCompleteListener)processMap.get(key);            if (listener != null)            {                if (debug)                {                    System.out.println(                        "ProcessActionFactory::handleQueueMessages() - " +                        "Remove from processMap");                }                listener.processComplete(                    machine, handle, message.getProcessRC(),                    message.getProcessResultAsList(),                    message.getProcessTimestamp());                processMap.remove(key);            }            else            {                // Log a warning message in the job log                String msg = "STAXProcessActionFactory.handleQueueMessage: " +                             "No listener found for message:\n" +                             STAFMarshallingContext.unmarshall(                                 message.getResult()).toString();                msg += "\nCurrentKeys=";                                Iterator iter = processMap.keySet().iterator();                                while (iter.hasNext())                {                    msg += iter.next() + ";";                }                                job.log(STAXJob.JOB_LOG, "warning", msg);                // If we received the "process end" message before we placed                // the machine/handle in the process map, just save the key                // and the message in the process map.  When STAXProcessAction                // receives the requestComplete message, since the key already                // exists, it will just remove it                                if (debug)                {                    System.out.println(                        "ProcessActionFactory::handleQueueMessages() - " +                        "Add to processMap");                }                processMap.put(key.toLowerCase(), message);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -