org.jdom.Namespace

Here are the examples of the java api class org.jdom.Namespace taken from open source projects.

1. TestActionStartXCommand#testActionReuseWfJobAppPath()

Project: oozie
File: TestActionStartXCommand.java
public void testActionReuseWfJobAppPath() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job = this.addRecordToWfJobTableWithCustomAppPath(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTableWithAppPathConfig(job.getId(), "1", WorkflowAction.Status.PREP);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    new ActionStartXCommand(action.getId(), "map-reduce").call();
    action = jpaService.execute(wfActionGetCmd);
    assertNotNull(action.getExternalId());
    Element actionXml = XmlUtils.parseXml(action.getConf());
    Namespace ns = actionXml.getNamespace();
    Element configElem = actionXml.getChild("configuration", ns);
    String strConf = XmlUtils.prettyPrint(configElem).toString();
    XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
    String workDir = inlineConf.get("work.dir", null);
    assertNotNull(workDir);
    assertFalse(workDir.contains("workflow.xml"));
}

2. PigActionExecutor#setupActionConf()

Project: oozie
File: PigActionExecutor.java
@SuppressWarnings("unchecked")
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
    super.setupActionConf(actionConf, context, actionXml, appPath);
    Namespace ns = actionXml.getNamespace();
    String script = actionXml.getChild("script", ns).getTextTrim();
    String pigName = new Path(script).getName();
    List<Element> params = (List<Element>) actionXml.getChildren("param", ns);
    String[] strParams = new String[params.size()];
    for (int i = 0; i < params.size(); i++) {
        strParams[i] = params.get(i).getTextTrim();
    }
    String[] strArgs = null;
    List<Element> eArgs = actionXml.getChildren("argument", ns);
    if (eArgs != null && eArgs.size() > 0) {
        strArgs = new String[eArgs.size()];
        for (int i = 0; i < eArgs.size(); i++) {
            strArgs[i] = eArgs.get(i).getTextTrim();
        }
    }
    PigMain.setPigScript(actionConf, pigName, strParams, strArgs);
    return actionConf;
}

3. MapReduceActionExecutor#getLauncherMain()

Project: oozie
File: MapReduceActionExecutor.java
@Override
protected String getLauncherMain(Configuration launcherConf, Element actionXml) {
    String mainClass;
    Namespace ns = actionXml.getNamespace();
    if (actionXml.getChild("streaming", ns) != null) {
        mainClass = launcherConf.get(LauncherMapper.CONF_OOZIE_ACTION_MAIN_CLASS, StreamingMain.class.getName());
    } else {
        if (actionXml.getChild("pipes", ns) != null) {
            mainClass = launcherConf.get(LauncherMapper.CONF_OOZIE_ACTION_MAIN_CLASS, PipesMain.class.getName());
        } else {
            mainClass = launcherConf.get(LauncherMapper.CONF_OOZIE_ACTION_MAIN_CLASS, MapReduceMain.class.getName());
        }
    }
    return mainClass;
}

4. JavaActionExecutor#createBaseHadoopConf()

Project: oozie
File: JavaActionExecutor.java
public Configuration createBaseHadoopConf(Context context, Element actionXml) {
    Configuration conf = new XConfiguration();
    conf.set(HADOOP_USER, context.getProtoActionConf().get(WorkflowAppService.HADOOP_USER));
    conf.set(HADOOP_UGI, context.getProtoActionConf().get(WorkflowAppService.HADOOP_UGI));
    if (context.getProtoActionConf().get(WorkflowAppService.HADOOP_JT_KERBEROS_NAME) != null) {
        conf.set(WorkflowAppService.HADOOP_JT_KERBEROS_NAME, context.getProtoActionConf().get(WorkflowAppService.HADOOP_JT_KERBEROS_NAME));
    }
    if (context.getProtoActionConf().get(WorkflowAppService.HADOOP_NN_KERBEROS_NAME) != null) {
        conf.set(WorkflowAppService.HADOOP_NN_KERBEROS_NAME, context.getProtoActionConf().get(WorkflowAppService.HADOOP_NN_KERBEROS_NAME));
    }
    conf.set(OozieClient.GROUP_NAME, context.getProtoActionConf().get(OozieClient.GROUP_NAME));
    Namespace ns = actionXml.getNamespace();
    String jobTracker = actionXml.getChild("job-tracker", ns).getTextTrim();
    String nameNode = actionXml.getChild("name-node", ns).getTextTrim();
    conf.set(HADOOP_JOB_TRACKER, jobTracker);
    conf.set(HADOOP_NAME_NODE, nameNode);
    conf.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "true");
    return conf;
}

