diff --git a/HMI_V5_10_SCHEMA_RECOVERY.md b/HMI_V5_10_SCHEMA_RECOVERY.md new file mode 100644 index 0000000..e1ce826 --- /dev/null +++ b/HMI_V5_10_SCHEMA_RECOVERY.md @@ -0,0 +1,47 @@ +# WidgetWorkbench V5.10 – Bootstrap- und JDBC-Recovery + +## Warum 503 / 403 aufgetreten sind + +- `/api/hmi/v1/security/csrf` blockierte bisher CSRF-Tokens, wenn der Tabellen-Bootstrap scheiterte. +- `/api/hmi/v1/diagnostics` setzte `hmi-admin` voraus, selbst wenn noch keine Rollentabellen existierten. +- Die JNDI-Ressource `dsCustNJTA` **kann nicht** aus der HMI automatisch erzeugt werden, solange der zugehörige JDBC-Pool und die Datenbank-Credentials fehlen. + +Ab V5.10 liefert der CSRF-Endpunkt einer bereits IMSAPI-authentifizierten Sitzung auch bei nicht initialisiertem Schema HTTP 200, inklusive `schemaReady=false` und ungefährlichem Fehlercode. Während `schemaReady=false` darf jeder **angemeldete IMSAPI-Benutzer** ausschließlich die lesende Datenbankdiagnose verwenden. Nach der Einrichtung benötigt er wieder `hmi-admin`. + +Ein fehlgeschlagener Tabellen-Bootstrap kann über `/backend/hmi-diagnose.html` wiederholt werden, wenn ein Betreiber den nur in `server.log` gedruckten **HMI SCHEMA RECOVERY CODE** verwendet. Dieser Code erlaubt ausschließlich die Wiederholung der fest eingebauten DDL-Initialisierung. Er verleiht keine Rollen, erlaubt kein freies SQL und ersetzt keine Pool-Konfiguration. Nach erfolgreichem Bootstrap wird der Code ungültig. Maximal acht ungültige Versuche pro Deployment. + +## Diagnose vor dem Update + +`https://SERVER:8181/backend/hmi-health` + +Prüfe `poolConnectedAtStartup`, `initializationPhase`, `failureCode`. + +```bash +# Aus dem GlassFish/Payara-bin-Verzeichnis (entsprechenden Domain-Namen einsetzen) +asadmin list-jdbc-resources +asadmin get 'resources.jdbc-resource.dsCustNJTA.*' +asadmin list-jdbc-connection-pools +asadmin ping-connection-pool POOL_NAME +# PostgreSQL ist hier NICHT Ziel: Es wird Oracle oder MS SQL Server unterstützt. +grep -E 'HMI schema initialization FAILED|HMI SCHEMA RECOVERY CODE|HmiSchemaBootstrap|dsCustNJTA' /pfad/domain1/logs/server.log | tail -n 35 +``` + +Wenn `dsCustNJTA` nicht existiert, muss ein GlassFish-Administrator die JDBC-Ressource mit einem **vorher korrekt konfigurierten** Pool verbinden. Das HMI kann keine Datenbank-Credentials erraten. Ist der Pool erreichbar, braucht der DB-User Rechte zum Erstellen/Ändern von Tabellen im Schema CUST bzw. cust. + +Bei `SCHEMA_MIGRATION_REQUIRED` gibt es bereits ein altes HMI-Tabellenschema. Dann **nicht Tabellen löschen**: erst die passende nichtdestruktive Migrationsdatei unter `hmi-docs` prüfen. + +## Recovery nach Pool-Konfiguration + +1. Per IMSAPI auf `/backend/hmi-diagnose.html` anmelden. +2. Mit **Pool und Tabellen jetzt prüfen** eine lesende Prüfung durchführen. +3. Erscheint weiterhin `schemaReady=false`: Einmaligen Betreiber-Code aus dem GlassFish-Log eingeben und **Tabellenanlage erneut prüfen**. +4. Für neu angelegte Tabellen die bisherige Einrichtung des ersten `hmi-admin` über den separaten `HMI FIRST ADMIN SETUP CODE` abschließen. Der Recovery-Code ist kein Administrator-Code. +5. Nach erfolgreicher Einrichtung wird die Datenbankdiagnose erneut nur für `hmi-admin` freigegeben. + +### Sicherheit + +Bitte weder den Recovery-Code noch Datenbankpasswörter in Git, Tickets oder Support-Chats kopieren. Ein `HTTP 503` enthält absichtlich keine JDBC-URLs, SQL-Texte oder Passwörter; die technischen Ursachen stehen im `server.log`. + +### Tests + +Java-11-Syntaxprüfung, REST-/Role-Gate-Kontrolltest und HTML-/JS-Syntaxprüfung bestanden. Kein Live-Test gegen den iTAC-GlassFish, Oracle oder SQL Server durchgeführt. Das vollständige WAR muss im Zielsystem mit Maven/Vite neu gebaut und deployed werden. diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiApiResource.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiApiResource.java index 573effb..15704ab 100644 --- a/backend/src/main/java/com/workbenchclassic/hmi/HmiApiResource.java +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiApiResource.java @@ -225,12 +225,15 @@ public class HmiApiResource { } return out; } - /** Requires a GlassFish administrator role; tests dsCustNJTA LIVE and returns safe metadata. */ + /** After initial setup: admin only. During failed first initialization: IMSAPI read-only diagnostics. */ @GET @Path("diagnostics") public Response diagnostics() { if (user() == null) return err(401, "IMSAPI-Anmeldung erforderlich"); - if (!admin()) return err(403, "hmi-admin role required"); + boolean initialized = HmiSchemaBootstrap.isReady(); + boolean isAdmin = admin(); + if (initialized && !isAdmin) return err(403, "hmi-admin role required"); JSONObject out = new JSONObject() + .put("access", !initialized && !isAdmin ? "INITIALIZATION_READ_ONLY" : "ADMIN") .put("user", user()) .put("readyAtDeployment", HmiSchemaBootstrap.isReady()) .put("initializationPhase", HmiSchemaBootstrap.phase()) diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiHealthServlet.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiHealthServlet.java index f9ffe38..4e67bea 100644 --- a/backend/src/main/java/com/workbenchclassic/hmi/HmiHealthServlet.java +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiHealthServlet.java @@ -17,6 +17,7 @@ public final class HmiHealthServlet extends HttpServlet { .put("poolConnectedAtStartup", HmiSchemaBootstrap.poolConnected()) .put("databaseKind", HmiSchemaBootstrap.databaseKind()) .put("schemaInitialized", HmiSchemaBootstrap.isReady()) + .put("operatorRetryAvailable", HmiSchemaRecovery.available()) .put("initializationPhase", HmiSchemaBootstrap.phase()) .put("failureCode", HmiSchemaBootstrap.failureCode()) .put("authMode", "IMSAPI_REGLOGIN") diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiImsapiSecurityResource.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiImsapiSecurityResource.java index aaeb061..5f75b49 100644 --- a/backend/src/main/java/com/workbenchclassic/hmi/HmiImsapiSecurityResource.java +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiImsapiSecurityResource.java @@ -74,7 +74,9 @@ public class HmiImsapiSecurityResource { .put("csrf",csrf).put("designer",HmiAuth.designer(request)) .put("publisher",HmiAuth.publisher(request)).put("admin",HmiAuth.admin(request)) .put("scriptEditor",HmiAuth.scriptEditor(request)) - .put("bootstrapRequired",HmiInitialAdmin.required())); + .put("bootstrapRequired",HmiInitialAdmin.required()) + .put("schemaReady",HmiSchemaBootstrap.isReady()) + .put("schemaFailureCode",HmiSchemaBootstrap.failureCode())); } catch (IllegalStateException ex) { return error(503,"IMSAPI-Ziel nicht automatisch ermittelbar; HMI und MES müssen direkt auf demselben Host laufen oder ein separates Ziel erhalten"); } catch (IOException ex) { @@ -89,12 +91,13 @@ public class HmiImsapiSecurityResource { public Response csrf() { String user=HmiAuth.user(request); if (user==null) return error(401,"IMSAPI-Anmeldung erforderlich"); - if (!HmiSchemaBootstrap.isReady()) return error(503,"HMI-Schema nicht bereit; Diagnose prüfen"); return json(200,new JSONObject().put("user",user).put("station",HmiAuth.station(request)) .put("csrf",HmiAuth.initCsrf(request)).put("designer",HmiAuth.designer(request)) .put("publisher",HmiAuth.publisher(request)).put("admin",HmiAuth.admin(request)) .put("scriptEditor",HmiAuth.scriptEditor(request)) - .put("bootstrapRequired",HmiInitialAdmin.required())); + .put("bootstrapRequired",HmiInitialAdmin.required()) + .put("schemaReady",HmiSchemaBootstrap.isReady()) + .put("schemaFailureCode",HmiSchemaBootstrap.failureCode())); } @POST @Path("logout") public Response logout() { diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaBootstrap.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaBootstrap.java index 71febdb..75c1d50 100644 --- a/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaBootstrap.java +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaBootstrap.java @@ -19,6 +19,7 @@ import javax.servlet.ServletContextListener; */ public final class HmiSchemaBootstrap implements ServletContextListener { private static final Logger LOG = Logger.getLogger(HmiSchemaBootstrap.class.getName()); + private static final Object START_LOCK = new Object(); private static volatile boolean ready = false; private static volatile String state = "Not initialized"; // The public health endpoint exposes only fixed diagnostic codes, never SQL errors or connection credentials. @@ -34,7 +35,10 @@ public final class HmiSchemaBootstrap implements ServletContextListener { static String databaseKind() { return databaseKind; } + static void retryInitialization() { new HmiSchemaBootstrap().contextInitialized(null); } + @Override public void contextInitialized(ServletContextEvent event) { + synchronized (START_LOCK) { ready = false; poolConnected = false; databaseKind = "UNKNOWN"; @@ -153,6 +157,7 @@ public final class HmiSchemaBootstrap implements ServletContextListener { HmiDb.useDatabase(oracle); ready = true; HmiInitialAdmin.initialize(c); + HmiSchemaRecovery.clear(); phase = "READY"; code = "NONE"; state = "Initialized: " + product + ", schema " + (oracle ? "CUST" : "cust") + ", version 7"; @@ -166,8 +171,10 @@ public final class HmiSchemaBootstrap implements ServletContextListener { else code = "DATABASE_ERROR"; } state = "Database initialization failed; inspect GlassFish logs"; + HmiSchemaRecovery.enableAfterFailure(); LOG.log(Level.SEVERE, "HMI schema initialization FAILED [" + code + ", phase=" + phase + "]; HMI endpoints remain unavailable", ex); } + } // START_LOCK } private boolean pageParentColumnExists(Connection c, boolean oracle) throws SQLException { diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecovery.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecovery.java new file mode 100644 index 0000000..ee384b5 --- /dev/null +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecovery.java @@ -0,0 +1,44 @@ +package com.workbenchclassic.hmi; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.SecureRandom; +import java.util.Base64; +import java.util.logging.Logger; + +/** A deployment-scoped operator secret authorizes ONLY re-running existing schema bootstrap. + * It neither creates a JDBC pool nor grants HMI roles. Keep the secret in server.log. */ +final class HmiSchemaRecovery { + private static final Logger LOG = Logger.getLogger(HmiSchemaRecovery.class.getName()); + private static final SecureRandom RANDOM = new SecureRandom(); + private static byte[] secretHash; + private static int failedAttempts; + private HmiSchemaRecovery() { } + + static synchronized void enableAfterFailure() { + if (secretHash != null) return; + byte[] data = new byte[32]; + RANDOM.nextBytes(data); + String secret = Base64.getUrlEncoder().withoutPadding().encodeToString(data); + secretHash = sha256(secret); + failedAttempts = 0; + LOG.warning("HMI SCHEMA RECOVERY CODE (deployment-only; keep confidential): " + secret); + LOG.warning("HMI schema bootstrap failed. Configure/ping dsCustNJTA first; an authenticated operator can retry via hmi-diagnose.html using the recovery code. This does NOT grant roles."); + } + static synchronized boolean available() { return secretHash != null && failedAttempts < 8; } + static synchronized boolean authorize(String candidate) { + if (!available()) return false; + if (candidate == null || candidate.length() > 150) { failedAttempts++; return false; } + boolean matched = MessageDigest.isEqual(secretHash, sha256(candidate)); + if (!matched) failedAttempts++; + return matched; + } + static synchronized void clear() { + secretHash = null; + failedAttempts = 0; + } + private static byte[] sha256(String value) { + try { return MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)); } + catch (java.security.NoSuchAlgorithmException ex) { throw new IllegalStateException(ex); } + } +} diff --git a/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecoveryResource.java b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecoveryResource.java new file mode 100644 index 0000000..8cf9ba5 --- /dev/null +++ b/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecoveryResource.java @@ -0,0 +1,42 @@ +package com.workbenchclassic.hmi; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.json.JSONObject; + +/** Safe manual retry when automatic schema creation failed at WAR startup. + * IMSAPI login + CSRF + secret from the local GlassFish log are all required. + * No SQL, arbitrary datasource, or privileged role-management operations are exposed. */ +@Path("/hmi/v1/maintenance/schema") +@Produces(MediaType.APPLICATION_JSON) +public final class HmiSchemaRecoveryResource { + @Context private HttpServletRequest request; + private Response reply(int status, JSONObject result) { + return Response.status(status).type(MediaType.APPLICATION_JSON) + .header("Cache-Control", "no-store").entity(result.toString()).build(); + } + @POST @Path("retry") @Consumes(MediaType.APPLICATION_JSON) + public Response retry(String body) { + if (HmiAuth.user(request) == null) return reply(401, new JSONObject().put("error", "IMSAPI-Anmeldung erforderlich")); + if (!HmiAuth.csrf(request)) return reply(403, new JSONObject().put("error", "CSRF/Origin ungueltig")); + if (HmiSchemaBootstrap.isReady()) return reply(409, new JSONObject().put("error", "Schema ist bereits initialisiert")); + if (body == null || body.length() > 400) return reply(400, new JSONObject().put("error", "Ungueltige Eingabe")); + JSONObject input; + try { input = new JSONObject(body); } + catch (Exception e) { return reply(400, new JSONObject().put("error", "Ungueltiges JSON")); } + if (!HmiSchemaRecovery.authorize(input.optString("recoveryCode", ""))) + return reply(403, new JSONObject().put("error", "Einrichtungscode ungueltig oder gesperrt")); + HmiSchemaBootstrap.retryInitialization(); + boolean ready = HmiSchemaBootstrap.isReady(); + return reply(ready ? 200 : 503, new JSONObject() + .put("ready", ready).put("phase", HmiSchemaBootstrap.phase()) + .put("failureCode", HmiSchemaBootstrap.failureCode()) + .put("error", ready ? JSONObject.NULL : "Initialisierung fehlgeschlagen; server.log pruefen")); + } +} diff --git a/backend/src/main/webapp/hmi-diagnose.html b/backend/src/main/webapp/hmi-diagnose.html index b98ccca..4635044 100644 --- a/backend/src/main/webapp/hmi-diagnose.html +++ b/backend/src/main/webapp/hmi-diagnose.html @@ -4,7 +4,13 @@

Workbench HMI · Systemdiagnose

Prüfung von IMSAPI-Anmeldung, GlassFish-Datasource und HMI-Schemainitialisierung. Es werden keine Zugangsdaten angezeigt.

Server und Datenbank beim Deployment

Prüfung läuft …

IMSAPI-Anmeldung und Rollen

Prüfung läuft …

Für eine authentifizierte Live-Diagnose mit IMSAPI anmelden:

Zum HMI
-

Live-Test über dsCustNJTA

Der Live-Test ist nur für über IMSAPI angemeldete HMI-Administratoren freigegeben.

Noch nicht geprüft.
+

Live-Test über dsCustNJTA

Bei fehlgeschlagener Erstinitialisierung ist der Lese-Test bereits nach IMSAPI-Anmeldung möglich; nach erfolgreicher Initialisierung nur für hmi-admin.

Noch nicht geprüft.
+

Systemeinstellungen · HTTP / HTTPS

Direkt neben der Datenbankdiagnose: Konfiguration der IMSAPI-HTTP-Verbindung und des Browser-Logins. Nur mit IMSAPI-Anmeldung und hmi-admin möglich.

Fehlen beide JVM-Optionen, ist HTTP standardmäßig zugelassen. Zum Sperren beide Schalter deaktivieren.

Bitte zunächst als HMI-Administrator anmelden.
@@ -21,14 +27,17 @@ +Workbench HMI
diff --git a/backend/target/backend-1.war b/backend/target/backend-1.war index c8c135a..1d6a152 100644 Binary files a/backend/target/backend-1.war and b/backend/target/backend-1.war differ diff --git a/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiApiResource.class b/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiApiResource.class index 8974ef8..137a1a2 100644 Binary files a/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiApiResource.class and b/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiApiResource.class differ diff --git a/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class b/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class index 852b23b..2629aba 100644 Binary files a/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class and b/backend/target/backend-1/WEB-INF/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class differ diff --git a/backend/target/backend-1/hmi/index.html b/backend/target/backend-1/hmi/index.html index 0e9d632..d0b163e 100644 --- a/backend/target/backend-1/hmi/index.html +++ b/backend/target/backend-1/hmi/index.html @@ -1,3 +1,3 @@ -Workbench HMI +Workbench HMI
diff --git a/backend/target/classes/com/workbenchclassic/hmi/HmiApiResource.class b/backend/target/classes/com/workbenchclassic/hmi/HmiApiResource.class index 8974ef8..137a1a2 100644 Binary files a/backend/target/classes/com/workbenchclassic/hmi/HmiApiResource.class and b/backend/target/classes/com/workbenchclassic/hmi/HmiApiResource.class differ diff --git a/backend/target/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class b/backend/target/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class index 852b23b..2629aba 100644 Binary files a/backend/target/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class and b/backend/target/classes/com/workbenchclassic/hmi/HmiSchemaBootstrap.class differ diff --git a/backend/target/jacoco.exec b/backend/target/jacoco.exec index 650be15..7d23b86 100644 Binary files a/backend/target/jacoco.exec and b/backend/target/jacoco.exec differ diff --git a/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 7669265..d527a97 100644 --- a/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,5 +1,6 @@ com/workbenchclassic/GetStationsApi$LineNode.class com/workbenchclassic/hmi/HmiStyleResource.class +com/workbenchclassic/hmi/HmiSchemaRecovery.class com/workbenchclassic/DBService.class com/workbenchclassic/GetERPGroups.class com/workbenchclassic/ImportUser.class @@ -41,6 +42,7 @@ com/workbenchclassic/hmi/HmiJvmOptions.class com/workbenchclassic/hmi/HmiApiResource.class com/workbenchclassic/hmi/HmiSystemSettingsResource.class com/workbenchclassic/hmi/HmiRolesResource.class +com/workbenchclassic/hmi/HmiSchemaRecoveryResource.class com/workbenchclassic/hmi/HmiTransportPolicy.class com/workbenchclassic/SetStationConfig.class com/workbenchclassic/hmi/HmiHealthServlet.class diff --git a/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index cd3a999..e5d168c 100644 --- a/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/backend/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -33,6 +33,8 @@ /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiOriginFilter.java /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiRolesResource.java /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaBootstrap.java +/home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecovery.java +/home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiSchemaRecoveryResource.java /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiStyleResource.java /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiStyles.java /home/chris/hmi/WidgetWorkbench/backend/src/main/java/com/workbenchclassic/hmi/HmiSystemSettingsResource.java diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.html index 10d752f..263b47a 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.html @@ -1 +1 @@ -HmiApiResource

HmiApiResource

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total4.507 of 4.5070 %567 of 5670 %3523525435436767
effective(String, String)4220 %660 %3434464611
validateTemplate(JSONObject)3570 %700 %3636494911
saveLayout(String, String)2430 %240 %1313232311
diagnostics()2010 %220 %1212282811
saveTemplate(String, String)1740 %240 %1313272711
assign(String)1630 %180 %1010131311
updatePage(String, String)1490 %100 %66222211
resolveTemplate(Connection, String, String, List)1470 %160 %99141411
createTemplate(String, String)1420 %120 %77171711
validateOverrides(JSONObject)1380 %200 %1111141411
createPage(String)1360 %60 %44191911
static {...}1340 %n/a113311
publish(String)1280 %200 %1111171711
pages()1230 %140 %88161611
validatePreferences(JSONObject)1180 %230 %1414101011
scripts(JSONObject)1100 %140 %88171711
groupMember(String, String)1060 %160 %99101011
renameRootMenu(String)1010 %100 %66131311
archive(String)950 %160 %99101011
viewableRoleNames()920 %60 %449911
updateDescendantMenus(Connection, String, String)870 %100 %66191911
getTemplate(String)840 %100 %669911
storePreferences(String, String, JSONObject)780 %20 %228811
templates(String)680 %40 %336611
fetchPage(Connection, String)680 %60 %445511
groups(Connection, String)620 %80 %559911
clob(ResultSet, String)510 %60 %447711
validWidgetRoles(JSONArray)510 %100 %669911
widgets()450 %40 %334411
validatePageParent(Connection, String, String)450 %120 %77101011
audit(Connection, String, String, String)440 %20 %224411
visiblePage(String, Map)410 %100 %669911
groupPreferences(String, String)310 %40 %333311
parentId(JSONObject)300 %80 %555511
preference(Connection, String, String)300 %20 %223311
myPreferences()260 %20 %222211
denied(boolean)240 %60 %444411
bounded(JSONObject, String, int, int, int)240 %60 %443311
pageMenu(JSONObject)240 %60 %444411
parentMenu(Connection, String)230 %20 %224411
parentOf(Connection, String)230 %20 %224411
myPreferencesSave(String)230 %20 %222211
status()210 %20 %221111
need(JSONObject, String, int)200 %40 %333311
merge(JSONObject, JSONObject)200 %20 %221111
writeAllowed(boolean)180 %40 %332211
stationKey(String)180 %60 %443311
boundedScale(double)180 %60 %441111
objectOrEmpty(String)150 %40 %331111
err(int, String)140 %n/a112211
dbError(Exception)120 %n/a112211
json(Object)110 %20 %221111
clob(PreparedStatement, int, String)100 %n/a112211
scriptChanges(JSONObject, JSONObject)100 %20 %221111
parse(String)90 %20 %221111
pageExists(Connection, String)90 %20 %221111
role(String)50 %n/a111111
user()40 %n/a111111
designer()40 %n/a111111
publisher()40 %n/a111111
admin()40 %n/a111111
scriptEditor()40 %n/a111111
csrfValid()40 %n/a111111
legalKey(String)40 %n/a111111
HmiApiResource()0 %n/a111111
id()0 %n/a111111
schema()0 %n/a111111
\ No newline at end of file +HmiApiResource

