Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/src/org/labkey/api/module/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ public enum ModuleState
private final Set<StartupPropertyHandler<? extends StartupProperty>> _startupPropertyHandlers = new ConcurrentSkipListSet<>(Comparator.comparing((StartupPropertyHandler<?> sph) -> sph.getScope(), String.CASE_INSENSITIVE_ORDER).thenComparing(StartupPropertyHandler::getStartupPropertyClassName));
private final MultiValuedMap<String, StartupPropertyEntry> _startupPropertyMap = new CaseInsensitiveKeyedHashSetValuedMap<>();

// If non-null (set by a startup property), overrides the name specified in the distribution.properties file
private String _distributionNameOverride = null;

private ModuleLoader()
{
MemTracker.getInstance().register(this);
Expand Down Expand Up @@ -2064,6 +2067,19 @@ public boolean isUpgradeInProgress()
}
}

public @Nullable String getDistributionNameOverride()
{
return _distributionNameOverride;
}

void setDistributionNameOverride(String distributionNameOverride)
{
if (isStartupComplete())
throw new IllegalStateException("Distribution name override must be set during startup");

_distributionNameOverride = distributionNameOverride;
}

// Did this server start up with no modules installed? If so, it's a new installation. This lets us tailor the
// module upgrade UI to "install" or "upgrade," as appropriate.
public boolean isNewInstall()
Expand Down
27 changes: 23 additions & 4 deletions api/src/org/labkey/api/module/ModuleLoaderStartupProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public String getDescription()
{
return "Comma-separated list of modules to disable during this server session. Note: Respected only when the \"startup\" modifier is specified.";
}
},
distributionName
{
@Override
public String getDescription()
{
return "Distribution name to show in the admin console, include in the export diagnostics zip file, and" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we normally capitalize this

Suggested change
return "Distribution name to show in the admin console, include in the export diagnostics zip file, and" +
return "Distribution name to show in the Admin Console, include in the export diagnostics zip file, and" +

"report to mothership. This name overrides the value provided in the distribution.properties file " +
"that's bundled with the distribution. Note: Respected only when the \"startup\" modifier is specified.";
}
};

private final LinkedList<String> _list = new LinkedList<>();
Expand All @@ -57,10 +67,19 @@ static void populate()
@Override
public void handle(Map<ModuleLoaderStartupProperties, StartupPropertyEntry> map)
{
map.forEach((sp, cp)-> Arrays.stream(StringUtils.split(cp.getValue(), ","))
.map(StringUtils::trimToNull)
.filter(Objects::nonNull)
.forEach(sp._list::add));
map.forEach((sp, cp)-> {
if (sp == distributionName)
{
ModuleLoader.getInstance().setDistributionNameOverride(StringUtils.trimToNull(cp.getValue()));
}
else
{
Arrays.stream(StringUtils.split(cp.getValue(), ","))
.map(StringUtils::trimToNull)
.filter(Objects::nonNull)
.forEach(sp._list::add);
}
});
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/settings/AppPropsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;

Expand Down Expand Up @@ -702,7 +703,7 @@ public Map<StashedStartupProperties, StartupPropertyEntry> getStashedStartupProp
@Override
public @NotNull String getDistributionName()
{
return DISTRIBUTION_NAME;
return Objects.requireNonNullElse(ModuleLoader.getInstance().getDistributionNameOverride(), DISTRIBUTION_NAME);
}

@Override
Expand Down
14 changes: 7 additions & 7 deletions core/src/org/labkey/core/admin/admin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@
%>
<%@ page import="org.apache.commons.lang3.ObjectUtils" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="org.apache.commons.lang3.Strings" %>
<%@ page import="org.labkey.api.admin.AdminBean" %>
<%@ page import="org.labkey.api.data.DbScope" %>
<%@ page import="org.labkey.api.data.dialect.SqlDialect" %>
<%@ page import="org.labkey.api.files.FileContentService" %>
<%@ page import="org.labkey.api.module.DefaultModule" %>
<%@ page import="org.labkey.api.module.Module" %>
<%@ page import="org.labkey.api.module.ModuleLoader"%>
<%@ page import="org.labkey.api.module.ModuleLoader" %>
<%@ page import="org.labkey.api.moduleeditor.api.ModuleEditorService" %>
<%@ page import="org.labkey.api.settings.AdminConsole" %>
<%@ page import="org.labkey.api.settings.AdminConsole.AdminLink" %>
<%@ page import="org.labkey.api.settings.AdminConsole.SettingsLinkType" %>
<%@ page import="org.labkey.api.settings.AppProps" %>
<%@ page import="org.labkey.api.util.DateUtil" %>
<%@ page import="org.labkey.api.util.Formats" %>
<%@ page import="org.labkey.api.util.HtmlString"%>
<%@ page import="org.labkey.api.util.HtmlString" %>
<%@ page import="org.labkey.api.util.HtmlStringBuilder" %>
<%@ page import="org.labkey.api.view.NavTree" %>
<%@ page import="org.labkey.core.admin.AdminController" %>
Expand All @@ -41,8 +43,6 @@
<%@ page import="java.util.Comparator" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="org.apache.commons.lang3.Strings" %>
<%@ page import="org.labkey.api.util.DateUtil" %>
<%@ page extends="org.labkey.api.jsp.JspBase" %>
<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %>
<%
Expand Down Expand Up @@ -101,9 +101,9 @@
{
timeCellCls = "lk-server-time-warning";
warning = HtmlStringBuilder.of(" - Warning: Web and database server times differ by ")
.append(timeDifference.getSeconds())
.append(" seconds!")
.getHtmlString();
.append(timeDifference.getSeconds())
.append(" seconds!")
.getHtmlString();
}
%>
<h4>Runtime Information</h4>
Expand Down