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.InstallStatus;
37 import info.magnolia.module.ModuleManagementException;
38 import info.magnolia.module.ModuleManager;
39
40 import java.io.Writer;
41
42
43
44
45
46 public class ModuleManagerNullUI implements ModuleManagerUI {
47 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ModuleManagerNullUI.class);
48
49 private final ModuleManager moduleManager;
50
51 public ModuleManagerNullUI(ModuleManager moduleManager) {
52 this.moduleManager = moduleManager;
53 }
54
55 @Override
56 public void onStartup() throws ModuleManagementException {
57 final ModuleManager.ModuleManagementState moduleMgtState = moduleManager.getStatus();
58 if (moduleMgtState.needsUpdateOrInstall()) {
59 log.info("\n" +
60 "*********************************************************************************************************\n" +
61 "* *\n" +
62 "* Magnolia needs module updates or installs, and the magnolia.update.auto property is set to true, *\n" +
63 "* so they will be applied automatically now. *\n" +
64 "* *\n" +
65 "*********************************************************************************************************");
66 moduleManager.performInstallOrUpdate();
67 final InstallStatus status = moduleManager.getInstallContext().getStatus();
68 if (!InstallStatus.installDone.equals(status)) {
69 log.warn("Install could not be performed. Please check your logs and fix the appropriate issues before trying again.");
70 return;
71 }
72 moduleManager.startModules();
73 } else {
74 moduleManager.startModules();
75 }
76 }
77
78 @Override
79 public boolean execute(Writer out, String command) throws ModuleManagementException {
80 throw new IllegalStateException("This implementation of ModuleManagerUI is only meant to be used at startup.");
81 }
82
83 @Override
84 public void renderTempPage(Writer out) {
85 throw new IllegalStateException("This implementation of ModuleManagerUI is only meant to be used at startup.");
86 }
87 }