01: package net.sourceforge.cruisecontrol.bootstrappers;
02:
03: import java.io.IOException;
04:
05: import net.sourceforge.cruisecontrol.Bootstrapper;
06: import net.sourceforge.cruisecontrol.CruiseControlException;
07: import net.sourceforge.cruisecontrol.sourcecontrols.AlienBrainCore;
08: import net.sourceforge.cruisecontrol.util.ManagedCommandline;
09: import net.sourceforge.cruisecontrol.util.ValidationHelper;
10:
11: public class AlienBrainBootstrapper extends AlienBrainCore implements
12: Bootstrapper {
13:
14: /** Configuration parameters */
15: private String localPath;
16: private boolean forceFileUpdate;
17: private String overwriteWritable = "skip";
18:
19: public void setLocalPath(String localPath) {
20: this .localPath = localPath;
21: }
22:
23: public void setForceFileUpdate(boolean forceFileUpdate) {
24: this .forceFileUpdate = forceFileUpdate;
25: }
26:
27: public void setOverwriteWritable(String policy) {
28: this .overwriteWritable = policy.toLowerCase();
29: }
30:
31: public void validate() throws CruiseControlException {
32: ValidationHelper
33: .assertIsSet(getPath(), "path", this .getClass());
34: ValidationHelper
35: .assertTrue(
36: "skip".equals(overwriteWritable)
37: || "replace".equals(overwriteWritable),
38: "overwritewritable must be one of 'skip' or 'replace' in AlienBrainBootstrapper");
39: }
40:
41: public void bootstrap() throws CruiseControlException {
42: try {
43: if (getBranch() != null) {
44: setActiveBranch(getBranch());
45: }
46:
47: ManagedCommandline cmdLine = buildBootstrapCommand();
48: cmdLine.execute();
49: } catch (IOException e) {
50: throw new CruiseControlException(
51: "Error executing AlienBrain bootstrap", e);
52: }
53: }
54:
55: public ManagedCommandline buildBootstrapCommand() {
56: ManagedCommandline cmdLine = buildCommonCommand();
57:
58: cmdLine.createArguments("getlatest", getPath());
59: addArgumentIfSet(cmdLine, localPath, "-localpath");
60: addFlagIfSet(cmdLine, forceFileUpdate, "-forcefileupdate");
61: addArgumentIfSet(cmdLine, overwriteWritable,
62: "-overwritewritable");
63:
64: return cmdLine;
65: }
66: }
|