1 37 package net.sourceforge.cruisecontrol; 38 39 import java.io.Serializable ; 40 import java.util.ArrayList ; 41 import java.util.Collections ; 42 import java.util.List ; 43 import java.util.Map ; 44 import java.util.Properties ; 45 import java.util.Iterator ; 46 47 import net.sourceforge.cruisecontrol.util.ValidationHelper; 48 49 53 public class ProjectConfig implements Serializable { 54 55 private String name; 56 private boolean buildAfterFailed = true; 57 private CCDateFormat dateFormat; 58 59 private Bootstrappers bootstrappers; 60 private LabelIncrementer labelIncrementer; 61 private Listeners listeners; 62 private Log log; 63 private ModificationSet modificationSet; 64 private Publishers publishers; 65 private Schedule schedule; 66 67 private Map properties; 68 69 75 public void validate() throws CruiseControlException { 76 if (dateFormat != null) { 77 dateFormat.validate(); 78 } 79 ValidationHelper.assertTrue(schedule != null, "project requires a schedule"); 80 81 if (bootstrappers != null) { 82 bootstrappers.validate(); 83 } 84 85 if (listeners != null) { 86 listeners.validate(); 87 } 88 89 if (log != null) { 90 log.validate(); 91 } 92 93 if (modificationSet != null) { 94 modificationSet.validate(); 95 } 96 97 if (schedule != null) { 98 schedule.validate(); 99 } 100 101 if (publishers != null) { 102 publishers.validate(); 103 } 104 } 105 106 public void setName(String name) { 107 this.name = name; 108 } 109 110 void setProperties(Map properties) { 112 this.properties = properties; 113 } 114 115 public void setBuildAfterFailed(boolean buildAfterFailed) { 116 this.buildAfterFailed = buildAfterFailed; 117 } 118 119 public void add(CCDateFormat dateFormat) { 120 this.dateFormat = dateFormat; 121 } 122 123 public void add(ModificationSet modificationSet) { 124 this.modificationSet = modificationSet; 125 } 126 127 public void add(Bootstrappers bootstrappers) { 128 this.bootstrappers = bootstrappers; 129 } 130 131 public void add(Listeners listeners) { 132 this.listeners = listeners; 133 } 134 135 public void add(Publishers publishers) { 136 this.publishers = publishers; 137 } 138 139 public void add(Schedule schedule) { 140 this.schedule = schedule; 141 } 142 143 public void add(Log log) { 144 this.log = log; 145 } 146 147 public void add(LabelIncrementer labelIncrementer) { 148 this.labelIncrementer = labelIncrementer; 149 } 150 151 public CCDateFormat getDateFormat() { return dateFormat; } 152 153 public boolean shouldBuildAfterFailed() { return buildAfterFailed; } 154 155 public Log getLog() { return log; } 156 157 public List getBootstrappers() { 158 return bootstrappers == null ? Collections.EMPTY_LIST : bootstrappers.getBootstrappers(); 159 } 160 161 public List getListeners() { return listeners == null ? Collections.EMPTY_LIST : listeners.getListeners(); } 162 163 public List getPublishers() { return publishers == null ? Collections.EMPTY_LIST : publishers.getPublishers(); } 164 165 public ModificationSet getModificationSet() { return modificationSet; } 166 167 public Schedule getSchedule() { return schedule; } 168 169 public LabelIncrementer getLabelIncrementer() { return labelIncrementer; } 170 171 public String getName() { return name; } 172 173 public Properties getProperties() { 175 Properties props = new Properties (); 176 props.putAll(properties); 177 return props; 178 } 179 180 public static class Bootstrappers { 181 private List bootstrappers = new ArrayList (); 182 public void add(Bootstrapper bootstrapper) { 183 bootstrappers.add(bootstrapper); 184 } 185 public List getBootstrappers() { return bootstrappers; } 186 187 public void validate() throws CruiseControlException { 188 for (Iterator iterator = bootstrappers.iterator(); iterator.hasNext();) { 189 Bootstrapper nextBootstrapper = (Bootstrapper) iterator.next(); 190 nextBootstrapper.validate(); 191 } 192 } 193 } 194 195 public static class Listeners { 196 private List listeners = new ArrayList (); 197 public void add(Listener listener) { 198 listeners.add(listener); 199 } 200 public List getListeners() { return listeners; } 201 202 public void validate() throws CruiseControlException { 203 for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { 204 Listener nextListener = (Listener) iterator.next(); 205 nextListener.validate(); 206 } 207 } 208 } 209 210 public static class Publishers { 211 private List publishers = new ArrayList (); 212 public void add(Publisher publisher) { 213 publishers.add(publisher); 214 } 215 public List getPublishers() { return publishers; } 216 217 public void validate() throws CruiseControlException { 218 for (Iterator iterator = publishers.iterator(); iterator.hasNext();) { 219 Publisher nextPublisher = (Publisher) iterator.next(); 220 nextPublisher.validate(); 221 } 222 223 } 224 } 225 } 226 | Popular Tags |