View Javadoc

1   package org.rundeck.api.generator;
2   
3   import org.dom4j.DocumentFactory;
4   import org.dom4j.Element;
5   import org.rundeck.api.domain.ProjectConfig;
6   
7   /**
8    * ProjectConfigGenerator is ...
9    *
10   * @author greg
11   * @since 2014-02-27
12   */
13  public class ProjectConfigGenerator extends BaseDocGenerator {
14      private ProjectConfig config;
15  
16      public ProjectConfigGenerator(ProjectConfig config) {
17          this.config = config;
18      }
19  
20      @Override
21      public Element generateXmlElement() {
22          Element configEl = DocumentFactory.getInstance().createElement("config");
23          if (null != config.getProperties()) {
24              for (String s : config.getProperties().keySet()) {
25                  Element property = configEl.addElement("property");
26                  property.addAttribute("key", s);
27                  property.addAttribute("value", config.getProperties().get(s));
28              }
29          }
30          return configEl;
31      }
32  
33  }