Package sos.xml

Examples of sos.xml.SOSXMLXPath


          logger.debug3("submitting job... ");
          logger.debug9(out.toString());
          String answer = spooler.execute_xml(out.toString());
          logger.debug3("answer from scheduler: "+answer);

          SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer(answer));     
          String errorMsg = "";
          if (xpath.selectSingleNodeValue("//spooler/answer/ERROR") != null) {
            String errorCode = xpath.selectSingleNodeValue("//spooler/answer/ERROR/@code");
            String errorText = xpath.selectSingleNodeValue("//spooler/answer/ERROR/@text");
            errorMsg = errorCode + ":"  + errorText;
          }

          if (!errorMsg.equals("")){
            throw new Exception ("Scheduler answer ERROR:" + errorMsg);
View Full Code Here


                    payload = "<?xml version='1.0' encoding='ISO-8859-1'?>" + payload;
                }
                this.setConfiguration(docBuilder.parse(new ByteArrayInputStream(payload.getBytes())));

                // add attributes from configuration
                SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer(payload));
                NodeList nodeList = null;
                NamedNodeMap nodeMapSettings = null;
               
                // get settings for log_level
                nodeQuery = "//settings/log_level";
                Node nodeSettings = xpath.selectSingleNode(nodeQuery);
                if (nodeSettings != null) {
                    nodeMapSettings = nodeSettings.getAttributes();
                    if (nodeMapSettings != null && nodeMapSettings.getNamedItem("value") != null) {
                    this.getLogger().debug1("Log Level is: " + nodeMapSettings.getNamedItem("value").getNodeValue() + "(" + this.logLevel2Int(nodeMapSettings.getNamedItem("value").getNodeValue()) + ")");
                    this.getLogger().setLogLevel(this.logLevel2Int(nodeMapSettings.getNamedItem("value").getNodeValue()));
                    }
                }
               
                // this.getLogger().debug7("adding parameters from configuration: " + spooler_task.order().xml_payload());

                //Looking for global env=yes in the params-section
                this.setEnvVars();    
                String env = "";
                boolean globalEnv = false;
               
                // look up the configuration for all states
                nodeQuery = "//job_chain[@name='" + spooler_task.order().job_chain().name() + "']/order";
                this.getLogger().debug9("lookup order query for job chain: " + nodeQuery);
                Node nodeParams = xpath.selectSingleNode(nodeQuery + "/params");
                if (nodeParams == null || !nodeParams.hasChildNodes()) {
                    nodeQuery = "//application[@name='" + spooler_task.order().job_chain().name() + "']/order";
                    this.getLogger().debug9("lookup order query for application: " + nodeQuery);
                    nodeParams = xpath.selectSingleNode(nodeQuery + "/params");
                }
               
                if (nodeParams != null && nodeParams.hasAttributes()) {
                    NamedNodeMap nodeMapParams = nodeParams.getAttributes();
                    if (nodeMapParams != null && nodeMapParams.getNamedItem("env") != null) {
                        env = nodeMapParams.getNamedItem("env").getNodeValue();
                        this.getLogger().debug3(".. parameter section with env=" + env + " found");
                        globalEnv = (env.equalsIgnoreCase("yes") || env.equals("1") || env.equalsIgnoreCase("on") || env.equalsIgnoreCase("true"));
                    }
                }
                            
                nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                for (int i=0; i<nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    String nodeValue = "";
                    String nodeName = "";
                    if (node.getNodeName().equalsIgnoreCase("param")) {
                        NamedNodeMap nodeMap = node.getAttributes();
                        if (nodeMap != null && nodeMap.getNamedItem("name") != null) {
                          
                            nodeName = nodeMap.getNamedItem("name").getNodeValue();
                            if (nodeMap.getNamedItem("value") != null) {
                              nodeValue = nodeMap.getNamedItem("value").getNodeValue();
                            } else {
                                NodeList children = node.getChildNodes();
                                for (int j=0; j<children.getLength(); j++) {
                                    Node item = children.item(j);
                                    switch (item.getNodeType())
                                    {
                                        case Node.TEXT_NODE:
                                        case Node.CDATA_SECTION_NODE:
                                            nodeValue += item.getNodeValue();
                                    }
                                }
                            }
                           
                            this.getLogger().debug1(".. global configuration parameter [" + nodeName + "]: "  + nodeValue );
                            spooler_task.order().params().set_var(nodeName, nodeValue);
                           
                            if (globalEnv || nodeMap.getNamedItem("env") != null) {
                              if (nodeMap.getNamedItem("env") != null) env = nodeMap.getNamedItem("env").getNodeValue();

                                boolean setEnv = globalEnv || (env.equalsIgnoreCase("yes") || env.equals("1") || env.equalsIgnoreCase("on") || env.equalsIgnoreCase("true"));                           
                              if (setEnv) {
                                 if (this.additional_envvars == null) this.additional_envvars = new TreeMap();
                                 this.additional_envvars.put(nodeName, nodeValue);
                              }
                            }                           
                        }
                    }
                }

                // look up the configuration for the order state
                nodeQuery = "//job_chain[@name='" + spooler_task.order().job_chain().name() + "']/order/process[@state='" + spooler_task.order().state() + "']";
                this.getLogger().debug9("lookup order node query: " + nodeQuery + "/params/param");
                nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                if (nodeList == null || nodeList.getLength() == 0) {
                    nodeQuery = "//application[@name='" + spooler_task.order().job_chain().name() + "']/order/process[@state='" + spooler_task.order().state() + "']";
                    this.getLogger().debug9("lookup order node query: " + nodeQuery + "/params/param");
                    nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                }

                /* Diesen Block kommentiere ich mal aus, denn das ist ja immer false
                 * if (nodeQuery == null || nodeQuery.length() == 0) {
                     // look up the configuration for the job name
View Full Code Here

                if (!payload.startsWith("<?xml ")) {
                    payload = "<?xml version='1.0' encoding='ISO-8859-1'?>" + payload;
                }
                this.setConfiguration(docBuilder.parse(new ByteArrayInputStream(payload.getBytes())));

                SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer(payload));
                NodeList nodeList = null;
                NamedNodeMap nodeMapSettings = null;

                nodeQuery = "//settings/log_level";
                Node nodeSettings = xpath.selectSingleNode(nodeQuery);
                if (nodeSettings != null) {
                    nodeMapSettings = nodeSettings.getAttributes();
                    if (nodeMapSettings != null && nodeMapSettings.getNamedItem("value") != null) {
                    this.getLogger().debug1("Log Level is: " + nodeMapSettings.getNamedItem("value").getNodeValue());
                    this.getLogger().setLogLevel(this.logLevel2Int(nodeMapSettings.getNamedItem("value").getNodeValue()));
                    }
                }

                this.setEnvVars();    
               
                // add attributes from configuration
                // this.getLogger().debug7("adding parameters from configuration: " + spooler_task.order().xml_payload());

                // look up the configuration for the all states
                nodeQuery = "//job_chain[@name='" + spooler_task.order().job_chain().name() + "']/order";
                this.getLogger().debug9("monitor: lookup order for job chain: " + nodeQuery + "/params/param");
                nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                if (nodeList == null || nodeList.getLength() == 0) {
                    nodeQuery = "//application[@name='" + spooler_task.order().job_chain().name() + "']/order";
                    this.getLogger().debug9("monitor: lookup order for application: " + nodeQuery + "/params/param");
                    nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                }
               
                for (int i=0; i<nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    String nodeValue = "";
                    String nodeName = "";
                    if (node.getNodeName().equalsIgnoreCase("param")) {
                        NamedNodeMap nodeMap = node.getAttributes();
                        if (nodeMap != null && nodeMap.getNamedItem("name") != null) {
                          
                            nodeName = nodeMap.getNamedItem("name").getNodeValue();
                            if (nodeMap.getNamedItem("value") != null) {
                              nodeValue = nodeMap.getNamedItem("value").getNodeValue();
                            } else {
                                NodeList children = node.getChildNodes();
                                for (int j=0; j<children.getLength(); j++) {
                                    Node item = children.item(j);
                                    switch (item.getNodeType())
                                    {
                                        case Node.TEXT_NODE:
                                        case Node.CDATA_SECTION_NODE:
                                            nodeValue += item.getNodeValue();
                                    }
                                }
                            }
                            this.getLogger().debug1(".. monitor: global configuration parameter [" + nodeName + "]: "  + nodeValue );
                            spooler_task.order().params().set_var(nodeName, nodeValue);
                        }
                    }
                }

                // look up the configuration for the order state
                nodeQuery = "//job_chain[@name='" + spooler_task.order().job_chain().name() + "']/order/process[@state='" + spooler_task.order().state() + "']";
                this.getLogger().debug9("monitor: lookup order node query for job chain: " + nodeQuery + "/params/param");
                nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                if (nodeList == null || nodeList.getLength() == 0) {
                    nodeQuery = "//application[@name='" + spooler_task.order().job_chain().name() + "']/order/process[@state='" + spooler_task.order().state() + "']";
                    this.getLogger().debug9("monitor: lookup order node query for application: " + nodeQuery + "/params/param");
                    nodeList = xpath.selectNodeList(nodeQuery + "/params/param");
                }

                /* Diesen Block kommentiere ich mal aus, denn das ist ja immer false
                 * if (nodeQuery == null || nodeQuery.length() == 0) {
                     // look up the configuration for the job name
View Full Code Here

      if (configFile.length() == 0)
        return;
     
      allParam= new HashMap(); //Hilfsvariaable
     
      SOSXMLXPath xpath = new SOSXMLXPath(this.configFile);
           
      org.w3c.dom.NodeList nl = xpath.selectNodeList(xpath.document.getElementsByTagName("param").item(0),"//param");
     
      for(int i =0; i < nl.getLength(); i++) {
        Node nParam = nl.item(i);
        org.w3c.dom.NamedNodeMap map = nParam.getAttributes();
        for (int j = 0; j < map.getLength(); j++) {
View Full Code Here

      if (configFile.length() == 0)
        return;
     
      allParam= new HashMap(); //Hilfsvariaable
     
      SOSXMLXPath xpath = new SOSXMLXPath(this.configFile);           
      org.w3c.dom.NodeList nl = xpath.selectNodeList("//param");                 
      for(int i =0; i < nl.getLength(); i++) {
        Node nParam = nl.item(i);
       
        if (nParam.getParentNode().getParentNode().getNodeName().equals("job") &&
            nParam.getParentNode().getParentNode().getAttributes().getNamedItem("name").getNodeValue().equals(jobname)) {
View Full Code Here

          remoteCommand.sendRequest(request);
          counter++;
//          hier die Fehlerhandhabung
          if (this.schedulerLauncherProtocol.equalsIgnoreCase("tcp")) { // no response is returned for UDP messages
            response = remoteCommand.getResponse();
            SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer(response));
            String errCode = xpath.selectSingleNodeValue("//ERROR/@code");
            String errMessage = xpath.selectSingleNodeValue("//ERROR/@text");
            sosLogger.info("..job scheduler response: " + response);               
            if ((errCode != null && errCode.length() > 0) || (errMessage != null && errMessage.length() > 0)) {
              sosLogger.warn("..job scheduler response reports error message: " + errMessage + " [" + errCode + "]");
              counterError++;
            }
View Full Code Here

            }

            Variable_set params = spooler.create_variable_set();
           
            // add order parameters from request xml element /params
            SOSXMLXPath xpath = new sos.xml.SOSXMLXPath(new StringBuffer(xml_document));
            String xmlParams = xpath.selectDocumentText("//params");
            if (xmlParams != null && xmlParams.length() > 0) {
                params.set_xml( xmlParams );
            }

            order.set_params( params );
View Full Code Here

              spooler_log.debug3( "content of request transformation:\n" + xml_document );
            } else {
              xml_document = request.string_content();
            }
         
            SOSXMLXPath xpath = new sos.xml.SOSXMLXPath(new StringBuffer(xml_document));
            // add order parameters from request xml element /params
            Variable_set params = spooler.create_variable_set();
            params.set_xml( xpath.selectDocumentText("//params") );
            order.set_payload( params );

            spooler_log.info( "web service request accepted for order \"" + order.id() + "\"" );

            return true;
View Full Code Here

    try {
      if (startscript) {
        getLogger().debug1("Start request is skipped, because this is a startscript.");
        return;
      }
      SOSXMLXPath xpath = new SOSXMLXPath(new StringBuffer(submit.get("xml").toString()));

      String path = submit.get("path").toString();
      path = extractRelativePath(path);
      String endOfPath = new File(path).getName();
      String startPath = new File(path).getParent().replaceAll("\\\\", "/");
      if (startPath.equals("/"))
        startPath = "";

      Matcher mat = hotFolderRegExPattern.matcher(endOfPath);
      mat.matches();
      String type = mat.group(3);
      String name = mat.group(2);

      boolean start = true;
      String nodeQuery = "//add_order[@at]";
      Node runtime;

      if (type.equals("order")) {
        Node atNode = xpath.selectSingleNode(nodeQuery);
        nodeQuery = "//run_time";
        runtime = xpath.selectSingleNode(nodeQuery);

        if (atNode == null && runtime == null) {
          start = false;
          getLog().debug1(
              "processActionAndStart:" + name
                  + " once=yes. Order will not be modified because 'no at and no run_time' is specified by <add_order>");
        }
      }

      nodeQuery = "//run_time[@repeat]";
      runtime = xpath.selectSingleNode(nodeQuery);
      if (runtime != null) {
        start = false;
        getLog().debug1("processActionAndStart:" + name + " once=yes. " + type + " will not be modified because 'repeat' is specified by <run_time>");
      }

      nodeQuery = "//run_time/period[@repeat]";
      runtime = xpath.selectSingleNode(nodeQuery);
      if (runtime != null && start) {
        start = false;
        getLog().debug1("processActionAndStart:" + name + " once=yes. " + type + " will not be started because 'repeat' is specified by <run_time>");
      }
View Full Code Here

  }

  // ======================================================
  class SchedulerUpdateAnswer {
    SchedulerUpdateAnswer(String xml) throws Exception {
      SOSXMLXPath xpathPayload = new sos.xml.SOSXMLXPath(new java.lang.StringBuffer(xml));
      this.release = xpathPayload.selectSingleNodeValue("//release");
      this.new_release = xpathPayload.selectSingleNodeValue("//new_release");
      this.os = xpathPayload.selectSingleNodeValue("//os");
      this.os_install = xpathPayload.selectSingleNodeValue("//os_install");
      this.automatic_download = xpathPayload.selectSingleNodeValue("//automatic_download");
      this.filename = xpathPayload.selectSingleNodeValue("//filename");
      update_needed = xpathPayload.selectSingleNodeValue("//update_needed");

    }
View Full Code Here

TOP

Related Classes of sos.xml.SOSXMLXPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.