5. LyricsService#parseSearchResult()

Project: libresonic
File: LyricsService.java
private LyricsInfo parseSearchResult(String xml) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new StringReader(xml));
    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();
    String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
    String song = root.getChildText("LyricSong", ns);
    String artist = root.getChildText("LyricArtist", ns);
    return new LyricsInfo(lyric, artist, song);
}

6. JDOMNodePointer#getNamespaceURI()

Project: commons-jxpath
File: JDOMNodePointer.java
public String getNamespaceURI(String prefix) {
    if (prefix.equals("xml")) {
        return Namespace.XML_NAMESPACE.getURI();
    }
    Element element = null;
    if (node instanceof Document) {
        element = ((Document) node).getRootElement();
    }
    if (node instanceof Element) {
        element = (Element) node;
    }
    if (element == null) {
        return null;
    }
    Namespace ns = element.getNamespace(prefix);
    return ns == null ? null : ns.getURI();
}

7. JDOMNamespaceIterator#getNodePointer()

Project: commons-jxpath
File: JDOMNamespaceIterator.java
public NodePointer getNodePointer() {
    if (position == 0) {
        if (!setPosition(1)) {
            return null;
        }
        position = 0;
    }
    int index = position - 1;
    if (index < 0) {
        index = 0;
    }
    Namespace ns = (Namespace) namespaces.get(index);
    return new JDOMNamespacePointer(parent, ns.getPrefix(), ns.getURI());
}

8. JDOMNamespaceIterator#collectNamespaces()

Project: commons-jxpath
File: JDOMNamespaceIterator.java
/**
     * Collect the namespaces from a JDOM Element.
     * @param element the source Element
     */
private void collectNamespaces(Element element) {
    Namespace ns = element.getNamespace();
    if (ns != null && !prefixes.contains(ns.getPrefix())) {
        namespaces.add(ns);
        prefixes.add(ns.getPrefix());
    }
    List others = element.getAdditionalNamespaces();
    for (int i = 0; i < others.size(); i++) {
        ns = (Namespace) others.get(i);
        if (ns != null && !prefixes.contains(ns.getPrefix())) {
            namespaces.add(ns);
            prefixes.add(ns.getPrefix());
        }
    }
    Object elementParent = element.getParent();
    if (elementParent instanceof Element) {
        collectNamespaces((Element) elementParent);
    }
}

9. OvalFileAggregator#reset()

Project: spacewalk
File: OvalFileAggregator.java
private void reset() {
    Namespace schema = Namespace.getNamespace("xsi", "http://www.w3.org/2000/10/XMLSchema-instance");
    Namespace oval = Namespace.getNamespace("oval", "removeme");
    aggregate = new Document();
    Element root = new Element("oval_definitions");
    root.setAttribute("schemaLocation", "http://oval.mitre.org/XMLSchema/oval-common-5 " + "oval-common-schema.xsd " + "http://oval.mitre.org/XMLSchema/oval-definitions-5 " + "oval-definitions-schema.xsd " + "http://oval.mitre.org/XMLSchema/oval-definitions-5#unix " + "unix-definitions-schema.xsd " + "http://oval.mitre.org/XMLSchema/oval-definitions-5#redhat " + "redhat-definitions-schema.xsd", schema);
    aggregate.setRootElement(root);
    Element generator = new Element("generator");
    Element prodName = new Element("product_name", oval);
    prodName.setText("Spacewalk");
    Element schemaVersion = new Element("schema_version", oval);
    schemaVersion.addNamespaceDeclaration(oval);
    schemaVersion.setText("5.0");
    Element timestamp = new Element("timestamp", oval);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    StringBuilder date = new StringBuilder();
    date.append(cal.get(Calendar.YEAR));
    date.append("-");
    int month = cal.get(Calendar.MONTH);
    if (month < 10) {
        date.append("0");
    }
    date.append(month);
    date.append("-");
    int day = cal.get(Calendar.DATE);
    if (day < 10) {
        date.append("0");
    }
    date.append(day);
    date.append("T").append(cal.get(Calendar.HOUR_OF_DAY));
    date.append(":").append(cal.get(Calendar.MINUTE));
    date.append(":").append(cal.get(Calendar.SECOND));
    timestamp.setText(date.toString());
    root.getChildren().add(generator);
    generator.getChildren().add(prodName);
    generator.getChildren().add(schemaVersion);
    generator.getChildren().add(timestamp);
    defs = new LinkedHashMap();
    tests = new LinkedHashMap();
    objects = new LinkedHashMap();
    states = new LinkedHashMap();
}

