Skip to content

Commit 78321e3

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_mcp_mvp
2 parents 26f6c18 + de18b4d commit 78321e3

18 files changed

Lines changed: 105 additions & 58 deletions

File tree

api/src/org/labkey/api/settings/OptionalFeatureFlag.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,45 @@ public class OptionalFeatureFlag implements Comparable<OptionalFeatureFlag>, Sta
1212
private static final Logger LOG = LogHelper.getLogger(OptionalFeatureFlag.class, "Warnings about optional feature flag names");
1313

1414
private final String _flag;
15+
private final String _propertyName;
1516
private final String _title;
1617
private final String _description;
1718
private final boolean _requiresRestart;
1819
private final boolean _hidden;
1920
private final FeatureType _type;
2021

2122
/**
22-
* @param flag must be unique. Can be used as a startup property to enable/disable the task, but only if it follows
23-
* the Java identifier rules (e.g., alphanumeric plus _, start with a letter, no spaces).
23+
* @param flag must be unique and conform to the Java identifier rules (e.g., alphanumeric plus _, start with a
24+
* letter, no spaces). That way it can be used as a startup property to enable/disable the task.
2425
*/
2526
public OptionalFeatureFlag(String flag, String title, String description, boolean requiresRestart, boolean hidden, FeatureType type)
27+
{
28+
this(flag, title, description, requiresRestart, hidden, type, false);
29+
}
30+
31+
OptionalFeatureFlag(String flag, String title, String description, boolean requiresRestart, boolean hidden, FeatureType type, boolean useDumbName /* true means allow a name that can't be used as a startup property name */)
2632
{
2733
_flag = flag;
2834
_title = title;
2935
_description = description;
3036
_requiresRestart = requiresRestart;
3137
_hidden = hidden;
3238
_type = type;
39+
if (!StringUtilsLabKey.isValidJavaIdentifier(_flag))
40+
{
41+
if (useDumbName)
42+
{
43+
_propertyName = null;
44+
}
45+
else
46+
{
47+
throw new IllegalStateException(_flag + " is not a valid Java identifier. Correct it so it can be used as a startup property. Or set useDumbName to true.");
48+
}
49+
}
50+
else
51+
{
52+
_propertyName = _flag;
53+
}
3354
}
3455

3556
public String getFlag()
@@ -83,14 +104,6 @@ public FeatureType getType()
83104
@Override
84105
public String getPropertyName()
85106
{
86-
String name = getFlag();
87-
if (!StringUtilsLabKey.isValidJavaIdentifier(name))
88-
{
89-
// This is a developer thing... no need to log a warning on production deployments
90-
if (AppProps.getInstance().isDevMode())
91-
LOG.warn("Feature flag name doesn't conform to the property name rules so it won't be available as a startup property: {}", name);
92-
name = null;
93-
}
94-
return name;
107+
return _propertyName;
95108
}
96109
}

api/src/org/labkey/api/settings/OptionalFeatureService.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,21 @@ static void setInstance(OptionalFeatureService impl)
4343
}
4444

4545
/**
46-
* @param flag must be unique. Can be used as a startup property to enable/disable the task, but only if it follows
47-
* the Java identifier rules (e.g., alphanumeric plus _, start with a letter, no spaces).
46+
* @param flag must be unique and conform to the Java identifier rules (e.g., alphanumeric plus _, start with a
47+
* letter, no spaces). That way it can be used as a startup property to enable/disable the task. If
48+
* you must use a flag that doesn't conform to these rules (why?) the call the other variant.
4849
*/
4950
default void addExperimentalFeatureFlag(String flag, String title, String description, boolean requiresRestart)
5051
{
51-
addFeatureFlag(new OptionalFeatureFlag(flag, title, description, requiresRestart, false, FeatureType.Experimental));
52+
addExperimentalFeatureFlag(flag, title, description, requiresRestart, false);
53+
}
54+
55+
/**
56+
* This is left for backward compatibility. Use the variant above and provide flag that follows Java identifier rules.
57+
*/
58+
default void addExperimentalFeatureFlag(String flag, String title, String description, boolean requiresRestart, boolean useDumbName)
59+
{
60+
addFeatureFlag(new OptionalFeatureFlag(flag, title, description, requiresRestart, false, FeatureType.Experimental, useDumbName));
5261
}
5362

5463
void addFeatureFlag(OptionalFeatureFlag optionalFeatureFlag);

core/module.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: Core
22
ModuleClass: org.labkey.core.CoreModule
3-
SchemaVersion: 26.003
3+
SchemaVersion: 26.004
44
Label: Administration and Essential Services
55
Description: The Core module provides central services such as login, \
66
security, administration, folder management, user management, \
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
ALTER TABLE core.Documents ADD ParentType VARCHAR(300);
2-
3-
SELECT core.executeJavaUpgradeCode('populateAttachmentParentTypeColumn');

core/resources/schemas/dbscripts/postgresql/core-25.009-25.010.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
DELETE FROM core.Documents WHERE
55
Container = (SELECT EntityId FROM core.Containers WHERE Parent IS NULL) AND
66
Parent = (SELECT EntityId FROM core.Containers WHERE Parent IS NULL) AND
7-
ParentType IS NULL AND
7+
ParentType IS NULL AND -- ParentType is always NULL at this point, since populating the column is deferred. But the DocumentName condition below is sufficiently specific.
88
(DocumentName LIKE 'auth_header_logo_%' OR DocumentName LIKE 'auth_login_page_logo_%');

core/resources/schemas/dbscripts/postgresql/core-26.000-26.001.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Detection of the data class Compound.Structure2D attachment column was corrected in a recent PR: https://github.com/LabKey/platform/pull/7513
2+
-- This re-populates the ParentType column to pick up those changes.
3+
SELECT core.executeJavaUpgradeCode('populateAttachmentParentTypeColumn');
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
ALTER TABLE core.Documents ADD ParentType NVARCHAR(300);
2-
3-
EXEC core.executeJavaUpgradeCode 'populateAttachmentParentTypeColumn';

core/resources/schemas/dbscripts/sqlserver/core-25.009-25.010.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
DELETE FROM core.Documents WHERE
55
Container = (SELECT EntityId FROM core.Containers WHERE Parent IS NULL) AND
66
Parent = (SELECT EntityId FROM core.Containers WHERE Parent IS NULL) AND
7-
ParentType IS NULL AND
7+
ParentType IS NULL AND -- ParentType is always NULL at this point, since populating the column is deferred. But the DocumentName condition below is sufficiently specific.
88
(DocumentName LIKE 'auth_header_logo_%' OR DocumentName LIKE 'auth_login_page_logo_%');

core/resources/schemas/dbscripts/sqlserver/core-26.000-26.001.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)