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