10. ForTestingActionExecutor#end()

Project: oozie
File: ForTestingActionExecutor.java
public void end(Context context, WorkflowAction action) throws ActionExecutorException {
    Element eConf = getConfiguration(action.getConf());
    Namespace ns = eConf.getNamespace();
    String error = eConf.getChild("error", ns).getText().trim();
    if ("end.transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "end");
    }
    if ("end.non-transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "end");
    }
    if ("end.error".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "end");
    }
    String signalValue = eConf.getChild("signal-value", ns).getText().trim();
    String externalStatus = action.getExternalStatus();
    WorkflowAction.Status status = null;
    if (externalStatus.equals("ok")) {
        status = WorkflowAction.Status.OK;
    } else {
        status = WorkflowAction.Status.ERROR;
    }
    if (signalValue.equals("based_on_action_status")) {
        signalValue = status.toString();
    }
    boolean callSetEndData = true;
    Element setEndData = eConf.getChild("avoid-set-end-data", ns);
    if (null != setEndData) {
        if (setEndData.getText().trim().equals("true")) {
            callSetEndData = false;
        }
    }
    if (callSetEndData) {
        context.setEndData(status, signalValue);
    }
}

11. ForTestingActionExecutor#start()

Project: oozie
File: ForTestingActionExecutor.java
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
    Element eConf = getConfiguration(action.getConf());
    Namespace ns = eConf.getNamespace();
    String error = eConf.getChild("error", ns).getText().trim();
    if ("start.transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.non-transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.error".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
    }
    String externalStatus = eConf.getChild("external-status", ns).getText().trim();
    String runningMode = "sync";
    Element runningModeElement = eConf.getChild("running-mode", ns);
    if (null != runningModeElement) {
        if (runningModeElement.getText().trim().equals("async")) {
            runningMode = "async";
        }
    }
    if (runningMode.equals("async")) {
        context.setStartData("blah", "blah", "blah");
        return;
    }
    boolean callSetExecutionData = true;
    Element setStartData = eConf.getChild("avoid-set-execution-data", ns);
    if (null != setStartData) {
        if (setStartData.getText().trim().equals("true")) {
            callSetExecutionData = false;
        }
    }
    if (callSetExecutionData) {
        context.setExecutionData(externalStatus, null);
    }
}

12. TestSubmitMRCommand#testWFXmlGeneration()

Project: oozie
File: TestSubmitMRCommand.java
public void testWFXmlGeneration() throws Exception {
    Configuration conf = new Configuration(false);
    conf.set(XOozieClient.JT, "jobtracker");
    conf.set(XOozieClient.NN, "namenode");
    conf.set(OozieClient.LIBPATH, "libpath");
    conf.set("mapred.mapper.class", "A.Mapper");
    conf.set("mapred.reducer.class", "A.Reducer");
    conf.set("oozie.libpath", "libpath");
    conf.set(XOozieClient.FILES, "/user/oozie/input1.txt,/user/oozie/input2.txt#my.txt");
    conf.set(XOozieClient.ARCHIVES, "/user/oozie/udf1.jar,/user/oozie/udf2.jar#my.jar");
    SubmitMRCommand submitMRCmd = new SubmitMRCommand(conf, "token");
    String xml = submitMRCmd.getWorkflowXml(conf);
    Element gen = XmlUtils.parseXml(xml);
    Namespace ns = gen.getNamespace();
    assertEquals("hadoop1", gen.getChild("start", ns).getAttributeValue("to"));
    assertEquals("hadoop1", gen.getChild("action", ns).getAttributeValue("name"));
    assertEquals("fail", gen.getChild("kill", ns).getAttributeValue("name"));
    assertEquals("end", gen.getChild("end", ns).getAttributeValue("name"));
    assertEquals("jobtracker", gen.getChild("action", ns).getChild("map-reduce", ns).getChildText("job-tracker", ns));
    assertEquals("namenode", gen.getChild("action", ns).getChild("map-reduce", ns).getChildText("name-node", ns));
    Element eConf = gen.getChild("action", ns).getChild("map-reduce", ns).getChild("configuration", ns);
    XConfiguration xConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(eConf).toString()));
    Properties genProps = xConf.toProperties();
    Properties expectedProps = new Properties();
    expectedProps.setProperty("mapred.mapper.class", "A.Mapper");
    expectedProps.setProperty("mapred.reducer.class", "A.Reducer");
    expectedProps.setProperty("oozie.libpath", "libpath");
    assertEquals(expectedProps, genProps);
    assertEquals("/user/oozie/input1.txt#input1.txt", ((Element) gen.getChild("action", ns).getChild("map-reduce", ns).getChildren("file", ns).get(0)).getText());
    assertEquals("/user/oozie/input2.txt#my.txt", ((Element) gen.getChild("action", ns).getChild("map-reduce", ns).getChildren("file", ns).get(1)).getText());
    assertEquals("/user/oozie/udf1.jar#udf1.jar", ((Element) gen.getChild("action", ns).getChild("map-reduce", ns).getChildren("archive", ns).get(0)).getText());
    assertEquals("/user/oozie/udf2.jar#my.jar", ((Element) gen.getChild("action", ns).getChild("map-reduce", ns).getChildren("archive", ns).get(1)).getText());
    assertEquals("end", gen.getChild("action", ns).getChild("ok", ns).getAttributeValue("to"));
    assertEquals("fail", gen.getChild("action", ns).getChild("error", ns).getAttributeValue("to"));
    assertNotNull(gen.getChild("kill", ns).getChild("message", ns));
}

