MCPcopy Index your code
hub / github.com/GerritCodeReview/gerrit / InitContainer

Class InitContainer

java/com/google/gerrit/pgm/init/InitContainer.java:37–122  ·  view source on GitHub ↗

Initialize the container configuration section.

Source from the content-addressed store, hash-verified

35
36/** Initialize the {@code container} configuration section. */
37@Singleton
38class InitContainer implements InitStep {
39 private final ConsoleUI ui;
40 private final SitePaths site;
41 private final Section container;
42
43 @Inject
44 InitContainer(ConsoleUI ui, SitePaths site, Section.Factory sections) {
45 this.ui = ui;
46 this.site = site;
47 this.container = sections.get("container", null);
48 }
49
50 @Override
51 public void run() throws FileNotFoundException, IOException {
52 ui.header("Container Process");
53
54 container.string("Run as", "user", username());
55 container.string("Java runtime", "javaHome", javaHome());
56
57 Path myWar;
58 try {
59 myWar = GerritLauncher.getDistributionArchive().toPath();
60 } catch (FileNotFoundException e) {
61 System.err.println("warn: Cannot find distribution archive (e.g. gerrit.war)");
62 myWar = null;
63 }
64
65 String path = container.get("war");
66 if (path != null) {
67 path =
68 container.string(
69 "Gerrit runtime", "war", myWar != null ? myWar.toAbsolutePath().toString() : null);
70 if (path == null || path.isEmpty()) {
71 throw die("container.war is required");
72 }
73
74 } else if (myWar != null) {
75 final boolean copy;
76 final Path siteWar = site.gerrit_war;
77 if (Files.exists(siteWar)) {
78 if (Files.isSameFile(siteWar, myWar)) {
79 copy = false;
80 } else {
81 copy = ui.yesno(true, "Upgrade %s", siteWar);
82 }
83 } else {
84 copy = ui.yesno(true, "Copy %s to %s", myWar.getFileName(), siteWar);
85 if (copy) {
86 container.unset("war");
87 } else {
88 container.set("war", myWar.toAbsolutePath().toString());
89 }
90 }
91 if (copy) {
92 if (!ui.isBatch()) {
93 System.err.format("Copying %s to %s", myWar.getFileName(), siteWar);
94 System.err.println();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected