KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > bootstrappers > AlienBrainBootstrapper


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