HmiApiResource

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total4.522 of 4.5220 %573 of 5730 %3553555465466767
effective(String, String)4220 %660 %3434464611
validateTemplate(JSONObject)3570 %700 %3636494911
saveLayout(String, String)2430 %240 %1313232311
diagnostics()2160 %280 %1515313111
saveTemplate(String, String)1740 %240 %1313272711
assign(String)1630 %180 %1010131311
updatePage(String, String)1490 %100 %66222211
resolveTemplate(Connection, String, String, List)1470 %160 %99141411
createTemplate(String, String)1420 %120 %77171711
validateOverrides(JSONObject)1380 %200 %1111141411
createPage(String)1360 %60 %44191911
static {...}1340 %n/a113311
publish(String)1280 %200 %1111171711
pages()1230 %140 %88161611
validatePreferences(JSONObject)1180 %230 %1414101011
scripts(JSONObject)1100 %140 %88171711
groupMember(String, String)1060 %160 %99101011
renameRootMenu(String)1010 %100 %66131311
archive(String)950 %160 %99101011
viewableRoleNames()920 %60 %449911
updateDescendantMenus(Connection, String, String)870 %100 %66191911
getTemplate(String)840 %100 %669911
storePreferences(String, String, JSONObject)780 %20 %228811
templates(String)680 %40 %336611
fetchPage(Connection, String)680 %60 %445511
groups(Connection, String)620 %80 %559911
clob(ResultSet, String)510 %60 %447711
validWidgetRoles(JSONArray)510 %100 %669911
widgets()450 %40 %334411
validatePageParent(Connection, String, String)450 %120 %77101011
audit(Connection, String, String, String)440 %20 %224411
visiblePage(String, Map)410 %100 %669911
groupPreferences(String, String)310 %40 %333311
parentId(JSONObject)300 %80 %555511
preference(Connection, String, String)300 %20 %223311
myPreferences()260 %20 %222211
denied(boolean)240 %60 %444411
bounded(JSONObject, String, int, int, int)240 %60 %443311
pageMenu(JSONObject)240 %60 %444411
parentMenu(Connection, String)230 %20 %224411
parentOf(Connection, String)230 %20 %224411
myPreferencesSave(String)230 %20 %222211
status()210 %20 %221111
need(JSONObject, String, int)200 %40 %333311
merge(JSONObject, JSONObject)200 %20 %221111
writeAllowed(boolean)180 %40 %332211
stationKey(String)180 %60 %443311
boundedScale(double)180 %60 %441111
objectOrEmpty(String)150 %40 %331111
err(int, String)140 %n/a112211
dbError(Exception)120 %n/a112211
json(Object)110 %20 %221111
clob(PreparedStatement, int, String)100 %n/a112211
scriptChanges(JSONObject, JSONObject)100 %20 %221111
parse(String)90 %20 %221111
pageExists(Connection, String)90 %20 %221111
role(String)50 %n/a111111
user()40 %n/a111111
designer()40 %n/a111111
publisher()40 %n/a111111
admin()40 %n/a111111
scriptEditor()40 %n/a111111
csrfValid()40 %n/a111111
legalKey(String)40 %n/a111111
HmiApiResource()0 %n/a111111
id()0 %n/a111111
schema()0 %n/a111111
\ No newline at end of file diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.java.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.java.html index a29adb9..d2380ea 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.java.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiApiResource.java.html @@ -225,548 +225,551 @@ import org.json.JSONObject; } return out; } - /** Requires a GlassFish administrator role; tests dsCustNJTA LIVE and returns safe metadata. */ + /** After initial setup: admin only. During failed first initialization: IMSAPI read-only diagnostics. */ @GET @Path("diagnostics") public Response diagnostics() { if (user() == null) return err(401, "IMSAPI-Anmeldung erforderlich"); - if (!admin()) return err(403, "hmi-admin role required"); - JSONObject out = new JSONObject() - .put("user", user()) - .put("readyAtDeployment", HmiSchemaBootstrap.isReady()) - .put("initializationPhase", HmiSchemaBootstrap.phase()) - .put("failureCode", HmiSchemaBootstrap.failureCode()) - .put("pool", "dsCustNJTA"); - try (Connection c = HmiDb.open()) { - String db = c.getMetaData().getDatabaseProductName(); - boolean oracle = db.toLowerCase(java.util.Locale.ROOT).contains("oracle"); - boolean sqlServer = db.toLowerCase(java.util.Locale.ROOT).contains("sql server"); - out.put("poolReachableNow", true).put("database", oracle ? "ORACLE" : sqlServer ? "SQL_SERVER" : "UNKNOWN") - .put("schema", oracle ? "CUST" : "cust"); - try (PreparedStatement p = c.prepareStatement(oracle ? "SELECT 1 FROM DUAL" : "SELECT 1"); - ResultSet rs = p.executeQuery()) { - out.put("connectionQueryOk", rs.next() && rs.getInt(1) == 1); + boolean initialized = HmiSchemaBootstrap.isReady(); + boolean isAdmin = admin(); + if (initialized && !isAdmin) return err(403, "hmi-admin role required"); + JSONObject out = new JSONObject() + .put("access", !initialized && !isAdmin ? "INITIALIZATION_READ_ONLY" : "ADMIN") + .put("user", user()) + .put("readyAtDeployment", HmiSchemaBootstrap.isReady()) + .put("initializationPhase", HmiSchemaBootstrap.phase()) + .put("failureCode", HmiSchemaBootstrap.failureCode()) + .put("pool", "dsCustNJTA"); + try (Connection c = HmiDb.open()) { + String db = c.getMetaData().getDatabaseProductName(); + boolean oracle = db.toLowerCase(java.util.Locale.ROOT).contains("oracle"); + boolean sqlServer = db.toLowerCase(java.util.Locale.ROOT).contains("sql server"); + out.put("poolReachableNow", true).put("database", oracle ? "ORACLE" : sqlServer ? "SQL_SERVER" : "UNKNOWN") + .put("schema", oracle ? "CUST" : "cust"); + try (PreparedStatement p = c.prepareStatement(oracle ? "SELECT 1 FROM DUAL" : "SELECT 1"); + ResultSet rs = p.executeQuery()) { + out.put("connectionQueryOk", rs.next() && rs.getInt(1) == 1); } - int found = 0; - String[] tables = {"HMI_APP_PAGE", "HMI_APP_LAYOUT", "HMI_APP_PREF", "HMI_APP_CSS_REVISION", "HMI_APP_SCHEMA_VERSION"}; - for (String t : tables) { - try (ResultSet rs = c.getMetaData().getTables(null, oracle ? "CUST" : "cust", t, new String[]{"TABLE"})) { - if (rs.next()) found++; + int found = 0; + String[] tables = {"HMI_APP_PAGE", "HMI_APP_LAYOUT", "HMI_APP_PREF", "HMI_APP_CSS_REVISION", "HMI_APP_SCHEMA_VERSION"}; + for (String t : tables) { + try (ResultSet rs = c.getMetaData().getTables(null, oracle ? "CUST" : "cust", t, new String[]{"TABLE"})) { + if (rs.next()) found++; } } - out.put("tablesFound", found).put("tablesExpected", tables.length); - return json(out); - } catch (SQLException e) { - java.util.logging.Logger.getLogger(HmiApiResource.class.getName()) - .log(java.util.logging.Level.WARNING, "Authenticated HMI diagnostics failed", e); - return json(out.put("poolReachableNow", false).put("connectionQueryOk", false).put("failure", "CHECK_GLASSFISH_LOG")); + out.put("tablesFound", found).put("tablesExpected", tables.length); + return json(out); + } catch (SQLException e) { + java.util.logging.Logger.getLogger(HmiApiResource.class.getName()) + .log(java.util.logging.Level.WARNING, "Authenticated HMI diagnostics failed", e); + return json(out.put("poolReachableNow", false).put("connectionQueryOk", false).put("failure", "CHECK_GLASSFISH_LOG")); } } @GET @Path("status") - public Response status() { Response r = denied(admin()); return r != null ? r : json(new JSONObject().put("ready",true).put("detail",HmiSchemaBootstrap.state())); } + public Response status() { Response r = denied(admin()); return r != null ? r : json(new JSONObject().put("ready",true).put("detail",HmiSchemaBootstrap.state())); } @GET @Path("widgets") - public Response widgets() { Response r = denied(true); if (r!=null) return r; - JSONArray a = new JSONArray(); - for (String t : WIDGET_TYPES) a.put(new JSONObject().put("type",t).put("name",t.replace("mes.", "MES: ").replace("ui.", "UI: "))); - return json(a); + public Response widgets() { Response r = denied(true); if (r!=null) return r; + JSONArray a = new JSONArray(); + for (String t : WIDGET_TYPES) a.put(new JSONObject().put("type",t).put("name",t.replace("mes.", "MES: ").replace("ui.", "UI: "))); + return json(a); } @GET @Path("roles") public Response viewableRoleNames() { - Response r=denied(designer()); if(r!=null)return r; - JSONArray out=new JSONArray(); java.util.Set<String> seen=new java.util.TreeSet<>(); - java.util.Collections.addAll(seen,"hmi-admin","hmi-designer","hmi-publisher","hmi-script-editor"); - try(Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement( - "SELECT ROLE_KEY FROM "+schema()+"HMI_APP_ROLE ORDER BY ROLE_KEY");ResultSet rs=p.executeQuery()) { - while(rs.next())seen.add(rs.getString(1)); - for(String name:seen)out.put(new JSONObject().put("key",name).put("description",name)); - return json(out); - }catch(SQLException e){return dbError(e);} + Response r=denied(designer()); if(r!=null)return r; + JSONArray out=new JSONArray(); java.util.Set<String> seen=new java.util.TreeSet<>(); + java.util.Collections.addAll(seen,"hmi-admin","hmi-designer","hmi-publisher","hmi-script-editor"); + try(Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement( + "SELECT ROLE_KEY FROM "+schema()+"HMI_APP_ROLE ORDER BY ROLE_KEY");ResultSet rs=p.executeQuery()) { + while(rs.next())seen.add(rs.getString(1)); + for(String name:seen)out.put(new JSONObject().put("key",name).put("description",name)); + return json(out); + }catch(SQLException e){return dbError(e);} } /** A hidden parent also hides the complete subtree for normal operators. */ private static boolean visiblePage(String pageId, java.util.Map<String,JSONObject> byId) { - java.util.Set<String> seen=new java.util.HashSet<>(); - String current=pageId; - while(current!=null) { - if(!seen.add(current))return false; - JSONObject page=byId.get(current); - if(page==null || !page.getBoolean("enabled"))return false; - current=page.isNull("parentPageId")?null:page.optString("parentPageId",null); - } - return true; + java.util.Set<String> seen=new java.util.HashSet<>(); + String current=pageId; + while(current!=null) { + if(!seen.add(current))return false; + JSONObject page=byId.get(current); + if(page==null || !page.getBoolean("enabled"))return false; + current=page.isNull("parentPageId")?null:page.optString("parentPageId",null); + } + return true; } @GET @Path("pages") public Response pages() { - Response r = denied(true); if (r!=null) return r; - JSONArray out = new JSONArray(); - java.util.Map<String,JSONObject> found=new java.util.LinkedHashMap<>(); - try(Connection c=HmiDb.open();PreparedStatement ps=c.prepareStatement( - "SELECT ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID FROM " + schema() + "HMI_APP_PAGE ORDER BY SORT_ORDER,TITLE"); - ResultSet rs=ps.executeQuery()) { - while(rs.next()) { - String parent=rs.getString(7); - JSONObject page=new JSONObject().put("id",rs.getString(1)).put("key",rs.getString(2)).put("title",rs.getString(3)) - .put("menuGroup",rs.getString(4)).put("order",rs.getInt(5)).put("enabled",rs.getInt(6)==1) - .put("parentPageId",parent==null?JSONObject.NULL:parent); - found.put(page.getString("id"),page); - } - for(JSONObject page:found.values()) if(designer()||visiblePage(page.getString("id"),found))out.put(page); - return json(out); - }catch(SQLException e){return dbError(e);} + Response r = denied(true); if (r!=null) return r; + JSONArray out = new JSONArray(); + java.util.Map<String,JSONObject> found=new java.util.LinkedHashMap<>(); + try(Connection c=HmiDb.open();PreparedStatement ps=c.prepareStatement( + "SELECT ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID FROM " + schema() + "HMI_APP_PAGE ORDER BY SORT_ORDER,TITLE"); + ResultSet rs=ps.executeQuery()) { + while(rs.next()) { + String parent=rs.getString(7); + JSONObject page=new JSONObject().put("id",rs.getString(1)).put("key",rs.getString(2)).put("title",rs.getString(3)) + .put("menuGroup",rs.getString(4)).put("order",rs.getInt(5)).put("enabled",rs.getInt(6)==1) + .put("parentPageId",parent==null?JSONObject.NULL:parent); + found.put(page.getString("id"),page); + } + for(JSONObject page:found.values()) if(designer()||visiblePage(page.getString("id"),found))out.put(page); + return json(out); + }catch(SQLException e){return dbError(e);} } /** Parent references are validated server-side to prevent broken or cyclic navigation. */ private static String parentId(JSONObject input) { - if (input.isNull("parentPageId") || !input.has("parentPageId")) return null; - String value = input.getString("parentPageId").trim(); - if (value.isEmpty()) return null; - if (!legalKey(value)) throw new JSONException("Invalid parentPageId"); - return value; + if (input.isNull("parentPageId") || !input.has("parentPageId")) return null; + String value = input.getString("parentPageId").trim(); + if (value.isEmpty()) return null; + if (!legalKey(value)) throw new JSONException("Invalid parentPageId"); + return value; } private static String pageMenu(JSONObject input) { - String menu = input.optString("menuGroup", "Allgemein").trim(); - if (menu.isEmpty() || menu.length() > 120 || menu.indexOf('/') >= 0) - throw new JSONException("Invalid root menu name"); - return menu; + String menu = input.optString("menuGroup", "Allgemein").trim(); + if (menu.isEmpty() || menu.length() > 120 || menu.indexOf('/') >= 0) + throw new JSONException("Invalid root menu name"); + return menu; } private static String parentMenu(Connection c, String parentId) throws SQLException { - try (PreparedStatement ps=c.prepareStatement("SELECT MENU_GROUP FROM " + schema() + "HMI_APP_PAGE WHERE ID=?")) { - ps.setString(1,parentId); - try (ResultSet rs=ps.executeQuery()) { - return rs.next() ? rs.getString(1) : null; + try (PreparedStatement ps=c.prepareStatement("SELECT MENU_GROUP FROM " + schema() + "HMI_APP_PAGE WHERE ID=?")) { + ps.setString(1,parentId); + try (ResultSet rs=ps.executeQuery()) { + return rs.next() ? rs.getString(1) : null; } } } private static String parentOf(Connection c, String id) throws SQLException { - try (PreparedStatement ps=c.prepareStatement("SELECT PARENT_PAGE_ID FROM " + schema() + "HMI_APP_PAGE WHERE ID=?")) { - ps.setString(1,id); - try (ResultSet rs=ps.executeQuery()) { - return rs.next() ? rs.getString(1) : null; + try (PreparedStatement ps=c.prepareStatement("SELECT PARENT_PAGE_ID FROM " + schema() + "HMI_APP_PAGE WHERE ID=?")) { + ps.setString(1,id); + try (ResultSet rs=ps.executeQuery()) { + return rs.next() ? rs.getString(1) : null; } } } private static void validatePageParent(Connection c, String currentId, String parent) throws SQLException { - if (parent == null) return; - java.util.Set<String> visited = new java.util.HashSet<>(); - String candidate = parent; - for (int depth=0;candidate!=null;depth++) { - if (depth > 32 || !visited.add(candidate) || candidate.equals(currentId)) - throw new JSONException("Navigation cycle or depth limit detected"); - if (parentMenu(c,candidate)==null) - throw new JSONException("Parent page not found"); - candidate = parentOf(c,candidate); + if (parent == null) return; + java.util.Set<String> visited = new java.util.HashSet<>(); + String candidate = parent; + for (int depth=0;candidate!=null;depth++) { + if (depth > 32 || !visited.add(candidate) || candidate.equals(currentId)) + throw new JSONException("Navigation cycle or depth limit detected"); + if (parentMenu(c,candidate)==null) + throw new JSONException("Parent page not found"); + candidate = parentOf(c,candidate); } - } + } /** Propagate the root-menu name through all descendants when a page changes group. */ private static void updateDescendantMenus(Connection c, String rootId, String menu) throws SQLException { - java.util.Set<String> seen = new java.util.HashSet<>(); - java.util.ArrayDeque<String> pending = new java.util.ArrayDeque<>(); - pending.add(rootId);seen.add(rootId); - while (!pending.isEmpty()) { - String current=pending.remove(); - try(PreparedStatement ps=c.prepareStatement("SELECT ID FROM " + schema() + "HMI_APP_PAGE WHERE PARENT_PAGE_ID=?")) { - ps.setString(1,current); - try(ResultSet rs=ps.executeQuery()) { - while(rs.next()) { - String child=rs.getString(1); - if (!seen.add(child)) throw new SQLException("Navigation cycle in stored page tree"); - if (seen.size()>1000) throw new SQLException("Too many navigation pages"); - pending.add(child); - } + java.util.Set<String> seen = new java.util.HashSet<>(); + java.util.ArrayDeque<String> pending = new java.util.ArrayDeque<>(); + pending.add(rootId);seen.add(rootId); + while (!pending.isEmpty()) { + String current=pending.remove(); + try(PreparedStatement ps=c.prepareStatement("SELECT ID FROM " + schema() + "HMI_APP_PAGE WHERE PARENT_PAGE_ID=?")) { + ps.setString(1,current); + try(ResultSet rs=ps.executeQuery()) { + while(rs.next()) { + String child=rs.getString(1); + if (!seen.add(child)) throw new SQLException("Navigation cycle in stored page tree"); + if (seen.size()>1000) throw new SQLException("Too many navigation pages"); + pending.add(child); + } } } - if(!current.equals(rootId)) { - try(PreparedStatement ps=c.prepareStatement("UPDATE " + schema() + "HMI_APP_PAGE SET MENU_GROUP=? WHERE ID=?")) { - ps.setString(1,menu);ps.setString(2,current);ps.executeUpdate(); + if(!current.equals(rootId)) { + try(PreparedStatement ps=c.prepareStatement("UPDATE " + schema() + "HMI_APP_PAGE SET MENU_GROUP=? WHERE ID=?")) { + ps.setString(1,menu);ps.setString(2,current);ps.executeUpdate(); } } - } - } + } + } @POST @Path("pages") @Consumes(MediaType.APPLICATION_JSON) public Response createPage(String body) { - Response r=writeAllowed(designer()); if(r!=null)return r; + Response r=writeAllowed(designer()); if(r!=null)return r; try { - JSONObject input=parse(body); - String key=need(input,"key",120); if(!legalKey(key)) return err(400,"Invalid page key"); - String title=need(input,"title",255), pageId=id(); - String menu=pageMenu(input), parent=parentId(input); - int order=bounded(input,"order",0,100000,0); - try (Connection c=HmiDb.open()) { - c.setAutoCommit(false); + JSONObject input=parse(body); + String key=need(input,"key",120); if(!legalKey(key)) return err(400,"Invalid page key"); + String title=need(input,"title",255), pageId=id(); + String menu=pageMenu(input), parent=parentId(input); + int order=bounded(input,"order",0,100000,0); + try (Connection c=HmiDb.open()) { + c.setAutoCommit(false); try { - validatePageParent(c,pageId,parent); - if(parent!=null)menu=parentMenu(c,parent); - try (PreparedStatement ps=c.prepareStatement( - "INSERT INTO "+schema()+"HMI_APP_PAGE(ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID) VALUES (?,?,?,?,?,1,?)")) { - ps.setString(1,pageId);ps.setString(2,key);ps.setString(3,title); - ps.setString(4,menu);ps.setInt(5,order);ps.setString(6,parent);ps.executeUpdate(); + validatePageParent(c,pageId,parent); + if(parent!=null)menu=parentMenu(c,parent); + try (PreparedStatement ps=c.prepareStatement( + "INSERT INTO "+schema()+"HMI_APP_PAGE(ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID) VALUES (?,?,?,?,?,1,?)")) { + ps.setString(1,pageId);ps.setString(2,key);ps.setString(3,title); + ps.setString(4,menu);ps.setInt(5,order);ps.setString(6,parent);ps.executeUpdate(); } - audit(c,"page.created",pageId,key);c.commit(); - } catch (Exception ex) {c.rollback();throw ex;} + audit(c,"page.created",pageId,key);c.commit(); + } catch (Exception ex) {c.rollback();throw ex;} } - return json(new JSONObject().put("id",pageId).put("key",key)); - } catch (JSONException e) { return err(400,e.getMessage()); } catch (SQLException e) { return dbError(e); } - catch (Exception e) { return err(400,"Cannot create page"); } + return json(new JSONObject().put("id",pageId).put("key",key)); + } catch (JSONException e) { return err(400,e.getMessage()); } catch (SQLException e) { return dbError(e); } + catch (Exception e) { return err(400,"Cannot create page"); } } @PUT @Path("pages/{pageId}") @Consumes(MediaType.APPLICATION_JSON) public Response updatePage(@PathParam("pageId") String pageId, String body) { - Response r=writeAllowed(designer()); if(r!=null)return r; + Response r=writeAllowed(designer()); if(r!=null)return r; try { - JSONObject input=parse(body); - String title=need(input,"title",255), menu=pageMenu(input), parent=parentId(input); - int order=bounded(input,"order",0,100000,0); - boolean enabled=input.optBoolean("enabled",true); - try(Connection c=HmiDb.open()) { - c.setAutoCommit(false); + JSONObject input=parse(body); + String title=need(input,"title",255), menu=pageMenu(input), parent=parentId(input); + int order=bounded(input,"order",0,100000,0); + boolean enabled=input.optBoolean("enabled",true); + try(Connection c=HmiDb.open()) { + c.setAutoCommit(false); try { - if (!pageExists(c,pageId)) {c.rollback();return err(404,"Page not found");} - validatePageParent(c,pageId,parent); - if(parent!=null)menu=parentMenu(c,parent); - try(PreparedStatement ps=c.prepareStatement( - "UPDATE "+schema()+"HMI_APP_PAGE SET TITLE=?,MENU_GROUP=?,SORT_ORDER=?,ENABLED=?,PARENT_PAGE_ID=? WHERE ID=?")) { - ps.setString(1,title);ps.setString(2,menu);ps.setInt(3,order); - ps.setInt(4,enabled?1:0);ps.setString(5,parent);ps.setString(6,pageId); - ps.executeUpdate(); + if (!pageExists(c,pageId)) {c.rollback();return err(404,"Page not found");} + validatePageParent(c,pageId,parent); + if(parent!=null)menu=parentMenu(c,parent); + try(PreparedStatement ps=c.prepareStatement( + "UPDATE "+schema()+"HMI_APP_PAGE SET TITLE=?,MENU_GROUP=?,SORT_ORDER=?,ENABLED=?,PARENT_PAGE_ID=? WHERE ID=?")) { + ps.setString(1,title);ps.setString(2,menu);ps.setInt(3,order); + ps.setInt(4,enabled?1:0);ps.setString(5,parent);ps.setString(6,pageId); + ps.executeUpdate(); } - updateDescendantMenus(c,pageId,menu); - audit(c,"page.updated",pageId,title);c.commit(); - }catch(Exception ex){c.rollback();throw ex;} - } - return json(new JSONObject().put("ok",true)); - } catch (JSONException e) { return err(400,e.getMessage()); } catch (SQLException e) { return dbError(e); } - catch (Exception e) { return err(400,"Cannot update page"); } + updateDescendantMenus(c,pageId,menu); + audit(c,"page.updated",pageId,title);c.commit(); + }catch(Exception ex){c.rollback();throw ex;} + } + return json(new JSONObject().put("ok",true)); + } catch (JSONException e) { return err(400,e.getMessage()); } catch (SQLException e) { return dbError(e); } + catch (Exception e) { return err(400,"Cannot update page"); } } /** Rename a root menu without changing individual pages' parent relationships. */ @PUT @Path("navigation/root") @Consumes(MediaType.APPLICATION_JSON) public Response renameRootMenu(String body) { - Response r=writeAllowed(designer());if(r!=null)return r; + Response r=writeAllowed(designer());if(r!=null)return r; try { - JSONObject input=parse(body); - String previous=need(input,"previous",120), next=need(input,"next",120); - if(!next.equals(pageMenu(new JSONObject().put("menuGroup",next))))return err(400,"Invalid menu"); - try(Connection c=HmiDb.open();PreparedStatement ps=c.prepareStatement( - "UPDATE "+schema()+"HMI_APP_PAGE SET MENU_GROUP=? WHERE MENU_GROUP=?")) { - ps.setString(1,next);ps.setString(2,previous); - int count=ps.executeUpdate(); - if(count==0)return err(404,"Root menu not found"); - audit(c,"root.renamed",previous,next); - return json(new JSONObject().put("updatedPages",count)); - } - }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} + JSONObject input=parse(body); + String previous=need(input,"previous",120), next=need(input,"next",120); + if(!next.equals(pageMenu(new JSONObject().put("menuGroup",next))))return err(400,"Invalid menu"); + try(Connection c=HmiDb.open();PreparedStatement ps=c.prepareStatement( + "UPDATE "+schema()+"HMI_APP_PAGE SET MENU_GROUP=? WHERE MENU_GROUP=?")) { + ps.setString(1,next);ps.setString(2,previous); + int count=ps.executeUpdate(); + if(count==0)return err(404,"Root menu not found"); + audit(c,"root.renamed",previous,next); + return json(new JSONObject().put("updatedPages",count)); + } + }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} } @GET @Path("pages/{pageId}/templates") public Response templates(@PathParam("pageId")String pageId) { - Response r=denied(designer());if(r!=null)return r; - JSONArray a=new JSONArray(); - try (Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement("SELECT ID,VERSION_NO,STATUS,UPDATED_BY FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=? ORDER BY VERSION_NO DESC")) { - p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){while(rs.next())a.put(new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("status",rs.getString(3)).put("author",rs.getString(4)));} - return json(a); - }catch(SQLException e){return dbError(e);} + Response r=denied(designer());if(r!=null)return r; + JSONArray a=new JSONArray(); + try (Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement("SELECT ID,VERSION_NO,STATUS,UPDATED_BY FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=? ORDER BY VERSION_NO DESC")) { + p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){while(rs.next())a.put(new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("status",rs.getString(3)).put("author",rs.getString(4)));} + return json(a); + }catch(SQLException e){return dbError(e);} } @POST @Path("pages/{pageId}/templates") @Consumes(MediaType.APPLICATION_JSON) public Response createTemplate(@PathParam("pageId") String pageId,String body) { - Response r=writeAllowed(designer());if(r!=null)return r; + Response r=writeAllowed(designer());if(r!=null)return r; try { - JSONObject layout=validateTemplate(parse(body)); - if (!scriptEditor() && !scripts(layout).isEmpty()) - return err(403, "JavaScript- und CheerpJ-Widgets erfordern hmi-script-editor"); - try(Connection c=HmiDb.open()) { - if(!pageExists(c,pageId))return err(404,"Page not found"); - int version=1; - try(PreparedStatement p=c.prepareStatement("SELECT MAX(VERSION_NO) FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=?")){ - p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){if(rs.next())version=rs.getInt(1)+1;} + JSONObject layout=validateTemplate(parse(body)); + if (!scriptEditor() && !scripts(layout).isEmpty()) + return err(403, "JavaScript- und CheerpJ-Widgets erfordern hmi-script-editor"); + try(Connection c=HmiDb.open()) { + if(!pageExists(c,pageId))return err(404,"Page not found"); + int version=1; + try(PreparedStatement p=c.prepareStatement("SELECT MAX(VERSION_NO) FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=?")){ + p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){if(rs.next())version=rs.getInt(1)+1;} } - String templateId=id(); - try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_TEMPLATE(ID,PAGE_ID,VERSION_NO,STATUS,LAYOUT_JSON,UPDATED_BY,UPDATED_AT) VALUES (?,?,?,?,?,?,?)")) { - p.setString(1,templateId);p.setString(2,pageId);p.setInt(3,version);p.setString(4,"DRAFT");clob(p,5,layout.toString()); - p.setString(6,user());p.setTimestamp(7,Timestamp.from(Instant.now()));p.executeUpdate(); + String templateId=id(); + try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_TEMPLATE(ID,PAGE_ID,VERSION_NO,STATUS,LAYOUT_JSON,UPDATED_BY,UPDATED_AT) VALUES (?,?,?,?,?,?,?)")) { + p.setString(1,templateId);p.setString(2,pageId);p.setInt(3,version);p.setString(4,"DRAFT");clob(p,5,layout.toString()); + p.setString(6,user());p.setTimestamp(7,Timestamp.from(Instant.now()));p.executeUpdate(); } - audit(c,"template.created",templateId,pageId); - return json(new JSONObject().put("id",templateId).put("version",version).put("status","DRAFT")); - } - } catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} + audit(c,"template.created",templateId,pageId); + return json(new JSONObject().put("id",templateId).put("version",version).put("status","DRAFT")); + } + } catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} } @PUT @Path("templates/{templateId}") @Consumes(MediaType.APPLICATION_JSON) public Response saveTemplate(@PathParam("templateId")String templateId,String body){ - Response r=writeAllowed(designer());if(r!=null)return r; + Response r=writeAllowed(designer());if(r!=null)return r; try { - JSONObject layout=validateTemplate(parse(body)); - try(Connection c=HmiDb.open()) { - c.setAutoCommit(false); + JSONObject layout=validateTemplate(parse(body)); + try(Connection c=HmiDb.open()) { + c.setAutoCommit(false); try { - String current = null; + String current = null; // Lock the draft while comparing its scripts and persisting the new version. - boolean oracle = HmiDb.isOracle(); - String sql = oracle - ? "SELECT LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=? AND STATUS='DRAFT' FOR UPDATE" - : "SELECT LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WITH (UPDLOCK, ROWLOCK) WHERE ID=? AND STATUS='DRAFT'"; - try(PreparedStatement locked=c.prepareStatement(sql)) { - locked.setString(1,templateId); - try(ResultSet rs=locked.executeQuery()) { - if(rs.next())current=clob(rs,"LAYOUT_JSON"); + boolean oracle = HmiDb.isOracle(); + String sql = oracle + ? "SELECT LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=? AND STATUS='DRAFT' FOR UPDATE" + : "SELECT LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WITH (UPDLOCK, ROWLOCK) WHERE ID=? AND STATUS='DRAFT'"; + try(PreparedStatement locked=c.prepareStatement(sql)) { + locked.setString(1,templateId); + try(ResultSet rs=locked.executeQuery()) { + if(rs.next())current=clob(rs,"LAYOUT_JSON"); } } - if(current==null) { c.rollback();return err(409,"Template not a draft or not found"); } - if (!scriptEditor() && scriptChanges(objectOrEmpty(current),layout)) { - c.rollback();return err(403,"Code- oder JNLP-Änderungen erfordern die Rolle hmi-script-editor"); + if(current==null) { c.rollback();return err(409,"Template not a draft or not found"); } + if (!scriptEditor() && scriptChanges(objectOrEmpty(current),layout)) { + c.rollback();return err(403,"Code- oder JNLP-Änderungen erfordern die Rolle hmi-script-editor"); } - try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET LAYOUT_JSON=?,UPDATED_BY=?,UPDATED_AT=? WHERE ID=? AND STATUS='DRAFT'")) { - clob(p,1,layout.toString());p.setString(2,user());p.setTimestamp(3,Timestamp.from(Instant.now()));p.setString(4,templateId); - if(p.executeUpdate()==0) {c.rollback();return err(409,"Template not a draft or not found");} - } - audit(c,"template.saved",templateId,""); - if(scriptChanges(objectOrEmpty(current),layout))audit(c,"widget.script.edited",templateId,"Code or JNLP configuration updated"); - c.commit(); - } catch(SQLException | RuntimeException ex) {c.rollback();throw ex;} - } - return json(new JSONObject().put("ok",true)); - }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} + try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET LAYOUT_JSON=?,UPDATED_BY=?,UPDATED_AT=? WHERE ID=? AND STATUS='DRAFT'")) { + clob(p,1,layout.toString());p.setString(2,user());p.setTimestamp(3,Timestamp.from(Instant.now()));p.setString(4,templateId); + if(p.executeUpdate()==0) {c.rollback();return err(409,"Template not a draft or not found");} + } + audit(c,"template.saved",templateId,""); + if(scriptChanges(objectOrEmpty(current),layout))audit(c,"widget.script.edited",templateId,"Code or JNLP configuration updated"); + c.commit(); + } catch(SQLException | RuntimeException ex) {c.rollback();throw ex;} + } + return json(new JSONObject().put("ok",true)); + }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} } @GET @Path("templates/{templateId}") public Response getTemplate(@PathParam("templateId")String templateId) { - Response r=denied(designer());if(r!=null)return r; - try(Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement("SELECT ID,PAGE_ID,VERSION_NO,STATUS,LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=?")){ - p.setString(1,templateId);try(ResultSet rs=p.executeQuery()){ - if(!rs.next())return err(404,"Template not found"); - return json(new JSONObject().put("id",rs.getString(1)).put("pageId",rs.getString(2)) - .put("version",rs.getInt(3)).put("status",rs.getString(4)) - .put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON")))); - } - }catch(SQLException e){return dbError(e);} + Response r=denied(designer());if(r!=null)return r; + try(Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement("SELECT ID,PAGE_ID,VERSION_NO,STATUS,LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=?")){ + p.setString(1,templateId);try(ResultSet rs=p.executeQuery()){ + if(!rs.next())return err(404,"Template not found"); + return json(new JSONObject().put("id",rs.getString(1)).put("pageId",rs.getString(2)) + .put("version",rs.getInt(3)).put("status",rs.getString(4)) + .put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON")))); + } + }catch(SQLException e){return dbError(e);} } @POST @Path("templates/{templateId}/archive") public Response archive(@PathParam("templateId")String templateId) { - Response r=writeAllowed(publisher());if(r!=null)return r; - try(Connection c=HmiDb.open()) { - try(PreparedStatement chk=c.prepareStatement("SELECT ID FROM "+schema()+"HMI_APP_ASSIGNMENT WHERE TEMPLATE_ID=?")) { - chk.setString(1,templateId);try(ResultSet rs=chk.executeQuery()){if(rs.next())return err(409,"Template is assigned; update assignments before archiving");} - } - try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET STATUS='ARCHIVED' WHERE ID=? AND STATUS='PUBLISHED'")) { - p.setString(1,templateId);if(p.executeUpdate()!=1)return err(409,"Not published or not found"); + Response r=writeAllowed(publisher());if(r!=null)return r; + try(Connection c=HmiDb.open()) { + try(PreparedStatement chk=c.prepareStatement("SELECT ID FROM "+schema()+"HMI_APP_ASSIGNMENT WHERE TEMPLATE_ID=?")) { + chk.setString(1,templateId);try(ResultSet rs=chk.executeQuery()){if(rs.next())return err(409,"Template is assigned; update assignments before archiving");} } - audit(c,"template.archived",templateId,"");return json(new JSONObject().put("ok",true)); - }catch(SQLException e){return dbError(e);} + try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET STATUS='ARCHIVED' WHERE ID=? AND STATUS='PUBLISHED'")) { + p.setString(1,templateId);if(p.executeUpdate()!=1)return err(409,"Not published or not found"); + } + audit(c,"template.archived",templateId,"");return json(new JSONObject().put("ok",true)); + }catch(SQLException e){return dbError(e);} } @POST @Path("templates/{templateId}/publish") public Response publish(@PathParam("templateId")String templateId) { - Response r=writeAllowed(publisher());if(r!=null)return r; - try(Connection c=HmiDb.open()) { - c.setAutoCommit(false); + Response r=writeAllowed(publisher());if(r!=null)return r; + try(Connection c=HmiDb.open()) { + c.setAutoCommit(false); try { String pageId; - try(PreparedStatement p=c.prepareStatement("SELECT PAGE_ID,STATUS FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=?")) { - p.setString(1,templateId); - try(ResultSet rs=p.executeQuery()){ - if(!rs.next()){c.rollback();return err(404,"Template not found");} - pageId=rs.getString(1); - if(!"DRAFT".equals(rs.getString(2))){c.rollback();return err(409,"Only drafts can be published");} - } - } + try(PreparedStatement p=c.prepareStatement("SELECT PAGE_ID,STATUS FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=?")) { + p.setString(1,templateId); + try(ResultSet rs=p.executeQuery()){ + if(!rs.next()){c.rollback();return err(404,"Template not found");} + pageId=rs.getString(1); + if(!"DRAFT".equals(rs.getString(2))){c.rollback();return err(409,"Only drafts can be published");} + } + } // Keep other published templates available for group/station assignments. // Default page resolves highest published version; explicit assignment stays pinned. - try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET STATUS='PUBLISHED' WHERE ID=? AND STATUS='DRAFT'")){ - p.setString(1,templateId);if(p.executeUpdate()!=1)throw new SQLException("Concurrent template publication"); + try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_TEMPLATE SET STATUS='PUBLISHED' WHERE ID=? AND STATUS='DRAFT'")){ + p.setString(1,templateId);if(p.executeUpdate()!=1)throw new SQLException("Concurrent template publication"); } - audit(c,"template.published",templateId,pageId);c.commit(); - return json(new JSONObject().put("ok",true)); - }catch(Exception ex){c.rollback();throw ex;} - }catch(Exception e){return dbError(e);} + audit(c,"template.published",templateId,pageId);c.commit(); + return json(new JSONObject().put("ok",true)); + }catch(Exception ex){c.rollback();throw ex;} + }catch(Exception e){return dbError(e);} } @GET @Path("pages/{pageId}/effective") public Response effective(@PathParam("pageId")String pageId,@QueryParam("station")String station){ - Response r=denied(true);if(r!=null)return r; - try(Connection c=HmiDb.open()){ - JSONObject page=fetchPage(c,pageId); - if(page==null)return err(404,"Page not found"); - if(!designer()){ - java.util.Set<String> seen=new java.util.HashSet<>(); - JSONObject ancestor=page; - while(ancestor!=null){ - if(!seen.add(ancestor.getString("id"))||!ancestor.getBoolean("enabled"))return err(404,"Page not found"); - String parent=ancestor.isNull("parentPageId")?null:ancestor.optString("parentPageId",null); - ancestor=parent==null?null:fetchPage(c,parent); - if(parent!=null&&ancestor==null)return err(404,"Page not found"); - } + Response r=denied(true);if(r!=null)return r; + try(Connection c=HmiDb.open()){ + JSONObject page=fetchPage(c,pageId); + if(page==null)return err(404,"Page not found"); + if(!designer()){ + java.util.Set<String> seen=new java.util.HashSet<>(); + JSONObject ancestor=page; + while(ancestor!=null){ + if(!seen.add(ancestor.getString("id"))||!ancestor.getBoolean("enabled"))return err(404,"Page not found"); + String parent=ancestor.isNull("parentPageId")?null:ancestor.optString("parentPageId",null); + ancestor=parent==null?null:fetchPage(c,parent); + if(parent!=null&&ancestor==null)return err(404,"Page not found"); + } } - List<String> groups=groups(c,user()); - JSONObject template=resolveTemplate(c,pageId,station,groups); - if(template==null)return err(404,"No published template assigned"); - JSONObject prefs=new JSONObject().put("fontScale",1).put("theme","ios").put("contrast","normal").put("accent","#a40640"); - merge(prefs,preference(c,"DEFAULT","*")); - for(String g:groups)merge(prefs,preference(c,"GROUP",g)); - if(station!=null&&!station.isEmpty())merge(prefs,preference(c,"STATION",station)); - merge(prefs,preference(c,"USER",user())); - JSONObject overrides=new JSONObject();String baseId=""; - try(PreparedStatement p=c.prepareStatement("SELECT BASE_TEMPLATE_ID,OVERRIDES_JSON FROM "+schema()+"HMI_APP_LAYOUT WHERE USER_ID=? AND PAGE_ID=? AND STATION_ID=?")){ - p.setString(1,user());p.setString(2,pageId);p.setString(3, stationKey(station)); - try(ResultSet rs=p.executeQuery()) {if(rs.next()){baseId=rs.getString(1);overrides=objectOrEmpty(clob(rs,"OVERRIDES_JSON"));}} + List<String> groups=groups(c,user()); + JSONObject template=resolveTemplate(c,pageId,station,groups); + if(template==null)return err(404,"No published template assigned"); + JSONObject prefs=new JSONObject().put("fontScale",1).put("theme","ios").put("contrast","normal").put("accent","#a40640"); + merge(prefs,preference(c,"DEFAULT","*")); + for(String g:groups)merge(prefs,preference(c,"GROUP",g)); + if(station!=null&&!station.isEmpty())merge(prefs,preference(c,"STATION",station)); + merge(prefs,preference(c,"USER",user())); + JSONObject overrides=new JSONObject();String baseId=""; + try(PreparedStatement p=c.prepareStatement("SELECT BASE_TEMPLATE_ID,OVERRIDES_JSON FROM "+schema()+"HMI_APP_LAYOUT WHERE USER_ID=? AND PAGE_ID=? AND STATION_ID=?")){ + p.setString(1,user());p.setString(2,pageId);p.setString(3, stationKey(station)); + try(ResultSet rs=p.executeQuery()) {if(rs.next()){baseId=rs.getString(1);overrides=objectOrEmpty(clob(rs,"OVERRIDES_JSON"));}} } - JSONObject layout=template.getJSONObject("layout"); - JSONArray effectiveWidgets=new JSONArray(); - java.util.Set<String> granted = HmiAuth.roles(request); - for(Object val:layout.getJSONArray("widgets")) { - JSONObject widget=new JSONObject(val.toString());String widgetId=widget.getString("id"); + JSONObject layout=template.getJSONObject("layout"); + JSONArray effectiveWidgets=new JSONArray(); + java.util.Set<String> granted = HmiAuth.roles(request); + for(Object val:layout.getJSONArray("widgets")) { + JSONObject widget=new JSONObject(val.toString());String widgetId=widget.getString("id"); // Security: role-restricted widgets must never be delivered in the effective payload. - JSONArray required = widget.optJSONArray("visibleToRoles"); - if (required!=null && required.length()>0 && !granted.contains("hmi-admin")) { - boolean allowed=false; - for(int i=0;i<required.length();i++) if(granted.contains(required.optString(i))) {allowed=true;break;} - if(!allowed)continue; + JSONArray required = widget.optJSONArray("visibleToRoles"); + if (required!=null && required.length()>0 && !granted.contains("hmi-admin")) { + boolean allowed=false; + for(int i=0;i<required.length();i++) if(granted.contains(required.optString(i))) {allowed=true;break;} + if(!allowed)continue; } - if(widget.optBoolean("personalizable",true)&&overrides.has(widgetId)){ - JSONObject o=overrides.getJSONObject(widgetId); - for(String key:new String[]{"x","y","w","h"})if(o.has(key))widget.put(key,o.getInt(key)); - if(!widget.optBoolean("mandatory",false)&&o.optBoolean("hidden",false))widget.put("hidden",true); - if(widget.getInt("x")+widget.getInt("w")>12)widget.put("x",0); + if(widget.optBoolean("personalizable",true)&&overrides.has(widgetId)){ + JSONObject o=overrides.getJSONObject(widgetId); + for(String key:new String[]{"x","y","w","h"})if(o.has(key))widget.put(key,o.getInt(key)); + if(!widget.optBoolean("mandatory",false)&&o.optBoolean("hidden",false))widget.put("hidden",true); + if(widget.getInt("x")+widget.getInt("w")>12)widget.put("x",0); } - effectiveWidgets.put(widget); - } - return json(new JSONObject().put("page",page).put("templateId",template.getString("id")) - .put("version",template.getInt("version")).put("originalTemplateId",baseId) - .put("layout",new JSONObject().put("widgets",effectiveWidgets)).put("preferences",prefs)); - }catch(Exception e){return dbError(e);} + effectiveWidgets.put(widget); + } + return json(new JSONObject().put("page",page).put("templateId",template.getString("id")) + .put("version",template.getInt("version")).put("originalTemplateId",baseId) + .put("layout",new JSONObject().put("widgets",effectiveWidgets)).put("preferences",prefs)); + }catch(Exception e){return dbError(e);} } @PUT @Path("pages/{pageId}/layout") @Consumes(MediaType.APPLICATION_JSON) public Response saveLayout(@PathParam("pageId")String pageId,String body){ - Response r=writeAllowed(true);if(r!=null)return r; + Response r=writeAllowed(true);if(r!=null)return r; try { - JSONObject in=parse(body); - JSONObject o=validateOverrides(in.getJSONObject("overrides")); - try(Connection c=HmiDb.open()){ - if(!pageExists(c,pageId))return err(404,"Page not found"); + JSONObject in=parse(body); + JSONObject o=validateOverrides(in.getJSONObject("overrides")); + try(Connection c=HmiDb.open()){ + if(!pageExists(c,pageId))return err(404,"Page not found"); // Server enforcement: only published, personalizable widget IDs can be overridden. - JSONObject template=resolveTemplate(c,pageId,in.optString("station",""),groups(c,user())); - if(template==null)return err(409,"Page has no published template"); - JSONObject allowed=new JSONObject(); - for(Object obj:template.getJSONObject("layout").getJSONArray("widgets")) { - JSONObject w=(JSONObject)obj;String widgetId=w.getString("id"); - if(!o.has(widgetId) || !w.optBoolean("personalizable",true))continue; - JSONObject override=o.getJSONObject(widgetId); - if(w.optBoolean("mandatory",false)&&override.optBoolean("hidden",false))return err(400,"Cannot hide mandatory widget"); - allowed.put(widgetId,override); - } + JSONObject template=resolveTemplate(c,pageId,in.optString("station",""),groups(c,user())); + if(template==null)return err(409,"Page has no published template"); + JSONObject allowed=new JSONObject(); + for(Object obj:template.getJSONObject("layout").getJSONArray("widgets")) { + JSONObject w=(JSONObject)obj;String widgetId=w.getString("id"); + if(!o.has(widgetId) || !w.optBoolean("personalizable",true))continue; + JSONObject override=o.getJSONObject(widgetId); + if(w.optBoolean("mandatory",false)&&override.optBoolean("hidden",false))return err(400,"Cannot hide mandatory widget"); + allowed.put(widgetId,override); + } int count; - try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_LAYOUT SET OVERRIDES_JSON=?,BASE_TEMPLATE_ID=?,UPDATED_AT=? WHERE USER_ID=? AND PAGE_ID=? AND STATION_ID=?")){ - clob(p,1,allowed.toString());p.setString(2,template.getString("id"));p.setTimestamp(3,Timestamp.from(Instant.now()));p.setString(4,user());p.setString(5,pageId);p.setString(6,stationKey(in.optString("station", "")));count=p.executeUpdate(); + try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_LAYOUT SET OVERRIDES_JSON=?,BASE_TEMPLATE_ID=?,UPDATED_AT=? WHERE USER_ID=? AND PAGE_ID=? AND STATION_ID=?")){ + clob(p,1,allowed.toString());p.setString(2,template.getString("id"));p.setTimestamp(3,Timestamp.from(Instant.now()));p.setString(4,user());p.setString(5,pageId);p.setString(6,stationKey(in.optString("station", "")));count=p.executeUpdate(); } - if(count==0){try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_LAYOUT(USER_ID,PAGE_ID,STATION_ID,BASE_TEMPLATE_ID,OVERRIDES_JSON,UPDATED_AT) VALUES(?,?,?,?,?,?)")){ - p.setString(1,user());p.setString(2,pageId);p.setString(3,stationKey(in.optString("station", "")));p.setString(4,template.getString("id"));clob(p,5,allowed.toString());p.setTimestamp(6,Timestamp.from(Instant.now()));p.executeUpdate(); + if(count==0){try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_LAYOUT(USER_ID,PAGE_ID,STATION_ID,BASE_TEMPLATE_ID,OVERRIDES_JSON,UPDATED_AT) VALUES(?,?,?,?,?,?)")){ + p.setString(1,user());p.setString(2,pageId);p.setString(3,stationKey(in.optString("station", "")));p.setString(4,template.getString("id"));clob(p,5,allowed.toString());p.setTimestamp(6,Timestamp.from(Instant.now()));p.executeUpdate(); }} - audit(c,"user.layout",pageId,"Saved overrides"); - return json(new JSONObject().put("ok",true).put("saved",allowed.length())); - } - }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} + audit(c,"user.layout",pageId,"Saved overrides"); + return json(new JSONObject().put("ok",true).put("saved",allowed.length())); + } + }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} } @GET @Path("preferences") - public Response myPreferences(){Response r=denied(true);if(r!=null)return r; - try(Connection c=HmiDb.open()){return json(preference(c,"USER",user()));}catch(SQLException e){return dbError(e);}} + public Response myPreferences(){Response r=denied(true);if(r!=null)return r; + try(Connection c=HmiDb.open()){return json(preference(c,"USER",user()));}catch(SQLException e){return dbError(e);}} @PUT @Path("preferences") @Consumes(MediaType.APPLICATION_JSON) - public Response myPreferencesSave(String body){Response r=writeAllowed(true);if(r!=null)return r; - try{return storePreferences("USER",user(),parse(body));}catch(JSONException e){return err(400,e.getMessage());}} + public Response myPreferencesSave(String body){Response r=writeAllowed(true);if(r!=null)return r; + try{return storePreferences("USER",user(),parse(body));}catch(JSONException e){return err(400,e.getMessage());}} @PUT @Path("groups/{group}/preferences") @Consumes(MediaType.APPLICATION_JSON) - public Response groupPreferences(@PathParam("group")String group,String body){Response r=writeAllowed(admin());if(r!=null)return r; - if(!legalKey(group))return err(400,"Invalid group"); - try{return storePreferences("GROUP",group,parse(body));}catch(JSONException e){return err(400,e.getMessage());}} + public Response groupPreferences(@PathParam("group")String group,String body){Response r=writeAllowed(admin());if(r!=null)return r; + if(!legalKey(group))return err(400,"Invalid group"); + try{return storePreferences("GROUP",group,parse(body));}catch(JSONException e){return err(400,e.getMessage());}} @PUT @Path("groups/{group}/members/{member}") public Response groupMember(@PathParam("group")String group,@PathParam("member")String member){ - Response r=writeAllowed(admin());if(r!=null)return r; - if(!legalKey(group)||member.length()>255||member.isEmpty())return err(400,"Invalid group or member"); - try(Connection c=HmiDb.open()){ - try(PreparedStatement p=c.prepareStatement("SELECT USER_ID FROM "+schema()+"HMI_APP_GROUP_MEMBER WHERE GROUP_ID=? AND USER_ID=?")){ - p.setString(1,group);p.setString(2,member);try(ResultSet rs=p.executeQuery()){if(rs.next())return json(new JSONObject().put("ok",true));} - } - try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_GROUP_MEMBER(USER_ID,GROUP_ID) VALUES (?,?)")){ - p.setString(1,member);p.setString(2,group);p.executeUpdate(); + Response r=writeAllowed(admin());if(r!=null)return r; + if(!legalKey(group)||member.length()>255||member.isEmpty())return err(400,"Invalid group or member"); + try(Connection c=HmiDb.open()){ + try(PreparedStatement p=c.prepareStatement("SELECT USER_ID FROM "+schema()+"HMI_APP_GROUP_MEMBER WHERE GROUP_ID=? AND USER_ID=?")){ + p.setString(1,group);p.setString(2,member);try(ResultSet rs=p.executeQuery()){if(rs.next())return json(new JSONObject().put("ok",true));} + } + try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_GROUP_MEMBER(USER_ID,GROUP_ID) VALUES (?,?)")){ + p.setString(1,member);p.setString(2,group);p.executeUpdate(); } - audit(c,"group.member.added",group,member);return json(new JSONObject().put("ok",true)); - }catch(SQLException e){return dbError(e);} + audit(c,"group.member.added",group,member);return json(new JSONObject().put("ok",true)); + }catch(SQLException e){return dbError(e);} } @POST @Path("assignments") @Consumes(MediaType.APPLICATION_JSON) - public Response assign(String body){Response r=writeAllowed(publisher());if(r!=null)return r; + public Response assign(String body){Response r=writeAllowed(publisher());if(r!=null)return r; try{ - JSONObject in=parse(body);String pageId=need(in,"pageId",64), templateId=need(in,"templateId",64), type=need(in,"scopeType",20), scope=need(in,"scopeId",255); - if(!type.equals("GROUP")&&!type.equals("STATION")&&!type.equals("DEFAULT"))return err(400,"Invalid scope"); - try(Connection c=HmiDb.open()){ - try(PreparedStatement check=c.prepareStatement("SELECT STATUS FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=? AND PAGE_ID=?")){ - check.setString(1,templateId);check.setString(2,pageId); - try(ResultSet rs=check.executeQuery()){if(!rs.next()||!"PUBLISHED".equals(rs.getString(1)))return err(400,"Only published templates can be assigned");} - } - try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_ASSIGNMENT(ID,PAGE_ID,SCOPE_TYPE,SCOPE_ID,TEMPLATE_ID,PRIORITY) VALUES(?,?,?,?,?,?)")){ - p.setString(1,id());p.setString(2,pageId);p.setString(3,type);p.setString(4,scope);p.setString(5,templateId);p.setInt(6,bounded(in,"priority",0,1000,0));p.executeUpdate(); + JSONObject in=parse(body);String pageId=need(in,"pageId",64), templateId=need(in,"templateId",64), type=need(in,"scopeType",20), scope=need(in,"scopeId",255); + if(!type.equals("GROUP")&&!type.equals("STATION")&&!type.equals("DEFAULT"))return err(400,"Invalid scope"); + try(Connection c=HmiDb.open()){ + try(PreparedStatement check=c.prepareStatement("SELECT STATUS FROM "+schema()+"HMI_APP_TEMPLATE WHERE ID=? AND PAGE_ID=?")){ + check.setString(1,templateId);check.setString(2,pageId); + try(ResultSet rs=check.executeQuery()){if(!rs.next()||!"PUBLISHED".equals(rs.getString(1)))return err(400,"Only published templates can be assigned");} + } + try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_ASSIGNMENT(ID,PAGE_ID,SCOPE_TYPE,SCOPE_ID,TEMPLATE_ID,PRIORITY) VALUES(?,?,?,?,?,?)")){ + p.setString(1,id());p.setString(2,pageId);p.setString(3,type);p.setString(4,scope);p.setString(5,templateId);p.setInt(6,bounded(in,"priority",0,1000,0));p.executeUpdate(); } - audit(c,"template.assigned",templateId,type+":"+scope);return json(new JSONObject().put("ok",true)); - } - }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} + audit(c,"template.assigned",templateId,type+":"+scope);return json(new JSONObject().put("ok",true)); + } + }catch(JSONException e){return err(400,e.getMessage());}catch(SQLException e){return dbError(e);} } private Response storePreferences(String type,String identity,JSONObject input){ - JSONObject prefs=validatePreferences(input); - try(Connection c=HmiDb.open()){ + JSONObject prefs=validatePreferences(input); + try(Connection c=HmiDb.open()){ int count; - try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_PREF SET PREFS_JSON=?,UPDATED_AT=? WHERE SCOPE_TYPE=? AND SCOPE_ID=?")){ - clob(p,1,prefs.toString());p.setTimestamp(2,Timestamp.from(Instant.now()));p.setString(3,type);p.setString(4,identity);count=p.executeUpdate(); + try(PreparedStatement p=c.prepareStatement("UPDATE "+schema()+"HMI_APP_PREF SET PREFS_JSON=?,UPDATED_AT=? WHERE SCOPE_TYPE=? AND SCOPE_ID=?")){ + clob(p,1,prefs.toString());p.setTimestamp(2,Timestamp.from(Instant.now()));p.setString(3,type);p.setString(4,identity);count=p.executeUpdate(); } - if(count==0){try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_PREF(SCOPE_TYPE,SCOPE_ID,PREFS_JSON,UPDATED_AT) VALUES (?,?,?,?)")){ - p.setString(1,type);p.setString(2,identity);clob(p,3,prefs.toString());p.setTimestamp(4,Timestamp.from(Instant.now()));p.executeUpdate(); + if(count==0){try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_PREF(SCOPE_TYPE,SCOPE_ID,PREFS_JSON,UPDATED_AT) VALUES (?,?,?,?)")){ + p.setString(1,type);p.setString(2,identity);clob(p,3,prefs.toString());p.setTimestamp(4,Timestamp.from(Instant.now()));p.executeUpdate(); }} - audit(c,"preferences.saved",type+":"+identity,"");return json(prefs); - }catch(SQLException e){return dbError(e);} + audit(c,"preferences.saved",type+":"+identity,"");return json(prefs); + }catch(SQLException e){return dbError(e);} } private JSONObject preference(Connection c,String type,String identity)throws SQLException{ - try(PreparedStatement p=c.prepareStatement("SELECT PREFS_JSON FROM "+schema()+"HMI_APP_PREF WHERE SCOPE_TYPE=? AND SCOPE_ID=?")){ - p.setString(1,type);p.setString(2,identity); - try(ResultSet rs=p.executeQuery()){return rs.next()?objectOrEmpty(clob(rs,"PREFS_JSON")):new JSONObject();} + try(PreparedStatement p=c.prepareStatement("SELECT PREFS_JSON FROM "+schema()+"HMI_APP_PREF WHERE SCOPE_TYPE=? AND SCOPE_ID=?")){ + p.setString(1,type);p.setString(2,identity); + try(ResultSet rs=p.executeQuery()){return rs.next()?objectOrEmpty(clob(rs,"PREFS_JSON")):new JSONObject();} } } - private static void merge(JSONObject target,JSONObject changes){for(String k:changes.keySet())target.put(k,changes.get(k));} + private static void merge(JSONObject target,JSONObject changes){for(String k:changes.keySet())target.put(k,changes.get(k));} private List<String> groups(Connection c,String userId)throws SQLException{ - List<String> a=new ArrayList<>(); - try(PreparedStatement p=c.prepareStatement("SELECT GROUP_ID FROM "+schema()+"HMI_APP_GROUP_MEMBER WHERE USER_ID=? ORDER BY GROUP_ID")){ - p.setString(1,userId);try(ResultSet rs=p.executeQuery()){while(rs.next())a.add(rs.getString(1));} + List<String> a=new ArrayList<>(); + try(PreparedStatement p=c.prepareStatement("SELECT GROUP_ID FROM "+schema()+"HMI_APP_GROUP_MEMBER WHERE USER_ID=? ORDER BY GROUP_ID")){ + p.setString(1,userId);try(ResultSet rs=p.executeQuery()){while(rs.next())a.add(rs.getString(1));} } - String pers=HmiAuth.persId(c,userId); - if(pers!=null)try(PreparedStatement p=c.prepareStatement( - "SELECT GROUP_KEY FROM "+schema()+"HMI_APP_PERSON_GROUP WHERE PERS_ID=? ORDER BY GROUP_KEY")) { - p.setString(1,pers); - try(ResultSet rs=p.executeQuery()) { while(rs.next())if(!a.contains(rs.getString(1)))a.add(rs.getString(1)); } + String pers=HmiAuth.persId(c,userId); + if(pers!=null)try(PreparedStatement p=c.prepareStatement( + "SELECT GROUP_KEY FROM "+schema()+"HMI_APP_PERSON_GROUP WHERE PERS_ID=? ORDER BY GROUP_KEY")) { + p.setString(1,pers); + try(ResultSet rs=p.executeQuery()) { while(rs.next())if(!a.contains(rs.getString(1)))a.add(rs.getString(1)); } } - return a; + return a; } private JSONObject fetchPage(Connection c,String pageId)throws SQLException{ - try(PreparedStatement p=c.prepareStatement("SELECT ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID FROM "+schema()+"HMI_APP_PAGE WHERE ID=?")){ - p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){ - return rs.next()?new JSONObject().put("id",rs.getString(1)).put("key",rs.getString(2)).put("title",rs.getString(3)) - .put("menuGroup",rs.getString(4)).put("order",rs.getInt(5)).put("enabled",rs.getInt(6)!=0) - .put("parentPageId",rs.getString(7)==null?JSONObject.NULL:rs.getString(7)):null; + try(PreparedStatement p=c.prepareStatement("SELECT ID,PAGE_KEY,TITLE,MENU_GROUP,SORT_ORDER,ENABLED,PARENT_PAGE_ID FROM "+schema()+"HMI_APP_PAGE WHERE ID=?")){ + p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){ + return rs.next()?new JSONObject().put("id",rs.getString(1)).put("key",rs.getString(2)).put("title",rs.getString(3)) + .put("menuGroup",rs.getString(4)).put("order",rs.getInt(5)).put("enabled",rs.getInt(6)!=0) + .put("parentPageId",rs.getString(7)==null?JSONObject.NULL:rs.getString(7)):null; } } } - private boolean pageExists(Connection c,String pageId)throws SQLException{return fetchPage(c,pageId)!=null;} + private boolean pageExists(Connection c,String pageId)throws SQLException{return fetchPage(c,pageId)!=null;} private JSONObject resolveTemplate(Connection c,String pageId,String station,List<String> groups)throws SQLException{ - List<String> ids=new ArrayList<>(); - if(station!=null&&!station.isEmpty())ids.add("STATION:"+station); - for(String g:groups)ids.add("GROUP:"+g); - ids.add("DEFAULT:*"); + List<String> ids=new ArrayList<>(); + if(station!=null&&!station.isEmpty())ids.add("STATION:"+station); + for(String g:groups)ids.add("GROUP:"+g); + ids.add("DEFAULT:*"); // Distinct selected precedence STATION > GROUP > DEFAULT; highest priority within a scope. - for(String selection:ids){ - String[] parts=selection.split(":",2); - try(PreparedStatement p=c.prepareStatement("SELECT T.ID,T.VERSION_NO,T.LAYOUT_JSON FROM "+schema()+"HMI_APP_ASSIGNMENT A JOIN "+schema()+"HMI_APP_TEMPLATE T ON A.TEMPLATE_ID=T.ID WHERE A.PAGE_ID=? AND A.SCOPE_TYPE=? AND A.SCOPE_ID=? AND T.STATUS='PUBLISHED' ORDER BY A.PRIORITY DESC,T.VERSION_NO DESC")){ - p.setString(1,pageId);p.setString(2,parts[0]);p.setString(3,parts[1]); - try(ResultSet rs=p.executeQuery()){if(rs.next())return new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON")));} - } - } - try(PreparedStatement p=c.prepareStatement("SELECT ID,VERSION_NO,LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=? AND STATUS='PUBLISHED' ORDER BY VERSION_NO DESC")){ - p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){ - return rs.next()?new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON"))):null; + for(String selection:ids){ + String[] parts=selection.split(":",2); + try(PreparedStatement p=c.prepareStatement("SELECT T.ID,T.VERSION_NO,T.LAYOUT_JSON FROM "+schema()+"HMI_APP_ASSIGNMENT A JOIN "+schema()+"HMI_APP_TEMPLATE T ON A.TEMPLATE_ID=T.ID WHERE A.PAGE_ID=? AND A.SCOPE_TYPE=? AND A.SCOPE_ID=? AND T.STATUS='PUBLISHED' ORDER BY A.PRIORITY DESC,T.VERSION_NO DESC")){ + p.setString(1,pageId);p.setString(2,parts[0]);p.setString(3,parts[1]); + try(ResultSet rs=p.executeQuery()){if(rs.next())return new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON")));} + } + } + try(PreparedStatement p=c.prepareStatement("SELECT ID,VERSION_NO,LAYOUT_JSON FROM "+schema()+"HMI_APP_TEMPLATE WHERE PAGE_ID=? AND STATUS='PUBLISHED' ORDER BY VERSION_NO DESC")){ + p.setString(1,pageId);try(ResultSet rs=p.executeQuery()){ + return rs.next()?new JSONObject().put("id",rs.getString(1)).put("version",rs.getInt(2)).put("layout",objectOrEmpty(clob(rs,"LAYOUT_JSON"))):null; } } } private void audit(Connection c,String action,String entity,String details)throws SQLException{ - try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_AUDIT(ID,ACTOR,ACTION_NAME,ENTITY_ID,DETAILS,CREATED_AT) VALUES(?,?,?,?,?,?)")){ - p.setString(1,id());p.setString(2,user());p.setString(3,action);p.setString(4,entity); - p.setString(5,details.length()>1000?details.substring(0,1000):details);p.setTimestamp(6,Timestamp.from(Instant.now()));p.executeUpdate(); + try(PreparedStatement p=c.prepareStatement("INSERT INTO "+schema()+"HMI_APP_AUDIT(ID,ACTOR,ACTION_NAME,ENTITY_ID,DETAILS,CREATED_AT) VALUES(?,?,?,?,?,?)")){ + p.setString(1,id());p.setString(2,user());p.setString(3,action);p.setString(4,entity); + p.setString(5,details.length()>1000?details.substring(0,1000):details);p.setTimestamp(6,Timestamp.from(Instant.now()));p.executeUpdate(); } - } + } private Response dbError(Exception ex){ - java.util.logging.Logger.getLogger(HmiApiResource.class.getName()).log(java.util.logging.Level.SEVERE,"HMI DB operation failed",ex); - return err(500,"Database operation failed; check server logs"); + java.util.logging.Logger.getLogger(HmiApiResource.class.getName()).log(java.util.logging.Level.SEVERE,"HMI DB operation failed",ex); + return err(500,"Database operation failed; check server logs"); } } \ No newline at end of file diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.html index e3b6881..78fae4c 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.html @@ -1 +1 @@ -HmiSchemaBootstrap

HmiSchemaBootstrap

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total707 of 7070 %80 of 800 %57571501501717
contextInitialized(ServletContextEvent)4290 %460 %2424818111
verifyLayoutStationKey(Connection, boolean)740 %120 %77151511
exists(Connection, String)430 %40 %336611
pageParentColumnExists(Connection, boolean)410 %60 %447711
addParentPageColumnIfMissing(Connection, boolean)320 %60 %44111111
createIfMissing(Connection, String, String)270 %40 %338811
static {...}170 %n/a117711
assertOracleSchemaExists(Connection)160 %20 %224411
createSqlServerSchema(Connection)80 %n/a113311
contextDestroyed(ServletContextEvent)50 %n/a111111
HmiSchemaBootstrap()0 %n/a111111
isReady()0 %n/a111111
state()0 %n/a111111
phase()0 %n/a111111
failureCode()0 %n/a111111
poolConnected()0 %n/a111111
databaseKind()0 %n/a111111
\ No newline at end of file +HmiSchemaBootstrap

HmiSchemaBootstrap

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total726 of 7260 %80 of 800 %58581561561818
contextInitialized(ServletContextEvent)4380 %460 %2424858511
verifyLayoutStationKey(Connection, boolean)740 %120 %77151511
exists(Connection, String)430 %40 %336611
pageParentColumnExists(Connection, boolean)410 %60 %447711
addParentPageColumnIfMissing(Connection, boolean)320 %60 %44111111
createIfMissing(Connection, String, String)270 %40 %338811
static {...}210 %n/a118811
assertOracleSchemaExists(Connection)160 %20 %224411
createSqlServerSchema(Connection)80 %n/a113311
retryInitialization()60 %n/a111111
contextDestroyed(ServletContextEvent)50 %n/a111111
HmiSchemaBootstrap()0 %n/a111111
isReady()0 %n/a111111
state()0 %n/a111111
phase()0 %n/a111111
failureCode()0 %n/a111111
poolConnected()0 %n/a111111
databaseKind()0 %n/a111111
\ No newline at end of file diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.java.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.java.html index 5cc9038..8304ca5 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.java.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/HmiSchemaBootstrap.java.html @@ -19,230 +19,237 @@ import javax.servlet.ServletContextListener; */ public final class HmiSchemaBootstrap implements ServletContextListener { private static final Logger LOG = Logger.getLogger(HmiSchemaBootstrap.class.getName()); - private static volatile boolean ready = false; - private static volatile String state = "Not initialized"; + private static final Object START_LOCK = new Object(); + private static volatile boolean ready = false; + private static volatile String state = "Not initialized"; // The public health endpoint exposes only fixed diagnostic codes, never SQL errors or connection credentials. - private static volatile String phase = "NOT_STARTED"; - private static volatile String code = "NONE"; - private static volatile boolean poolConnected = false; - private static volatile String databaseKind = "UNKNOWN"; - static boolean isReady() { return ready; } - static String state() { return state; } - static String phase() { return phase; } - static String failureCode() { return code; } - static boolean poolConnected() { return poolConnected; } - static String databaseKind() { return databaseKind; } + private static volatile String phase = "NOT_STARTED"; + private static volatile String code = "NONE"; + private static volatile boolean poolConnected = false; + private static volatile String databaseKind = "UNKNOWN"; + static boolean isReady() { return ready; } + static String state() { return state; } + static String phase() { return phase; } + static String failureCode() { return code; } + static boolean poolConnected() { return poolConnected; } + static String databaseKind() { return databaseKind; } + static void retryInitialization() { new HmiSchemaBootstrap().contextInitialized(null); } + @Override public void contextInitialized(ServletContextEvent event) { - ready = false; - poolConnected = false; - databaseKind = "UNKNOWN"; - code = "NONE"; - phase = "DATASOURCE_LOOKUP"; - try (Connection c = HmiDb.open()) { - poolConnected = true; - phase = "DATABASE_DETECTION"; - String product = c.getMetaData().getDatabaseProductName().toLowerCase(Locale.ROOT); - boolean oracle = product.contains("oracle"); - boolean sqlServer = product.contains("microsoft sql server") || product.contains("sql server"); - if (!oracle && !sqlServer) { - code = "UNSUPPORTED_DATABASE"; - throw new SQLException("Unsupported dsCustNJTA database: " + product); + synchronized (START_LOCK) { + ready = false; + poolConnected = false; + databaseKind = "UNKNOWN"; + code = "NONE"; + phase = "DATASOURCE_LOOKUP"; + try (Connection c = HmiDb.open()) { + poolConnected = true; + phase = "DATABASE_DETECTION"; + String product = c.getMetaData().getDatabaseProductName().toLowerCase(Locale.ROOT); + boolean oracle = product.contains("oracle"); + boolean sqlServer = product.contains("microsoft sql server") || product.contains("sql server"); + if (!oracle && !sqlServer) { + code = "UNSUPPORTED_DATABASE"; + throw new SQLException("Unsupported dsCustNJTA database: " + product); } - databaseKind = oracle ? "ORACLE" : "SQL_SERVER"; - phase = "SCHEMA_CHECK"; - if (sqlServer) createSqlServerSchema(c); - else assertOracleSchemaExists(c); + databaseKind = oracle ? "ORACLE" : "SQL_SERVER"; + phase = "SCHEMA_CHECK"; + if (sqlServer) createSqlServerSchema(c); + else assertOracleSchemaExists(c); - phase = "SCHEMA_INITIALIZATION"; - String prefix = oracle ? "CUST." : "cust."; - String text = oracle ? "CLOB" : "NVARCHAR(MAX)"; - String shortText = oracle ? "VARCHAR2" : "NVARCHAR"; - String numeric = oracle ? "NUMBER(10)" : "INT"; - String date = oracle ? "TIMESTAMP" : "DATETIME2"; - String now = oracle ? "SYSTIMESTAMP" : "SYSUTCDATETIME()"; - createIfMissing(c, "HMI_APP_PAGE", "CREATE TABLE " + prefix + "HMI_APP_PAGE (" + phase = "SCHEMA_INITIALIZATION"; + String prefix = oracle ? "CUST." : "cust."; + String text = oracle ? "CLOB" : "NVARCHAR(MAX)"; + String shortText = oracle ? "VARCHAR2" : "NVARCHAR"; + String numeric = oracle ? "NUMBER(10)" : "INT"; + String date = oracle ? "TIMESTAMP" : "DATETIME2"; + String now = oracle ? "SYSTIMESTAMP" : "SYSUTCDATETIME()"; + createIfMissing(c, "HMI_APP_PAGE", "CREATE TABLE " + prefix + "HMI_APP_PAGE (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, PAGE_KEY " + shortText + "(120) NOT NULL UNIQUE, " + "TITLE " + shortText + "(255) NOT NULL, MENU_GROUP " + shortText + "(120), " + "PARENT_PAGE_ID " + shortText + "(64), " + "SORT_ORDER " + numeric + " DEFAULT 0 NOT NULL, ENABLED " + numeric + " DEFAULT 1 NOT NULL)"); // V5.2: compatible migration for existing Oracle and SQL Server installations. // Never drops or recreates HMI_APP_PAGE, preserving all published templates/layouts. - addParentPageColumnIfMissing(c, oracle); - createIfMissing(c, "HMI_APP_TEMPLATE", "CREATE TABLE " + prefix + "HMI_APP_TEMPLATE (" + addParentPageColumnIfMissing(c, oracle); + createIfMissing(c, "HMI_APP_TEMPLATE", "CREATE TABLE " + prefix + "HMI_APP_TEMPLATE (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, PAGE_ID " + shortText + "(64) NOT NULL, " + "VERSION_NO " + numeric + " NOT NULL, STATUS " + shortText + "(20) NOT NULL, " + "LAYOUT_JSON " + text + " NOT NULL, UPDATED_BY " + shortText + "(255), " + "UPDATED_AT " + date + " DEFAULT " + now + " NOT NULL)"); - createIfMissing(c, "HMI_APP_ASSIGNMENT", "CREATE TABLE " + prefix + "HMI_APP_ASSIGNMENT (" + createIfMissing(c, "HMI_APP_ASSIGNMENT", "CREATE TABLE " + prefix + "HMI_APP_ASSIGNMENT (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, PAGE_ID " + shortText + "(64) NOT NULL, " + "SCOPE_TYPE " + shortText + "(20) NOT NULL, SCOPE_ID " + shortText + "(255) NOT NULL, " + "TEMPLATE_ID " + shortText + "(64) NOT NULL, PRIORITY " + numeric + " DEFAULT 0 NOT NULL)"); - createIfMissing(c, "HMI_APP_LAYOUT", "CREATE TABLE " + prefix + "HMI_APP_LAYOUT (" + createIfMissing(c, "HMI_APP_LAYOUT", "CREATE TABLE " + prefix + "HMI_APP_LAYOUT (" + "USER_ID " + shortText + "(255) NOT NULL, PAGE_ID " + shortText + "(64) NOT NULL, " + "STATION_ID " + shortText + "(120) DEFAULT '*' NOT NULL, BASE_TEMPLATE_ID " + shortText + "(64), OVERRIDES_JSON " + text + " NOT NULL, " + "UPDATED_AT " + date + " DEFAULT " + now + " NOT NULL, " + "PRIMARY KEY (USER_ID, PAGE_ID, STATION_ID))"); - createIfMissing(c, "HMI_APP_PREF", "CREATE TABLE " + prefix + "HMI_APP_PREF (" + createIfMissing(c, "HMI_APP_PREF", "CREATE TABLE " + prefix + "HMI_APP_PREF (" + "SCOPE_TYPE " + shortText + "(20) NOT NULL, SCOPE_ID " + shortText + "(255) NOT NULL, " + "PREFS_JSON " + text + " NOT NULL, UPDATED_AT " + date + " DEFAULT " + now + " NOT NULL, " + "PRIMARY KEY (SCOPE_TYPE, SCOPE_ID))"); - createIfMissing(c, "HMI_APP_GROUP_MEMBER", "CREATE TABLE " + prefix + "HMI_APP_GROUP_MEMBER (" + createIfMissing(c, "HMI_APP_GROUP_MEMBER", "CREATE TABLE " + prefix + "HMI_APP_GROUP_MEMBER (" + "USER_ID " + shortText + "(255) NOT NULL, GROUP_ID " + shortText + "(120) NOT NULL, " + "PRIMARY KEY (USER_ID, GROUP_ID))"); - createIfMissing(c, "HMI_APP_AUDIT", "CREATE TABLE " + prefix + "HMI_APP_AUDIT (" + createIfMissing(c, "HMI_APP_AUDIT", "CREATE TABLE " + prefix + "HMI_APP_AUDIT (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, ACTOR " + shortText + "(255) NOT NULL, " + "ACTION_NAME " + shortText + "(120) NOT NULL, ENTITY_ID " + shortText + "(255), " + "DETAILS " + shortText + "(1000), CREATED_AT " + date + " DEFAULT " + now + " NOT NULL)"); // Versioned ios.css content, separate from the immutable WAR fallback. - createIfMissing(c, "HMI_APP_CSS_REVISION", "CREATE TABLE " + prefix + "HMI_APP_CSS_REVISION (" + createIfMissing(c, "HMI_APP_CSS_REVISION", "CREATE TABLE " + prefix + "HMI_APP_CSS_REVISION (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, VERSION_NO " + numeric + " NOT NULL UNIQUE, " + "STATUS " + shortText + "(20) NOT NULL, CSS_CONTENT " + text + " NOT NULL, " + "UPDATED_BY " + shortText + "(255), UPDATED_AT " + date + " DEFAULT " + now + " NOT NULL)"); // V5: Person-oriented roles, groups and uploaded HMI image assets. - String binary = oracle ? "BLOB" : "VARBINARY(MAX)"; - createIfMissing(c, "HMI_APP_ROLE", "CREATE TABLE " + prefix + "HMI_APP_ROLE (" + String binary = oracle ? "BLOB" : "VARBINARY(MAX)"; + createIfMissing(c, "HMI_APP_ROLE", "CREATE TABLE " + prefix + "HMI_APP_ROLE (" + "ROLE_KEY " + shortText + "(120) NOT NULL PRIMARY KEY, DESCRIPTION " + shortText + "(255))"); - createIfMissing(c, "HMI_APP_GROUP_DEF", "CREATE TABLE " + prefix + "HMI_APP_GROUP_DEF (" + createIfMissing(c, "HMI_APP_GROUP_DEF", "CREATE TABLE " + prefix + "HMI_APP_GROUP_DEF (" + "GROUP_KEY " + shortText + "(120) NOT NULL PRIMARY KEY, DESCRIPTION " + shortText + "(255))"); - createIfMissing(c, "HMI_APP_GROUP_ROLE", "CREATE TABLE " + prefix + "HMI_APP_GROUP_ROLE (" + createIfMissing(c, "HMI_APP_GROUP_ROLE", "CREATE TABLE " + prefix + "HMI_APP_GROUP_ROLE (" + "GROUP_KEY " + shortText + "(120) NOT NULL, ROLE_KEY " + shortText + "(120) NOT NULL, PRIMARY KEY (GROUP_KEY,ROLE_KEY))"); - createIfMissing(c, "HMI_APP_PERSON_ROLE", "CREATE TABLE " + prefix + "HMI_APP_PERSON_ROLE (" + createIfMissing(c, "HMI_APP_PERSON_ROLE", "CREATE TABLE " + prefix + "HMI_APP_PERSON_ROLE (" + "PERS_ID " + shortText + "(120) NOT NULL, ROLE_KEY " + shortText + "(120) NOT NULL, PRIMARY KEY (PERS_ID,ROLE_KEY))"); - createIfMissing(c, "HMI_APP_PERSON_GROUP", "CREATE TABLE " + prefix + "HMI_APP_PERSON_GROUP (" + createIfMissing(c, "HMI_APP_PERSON_GROUP", "CREATE TABLE " + prefix + "HMI_APP_PERSON_GROUP (" + "PERS_ID " + shortText + "(120) NOT NULL, GROUP_KEY " + shortText + "(120) NOT NULL, PRIMARY KEY (PERS_ID,GROUP_KEY))"); - createIfMissing(c, "HMI_APP_LOGIN_PERSON", "CREATE TABLE " + prefix + "HMI_APP_LOGIN_PERSON (" + createIfMissing(c, "HMI_APP_LOGIN_PERSON", "CREATE TABLE " + prefix + "HMI_APP_LOGIN_PERSON (" + "LOGIN_ID " + shortText + "(255) NOT NULL PRIMARY KEY, PERS_ID " + shortText + "(120) NOT NULL)"); // First-run administration: one permanent, database-locked claim marker. - createIfMissing(c, "HMI_APP_BOOTSTRAP", "CREATE TABLE " + prefix + "HMI_APP_BOOTSTRAP (" + createIfMissing(c, "HMI_APP_BOOTSTRAP", "CREATE TABLE " + prefix + "HMI_APP_BOOTSTRAP (" + "ID " + shortText + "(24) NOT NULL PRIMARY KEY, CLAIMED_BY " + shortText + "(255), CLAIMED_AT " + date + ")"); - try(PreparedStatement ps=c.prepareStatement("SELECT ID FROM " + prefix + "HMI_APP_BOOTSTRAP WHERE ID='GLOBAL'"); - ResultSet rs=ps.executeQuery()) { - if(!rs.next())try(PreparedStatement insert=c.prepareStatement( + try(PreparedStatement ps=c.prepareStatement("SELECT ID FROM " + prefix + "HMI_APP_BOOTSTRAP WHERE ID='GLOBAL'"); + ResultSet rs=ps.executeQuery()) { + if(!rs.next())try(PreparedStatement insert=c.prepareStatement( "INSERT INTO " + prefix + "HMI_APP_BOOTSTRAP(ID) VALUES ('GLOBAL')")) { - try{insert.executeUpdate();}catch(SQLException concurrent){ - try(PreparedStatement chk=c.prepareStatement("SELECT ID FROM " + prefix + "HMI_APP_BOOTSTRAP WHERE ID='GLOBAL'"); - ResultSet check=chk.executeQuery()){if(!check.next())throw concurrent;} - } + try{insert.executeUpdate();}catch(SQLException concurrent){ + try(PreparedStatement chk=c.prepareStatement("SELECT ID FROM " + prefix + "HMI_APP_BOOTSTRAP WHERE ID='GLOBAL'"); + ResultSet check=chk.executeQuery()){if(!check.next())throw concurrent;} + } } } - createIfMissing(c, "HMI_APP_ASSET", "CREATE TABLE " + prefix + "HMI_APP_ASSET (" + createIfMissing(c, "HMI_APP_ASSET", "CREATE TABLE " + prefix + "HMI_APP_ASSET (" + "ID " + shortText + "(64) NOT NULL PRIMARY KEY, ORIGINAL_NAME " + shortText + "(255) NOT NULL, " + "MIME_TYPE " + shortText + "(80) NOT NULL, CONTENT " + binary + " NOT NULL, " + "CONTENT_SIZE " + numeric + " NOT NULL, UPDATED_BY " + shortText + "(255) NOT NULL)"); - createIfMissing(c, "HMI_APP_SCHEMA_VERSION", "CREATE TABLE " + prefix + "HMI_APP_SCHEMA_VERSION (" + createIfMissing(c, "HMI_APP_SCHEMA_VERSION", "CREATE TABLE " + prefix + "HMI_APP_SCHEMA_VERSION (" + "VERSION_NO " + numeric + " NOT NULL PRIMARY KEY, INSTALLED_AT " + date + " DEFAULT " + now + " NOT NULL)"); // Fail closed when a v1 schema exists: do not alter existing PKs on a production database. // See hmi-docs/migrate-v1-to-v2-*.sql for non-destructive, operator-reviewed migration. - phase = "SCHEMA_VERIFICATION"; - verifyLayoutStationKey(c, oracle); - try (PreparedStatement check = c.prepareStatement("SELECT VERSION_NO FROM " + prefix + "HMI_APP_SCHEMA_VERSION WHERE VERSION_NO = 7"); - ResultSet rs = check.executeQuery()) { - if (!rs.next()) { - try (PreparedStatement insert = c.prepareStatement("INSERT INTO " + prefix + "HMI_APP_SCHEMA_VERSION(VERSION_NO) VALUES (7)")) { - insert.executeUpdate(); - } catch (SQLException concurrent) { // A second cluster member may have inserted simultaneously. - try (PreparedStatement confirm = c.prepareStatement("SELECT VERSION_NO FROM " + prefix + "HMI_APP_SCHEMA_VERSION WHERE VERSION_NO = 7"); - ResultSet rs2 = confirm.executeQuery()) { - if (!rs2.next()) throw concurrent; + phase = "SCHEMA_VERIFICATION"; + verifyLayoutStationKey(c, oracle); + try (PreparedStatement check = c.prepareStatement("SELECT VERSION_NO FROM " + prefix + "HMI_APP_SCHEMA_VERSION WHERE VERSION_NO = 7"); + ResultSet rs = check.executeQuery()) { + if (!rs.next()) { + try (PreparedStatement insert = c.prepareStatement("INSERT INTO " + prefix + "HMI_APP_SCHEMA_VERSION(VERSION_NO) VALUES (7)")) { + insert.executeUpdate(); + } catch (SQLException concurrent) { // A second cluster member may have inserted simultaneously. + try (PreparedStatement confirm = c.prepareStatement("SELECT VERSION_NO FROM " + prefix + "HMI_APP_SCHEMA_VERSION WHERE VERSION_NO = 7"); + ResultSet rs2 = confirm.executeQuery()) { + if (!rs2.next()) throw concurrent; } - } + } } } - HmiDb.useDatabase(oracle); - ready = true; - HmiInitialAdmin.initialize(c); - phase = "READY"; - code = "NONE"; - state = "Initialized: " + product + ", schema " + (oracle ? "CUST" : "cust") + ", version 7"; - LOG.info("HMI " + state); - } catch (Exception ex) { - ready = false; - if ("NONE".equals(code)) { - if (!poolConnected) code = "POOL_CONNECTION_FAILED"; - else if ("SCHEMA_VERIFICATION".equals(phase)) code = "SCHEMA_MIGRATION_REQUIRED"; - else if ("SCHEMA_INITIALIZATION".equals(phase) || "SCHEMA_CHECK".equals(phase)) code = "SCHEMA_SETUP_FAILED"; - else code = "DATABASE_ERROR"; + HmiDb.useDatabase(oracle); + ready = true; + HmiInitialAdmin.initialize(c); + HmiSchemaRecovery.clear(); + phase = "READY"; + code = "NONE"; + state = "Initialized: " + product + ", schema " + (oracle ? "CUST" : "cust") + ", version 7"; + LOG.info("HMI " + state); + } catch (Exception ex) { + ready = false; + if ("NONE".equals(code)) { + if (!poolConnected) code = "POOL_CONNECTION_FAILED"; + else if ("SCHEMA_VERIFICATION".equals(phase)) code = "SCHEMA_MIGRATION_REQUIRED"; + else if ("SCHEMA_INITIALIZATION".equals(phase) || "SCHEMA_CHECK".equals(phase)) code = "SCHEMA_SETUP_FAILED"; + else code = "DATABASE_ERROR"; } - state = "Database initialization failed; inspect GlassFish logs"; - LOG.log(Level.SEVERE, "HMI schema initialization FAILED [" + code + ", phase=" + phase + "]; HMI endpoints remain unavailable", ex); - } - } + state = "Database initialization failed; inspect GlassFish logs"; + HmiSchemaRecovery.enableAfterFailure(); + LOG.log(Level.SEVERE, "HMI schema initialization FAILED [" + code + ", phase=" + phase + "]; HMI endpoints remain unavailable", ex); + } + } // START_LOCK + } private boolean pageParentColumnExists(Connection c, boolean oracle) throws SQLException { - DatabaseMetaData md = c.getMetaData(); - String schemaName = oracle ? "CUST" : "cust"; - try (ResultSet rs = md.getColumns(null, schemaName, "HMI_APP_PAGE", "PARENT_PAGE_ID")) { - if (rs.next()) return true; - } + DatabaseMetaData md = c.getMetaData(); + String schemaName = oracle ? "CUST" : "cust"; + try (ResultSet rs = md.getColumns(null, schemaName, "HMI_APP_PAGE", "PARENT_PAGE_ID")) { + if (rs.next()) return true; + } // Some SQL Server drivers return the schema with different capitalization. - try (ResultSet rs = md.getColumns(null, schemaName.toUpperCase(Locale.ROOT), "HMI_APP_PAGE", "PARENT_PAGE_ID")) { - return rs.next(); + try (ResultSet rs = md.getColumns(null, schemaName.toUpperCase(Locale.ROOT), "HMI_APP_PAGE", "PARENT_PAGE_ID")) { + return rs.next(); } } private void addParentPageColumnIfMissing(Connection c, boolean oracle) throws SQLException { - if (pageParentColumnExists(c, oracle)) return; - String ddl = oracle - ? "ALTER TABLE CUST.HMI_APP_PAGE ADD (PARENT_PAGE_ID VARCHAR2(64))" - : "ALTER TABLE cust.HMI_APP_PAGE ADD PARENT_PAGE_ID NVARCHAR(64) NULL"; - try (Statement st = c.createStatement()) { - st.execute(ddl); - LOG.info("HMI schema V5.2: added HMI_APP_PAGE.PARENT_PAGE_ID"); - } catch (SQLException error) { + if (pageParentColumnExists(c, oracle)) return; + String ddl = oracle + ? "ALTER TABLE CUST.HMI_APP_PAGE ADD (PARENT_PAGE_ID VARCHAR2(64))" + : "ALTER TABLE cust.HMI_APP_PAGE ADD PARENT_PAGE_ID NVARCHAR(64) NULL"; + try (Statement st = c.createStatement()) { + st.execute(ddl); + LOG.info("HMI schema V5.2: added HMI_APP_PAGE.PARENT_PAGE_ID"); + } catch (SQLException error) { // A second GlassFish instance might have applied the same migration. - if (!pageParentColumnExists(c, oracle)) throw error; - } - } + if (!pageParentColumnExists(c, oracle)) throw error; + } + } private void verifyLayoutStationKey(Connection c, boolean oracle) throws SQLException { - DatabaseMetaData md = c.getMetaData(); - String schema = oracle ? "CUST" : "cust"; - boolean station = false, user = false, page = false; - try (ResultSet columns = md.getColumns(null, schema, "HMI_APP_LAYOUT", "STATION_ID")) { - if (!columns.next()) throw new SQLException("HMI schema v1 layout detected (STATION_ID missing); apply documented v1 to v2 migration"); + DatabaseMetaData md = c.getMetaData(); + String schema = oracle ? "CUST" : "cust"; + boolean station = false, user = false, page = false; + try (ResultSet columns = md.getColumns(null, schema, "HMI_APP_LAYOUT", "STATION_ID")) { + if (!columns.next()) throw new SQLException("HMI schema v1 layout detected (STATION_ID missing); apply documented v1 to v2 migration"); } - try (ResultSet pk = md.getPrimaryKeys(null, schema, "HMI_APP_LAYOUT")) { - while (pk.next()) { - String name = pk.getString("COLUMN_NAME"); - station |= "STATION_ID".equalsIgnoreCase(name); - user |= "USER_ID".equalsIgnoreCase(name); - page |= "PAGE_ID".equalsIgnoreCase(name); - } + try (ResultSet pk = md.getPrimaryKeys(null, schema, "HMI_APP_LAYOUT")) { + while (pk.next()) { + String name = pk.getString("COLUMN_NAME"); + station |= "STATION_ID".equalsIgnoreCase(name); + user |= "USER_ID".equalsIgnoreCase(name); + page |= "PAGE_ID".equalsIgnoreCase(name); + } } - if (!station || !user || !page) { - throw new SQLException("HMI_APP_LAYOUT requires composite primary key USER_ID, PAGE_ID, STATION_ID; apply documented v1 to v2 migration"); + if (!station || !user || !page) { + throw new SQLException("HMI_APP_LAYOUT requires composite primary key USER_ID, PAGE_ID, STATION_ID; apply documented v1 to v2 migration"); } - } + } private void createSqlServerSchema(Connection c) throws SQLException { - try (Statement st = c.createStatement()) { - st.execute("IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'cust') EXEC('CREATE SCHEMA cust')"); + try (Statement st = c.createStatement()) { + st.execute("IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'cust') EXEC('CREATE SCHEMA cust')"); } - } + } private void assertOracleSchemaExists(Connection c) throws SQLException { - try (PreparedStatement ps = c.prepareStatement("SELECT 1 FROM ALL_USERS WHERE USERNAME = 'CUST'"); - ResultSet rs = ps.executeQuery()) { - if (!rs.next()) throw new SQLException("Oracle schema CUST does not exist. Provision it first using DBA privileges."); + try (PreparedStatement ps = c.prepareStatement("SELECT 1 FROM ALL_USERS WHERE USERNAME = 'CUST'"); + ResultSet rs = ps.executeQuery()) { + if (!rs.next()) throw new SQLException("Oracle schema CUST does not exist. Provision it first using DBA privileges."); } - } + } private void createIfMissing(Connection c, String table, String ddl) throws SQLException { - if (exists(c, table)) return; - try (Statement st = c.createStatement()) { - st.execute(ddl); - LOG.info("Created HMI table CUST." + table); - } catch (SQLException e) { - if (!exists(c, table)) throw e; // Only suppress a concurrent, successful table creation. - } - } + if (exists(c, table)) return; + try (Statement st = c.createStatement()) { + st.execute(ddl); + LOG.info("Created HMI table CUST." + table); + } catch (SQLException e) { + if (!exists(c, table)) throw e; // Only suppress a concurrent, successful table creation. + } + } private boolean exists(Connection c, String table) throws SQLException { - DatabaseMetaData m = c.getMetaData(); - try (ResultSet rs = m.getTables(null, "CUST", table, new String[]{"TABLE"})) { - if (rs.next()) return true; - } - try (ResultSet rs = m.getTables(null, "cust", table, new String[]{"TABLE"})) { - return rs.next(); + DatabaseMetaData m = c.getMetaData(); + try (ResultSet rs = m.getTables(null, "CUST", table, new String[]{"TABLE"})) { + if (rs.next()) return true; + } + try (ResultSet rs = m.getTables(null, "cust", table, new String[]{"TABLE"})) { + return rs.next(); } } - @Override public void contextDestroyed(ServletContextEvent event) { ready = false; phase = "STOPPED"; } + @Override public void contextDestroyed(ServletContextEvent event) { ready = false; phase = "STOPPED"; } } \ No newline at end of file diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/index.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/index.html index fd56831..6becd64 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/index.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/index.html @@ -1 +1 @@ -com.workbenchclassic.hmi

com.workbenchclassic.hmi

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total11.141 of 11.1410 %1.415 of 1.4150 %9359351.5541.5542242242222
HmiApiResource4.5070 %5670 %352352543543676711
HmiRolesResource9520 %860 %6565104104222211
HmiSchemaBootstrap7070 %800 %5757150150171711
HmiStyleResource6540 %560 %45455151171711
HmiImsapiGateway5280 %960 %535368685511
HmiAuth4820 %1000 %67677676171711
HmiImsapiSecurityResource4360 %500 %313170706611
HmiWorkplaceProxyResource4300 %600 %383883838811
HmiInitialAdmin4200 %680 %424276768811
HmiJvmOptions3720 %320 %242469698811
HmiAssetsResource3580 %600 %353537375511
HmiLegacyWidgetResource3540 %460 %323250507711
HmiSystemSettingsResource1970 %240 %181837376611
HmiBootstrapResource1570 %140 %111123234411
HmiImsapiActionResource1530 %200 %131322223311
HmiStyles1360 %280 %181821214411
HmiTransportPolicy880 %160 %131318185511
HmiHealthServlet670 %n/a2220202211
HmiJvmOptions.new Callable() {...}440 %0 %44882211
HmiThemeServlet430 %0 %4411112211
HmiOriginFilter0 %0 %5512124411
HmiDb0 %0 %66665511
\ No newline at end of file +com.workbenchclassic.hmi

com.workbenchclassic.hmi

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total11.409 of 11.4090 %1.449 of 1.4490 %9629621.6061.6062342342424
HmiApiResource4.5220 %5730 %355355546546676711
HmiRolesResource9520 %860 %6565104104222211
HmiSchemaBootstrap7260 %800 %5858156156181811
HmiStyleResource6540 %560 %45455151171711
HmiImsapiGateway5280 %960 %535368685511
HmiAuth4820 %1000 %67677676171711
HmiImsapiSecurityResource4410 %480 %303073736611
HmiWorkplaceProxyResource4300 %600 %383883838811
HmiInitialAdmin4200 %680 %424276768811
HmiJvmOptions3720 %320 %242469698811
HmiAssetsResource3580 %600 %353537375511
HmiLegacyWidgetResource3540 %460 %323250507711
HmiSystemSettingsResource1970 %240 %181837376611
HmiBootstrapResource1570 %140 %111123234411
HmiImsapiActionResource1530 %200 %131322223311
HmiStyles1360 %280 %181821214411
HmiSchemaRecoveryResource1340 %160 %111117173311
HmiSchemaRecovery920 %140 %131322226611
HmiTransportPolicy880 %160 %131318185511
HmiHealthServlet700 %n/a2221212211
HmiJvmOptions.new Callable() {...}440 %0 %44882211
HmiThemeServlet430 %0 %4411112211
HmiOriginFilter0 %0 %5512124411
HmiDb0 %0 %66665511
\ No newline at end of file diff --git a/backend/target/site/jacoco/com.workbenchclassic.hmi/index.source.html b/backend/target/site/jacoco/com.workbenchclassic.hmi/index.source.html index f004667..378a176 100644 --- a/backend/target/site/jacoco/com.workbenchclassic.hmi/index.source.html +++ b/backend/target/site/jacoco/com.workbenchclassic.hmi/index.source.html @@ -1 +1 @@ -com.workbenchclassic.hmi

com.workbenchclassic.hmi

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total11.141 of 11.1410 %1.415 of 1.4150 %9359351.5541.5542242242222
HmiApiResource.java4.5070 %5670 %352352543543676711
HmiRolesResource.java9520 %860 %6565104104222211
HmiSchemaBootstrap.java7070 %800 %5757150150171711
HmiStyleResource.java6540 %560 %45455151171711
HmiImsapiGateway.java5280 %960 %535368685511
HmiAuth.java4820 %1000 %67677676171711
HmiImsapiSecurityResource.java4360 %500 %313170706611
HmiWorkplaceProxyResource.java4300 %600 %383883838811
HmiInitialAdmin.java4200 %680 %424276768811
HmiJvmOptions.java4160 %360 %28287676101022
HmiAssetsResource.java3580 %600 %353537375511
HmiLegacyWidgetResource.java3540 %460 %323250507711
HmiSystemSettingsResource.java1970 %240 %181837376611
HmiBootstrapResource.java1570 %140 %111123234411
HmiImsapiActionResource.java1530 %200 %131322223311
HmiStyles.java1360 %280 %181821214411
HmiTransportPolicy.java880 %160 %131318185511
HmiHealthServlet.java670 %n/a2220202211
HmiThemeServlet.java430 %0 %4411112211
HmiOriginFilter.java0 %0 %5512124411
HmiDb.java0 %0 %66665511
\ No newline at end of file +com.workbenchclassic.hmi

com.workbenchclassic.hmi

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total11.409 of 11.4090 %1.449 of 1.4490 %9629621.6061.6062342342424
HmiApiResource.java4.5220 %5730 %355355546546676711
HmiRolesResource.java9520 %860 %6565104104222211
HmiSchemaBootstrap.java7260 %800 %5858156156181811
HmiStyleResource.java6540 %560 %45455151171711
HmiImsapiGateway.java5280 %960 %535368685511
HmiAuth.java4820 %1000 %67677676171711
HmiImsapiSecurityResource.java4410 %480 %303073736611
HmiWorkplaceProxyResource.java4300 %600 %383883838811
HmiInitialAdmin.java4200 %680 %424276768811
HmiJvmOptions.java4160 %360 %28287676101022
HmiAssetsResource.java3580 %600 %353537375511
HmiLegacyWidgetResource.java3540 %460 %323250507711
HmiSystemSettingsResource.java1970 %240 %181837376611
HmiBootstrapResource.java1570 %140 %111123234411
HmiImsapiActionResource.java1530 %200 %131322223311
HmiStyles.java1360 %280 %181821214411
HmiSchemaRecoveryResource.java1340 %160 %111117173311
HmiSchemaRecovery.java920 %140 %131322226611
HmiTransportPolicy.java880 %160 %131318185511
HmiHealthServlet.java700 %n/a2221212211
HmiThemeServlet.java430 %0 %4411112211
HmiOriginFilter.java0 %0 %5512124411
HmiDb.java0 %0 %66665511
\ No newline at end of file diff --git a/backend/target/site/jacoco/index.html b/backend/target/site/jacoco/index.html index 64d0ae0..beccbaa 100644 --- a/backend/target/site/jacoco/index.html +++ b/backend/target/site/jacoco/index.html @@ -1 +1 @@ -backend

backend

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total16.282 of 16.2820 %1.639 of 1.6390 %1.1621.1622.7552.7553393394949
com.workbenchclassic.hmi11.1410 %1.4150 %9359351.5541.5542242242222
com.workbenchclassic5.1410 %2240 %2272271.2011.2011151152727
\ No newline at end of file +backend

backend

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total16.550 of 16.5500 %1.673 of 1.6730 %1.1891.1892.8072.8073493495151
com.workbenchclassic.hmi11.4090 %1.4490 %9629621.6061.6062342342424
com.workbenchclassic5.1410 %2240 %2272271.2011.2011151152727
\ No newline at end of file diff --git a/backend/target/site/jacoco/jacoco-sessions.html b/backend/target/site/jacoco/jacoco-sessions.html index eb5a8a3..6000d8d 100644 --- a/backend/target/site/jacoco/jacoco-sessions.html +++ b/backend/target/site/jacoco/jacoco-sessions.html @@ -1 +1 @@ -Sessions

Sessions

This coverage report is based on execution data from the following sessions:

SessionStart TimeDump Time
kubernetes-d80dd44b25.10.2026, 08:54:4925.10.2026, 08:54:50

Execution data for the following classes is considered in this report:

ClassId
com.workbenchclassic.AppTest7718c7447416258a
org.apache.maven.surefire.api.booter.BaseProviderFactory5bdb25554fb3d5df
org.apache.maven.surefire.api.booter.BiProperty9a2074ae999b3c8a
org.apache.maven.surefire.api.booter.Commandf31ca5085797c808
org.apache.maven.surefire.api.booter.DumpErrorSingletone3f1c75f159a9ac5
org.apache.maven.surefire.api.booter.ForkedProcessEventTypedc56c5dba14b9d58
org.apache.maven.surefire.api.booter.ForkingReporterFactorybcadcd63978e8dcf
org.apache.maven.surefire.api.booter.ForkingRunListener08c963875a23e517
org.apache.maven.surefire.api.booter.MasterProcessCommand90562129b4defd58
org.apache.maven.surefire.api.booter.Shutdownfab38023c4f1ded4
org.apache.maven.surefire.api.cli.CommandLineOption4401c2efb3702254
org.apache.maven.surefire.api.provider.AbstractProvidercf68f167cf236f7b
org.apache.maven.surefire.api.report.ConsoleOutputCaptureb8719a08fbb63e05
org.apache.maven.surefire.api.report.ConsoleOutputCapture.ForwardingPrintStream7c2392ea44674f2d
org.apache.maven.surefire.api.report.ConsoleOutputCapture.NullOutputStreamf7132188596462e2
org.apache.maven.surefire.api.report.ReporterConfiguration39591ad2c5816a79
org.apache.maven.surefire.api.report.RunModef02e60476bce4d8d
org.apache.maven.surefire.api.report.SimpleReportEntrye252cb5986c391cc
org.apache.maven.surefire.api.suite.RunResult8d97f6894fd90ced
org.apache.maven.surefire.api.testset.DirectoryScannerParametersc53ea59aeaf0b80a
org.apache.maven.surefire.api.testset.IncludedExcludedPatterns43b8f8de9b3a1945
org.apache.maven.surefire.api.testset.ResolvedTest7e73a65f1017294e
org.apache.maven.surefire.api.testset.ResolvedTest.ClassMatcher0f9c29dc1562afeb
org.apache.maven.surefire.api.testset.ResolvedTest.MethodMatcherfccae89ce7b4ee31
org.apache.maven.surefire.api.testset.ResolvedTest.Typebf93fc9765a2bd72
org.apache.maven.surefire.api.testset.RunOrderParameterscb70af248c260139
org.apache.maven.surefire.api.testset.TestArtifactInfoc68e923f629df613
org.apache.maven.surefire.api.testset.TestListResolver3dc896f10c8df96c
org.apache.maven.surefire.api.testset.TestRequest976405c051909d71
org.apache.maven.surefire.api.util.CloseableIteratorf2c0acf940ec6fbe
org.apache.maven.surefire.api.util.DefaultRunOrderCalculator1f50ae9e4b9717cd
org.apache.maven.surefire.api.util.DefaultScanResult46fdc84739146387
org.apache.maven.surefire.api.util.ReflectionUtils6079e135f863f220
org.apache.maven.surefire.api.util.RunOrder0ea36dbbf05327aa
org.apache.maven.surefire.api.util.TestsToRuncc3376426ef9c01c
org.apache.maven.surefire.api.util.TestsToRun.ClassesIteratorcd6601db7bc899db
org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleReadableChannel6abb59e4c94390af
org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel989f9bf3c66ab7be
org.apache.maven.surefire.api.util.internal.Channels95e459b596e3b873
org.apache.maven.surefire.api.util.internal.Channels.39770f03bd51e14f7
org.apache.maven.surefire.api.util.internal.Channels.4a0e3eaa91d355cc2
org.apache.maven.surefire.api.util.internal.DaemonThreadFactorya56bf84543725f3a
org.apache.maven.surefire.api.util.internal.DaemonThreadFactory.NamedThreadFactorycfeefeb0265a8a13
org.apache.maven.surefire.api.util.internal.DumpFileUtils9a7dbfdf3c2027c8
org.apache.maven.surefire.api.util.internal.ImmutableMapee11b540cdd4034e
org.apache.maven.surefire.api.util.internal.ImmutableMap.Node984f6258c6d6ac9c
org.apache.maven.surefire.api.util.internal.ObjectUtils8c788ffcde97fbb4
org.apache.maven.surefire.booter.AbstractPathConfiguration4839ca4be6e46906
org.apache.maven.surefire.booter.BooterDeserializer02dc12ed0aec9547
org.apache.maven.surefire.booter.ClassLoaderConfiguration462fdbd63f8ea8c8
org.apache.maven.surefire.booter.Classpath5c18bd381e88bcc8
org.apache.maven.surefire.booter.ClasspathConfiguration4c9fc97c565be4cc
org.apache.maven.surefire.booter.CommandReaderc29c2eca0cd24bfc
org.apache.maven.surefire.booter.CommandReader.1727226d97ed192cb
org.apache.maven.surefire.booter.CommandReader.CommandRunnable41ac58e8d85ca2bd
org.apache.maven.surefire.booter.ForkedBooter708bf5b29b088537
org.apache.maven.surefire.booter.ForkedBooter.17d062229af4458f7
org.apache.maven.surefire.booter.ForkedBooter.3093e1d6ec83caf1c
org.apache.maven.surefire.booter.ForkedBooter.488f2f3e42230f38d
org.apache.maven.surefire.booter.ForkedBooter.6a150022bee6cbd41
org.apache.maven.surefire.booter.ForkedBooter.77d0ab78a1157bb24
org.apache.maven.surefire.booter.ForkedBooter.801800b3929973273
org.apache.maven.surefire.booter.ForkedBooter.PingSchedulerfb97687ca93ecbd1
org.apache.maven.surefire.booter.PpidCheckercc99aab0e566c991
org.apache.maven.surefire.booter.ProcessCheckerType5e6688e4a6a909e6
org.apache.maven.surefire.booter.PropertiesWrapperf63d2b2f2fd9087a
org.apache.maven.surefire.booter.ProviderConfiguration146800cea9c5f6cc
org.apache.maven.surefire.booter.StartupConfiguration1cb50557cb9ebb0b
org.apache.maven.surefire.booter.SystemPropertyManager3a0459e270104889
org.apache.maven.surefire.booter.TypeEncodedValue25e613e357b4f737
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelDecoder477264b3887a3b8b
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelDecoder.FrameCompletion00319e897e4dfd77
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelEncoderd52ce258d8e88d04
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelProcessorFactory3e8e80dcadf11ad6
org.apache.maven.surefire.booter.spi.SurefireMasterProcessChannelProcessorFactory6bb9533ad5c08a49
org.apache.maven.surefire.junitplatform.JUnitPlatformProvider847b42ef97f97d2b
org.apache.maven.surefire.junitplatform.RunListenerAdapterd23fd29ada1102cb
org.apache.maven.surefire.junitplatform.RunListenerAdapter.155724259eef83afa
org.apache.maven.surefire.junitplatform.TestPlanScannerFiltera3ae2542fd30e874
org.apache.maven.surefire.shared.codec.binary.Base64cd6927ec7cf0569e
org.apache.maven.surefire.shared.codec.binary.BaseNCodecc8dd8163b58acfc1
org.apache.maven.surefire.shared.codec.binary.BaseNCodec.Context84b370e464e7008c
org.apache.maven.surefire.shared.lang3.JavaVersion590095a767529b48
org.apache.maven.surefire.shared.lang3.StringUtilsae3c2c379ffab6fd
org.apache.maven.surefire.shared.lang3.SystemUtilse4faf882077bc6c0
org.apache.maven.surefire.shared.lang3.math.NumberUtils505629194db735ed
org.apache.maven.surefire.shared.utils.StringUtils5ba1288622b5e22e
org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtilsb7b46c5c1f482bd4
org.apiguardian.api.API.Status0341e8d99fc36573
org.junit.jupiter.api.AssertEquals6b16b14f06d2f13c
org.junit.jupiter.api.Assertions7406fdbebf83bc7a
org.junit.jupiter.api.DisplayNameGeneratorc813afbd86fd7cc8
org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores82e8bc7daaa8e1e0
org.junit.jupiter.api.DisplayNameGenerator.Standardf23772be1d9bb824
org.junit.jupiter.api.TestInstance.Lifecycle548dd47a98f9c8af
org.junit.jupiter.api.extension.ConditionEvaluationResult2f9dc9ea54b57975
org.junit.jupiter.api.extension.ExtensionContext1789eac1274261fc
org.junit.jupiter.api.extension.ExtensionContext.Namespace9ecb19f5d8d233f2
org.junit.jupiter.api.extension.InvocationInterceptor996f7741ba5ec355
org.junit.jupiter.engine.JupiterTestEngine42bfd69ac4ff9a31
org.junit.jupiter.engine.config.CachingJupiterConfiguratione0782b8c7a730030
org.junit.jupiter.engine.config.ClassNamePatternParameterConverterdb88e74320096433
org.junit.jupiter.engine.config.DefaultJupiterConfiguration9edf3c93edb9be05
org.junit.jupiter.engine.config.DisplayNameGeneratorParameterConverter10239f24d8c710ad
org.junit.jupiter.engine.config.EnumConfigurationParameterConverter339f5752af685066
org.junit.jupiter.engine.descriptor.AbstractExtensionContext9bf01323cf853683
org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor93da3ced5777b865
org.junit.jupiter.engine.descriptor.ClassExtensionContextda8d011f2fd97107
org.junit.jupiter.engine.descriptor.ClassTestDescriptorf5d10ac1d89bb01f
org.junit.jupiter.engine.descriptor.DisplayNameUtils5b062d6beb8f55b6
org.junit.jupiter.engine.descriptor.ExtensionUtils857bd7cde465ada0
org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor8502a8ddd495080f
org.junit.jupiter.engine.descriptor.JupiterEngineExtensionContext37e3ac8bbe8deb47
org.junit.jupiter.engine.descriptor.JupiterTestDescriptoracf2905fc10efa75
org.junit.jupiter.engine.descriptor.LifecycleMethodUtils1162b59df6db6b33
org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor120c02c460cd1892
org.junit.jupiter.engine.descriptor.MethodExtensionContextafe114c2ffc920b7
org.junit.jupiter.engine.descriptor.TestInstanceLifecycleUtils8d8758db35676c1c
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptorb9a613d54c81997c
org.junit.jupiter.engine.discovery.ClassSelectorResolvera62bf2e2a3da3cb2
org.junit.jupiter.engine.discovery.DiscoverySelectorResolver9913614fbfb4142b
org.junit.jupiter.engine.discovery.MethodFinder5ea468d2eb528361
org.junit.jupiter.engine.discovery.MethodOrderingVisitorbd9a3fc474bdccea
org.junit.jupiter.engine.discovery.MethodSelectorResolver9e004b1ce9842826
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType76d091417c997edb
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.1098756f55a3f159b
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.2b4451da4ca26c94f
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.3a9cba48e54e36d6b
org.junit.jupiter.engine.discovery.predicates.IsInnerClassf7d9846d00228720
org.junit.jupiter.engine.discovery.predicates.IsNestedTestClasse47ff7cd33073803
org.junit.jupiter.engine.discovery.predicates.IsPotentialTestContainerfcb5565ad4483f6c
org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests2a6af63531e197a1
org.junit.jupiter.engine.discovery.predicates.IsTestFactoryMethoda2c68978bd6bfbc6
org.junit.jupiter.engine.discovery.predicates.IsTestMethod8b244977e441886e
org.junit.jupiter.engine.discovery.predicates.IsTestTemplateMethod0baf1066bf0cbad7
org.junit.jupiter.engine.discovery.predicates.IsTestableMethod59a0b58a40803fe2
org.junit.jupiter.engine.execution.ConditionEvaluatorc2ba33ab802578df
org.junit.jupiter.engine.execution.ConstructorInvocation4aef47e7c0afe594
org.junit.jupiter.engine.execution.DefaultTestInstances37fd85d961d60c98
org.junit.jupiter.engine.execution.ExecutableInvoker88626e54fda7c10e
org.junit.jupiter.engine.execution.ExecutableInvoker.ReflectiveInterceptorCall1e58a02ac712330c
org.junit.jupiter.engine.execution.ExtensionValuesStoreb7ff2e73f692c652
org.junit.jupiter.engine.execution.ExtensionValuesStore.CompositeKey24fed135af0eff32
org.junit.jupiter.engine.execution.ExtensionValuesStore.MemoizingSupplier5be22cd9e3599327
org.junit.jupiter.engine.execution.InvocationInterceptorChain008224a337018874
org.junit.jupiter.engine.execution.InvocationInterceptorChain.InterceptedInvocation62ff9a2338ce3045
org.junit.jupiter.engine.execution.InvocationInterceptorChain.ValidatingInvocation2434903e45fcd05c
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext868921f800563654
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.Builderd23096bee4e10887
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.State0a606b935b0623c0
org.junit.jupiter.engine.execution.MethodInvocation6f894f3cd37e86c5
org.junit.jupiter.engine.execution.NamespaceAwareStore3ffe1c39d58eaf53
org.junit.jupiter.engine.execution.TestInstancesProviderbb5b676e93849b60
org.junit.jupiter.engine.extension.DisabledCondition23223b45668b6ef2
org.junit.jupiter.engine.extension.ExtensionRegistry7f89cc3238c43287
org.junit.jupiter.engine.extension.MutableExtensionRegistry094514ca9919cd68
org.junit.jupiter.engine.extension.RepeatedTestExtension1b7914cc8cf83732
org.junit.jupiter.engine.extension.TempDirectory3ed1c1e958835b3c
org.junit.jupiter.engine.extension.TestInfoParameterResolver1b5b370a56807cae
org.junit.jupiter.engine.extension.TestReporterParameterResolver60beaf7c80fe99cc
org.junit.jupiter.engine.extension.TimeoutConfigurationd1c949ce4363e069
org.junit.jupiter.engine.extension.TimeoutDurationParser47f3e400722ef57b
org.junit.jupiter.engine.extension.TimeoutExtensionf396c89f10d2bf92
org.junit.jupiter.engine.support.JupiterThrowableCollectorFactorybe8bb2befc643502
org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollectorea5378eacfd98d84
org.junit.platform.commons.function.Tryed940444537e81c8
org.junit.platform.commons.function.Try.Failure11c2a90efd237384
org.junit.platform.commons.function.Try.Successc4950437cb3f8d07
org.junit.platform.commons.logging.LoggerFactory3ba683e3050bf0cd
org.junit.platform.commons.logging.LoggerFactory.DelegatingLoggerc601ec41368ffb23
org.junit.platform.commons.support.AnnotationSupport9943d504ff0c08cc
org.junit.platform.commons.support.ReflectionSupport534b5bde0100740f
org.junit.platform.commons.util.AnnotationUtilsf61f84cc85e2534a
org.junit.platform.commons.util.BlacklistedExceptionsbde618675b598c40
org.junit.platform.commons.util.ClassLoaderUtilsc4b37ecc9a1c73f1
org.junit.platform.commons.util.ClassUtils8883e6fc8a933271
org.junit.platform.commons.util.ClasspathScannerac8b6266e9b6789d
org.junit.platform.commons.util.CollectionUtilsa5cea6ca5e67470d
org.junit.platform.commons.util.Preconditions96db76b91278a526
org.junit.platform.commons.util.ReflectionUtils9fe1fac13e880dd6
org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode12b3937debd6b2c1
org.junit.platform.commons.util.StringUtilsae2f08e02cb55734
org.junit.platform.engine.CompositeFilterec8dc82249eeb7a9
org.junit.platform.engine.CompositeFilter.170825b5141694d2a
org.junit.platform.engine.EngineDiscoveryListener22998ffae2c92a7c
org.junit.platform.engine.EngineDiscoveryListener.1df3f3b5f98f0bac1
org.junit.platform.engine.ExecutionRequested3835cc21e5a048
org.junit.platform.engine.Filterf932423ccd3b54bf
org.junit.platform.engine.FilterResultcdaa92f4f6f79059
org.junit.platform.engine.SelectorResolutionResult84379bf9c19eb4b1
org.junit.platform.engine.SelectorResolutionResult.Status7127e7bcdd8dd16b
org.junit.platform.engine.TestDescriptor9fce516d5ec67d95
org.junit.platform.engine.TestDescriptor.Type3d400391a113f4d2
org.junit.platform.engine.TestExecutionResultfd67f84654a5aa1c
org.junit.platform.engine.TestExecutionResult.Status26685ff07ec05579
org.junit.platform.engine.UniqueIde031943c734b350e
org.junit.platform.engine.UniqueId.Segmente194895cf704d270
org.junit.platform.engine.UniqueIdFormatd5b6ae13b16471ae
org.junit.platform.engine.discovery.ClassSelector502567f08c42b0d4
org.junit.platform.engine.discovery.DiscoverySelectors82f61a948dbe4f5a
org.junit.platform.engine.discovery.MethodSelectora07d3186374af8d5
org.junit.platform.engine.support.descriptor.AbstractTestDescriptor2bfbf25c43491443
org.junit.platform.engine.support.descriptor.ClassSourceebe18bb735086cbe
org.junit.platform.engine.support.descriptor.EngineDescriptorb7dbf6dfb794516c
org.junit.platform.engine.support.descriptor.MethodSourceadbe9ff8c196551c
org.junit.platform.engine.support.discovery.ClassContainerSelectorResolver13e03d83db463757
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolutionf23cc843ffd69e68
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.DefaultContext1062edde7e863f79
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver96067c54823596a5
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.Builder4536a37bf6e65b70
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.DefaultInitializationContextf1925780e6c4e71e
org.junit.platform.engine.support.discovery.SelectorResolver80cba972b4f10568
org.junit.platform.engine.support.discovery.SelectorResolver.Matcha6c967fba828723c
org.junit.platform.engine.support.discovery.SelectorResolver.Match.Typeb37cc687ae9a3084
org.junit.platform.engine.support.discovery.SelectorResolver.Resolution6a587b13ca925431
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine97ffbc145c7d4a83
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor68a36544a3925ed3
org.junit.platform.engine.support.hierarchical.LockManager3b5f78863ff21738
org.junit.platform.engine.support.hierarchical.Nodeb49761977ceb7101
org.junit.platform.engine.support.hierarchical.Node.SkipResultbd08edf24f1dd4d9
org.junit.platform.engine.support.hierarchical.NodeExecutionAdvisore5cf54a3abfe8a32
org.junit.platform.engine.support.hierarchical.NodeTestTask2d78f1925dd4882a
org.junit.platform.engine.support.hierarchical.NodeTestTask.DefaultDynamicTestExecutorfdbc89e07549b13b
org.junit.platform.engine.support.hierarchical.NodeTestTaskContext844fff78e0efe7ef
org.junit.platform.engine.support.hierarchical.NodeTreeWalkerb0b50dbbc8c467a5
org.junit.platform.engine.support.hierarchical.NodeUtilsd602362461bcf308
org.junit.platform.engine.support.hierarchical.NodeUtils.1f707e15bc93748e1
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService054c281153908bb9
org.junit.platform.engine.support.hierarchical.ThrowableCollector655e27ddc85aeb2a
org.junit.platform.launcher.EngineDiscoveryResult8a104796dc402ce9
org.junit.platform.launcher.EngineDiscoveryResult.Statusb30c4012c3e2f07e
org.junit.platform.launcher.LauncherDiscoveryListener456d3e735c22aa48
org.junit.platform.launcher.LauncherDiscoveryListener.1a120e75b9fe22bf4
org.junit.platform.launcher.TestIdentifier225bb434f8f223e2
org.junit.platform.launcher.TestPlan60578bb4f50b5157
org.junit.platform.launcher.core.DefaultDiscoveryRequestc69d8a6244047852
org.junit.platform.launcher.core.DefaultLauncherb535c0b0b3751eb8
org.junit.platform.launcher.core.DefaultLauncherConfiga355b55f1fea9e21
org.junit.platform.launcher.core.DelegatingEngineExecutionListener1e5487ee783deeca
org.junit.platform.launcher.core.EngineDiscoveryResultValidator93df7a3977833cf5
org.junit.platform.launcher.core.ExecutionListenerAdapterc5de7169f1a88932
org.junit.platform.launcher.core.InternalTestPlan4bd2d207c99632bd
org.junit.platform.launcher.core.LauncherConfigb3c713ac595fde03
org.junit.platform.launcher.core.LauncherConfig.Buildera17564c5b87448a3
org.junit.platform.launcher.core.LauncherConfigurationParameters461c933a6a874583
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder718cd866fd0e3b49
org.junit.platform.launcher.core.LauncherFactoryd419bbcae8fd872b
org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener72e79df7e2d97cc9
org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener.Outcome4d8244bde278efbb
org.junit.platform.launcher.core.Root77042aab5235c2d8
org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry7c054c4cf76cb0f6
org.junit.platform.launcher.core.ServiceLoaderTestExecutionListenerRegistry2299bac1075a6bf3
org.junit.platform.launcher.core.StreamInterceptingTestExecutionListener3a1f3bd6b32f854b
org.junit.platform.launcher.core.TestExecutionListenerRegistryf61866dbd0e36091
org.junit.platform.launcher.core.TestExecutionListenerRegistry.CompositeTestExecutionListener583008686628ab79
org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener267176035c858efc
org.junit.platform.launcher.listeners.discovery.LauncherDiscoveryListenersc83fb9349eaee2dc
\ No newline at end of file +Sessions

Sessions

This coverage report is based on execution data from the following sessions:

SessionStart TimeDump Time
kubernetes-898944db26.10.2026, 19:10:1126.10.2026, 19:10:11

Execution data for the following classes is considered in this report:

ClassId
com.workbenchclassic.AppTest7718c7447416258a
org.apache.maven.surefire.api.booter.BaseProviderFactory5bdb25554fb3d5df
org.apache.maven.surefire.api.booter.BiProperty9a2074ae999b3c8a
org.apache.maven.surefire.api.booter.Commandf31ca5085797c808
org.apache.maven.surefire.api.booter.DumpErrorSingletone3f1c75f159a9ac5
org.apache.maven.surefire.api.booter.ForkedProcessEventTypedc56c5dba14b9d58
org.apache.maven.surefire.api.booter.ForkingReporterFactorybcadcd63978e8dcf
org.apache.maven.surefire.api.booter.ForkingRunListener08c963875a23e517
org.apache.maven.surefire.api.booter.MasterProcessCommand90562129b4defd58
org.apache.maven.surefire.api.booter.Shutdownfab38023c4f1ded4
org.apache.maven.surefire.api.cli.CommandLineOption4401c2efb3702254
org.apache.maven.surefire.api.provider.AbstractProvidercf68f167cf236f7b
org.apache.maven.surefire.api.report.ConsoleOutputCaptureb8719a08fbb63e05
org.apache.maven.surefire.api.report.ConsoleOutputCapture.ForwardingPrintStream7c2392ea44674f2d
org.apache.maven.surefire.api.report.ConsoleOutputCapture.NullOutputStreamf7132188596462e2
org.apache.maven.surefire.api.report.ReporterConfiguration39591ad2c5816a79
org.apache.maven.surefire.api.report.RunModef02e60476bce4d8d
org.apache.maven.surefire.api.report.SimpleReportEntrye252cb5986c391cc
org.apache.maven.surefire.api.suite.RunResult8d97f6894fd90ced
org.apache.maven.surefire.api.testset.DirectoryScannerParametersc53ea59aeaf0b80a
org.apache.maven.surefire.api.testset.IncludedExcludedPatterns43b8f8de9b3a1945
org.apache.maven.surefire.api.testset.ResolvedTest7e73a65f1017294e
org.apache.maven.surefire.api.testset.ResolvedTest.ClassMatcher0f9c29dc1562afeb
org.apache.maven.surefire.api.testset.ResolvedTest.MethodMatcherfccae89ce7b4ee31
org.apache.maven.surefire.api.testset.ResolvedTest.Typebf93fc9765a2bd72
org.apache.maven.surefire.api.testset.RunOrderParameterscb70af248c260139
org.apache.maven.surefire.api.testset.TestArtifactInfoc68e923f629df613
org.apache.maven.surefire.api.testset.TestListResolver3dc896f10c8df96c
org.apache.maven.surefire.api.testset.TestRequest976405c051909d71
org.apache.maven.surefire.api.util.CloseableIteratorf2c0acf940ec6fbe
org.apache.maven.surefire.api.util.DefaultRunOrderCalculator1f50ae9e4b9717cd
org.apache.maven.surefire.api.util.DefaultScanResult46fdc84739146387
org.apache.maven.surefire.api.util.ReflectionUtils6079e135f863f220
org.apache.maven.surefire.api.util.RunOrder0ea36dbbf05327aa
org.apache.maven.surefire.api.util.TestsToRuncc3376426ef9c01c
org.apache.maven.surefire.api.util.TestsToRun.ClassesIteratorcd6601db7bc899db
org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleReadableChannel6abb59e4c94390af
org.apache.maven.surefire.api.util.internal.AbstractNoninterruptibleWritableChannel989f9bf3c66ab7be
org.apache.maven.surefire.api.util.internal.Channels95e459b596e3b873
org.apache.maven.surefire.api.util.internal.Channels.39770f03bd51e14f7
org.apache.maven.surefire.api.util.internal.Channels.4a0e3eaa91d355cc2
org.apache.maven.surefire.api.util.internal.DaemonThreadFactorya56bf84543725f3a
org.apache.maven.surefire.api.util.internal.DaemonThreadFactory.NamedThreadFactorycfeefeb0265a8a13
org.apache.maven.surefire.api.util.internal.DumpFileUtils9a7dbfdf3c2027c8
org.apache.maven.surefire.api.util.internal.ImmutableMapee11b540cdd4034e
org.apache.maven.surefire.api.util.internal.ImmutableMap.Node984f6258c6d6ac9c
org.apache.maven.surefire.api.util.internal.ObjectUtils8c788ffcde97fbb4
org.apache.maven.surefire.booter.AbstractPathConfiguration4839ca4be6e46906
org.apache.maven.surefire.booter.BooterDeserializer02dc12ed0aec9547
org.apache.maven.surefire.booter.ClassLoaderConfiguration462fdbd63f8ea8c8
org.apache.maven.surefire.booter.Classpath5c18bd381e88bcc8
org.apache.maven.surefire.booter.ClasspathConfiguration4c9fc97c565be4cc
org.apache.maven.surefire.booter.CommandReaderc29c2eca0cd24bfc
org.apache.maven.surefire.booter.CommandReader.1727226d97ed192cb
org.apache.maven.surefire.booter.CommandReader.CommandRunnable41ac58e8d85ca2bd
org.apache.maven.surefire.booter.ForkedBooter708bf5b29b088537
org.apache.maven.surefire.booter.ForkedBooter.17d062229af4458f7
org.apache.maven.surefire.booter.ForkedBooter.3093e1d6ec83caf1c
org.apache.maven.surefire.booter.ForkedBooter.488f2f3e42230f38d
org.apache.maven.surefire.booter.ForkedBooter.6a150022bee6cbd41
org.apache.maven.surefire.booter.ForkedBooter.77d0ab78a1157bb24
org.apache.maven.surefire.booter.ForkedBooter.801800b3929973273
org.apache.maven.surefire.booter.ForkedBooter.PingSchedulerfb97687ca93ecbd1
org.apache.maven.surefire.booter.PpidCheckercc99aab0e566c991
org.apache.maven.surefire.booter.ProcessCheckerType5e6688e4a6a909e6
org.apache.maven.surefire.booter.PropertiesWrapperf63d2b2f2fd9087a
org.apache.maven.surefire.booter.ProviderConfiguration146800cea9c5f6cc
org.apache.maven.surefire.booter.StartupConfiguration1cb50557cb9ebb0b
org.apache.maven.surefire.booter.SystemPropertyManager3a0459e270104889
org.apache.maven.surefire.booter.TypeEncodedValue25e613e357b4f737
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelDecoder477264b3887a3b8b
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelDecoder.FrameCompletion00319e897e4dfd77
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelEncoderd52ce258d8e88d04
org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelProcessorFactory3e8e80dcadf11ad6
org.apache.maven.surefire.booter.spi.SurefireMasterProcessChannelProcessorFactory6bb9533ad5c08a49
org.apache.maven.surefire.junitplatform.JUnitPlatformProvider847b42ef97f97d2b
org.apache.maven.surefire.junitplatform.RunListenerAdapterd23fd29ada1102cb
org.apache.maven.surefire.junitplatform.RunListenerAdapter.155724259eef83afa
org.apache.maven.surefire.junitplatform.TestPlanScannerFiltera3ae2542fd30e874
org.apache.maven.surefire.shared.codec.binary.Base64cd6927ec7cf0569e
org.apache.maven.surefire.shared.codec.binary.BaseNCodecc8dd8163b58acfc1
org.apache.maven.surefire.shared.codec.binary.BaseNCodec.Context84b370e464e7008c
org.apache.maven.surefire.shared.lang3.JavaVersion590095a767529b48
org.apache.maven.surefire.shared.lang3.StringUtilsae3c2c379ffab6fd
org.apache.maven.surefire.shared.lang3.SystemUtilse4faf882077bc6c0
org.apache.maven.surefire.shared.lang3.math.NumberUtils505629194db735ed
org.apache.maven.surefire.shared.utils.StringUtils5ba1288622b5e22e
org.apache.maven.surefire.shared.utils.cli.ShutdownHookUtilsb7b46c5c1f482bd4
org.apiguardian.api.API.Status0341e8d99fc36573
org.junit.jupiter.api.AssertEquals6b16b14f06d2f13c
org.junit.jupiter.api.Assertions7406fdbebf83bc7a
org.junit.jupiter.api.DisplayNameGeneratorc813afbd86fd7cc8
org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores82e8bc7daaa8e1e0
org.junit.jupiter.api.DisplayNameGenerator.Standardf23772be1d9bb824
org.junit.jupiter.api.TestInstance.Lifecycle548dd47a98f9c8af
org.junit.jupiter.api.extension.ConditionEvaluationResult2f9dc9ea54b57975
org.junit.jupiter.api.extension.ExtensionContext1789eac1274261fc
org.junit.jupiter.api.extension.ExtensionContext.Namespace9ecb19f5d8d233f2
org.junit.jupiter.api.extension.InvocationInterceptor996f7741ba5ec355
org.junit.jupiter.engine.JupiterTestEngine42bfd69ac4ff9a31
org.junit.jupiter.engine.config.CachingJupiterConfiguratione0782b8c7a730030
org.junit.jupiter.engine.config.ClassNamePatternParameterConverterdb88e74320096433
org.junit.jupiter.engine.config.DefaultJupiterConfiguration9edf3c93edb9be05
org.junit.jupiter.engine.config.DisplayNameGeneratorParameterConverter10239f24d8c710ad
org.junit.jupiter.engine.config.EnumConfigurationParameterConverter339f5752af685066
org.junit.jupiter.engine.descriptor.AbstractExtensionContext9bf01323cf853683
org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor93da3ced5777b865
org.junit.jupiter.engine.descriptor.ClassExtensionContextda8d011f2fd97107
org.junit.jupiter.engine.descriptor.ClassTestDescriptorf5d10ac1d89bb01f
org.junit.jupiter.engine.descriptor.DisplayNameUtils5b062d6beb8f55b6
org.junit.jupiter.engine.descriptor.ExtensionUtils857bd7cde465ada0
org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor8502a8ddd495080f
org.junit.jupiter.engine.descriptor.JupiterEngineExtensionContext37e3ac8bbe8deb47
org.junit.jupiter.engine.descriptor.JupiterTestDescriptoracf2905fc10efa75
org.junit.jupiter.engine.descriptor.LifecycleMethodUtils1162b59df6db6b33
org.junit.jupiter.engine.descriptor.MethodBasedTestDescriptor120c02c460cd1892
org.junit.jupiter.engine.descriptor.MethodExtensionContextafe114c2ffc920b7
org.junit.jupiter.engine.descriptor.TestInstanceLifecycleUtils8d8758db35676c1c
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptorb9a613d54c81997c
org.junit.jupiter.engine.discovery.ClassSelectorResolvera62bf2e2a3da3cb2
org.junit.jupiter.engine.discovery.DiscoverySelectorResolver9913614fbfb4142b
org.junit.jupiter.engine.discovery.MethodFinder5ea468d2eb528361
org.junit.jupiter.engine.discovery.MethodOrderingVisitorbd9a3fc474bdccea
org.junit.jupiter.engine.discovery.MethodSelectorResolver9e004b1ce9842826
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType76d091417c997edb
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.1098756f55a3f159b
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.2b4451da4ca26c94f
org.junit.jupiter.engine.discovery.MethodSelectorResolver.MethodType.3a9cba48e54e36d6b
org.junit.jupiter.engine.discovery.predicates.IsInnerClassf7d9846d00228720
org.junit.jupiter.engine.discovery.predicates.IsNestedTestClasse47ff7cd33073803
org.junit.jupiter.engine.discovery.predicates.IsPotentialTestContainerfcb5565ad4483f6c
org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests2a6af63531e197a1
org.junit.jupiter.engine.discovery.predicates.IsTestFactoryMethoda2c68978bd6bfbc6
org.junit.jupiter.engine.discovery.predicates.IsTestMethod8b244977e441886e
org.junit.jupiter.engine.discovery.predicates.IsTestTemplateMethod0baf1066bf0cbad7
org.junit.jupiter.engine.discovery.predicates.IsTestableMethod59a0b58a40803fe2
org.junit.jupiter.engine.execution.ConditionEvaluatorc2ba33ab802578df
org.junit.jupiter.engine.execution.ConstructorInvocation4aef47e7c0afe594
org.junit.jupiter.engine.execution.DefaultTestInstances37fd85d961d60c98
org.junit.jupiter.engine.execution.ExecutableInvoker88626e54fda7c10e
org.junit.jupiter.engine.execution.ExecutableInvoker.ReflectiveInterceptorCall1e58a02ac712330c
org.junit.jupiter.engine.execution.ExtensionValuesStoreb7ff2e73f692c652
org.junit.jupiter.engine.execution.ExtensionValuesStore.CompositeKey24fed135af0eff32
org.junit.jupiter.engine.execution.ExtensionValuesStore.MemoizingSupplier5be22cd9e3599327
org.junit.jupiter.engine.execution.InvocationInterceptorChain008224a337018874
org.junit.jupiter.engine.execution.InvocationInterceptorChain.InterceptedInvocation62ff9a2338ce3045
org.junit.jupiter.engine.execution.InvocationInterceptorChain.ValidatingInvocation2434903e45fcd05c
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext868921f800563654
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.Builderd23096bee4e10887
org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.State0a606b935b0623c0
org.junit.jupiter.engine.execution.MethodInvocation6f894f3cd37e86c5
org.junit.jupiter.engine.execution.NamespaceAwareStore3ffe1c39d58eaf53
org.junit.jupiter.engine.execution.TestInstancesProviderbb5b676e93849b60
org.junit.jupiter.engine.extension.DisabledCondition23223b45668b6ef2
org.junit.jupiter.engine.extension.ExtensionRegistry7f89cc3238c43287
org.junit.jupiter.engine.extension.MutableExtensionRegistry094514ca9919cd68
org.junit.jupiter.engine.extension.RepeatedTestExtension1b7914cc8cf83732
org.junit.jupiter.engine.extension.TempDirectory3ed1c1e958835b3c
org.junit.jupiter.engine.extension.TestInfoParameterResolver1b5b370a56807cae
org.junit.jupiter.engine.extension.TestReporterParameterResolver60beaf7c80fe99cc
org.junit.jupiter.engine.extension.TimeoutConfigurationd1c949ce4363e069
org.junit.jupiter.engine.extension.TimeoutDurationParser47f3e400722ef57b
org.junit.jupiter.engine.extension.TimeoutExtensionf396c89f10d2bf92
org.junit.jupiter.engine.support.JupiterThrowableCollectorFactorybe8bb2befc643502
org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollectorea5378eacfd98d84
org.junit.platform.commons.function.Tryed940444537e81c8
org.junit.platform.commons.function.Try.Failure11c2a90efd237384
org.junit.platform.commons.function.Try.Successc4950437cb3f8d07
org.junit.platform.commons.logging.LoggerFactory3ba683e3050bf0cd
org.junit.platform.commons.logging.LoggerFactory.DelegatingLoggerc601ec41368ffb23
org.junit.platform.commons.support.AnnotationSupport9943d504ff0c08cc
org.junit.platform.commons.support.ReflectionSupport534b5bde0100740f
org.junit.platform.commons.util.AnnotationUtilsf61f84cc85e2534a
org.junit.platform.commons.util.BlacklistedExceptionsbde618675b598c40
org.junit.platform.commons.util.ClassLoaderUtilsc4b37ecc9a1c73f1
org.junit.platform.commons.util.ClassUtils8883e6fc8a933271
org.junit.platform.commons.util.ClasspathScannerac8b6266e9b6789d
org.junit.platform.commons.util.CollectionUtilsa5cea6ca5e67470d
org.junit.platform.commons.util.Preconditions96db76b91278a526
org.junit.platform.commons.util.ReflectionUtils9fe1fac13e880dd6
org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode12b3937debd6b2c1
org.junit.platform.commons.util.StringUtilsae2f08e02cb55734
org.junit.platform.engine.CompositeFilterec8dc82249eeb7a9
org.junit.platform.engine.CompositeFilter.170825b5141694d2a
org.junit.platform.engine.EngineDiscoveryListener22998ffae2c92a7c
org.junit.platform.engine.EngineDiscoveryListener.1df3f3b5f98f0bac1
org.junit.platform.engine.ExecutionRequested3835cc21e5a048
org.junit.platform.engine.Filterf932423ccd3b54bf
org.junit.platform.engine.FilterResultcdaa92f4f6f79059
org.junit.platform.engine.SelectorResolutionResult84379bf9c19eb4b1
org.junit.platform.engine.SelectorResolutionResult.Status7127e7bcdd8dd16b
org.junit.platform.engine.TestDescriptor9fce516d5ec67d95
org.junit.platform.engine.TestDescriptor.Type3d400391a113f4d2
org.junit.platform.engine.TestExecutionResultfd67f84654a5aa1c
org.junit.platform.engine.TestExecutionResult.Status26685ff07ec05579
org.junit.platform.engine.UniqueIde031943c734b350e
org.junit.platform.engine.UniqueId.Segmente194895cf704d270
org.junit.platform.engine.UniqueIdFormatd5b6ae13b16471ae
org.junit.platform.engine.discovery.ClassSelector502567f08c42b0d4
org.junit.platform.engine.discovery.DiscoverySelectors82f61a948dbe4f5a
org.junit.platform.engine.discovery.MethodSelectora07d3186374af8d5
org.junit.platform.engine.support.descriptor.AbstractTestDescriptor2bfbf25c43491443
org.junit.platform.engine.support.descriptor.ClassSourceebe18bb735086cbe
org.junit.platform.engine.support.descriptor.EngineDescriptorb7dbf6dfb794516c
org.junit.platform.engine.support.descriptor.MethodSourceadbe9ff8c196551c
org.junit.platform.engine.support.discovery.ClassContainerSelectorResolver13e03d83db463757
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolutionf23cc843ffd69e68
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.DefaultContext1062edde7e863f79
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver96067c54823596a5
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.Builder4536a37bf6e65b70
org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.DefaultInitializationContextf1925780e6c4e71e
org.junit.platform.engine.support.discovery.SelectorResolver80cba972b4f10568
org.junit.platform.engine.support.discovery.SelectorResolver.Matcha6c967fba828723c
org.junit.platform.engine.support.discovery.SelectorResolver.Match.Typeb37cc687ae9a3084
org.junit.platform.engine.support.discovery.SelectorResolver.Resolution6a587b13ca925431
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine97ffbc145c7d4a83
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor68a36544a3925ed3
org.junit.platform.engine.support.hierarchical.LockManager3b5f78863ff21738
org.junit.platform.engine.support.hierarchical.Nodeb49761977ceb7101
org.junit.platform.engine.support.hierarchical.Node.SkipResultbd08edf24f1dd4d9
org.junit.platform.engine.support.hierarchical.NodeExecutionAdvisore5cf54a3abfe8a32
org.junit.platform.engine.support.hierarchical.NodeTestTask2d78f1925dd4882a
org.junit.platform.engine.support.hierarchical.NodeTestTask.DefaultDynamicTestExecutorfdbc89e07549b13b
org.junit.platform.engine.support.hierarchical.NodeTestTaskContext844fff78e0efe7ef
org.junit.platform.engine.support.hierarchical.NodeTreeWalkerb0b50dbbc8c467a5
org.junit.platform.engine.support.hierarchical.NodeUtilsd602362461bcf308
org.junit.platform.engine.support.hierarchical.NodeUtils.1f707e15bc93748e1
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService054c281153908bb9
org.junit.platform.engine.support.hierarchical.ThrowableCollector655e27ddc85aeb2a
org.junit.platform.launcher.EngineDiscoveryResult8a104796dc402ce9
org.junit.platform.launcher.EngineDiscoveryResult.Statusb30c4012c3e2f07e
org.junit.platform.launcher.LauncherDiscoveryListener456d3e735c22aa48
org.junit.platform.launcher.LauncherDiscoveryListener.1a120e75b9fe22bf4
org.junit.platform.launcher.TestIdentifier225bb434f8f223e2
org.junit.platform.launcher.TestPlan60578bb4f50b5157
org.junit.platform.launcher.core.DefaultDiscoveryRequestc69d8a6244047852
org.junit.platform.launcher.core.DefaultLauncherb535c0b0b3751eb8
org.junit.platform.launcher.core.DefaultLauncherConfiga355b55f1fea9e21
org.junit.platform.launcher.core.DelegatingEngineExecutionListener1e5487ee783deeca
org.junit.platform.launcher.core.EngineDiscoveryResultValidator93df7a3977833cf5
org.junit.platform.launcher.core.ExecutionListenerAdapterc5de7169f1a88932
org.junit.platform.launcher.core.InternalTestPlan4bd2d207c99632bd
org.junit.platform.launcher.core.LauncherConfigb3c713ac595fde03
org.junit.platform.launcher.core.LauncherConfig.Buildera17564c5b87448a3
org.junit.platform.launcher.core.LauncherConfigurationParameters461c933a6a874583
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder718cd866fd0e3b49
org.junit.platform.launcher.core.LauncherFactoryd419bbcae8fd872b
org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener72e79df7e2d97cc9
org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener.Outcome4d8244bde278efbb
org.junit.platform.launcher.core.Root77042aab5235c2d8
org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry7c054c4cf76cb0f6
org.junit.platform.launcher.core.ServiceLoaderTestExecutionListenerRegistry2299bac1075a6bf3
org.junit.platform.launcher.core.StreamInterceptingTestExecutionListener3a1f3bd6b32f854b
org.junit.platform.launcher.core.TestExecutionListenerRegistryf61866dbd0e36091
org.junit.platform.launcher.core.TestExecutionListenerRegistry.CompositeTestExecutionListener583008686628ab79
org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener267176035c858efc
org.junit.platform.launcher.listeners.discovery.LauncherDiscoveryListenersc83fb9349eaee2dc
\ No newline at end of file diff --git a/backend/target/site/jacoco/jacoco.csv b/backend/target/site/jacoco/jacoco.csv index 91ec899..b7c9e46 100644 --- a/backend/target/site/jacoco/jacoco.csv +++ b/backend/target/site/jacoco/jacoco.csv @@ -1,22 +1,24 @@ GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED backend,com.workbenchclassic.hmi,HmiImsapiGateway,528,0,96,0,68,0,53,0,5,0 -backend,com.workbenchclassic.hmi,HmiSchemaBootstrap,707,0,80,0,150,0,57,0,17,0 +backend,com.workbenchclassic.hmi,HmiSchemaBootstrap,726,0,80,0,156,0,58,0,18,0 backend,com.workbenchclassic.hmi,HmiJvmOptions.new Callable() {...},44,0,4,0,8,0,4,0,2,0 backend,com.workbenchclassic.hmi,HmiAuth,482,0,100,0,76,0,67,0,17,0 -backend,com.workbenchclassic.hmi,HmiImsapiSecurityResource,436,0,50,0,70,0,31,0,6,0 +backend,com.workbenchclassic.hmi,HmiImsapiSecurityResource,441,0,48,0,73,0,30,0,6,0 backend,com.workbenchclassic.hmi,HmiLegacyWidgetResource,354,0,46,0,50,0,32,0,7,0 -backend,com.workbenchclassic.hmi,HmiHealthServlet,67,0,0,0,20,0,2,0,2,0 +backend,com.workbenchclassic.hmi,HmiHealthServlet,70,0,0,0,21,0,2,0,2,0 backend,com.workbenchclassic.hmi,HmiThemeServlet,43,0,4,0,11,0,4,0,2,0 backend,com.workbenchclassic.hmi,HmiJvmOptions,372,0,32,0,69,0,24,0,8,0 backend,com.workbenchclassic.hmi,HmiImsapiActionResource,153,0,20,0,22,0,13,0,3,0 backend,com.workbenchclassic.hmi,HmiStyleResource,654,0,56,0,51,0,45,0,17,0 backend,com.workbenchclassic.hmi,HmiTransportPolicy,88,0,16,0,18,0,13,0,5,0 +backend,com.workbenchclassic.hmi,HmiSchemaRecovery,92,0,14,0,22,0,13,0,6,0 backend,com.workbenchclassic.hmi,HmiRolesResource,952,0,86,0,104,0,65,0,22,0 backend,com.workbenchclassic.hmi,HmiStyles,136,0,28,0,21,0,18,0,4,0 +backend,com.workbenchclassic.hmi,HmiSchemaRecoveryResource,134,0,16,0,17,0,11,0,3,0 backend,com.workbenchclassic.hmi,HmiSystemSettingsResource,197,0,24,0,37,0,18,0,6,0 backend,com.workbenchclassic.hmi,HmiOriginFilter,32,0,2,0,12,0,5,0,4,0 backend,com.workbenchclassic.hmi,HmiDb,24,0,2,0,6,0,6,0,5,0 -backend,com.workbenchclassic.hmi,HmiApiResource,4507,0,567,0,543,0,352,0,67,0 +backend,com.workbenchclassic.hmi,HmiApiResource,4522,0,573,0,546,0,355,0,67,0 backend,com.workbenchclassic.hmi,HmiBootstrapResource,157,0,14,0,23,0,11,0,4,0 backend,com.workbenchclassic.hmi,HmiWorkplaceProxyResource,430,0,60,0,83,0,38,0,8,0 backend,com.workbenchclassic.hmi,HmiAssetsResource,358,0,60,0,37,0,35,0,5,0 diff --git a/backend/target/site/jacoco/jacoco.xml b/backend/target/site/jacoco/jacoco.xml index 99e90ba..12996c8 100644 --- a/backend/target/site/jacoco/jacoco.xml +++ b/backend/target/site/jacoco/jacoco.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/backend/target/surefire-reports/TEST-com.workbenchclassic.AppTest.xml b/backend/target/surefire-reports/TEST-com.workbenchclassic.AppTest.xml index 0853925..584a968 100644 --- a/backend/target/surefire-reports/TEST-com.workbenchclassic.AppTest.xml +++ b/backend/target/surefire-reports/TEST-com.workbenchclassic.AppTest.xml @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -54,5 +54,5 @@ - + \ No newline at end of file diff --git a/backend/target/surefire-reports/com.workbenchclassic.AppTest.txt b/backend/target/surefire-reports/com.workbenchclassic.AppTest.txt index 7f797fa..e41ef82 100644 --- a/backend/target/surefire-reports/com.workbenchclassic.AppTest.txt +++ b/backend/target/surefire-reports/com.workbenchclassic.AppTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: com.workbenchclassic.AppTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 s - in com.workbenchclassic.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.048 s - in com.workbenchclassic.AppTest diff --git a/hmi-frontend/src/App.vue b/hmi-frontend/src/App.vue index 4a70dac..0fd9b99 100644 --- a/hmi-frontend/src/App.vue +++ b/hmi-frontend/src/App.vue @@ -181,6 +181,7 @@ async function setup(){ identity.value=await signInContext(); if(identity.value.station){station.value=identity.value.station;localStorage.setItem('hmi.stationNumber',station.value);} authIssue.value=null; + if(identity.value.schemaReady === false){authIssue.value='database';warning.value='Die HMI-Tabellen sind noch nicht initialisiert. Bitte Systemdiagnose öffnen.';return;} if(!identity.value.bootstrapRequired)await reloadPages(); } catch(e){ const status=e instanceof HmiHttpError?e.status:0; @@ -196,6 +197,7 @@ async function startLogin(){ identity.value=await imsapiLogin(loginUser.value,loginPassword.value,station.value); loginPassword.value='';authIssue.value=null;warning.value=''; localStorage.setItem('hmi.stationNumber',station.value); + if(identity.value.schemaReady === false){authIssue.value='database';warning.value='HMI-Datenbank ist nicht bereit. Die Systemdiagnose ist jetzt ohne Administratorrolle verfügbar.';return;} if(!identity.value.bootstrapRequired)await reloadPages(); }catch(e){warning.value=e instanceof Error?e.message:String(e);authIssue.value='login';} finally{loginBusy.value=false;} diff --git a/hmi-frontend/src/api.ts b/hmi-frontend/src/api.ts index 3e307c6..7ac9fb2 100644 --- a/hmi-frontend/src/api.ts +++ b/hmi-frontend/src/api.ts @@ -1,6 +1,6 @@ const root = '/backend/api/hmi/v1'; export class HmiHttpError extends Error { constructor(public readonly status: number, message: string) { super(message); this.name = 'HmiHttpError'; } } -export interface Identity { csrf: string; user: string; station: string; designer: boolean; publisher: boolean; admin: boolean; scriptEditor: boolean; bootstrapRequired?: boolean; } +export interface Identity { csrf: string; user: string; station: string; designer: boolean; publisher: boolean; admin: boolean; scriptEditor: boolean; bootstrapRequired?: boolean; schemaReady?: boolean; schemaFailureCode?: string; } let identity: Identity | null = null; export function currentIdentity(): Identity | null { return identity; } export async function imsapiLogin(username: string, password: string, station: string): Promise {