View Javadoc

1   package org.rundeck.api.parser;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.dom4j.Node;
5   import org.rundeck.api.domain.BaseState;
6   import org.rundeck.api.domain.RundeckWFExecState;
7   
8   /**
9    * $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:19 PM
10   */
11  public class BaseStateParser extends BaseXpathParser<BaseState> {
12      public static void parseBaseState(Node targetNode, BaseState state) {
13          state.setEndTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("endTime"))));
14          state.setStartTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("startTime"))));
15          state.setUpdateTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("updateTime"))));
16  
17          try {
18              state.setExecutionState(RundeckWFExecState.valueOf(StringUtils.upperCase(targetNode.valueOf
19                      ("executionState"))));
20          } catch (IllegalArgumentException e) {
21              state.setExecutionState(null);
22          }
23      }
24  
25      private String xpath;
26  
27      public BaseStateParser() {
28      }
29  
30      public BaseStateParser(String xpath) {
31  
32          this.xpath = xpath;
33      }
34  
35      @Override
36      public BaseState parse(Node targetNode) {
37          BaseState baseState = new BaseState();
38          parseBaseState(targetNode, baseState);
39          return baseState;
40      }
41  }