1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.rundeck.api.parser;
17
18 import java.util.List;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.dom4j.Node;
22 import org.rundeck.api.domain.RundeckJob;
23 import org.rundeck.api.domain.RundeckJobsImportResult;
24
25
26
27
28
29
30 public class JobsImportResultParser extends BaseXpathParser<RundeckJobsImportResult> {
31
32
33 public JobsImportResultParser(final String xpath) {
34 super(xpath);
35 }
36
37 @Override
38 public RundeckJobsImportResult parse(Node resultNode) {
39
40 RundeckJobsImportResult result = new RundeckJobsImportResult();
41
42 @SuppressWarnings("unchecked")
43 List<Node> succeededJobsNodes = resultNode.selectNodes("succeeded/job");
44 if (succeededJobsNodes != null) {
45 for (Node succeededJobNode : succeededJobsNodes) {
46 RundeckJob job = new JobParser().parseXmlNode(succeededJobNode);
47 result.addSucceededJob(job);
48 }
49 }
50
51 @SuppressWarnings("unchecked")
52 List<Node> skippedJobsNodes = resultNode.selectNodes("skipped/job");
53 if (skippedJobsNodes != null) {
54 for (Node skippedJobNode : skippedJobsNodes) {
55 RundeckJob job = new JobParser().parseXmlNode(skippedJobNode);
56 result.addSkippedJob(job);
57 }
58 }
59
60 @SuppressWarnings("unchecked")
61 List<Node> failedJobsNodes = resultNode.selectNodes("failed/job");
62 if (failedJobsNodes != null) {
63 for (Node failedJobNode : failedJobsNodes) {
64 RundeckJob job = new JobParser().parseXmlNode(failedJobNode);
65 result.addFailedJob(job, failedJobNode.valueOf("error"));
66 }
67 }
68
69 return result;
70 }
71
72 }