Skip to content

Commit 027cca5

Browse files
committed
MIR-1565 fix some issues with the start of mir-wizard
1 parent 62401e3 commit 027cca5

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

mir-wizard/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@
136136
<groupId>org.mycore</groupId>
137137
<artifactId>mycore-classifications</artifactId>
138138
</dependency>
139+
<dependency>
140+
<groupId>org.mycore</groupId>
141+
<artifactId>mycore-cronjob</artifactId>
142+
</dependency>
139143
<dependency>
140144
<groupId>org.mycore</groupId>
141145
<artifactId>mycore-solr</artifactId>

mir-wizard/src/main/java/org/mycore/mir/wizard/MIRWizardStartupHandler.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.File;
2626
import java.io.IOException;
27+
import java.time.Duration;
2728
import java.util.EnumSet;
2829
import java.util.Locale;
2930
import java.util.UUID;
@@ -38,6 +39,7 @@
3839
import org.mycore.common.config.MCRConfiguration2;
3940
import org.mycore.common.config.MCRConfigurationDir;
4041
import org.mycore.common.events.MCRStartupHandler;
42+
import org.mycore.mcr.cronjob.MCRCronjobManager;
4143

4244
import jakarta.servlet.DispatcherType;
4345
import jakarta.servlet.FilterRegistration.Dynamic;
@@ -136,6 +138,9 @@ public void startUp(ServletContext servletContext) {
136138
}
137139
}
138140

141+
LOGGER.info("Disabling MyCoRe Cron Jobs");
142+
MCRCronjobManager.getInstance().prepareClose();
143+
139144
servletContext.setAttribute(MCRStartupHandler.HALT_ON_ERROR, Boolean.toString(false));
140145

141146
LOGGER.info("Register " + WIZARD_FILTER_NAME + "...");
@@ -158,6 +163,8 @@ public void startUp(ServletContext servletContext) {
158163
LOGGER.info("Couldn't map " + WIZARD_SERVLET_NAME + "!");
159164
}
160165

166+
String wizStylesheet = MCRConfiguration2.getStringOrThrow("MIR.Wizard.LayoutStylesheet");
167+
MCRConfiguration2.set("MCR.LayoutTransformerFactory.Default.Stylesheets", wizStylesheet);
161168
//disable ACL system
162169
//store for later use...
163170
servletContext.setAttribute(ACCESS_CLASS, MCRConfiguration2.getString(ACCESS_CLASS).orElse(null));
@@ -166,11 +173,23 @@ public void startUp(ServletContext servletContext) {
166173
MCRConfiguration2.set(ACCESS_CLASS, MCRAccessBaseImpl.class.getName());
167174
MCRConfiguration2.set(ACCESS_STRATEGY_CLASS, MCRObjectIDStrategy.class.getName());
168175

169-
//generate UUID as login token
170-
final String token = UUID.randomUUID().toString();
171-
servletContext.setAttribute(LOGIN_TOKEN, token);
176+
Thread.ofVirtual()
177+
.name("login-token")
178+
.start(() -> {
179+
//generate UUID as login token
180+
final String token = UUID.randomUUID().toString();
181+
servletContext.setAttribute(LOGIN_TOKEN, token);
182+
183+
//wait for a few seconds to put the token at the end of the log output
184+
try {
185+
Thread.sleep(Duration.ofSeconds(4));
186+
} catch (InterruptedException e) {
187+
Thread.currentThread().interrupt();
188+
return;
189+
}
172190

173-
outputLoginToken(servletContext);
191+
outputLoginToken(servletContext);
192+
});
174193
}
175194
}
176195

0 commit comments

Comments
 (0)