1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.rundeck.api.parser;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.dom4j.Node;
29 import org.rundeck.api.domain.RundeckJobDelete;
30 import org.rundeck.api.domain.RundeckJobDeleteBulk;
31
32 import java.util.*;
33
34
35
36
37
38
39
40 public class BulkDeleteParser extends BaseXpathParser<RundeckJobDeleteBulk> {
41
42
43 public BulkDeleteParser(final String xpath) {
44 super(xpath);
45 }
46
47 @Override
48 public RundeckJobDeleteBulk parse(Node subnode) {
49 final ArrayList<RundeckJobDelete> deletes = new ArrayList<RundeckJobDelete>();
50 final List results = subnode.selectNodes("(succeeded|failed)/deleteJobResult");
51 final DeleteParser parser = new DeleteParser();
52 if (null != results && results.size() > 0) {
53 for (final Object o : results) {
54 deletes.add(parser.parseXmlNode((Node) o));
55 }
56 }
57
58 final String requestcount = StringUtils.trimToNull(subnode.valueOf("@requestCount"));
59 final String allsuccessString = StringUtils.trimToNull(subnode.valueOf("@allsuccessful"));
60 int count = 0;
61 boolean allsuccess = false;
62 if (null != requestcount) {
63 try {
64 count = Integer.parseInt(requestcount);
65 } catch (NumberFormatException e) {
66
67 }
68 }
69 if (null != allsuccessString) {
70 allsuccess = Boolean.parseBoolean(allsuccessString);
71 }
72
73 return new RundeckJobDeleteBulk(deletes, count, allsuccess);
74 }
75 }