1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.ui;
35
36 import info.magnolia.module.ModuleManagementException;
37 import info.magnolia.module.ModuleManager;
38 import info.magnolia.module.InstallStatus;
39
40 import java.io.Writer;
41
42
43
44
45
46
47
48
49 public class ModuleManagerNullUI implements ModuleManagerUI {
50 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ModuleManagerNullUI.class);
51
52 private final ModuleManager moduleManager;
53
54 public ModuleManagerNullUI(ModuleManager moduleManager) {
55 this.moduleManager = moduleManager;
56 }
57
58 public void onStartup() throws ModuleManagementException {
59 final ModuleManager.ModuleManagementState moduleMgtState = moduleManager.getStatus();
60 if (moduleMgtState.needsUpdateOrInstall()) {
61 log.info("\n" +
62 "*********************************************************************************************************\n" +
63 "* *\n" +
64 "* Magnolia needs module updates or installs, and the magnolia.update.auto property is set to true, *\n" +
65 "* so they will be applied automatically now. *\n" +
66 "* *\n" +
67 "*********************************************************************************************************");
68 moduleManager.performInstallOrUpdate();
69 final InstallStatus status = moduleManager.getInstallContext().getStatus();
70 if (!InstallStatus.installDone.equals(status)) {
71 log.warn("Install could not be performed. Please check your logs and fix the appropriate issues before trying again.");
72 return;
73 }
74 moduleManager.startModules();
75 } else {
76 moduleManager.startModules();
77 }
78 }
79
80 public boolean execute(Writer out, String command) throws ModuleManagementException {
81 throw new IllegalStateException("This implementation of ModuleManagerUI is only meant to be used at startup.");
82 }
83
84 public void renderTempPage(Writer out) {
85 throw new IllegalStateException("This implementation of ModuleManagerUI is only meant to be used at startup.");
86 }
87 }