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 import org.dom4j.Node;
20 import org.rundeck.api.domain.RundeckEvent;
21 import org.rundeck.api.domain.RundeckHistory;
22
23
24
25
26
27
28 public class HistoryParser extends BaseXpathParser<RundeckHistory> {
29
30
31 public HistoryParser(final String xpath) {
32 super(xpath);
33 }
34
35 @Override
36 public RundeckHistory parse(Node eventsNode) {
37
38 RundeckHistory history = new RundeckHistory();
39
40 history.setCount(Integer.valueOf(eventsNode.valueOf("@count")));
41 history.setTotal(Integer.valueOf(eventsNode.valueOf("@total")));
42 history.setMax(Integer.valueOf(eventsNode.valueOf("@max")));
43 history.setOffset(Integer.valueOf(eventsNode.valueOf("@offset")));
44
45 @SuppressWarnings("unchecked")
46 List<Node> eventNodes = eventsNode.selectNodes("event");
47 EventParser eventParser = new EventParser();
48
49 for (Node eventNode : eventNodes) {
50 RundeckEvent event = eventParser.parseXmlNode(eventNode);
51 history.addEvent(event);
52 }
53
54 return history;
55 }
56
57 }