13. LiteWorkflowAppParser#parse()

Project: oozie
File: LiteWorkflowAppParser.java
/**
     * Parse xml to {@link LiteWorkflowApp}
     *
     * @param strDef
     * @param root
     * @return LiteWorkflowApp
     * @throws WorkflowException
     */
@SuppressWarnings({ "unchecked", "ConstantConditions" })
private LiteWorkflowApp parse(String strDef, Element root) throws WorkflowException {
    Namespace ns = root.getNamespace();
    LiteWorkflowApp def = null;
    for (Element eNode : (List<Element>) root.getChildren()) {
        if (eNode.getName().equals(START_E)) {
            def = new LiteWorkflowApp(root.getAttributeValue(NAME_A), strDef, new StartNodeDef(eNode.getAttributeValue(TO_A)));
        } else {
            if (eNode.getName().equals(END_E)) {
                def.addNode(new EndNodeDef(eNode.getAttributeValue(NAME_A)));
            } else {
                if (eNode.getName().equals(KILL_E)) {
                    def.addNode(new KillNodeDef(eNode.getAttributeValue(NAME_A), eNode.getChildText(KILL_MESSAGE_E, ns)));
                } else {
                    if (eNode.getName().equals(FORK_E)) {
                        List<String> paths = new ArrayList<String>();
                        for (Element tran : (List<Element>) eNode.getChildren(FORK_PATH_E, ns)) {
                            paths.add(tran.getAttributeValue(FORK_START_A));
                        }
                        def.addNode(new ForkNodeDef(eNode.getAttributeValue(NAME_A), paths));
                    } else {
                        if (eNode.getName().equals(JOIN_E)) {
                            def.addNode(new JoinNodeDef(eNode.getAttributeValue(NAME_A), eNode.getAttributeValue(TO_A)));
                        } else {
                            if (eNode.getName().equals(DECISION_E)) {
                                Element eSwitch = eNode.getChild(DECISION_SWITCH_E, ns);
                                List<String> transitions = new ArrayList<String>();
                                for (Element e : (List<Element>) eSwitch.getChildren(DECISION_CASE_E, ns)) {
                                    transitions.add(e.getAttributeValue(TO_A));
                                }
                                transitions.add(eSwitch.getChild(DECISION_DEFAULT_E, ns).getAttributeValue(TO_A));
                                String switchStatement = XmlUtils.prettyPrint(eSwitch).toString();
                                def.addNode(new DecisionNodeDef(eNode.getAttributeValue(NAME_A), switchStatement, decisionHandlerClass, transitions));
                            } else {
                                if (ACTION_E.equals(eNode.getName())) {
                                    String[] transitions = new String[2];
                                    Element eActionConf = null;
                                    for (Element elem : (List<Element>) eNode.getChildren()) {
                                        if (ACTION_OK_E.equals(elem.getName())) {
                                            transitions[0] = elem.getAttributeValue(TO_A);
                                        } else {
                                            if (ACTION_ERROR_E.equals(elem.getName())) {
                                                transitions[1] = elem.getAttributeValue(TO_A);
                                            } else {
                                                if (SLA_INFO.equals(elem.getName()) || CREDENTIALS.equals(elem.getName())) {
                                                    continue;
                                                } else {
                                                    eActionConf = elem;
                                                }
                                            }
                                        }
                                    }
                                    String credStr = eNode.getAttributeValue(CRED_A);
                                    String userRetryMaxStr = eNode.getAttributeValue(USER_RETRY_MAX_A);
                                    String userRetryIntervalStr = eNode.getAttributeValue(USER_RETRY_INTERVAL_A);
                                    String actionConf = XmlUtils.prettyPrint(eActionConf).toString();
                                    def.addNode(new ActionNodeDef(eNode.getAttributeValue(NAME_A), actionConf, actionHandlerClass, transitions[0], transitions[1], credStr, userRetryMaxStr, userRetryIntervalStr));
                                } else {
                                    if (SLA_INFO.equals(eNode.getName()) || CREDENTIALS.equals(eNode.getName())) {
                                    // No operation is required
                                    } else {
                                        throw new WorkflowException(ErrorCode.E0703, eNode.getName());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return def;
}

14. SubmitPigXCommand#getWorkflowXml()

Project: oozie
File: SubmitPigXCommand.java
/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
     * .hadoop.conf.Configuration)
     */
@Override
protected String getWorkflowXml(Configuration conf) {
    for (String key : MANDATORY_OOZIE_CONFS) {
        String value = conf.get(key);
        if (value == null) {
            throw new RuntimeException(key + " is not specified");
        }
    }
    Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
    Element root = new Element("workflow-app", ns);
    root.setAttribute("name", "oozie-pig");
    Element start = new Element("start", ns);
    start.setAttribute("to", "pig1");
    root.addContent(start);
    Element action = new Element("action", ns);
    action.setAttribute("name", "pig1");
    Element pig = generatePigSection(conf, ns);
    action.addContent(pig);
    Element ok = new Element("ok", ns);
    ok.setAttribute("to", "end");
    action.addContent(ok);
    Element error = new Element("error", ns);
    error.setAttribute("to", "fail");
    action.addContent(error);
    root.addContent(action);
    Element kill = new Element("kill", ns);
    kill.setAttribute("name", "fail");
    Element message = new Element("message", ns);
    message.addContent("Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]");
    kill.addContent(message);
    root.addContent(kill);
    Element end = new Element("end", ns);
    end.setAttribute("name", "end");
    root.addContent(end);
    return XmlUtils.prettyPrint(root).toString();
}

15. SubmitPigCommand#getWorkflowXml()

Project: oozie
File: SubmitPigCommand.java
/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
     * .hadoop.conf.Configuration)
     */
@Override
protected String getWorkflowXml(Configuration conf) {
    for (String key : MANDATORY_OOZIE_CONFS) {
        String value = conf.get(key);
        if (value == null) {
            throw new RuntimeException(key + " is not specified");
        }
    }
    Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
    Element root = new Element("workflow-app", ns);
    root.setAttribute("name", "oozie-pig");
    Element start = new Element("start", ns);
    start.setAttribute("to", "pig1");
    root.addContent(start);
    Element action = new Element("action", ns);
    action.setAttribute("name", "pig1");
    Element pig = generatePigSection(conf, ns);
    action.addContent(pig);
    Element ok = new Element("ok", ns);
    ok.setAttribute("to", "end");
    action.addContent(ok);
    Element error = new Element("error", ns);
    error.setAttribute("to", "fail");
    action.addContent(error);
    root.addContent(action);
    Element kill = new Element("kill", ns);
    kill.setAttribute("name", "fail");
    Element message = new Element("message", ns);
    message.addContent("Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]");
    kill.addContent(message);
    root.addContent(kill);
    Element end = new Element("end", ns);
    end.setAttribute("name", "end");
    root.addContent(end);
    return XmlUtils.prettyPrint(root).toString();
}

16. SubmitMRXCommand#getWorkflowXml()

Project: oozie
File: SubmitMRXCommand.java
/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
     * .hadoop.conf.Configuration)
     */
@Override
protected String getWorkflowXml(Configuration conf) {
    for (String key : MANDATORY_OOZIE_CONFS) {
        String value = conf.get(key);
        if (value == null) {
            throw new RuntimeException(key + " is not specified");
        }
    }
    Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
    Element root = new Element("workflow-app", ns);
    root.setAttribute("name", "oozie-mapreduce");
    Element start = new Element("start", ns);
    start.setAttribute("to", "hadoop1");
    root.addContent(start);
    Element action = new Element("action", ns);
    action.setAttribute("name", "hadoop1");
    Element mapreduce = generateMRSection(conf, ns);
    action.addContent(mapreduce);
    Element ok = new Element("ok", ns);
    ok.setAttribute("to", "end");
    action.addContent(ok);
    Element error = new Element("error", ns);
    error.setAttribute("to", "fail");
    action.addContent(error);
    root.addContent(action);
    Element kill = new Element("kill", ns);
    kill.setAttribute("name", "fail");
    Element message = new Element("message", ns);
    message.addContent("Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]");
    kill.addContent(message);
    root.addContent(kill);
    Element end = new Element("end", ns);
    end.setAttribute("name", "end");
    root.addContent(end);
    return XmlUtils.prettyPrint(root).toString();
}

17. SubmitMRCommand#getWorkflowXml()

Project: oozie
File: SubmitMRCommand.java
/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
     * .hadoop.conf.Configuration)
     */
@Override
protected String getWorkflowXml(Configuration conf) {
    for (String key : MANDATORY_OOZIE_CONFS) {
        String value = conf.get(key);
        if (value == null) {
            throw new RuntimeException(key + " is not specified");
        }
    }
    Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
    Element root = new Element("workflow-app", ns);
    root.setAttribute("name", "oozie-mapreduce");
    Element start = new Element("start", ns);
    start.setAttribute("to", "hadoop1");
    root.addContent(start);
    Element action = new Element("action", ns);
    action.setAttribute("name", "hadoop1");
    Element mapreduce = generateMRSection(conf, ns);
    action.addContent(mapreduce);
    Element ok = new Element("ok", ns);
    ok.setAttribute("to", "end");
    action.addContent(ok);
    Element error = new Element("error", ns);
    error.setAttribute("to", "fail");
    action.addContent(error);
    root.addContent(action);
    Element kill = new Element("kill", ns);
    kill.setAttribute("name", "fail");
    Element message = new Element("message", ns);
    message.addContent("Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]");
    kill.addContent(message);
    root.addContent(kill);
    Element end = new Element("end", ns);
    end.setAttribute("name", "end");
    root.addContent(end);
    return XmlUtils.prettyPrint(root).toString();
}

18. SshActionExecutor#start()

Project: oozie
File: SshActionExecutor.java
/**
     * Start the ssh action execution.
     *
     * @param context action execution context.
     * @param action action object.
     */
@SuppressWarnings("unchecked")
@Override
public void start(final Context context, final WorkflowAction action) throws ActionExecutorException {
    XLog log = XLog.getLog(getClass());
    log.info("start() begins");
    String confStr = action.getConf();
    Element conf;
    try {
        conf = XmlUtils.parseXml(confStr);
    } catch (Exception ex) {
        throw convertException(ex);
    }
    Namespace nameSpace = conf.getNamespace();
    Element hostElement = conf.getChild("host", nameSpace);
    String hostString = hostElement.getValue().trim();
    hostString = prepareUserHost(hostString, context);
    final String host = hostString;
    final String dirLocation = execute(new Callable<String>() {

        public String call() throws Exception {
            return setupRemote(host, context, action);
        }
    });
    String runningPid = execute(new Callable<String>() {

        public String call() throws Exception {
            return checkIfRunning(host, context, action);
        }
    });
    String pid = "";
    if (runningPid == null) {
        final Element commandElement = conf.getChild("command", nameSpace);
        final boolean ignoreOutput = conf.getChild("capture-output", nameSpace) == null;
        if (commandElement != null) {
            List<Element> argsList = conf.getChildren("args", nameSpace);
            StringBuilder args = new StringBuilder("");
            if ((argsList != null) && (argsList.size() > 0)) {
                for (Element argsElement : argsList) {
                    args = args.append(argsElement.getValue()).append(" ");
                }
                args.setLength(args.length() - 1);
            }
            final String argsString = args.toString();
            final String recoveryId = context.getRecoveryId();
            pid = execute(new Callable<String>() {

                @Override
                public String call() throws Exception {
                    return doExecute(host, dirLocation, commandElement.getValue(), argsString, ignoreOutput, action, recoveryId);
                }
            });
        }
        context.setStartData(pid, host, host);
    } else {
        pid = runningPid;
        context.setStartData(pid, host, host);
        check(context, action);
    }
    log.info("start() ends");
}

19. PigActionExecutor#setupLauncherConf()

Project: oozie
File: PigActionExecutor.java
@Override
protected Configuration setupLauncherConf(Configuration conf, Element actionXml, Path appPath, Context context) throws ActionExecutorException {
    super.setupLauncherConf(conf, actionXml, appPath, context);
    Namespace ns = actionXml.getNamespace();
    String script = actionXml.getChild("script", ns).getTextTrim();
    String pigName = new Path(script).getName();
    String pigScriptContent = context.getProtoActionConf().get(XOozieClient.PIG_SCRIPT);
    Path pigScriptFile = null;
    if (pigScriptContent != null) {
        // Create pig script on hdfs if this is
        // an http submission pig job;
        FSDataOutputStream dos = null;
        try {
            Path actionPath = context.getActionDir();
            pigScriptFile = new Path(actionPath, script);
            FileSystem fs = context.getAppFileSystem();
            dos = fs.create(pigScriptFile);
            dos.writeBytes(pigScriptContent);
            addToCache(conf, actionPath, script + "#" + pigName, false);
        } catch (Exception ex) {
            throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FAILED_OPERATION", XLog.format("Not able to write pig script file {0} on hdfs", pigScriptFile), ex);
        } finally {
            try {
                if (dos != null) {
                    dos.close();
                }
            } catch (IOException ex) {
                XLog.getLog(getClass()).error("Error: " + ex.getMessage());
            }
        }
    } else {
        addToCache(conf, appPath, script + "#" + pigName, false);
    }
    return conf;
}

20. MapReduceActionExecutor#setupActionConf()

Project: oozie
File: MapReduceActionExecutor.java
@Override
@SuppressWarnings("unchecked")
Configuration setupActionConf(Configuration actionConf, Context context, Element actionXml, Path appPath) throws ActionExecutorException {
    Namespace ns = actionXml.getNamespace();
    if (actionXml.getChild("streaming", ns) != null) {
        Element streamingXml = actionXml.getChild("streaming", ns);
        String mapper = streamingXml.getChildTextTrim("mapper", ns);
        String reducer = streamingXml.getChildTextTrim("reducer", ns);
        String recordReader = streamingXml.getChildTextTrim("record-reader", ns);
        List<Element> list = (List<Element>) streamingXml.getChildren("record-reader-mapping", ns);
        String[] recordReaderMapping = new String[list.size()];
        for (int i = 0; i < list.size(); i++) {
            recordReaderMapping[i] = list.get(i).getTextTrim();
        }
        list = (List<Element>) streamingXml.getChildren("env", ns);
        String[] env = new String[list.size()];
        for (int i = 0; i < list.size(); i++) {
            env[i] = list.get(i).getTextTrim();
        }
        StreamingMain.setStreaming(actionConf, mapper, reducer, recordReader, recordReaderMapping, env);
    } else {
        if (actionXml.getChild("pipes", ns) != null) {
            Element pipesXml = actionXml.getChild("pipes", ns);
            String map = pipesXml.getChildTextTrim("map", ns);
            String reduce = pipesXml.getChildTextTrim("reduce", ns);
            String inputFormat = pipesXml.getChildTextTrim("inputformat", ns);
            String partitioner = pipesXml.getChildTextTrim("partitioner", ns);
            String writer = pipesXml.getChildTextTrim("writer", ns);
            String program = pipesXml.getChildTextTrim("program", ns);
            PipesMain.setPipes(actionConf, map, reduce, inputFormat, partitioner, writer, program, appPath);
        }
    }
    actionConf = super.setupActionConf(actionConf, context, actionXml, appPath);
    return actionConf;
}

21. JavaActionExecutor#getCaptureOutput()

Project: oozie
File: JavaActionExecutor.java
protected boolean getCaptureOutput(WorkflowAction action) throws JDOMException {
    Element eConf = XmlUtils.parseXml(action.getConf());
    Namespace ns = eConf.getNamespace();
    Element captureOutput = eConf.getChild("capture-output", ns);
    return captureOutput != null;
}

22. JavaActionExecutor#prepare()

Project: oozie
File: JavaActionExecutor.java
void prepare(Context context, Element actionXml) throws ActionExecutorException {
    Namespace ns = actionXml.getNamespace();
    Element prepare = actionXml.getChild("prepare", ns);
    if (prepare != null) {
        XLog.getLog(getClass()).debug("Preparing the action with FileSystem operation");
        FsActionExecutor fsAe = new FsActionExecutor();
        fsAe.doOperations(context, prepare);
        XLog.getLog(getClass()).debug("FS Operation is completed");
    }
}

23. JavaActionExecutor#getLauncherMain()

Project: oozie
File: JavaActionExecutor.java
protected String getLauncherMain(Configuration launcherConf, Element actionXml) {
    Namespace ns = actionXml.getNamespace();
    Element e = actionXml.getChild("main-class", ns);
    return e.getTextTrim();
}

24. EmailActionExecutor#validateAndMail()

Project: oozie
File: EmailActionExecutor.java
@SuppressWarnings("unchecked")
protected void validateAndMail(Context context, Element element) throws ActionExecutorException {
    // The XSD does the min/max occurrence validation for us.
    Namespace ns = Namespace.getNamespace("uri:oozie:email-action:0.1");
    String tos[] = new String[0];
    String ccs[] = new String[0];
    String subject = "";
    String body = "";
    Element child = null;
    // <to> - One ought to exist.
    String text = element.getChildTextTrim(TO, ns);
    if (text.isEmpty()) {
        throw new ActionExecutorException(ErrorType.ERROR, "EM001", "No receipents were specified in the to-address field.");
    }
    tos = text.split(COMMA);
    // <cc> - Optional, but only one ought to exist.
    try {
        ccs = element.getChildTextTrim(CC, ns).split(COMMA);
    } catch (Exception e) {
        ccs = new String[0];
    }
    // <subject> - One ought to exist.
    subject = element.getChildTextTrim(SUB, ns);
    // <body> - One ought to exist.
    body = element.getChildTextTrim(BOD, ns);
    // All good - lets try to mail!
    email(context, tos, ccs, subject, body);
}

25. PodcastService#getITunesAttribute()

Project: libresonic
File: PodcastService.java
private String getITunesAttribute(Element element, String childName, String attributeName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        Element elem = element.getChild(childName, ns);
        if (elem != null) {
            return StringUtils.trimToNull(elem.getAttributeValue(attributeName));
        }
    }
    return null;
}

26. PodcastService#getITunesElement()

Project: libresonic
File: PodcastService.java
private String getITunesElement(Element element, String childName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        String value = element.getChildTextTrim(childName, ns);
        if (value != null) {
            return value;
        }
    }
    return null;
}

27. NATO4676Decoder#readTrackPointDetail()

Project: geowave
File: NATO4676Decoder.java
private TrackPointDetail readTrackPointDetail(final Element element, final Namespace xmlns) {
    final Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    final TrackPointDetail detail = new TrackPointDetail();
    final List<Element> children = element.getChildren();
    final Iterator<Element> childIter = children.iterator();
    while (childIter.hasNext()) {
        final Element child = childIter.next();
        final String childName = child.getName();
        final String childValue = child.getValue();
        if ("pointDetailPosition".equals(childName)) {
            // check which type...
            final Attribute xsitype = child.getAttribute("type", xsi);
            if (xsitype != null) {
                if ("GeodeticPosition".equals(xsitype.getValue())) {
                    detail.location = readGeodeticPosition(child, xmlns);
                } else if ("LocalCartesianPosition".equals(xsitype.getValue())) {
                // TODO: Add support for reading LocalCartesianPosition
                }
            } else {
                try {
                    final GeodeticPosition geoPos = readGeodeticPosition(child, xmlns);
                    if (geoPos != null) {
                        detail.location = geoPos;
                    }
                } catch (final Exception e) {
                    LOGGER.error("Could not identify TrackPoint position type", e);
                }
            }
        } else if ("pointDetailVelocity".equals(childName)) {
            final Attribute xsitype = child.getAttribute("type", xsi);
            if (xsitype != null) {
                if ("LocalCartesianVelocity".equals(xsitype.getValue())) {
                    final Double[] velCoords = readLocalCartesianVelocity(child);
                    detail.velocityX = velCoords[0];
                    detail.velocityY = velCoords[1];
                    detail.velocityZ = velCoords[2];
                }
            } else {
                try {
                    final Double[] velCoords = readLocalCartesianVelocity(child);
                    detail.velocityX = velCoords[0];
                    detail.velocityY = velCoords[1];
                    detail.velocityZ = velCoords[2];
                } catch (final Exception e) {
                    LOGGER.error("Could not identify TrackPoint velocity", e);
                }
            }
        } else if ("pointDetailAcceleration".equals(childName)) {
            final Attribute xsitype = child.getAttribute("type", xsi);
            if (xsitype != null) {
                if ("LocalCartesianAcceleration".equals(xsitype.getValue())) {
                    final Double[] accelCoords = readLocalCartesianAccel(child);
                    detail.accelerationX = accelCoords[0];
                    detail.accelerationY = accelCoords[1];
                    detail.accelerationZ = accelCoords[2];
                }
            } else {
                try {
                    final Double[] accelCoords = readLocalCartesianAccel(child);
                    detail.accelerationX = accelCoords[0];
                    detail.accelerationY = accelCoords[1];
                    detail.accelerationZ = accelCoords[2];
                } catch (final Exception e) {
                    LOGGER.error("Could not identify TrackPoint velocity", e);
                }
            }
        } else if ("pointDetailCovarianceMatrix".equals(childName)) {
            detail.covarianceMatrix = readCovarianceMatrix(child, xmlns);
        }
    }
    return detail;
}