View Javadoc

1   package org.rundeck.api.parser;
2   
3   import org.dom4j.Node;
4   import org.rundeck.api.domain.ProjectConfig;
5   
6   import java.util.List;
7   
8   /**
9    * ProjectConfigParser parses project "config" element contents
10   *
11   * @author greg
12   * @since 2014-02-27
13   */
14  public class ProjectConfigParser extends BaseXpathParser<ProjectConfig> {
15      private String xpath;
16  
17      public ProjectConfigParser() {
18          super();
19      }
20  
21      public ProjectConfigParser(String xpath) {
22          super(xpath);
23      }
24  
25      @Override
26      public ProjectConfig parse(Node config1) {
27          ProjectConfig config = new ProjectConfig();
28          List property = config1.selectNodes("property");
29          for (Object o : property) {
30              Node propnode = (Node) o;
31              String key = propnode.valueOf("@key");
32              String value = propnode.valueOf("@value");
33              if (null != key && null != value) {
34                  config.setProperty(key, value);
35              }
36          }
37          return config;
38      }
39  
40  }