Skip to content

Commit 07c632a

Browse files
committed
unsafe
1 parent 4a326d1 commit 07c632a

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

core/src/org/labkey/core/admin/admin.jsp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<%@ page import="org.labkey.api.settings.AppProps" %>
3131
<%@ page import="org.labkey.api.util.Formats" %>
3232
<%@ page import="org.labkey.api.util.HtmlString"%>
33+
<%@ page import="org.labkey.api.util.HtmlStringBuilder" %>
3334
<%@ page import="org.labkey.api.view.NavTree" %>
3435
<%@ page import="org.labkey.core.admin.AdminController" %>
3536
<%@ page import="java.text.DecimalFormat" %>
@@ -51,6 +52,7 @@
5152
.lk-admin-section { display: none; }
5253
.header-title { margin-bottom: 5px; }
5354
.header-link { margin: 0 5px 20px 0; }
55+
.lk-server-time-warning { color: red; }
5456
</style>
5557
<div class="row">
5658
<div class="col-sm-12 col-md-3">
@@ -87,13 +89,19 @@
8789
<br/>
8890
<%
8991
row = 0;
92+
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtil.getJsonDateTimeFormatString());
93+
String timeCellCls = "";
94+
HtmlString warning = HtmlString.EMPTY_STRING;
9095
9196
SqlDialect.ServerDatabaseTimeDifference timeDifference = SqlDialect.getServerDatabaseTimeDifference(DbScope.getLabKeyScope());
92-
boolean exceedsThreshold = timeDifference.exceedsWarningThreshold();
93-
94-
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtil.getJsonDateTimeFormatString());
95-
HtmlString style = unsafe(exceedsThreshold ? " style=\"color:red;\"" : "");
96-
HtmlString warning = unsafe(exceedsThreshold ? " - Warning: Web and database server times differ by " + timeDifference.getSeconds() + " seconds!" : "");
97+
if (timeDifference.exceedsWarningThreshold())
98+
{
99+
timeCellCls = "lk-server-time-warning";
100+
warning = HtmlStringBuilder.of(" - Warning: Web and database server times differ by ")
101+
.append(timeDifference.getSeconds())
102+
.append(" seconds!")
103+
.getHtmlString();
104+
}
97105
%>
98106
<h4>Runtime Information</h4>
99107
<table class="labkey-data-region-legacy labkey-show-borders">
@@ -118,9 +126,9 @@
118126
<tr class="<%=getShadeRowClass(row++)%>"><td>Working Dir</td><td><%=h(AdminBean.workingDir)%></td></tr>
119127
<tr class="<%=getShadeRowClass(row++)%>"><td>Server GUID</td><td style="font-family:monospace"><%=h(AdminBean.serverGuid)%></td></tr>
120128
<tr class="<%=getShadeRowClass(row++)%>"><td>Server Session GUID</td><td style="font-family:monospace"><%=h(AdminBean.serverSessionGuid)%></td></tr>
121-
<tr class="<%=getShadeRowClass(row++)%>"><td>Server Startup Time</td><td<%=style%>><%=h(AdminBean.serverStartupTime)%></td></tr>
122-
<tr class="<%=getShadeRowClass(row++)%>"><td>Web Server Time</td><td<%=style%>><%=h(timeDifference.serverTime().format(dateTimeFormatter))%><%=warning%></td></tr>
123-
<tr class="<%=getShadeRowClass(row++)%>"><td>Database Server Time</td><td<%=style%>><%=h(timeDifference.databaseTime().format(dateTimeFormatter))%><%=warning%></td></tr>
129+
<tr class="<%=getShadeRowClass(row++)%>"><td>Server Startup Time</td><td class="<%=h(timeCellCls)%>"><%=h(AdminBean.serverStartupTime)%></td></tr>
130+
<tr class="<%=getShadeRowClass(row++)%>"><td>Web Server Time</td><td class="<%=h(timeCellCls)%>"><%=h(timeDifference.serverTime().format(dateTimeFormatter))%><%=warning%></td></tr>
131+
<tr class="<%=getShadeRowClass(row++)%>"><td>Database Server Time</td><td class="<%=h(timeCellCls)%>"><%=h(timeDifference.databaseTime().format(dateTimeFormatter))%><%=warning%></td></tr>
124132
</table>
125133
</labkey:panel>
126134
<labkey:panel id="links" className="lk-admin-section">

0 commit comments

Comments
 (0)