Skip to content

Commit cef8a01

Browse files
authored
Stop generating controller-first URLs (#7434)
1 parent fc6eeb9 commit cef8a01

10 files changed

Lines changed: 13 additions & 80 deletions

File tree

api/src/org/labkey/api/jsp/taglib/FormTag.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public Object getAction()
6969
@Deprecated // TODO: Eliminate all usages and remove
7070
public void setAction(String s)
7171
{
72-
if (AppProps.getInstance().getUseContainerRelativeURL() &&
73-
StringUtils.containsNone(s, "/-") && (StringUtils.endsWith(s, ".view") || StringUtils.endsWith(s, ".post")))
72+
if (StringUtils.containsNone(s, "/-") && (StringUtils.endsWith(s, ".view") || StringUtils.endsWith(s, ".post")))
7473
{
7574
ViewContext ctx = HttpView.getRootContext();
7675
if (null != ctx)

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public interface AppProps
4949
String EXPERIMENTAL_RESOLVE_PROPERTY_URI_COLUMNS = "resolve-property-uri-columns";
5050
String ADMIN_PROVIDED_ALLOWED_EXTERNAL_RESOURCES = "allowedExternalResources";
5151
String QUANTITY_COLUMN_SUFFIX_TESTING = "quantityColumnSuffixTesting";
52-
String GENERATE_CONTROLLER_FIRST_URLS = "generateControllerFirstUrls";
5352
String REJECT_CONTROLLER_FIRST_URLS = "rejectControllerFirstUrls";
5453
String MULTI_VALUE_TEXT_CHOICE = "multiChoiceDataType";
5554

@@ -208,13 +207,6 @@ static WriteableAppProps getWriteableInstance()
208207
*/
209208
@Nullable String getAdministratorContactEmail(boolean includeAppAdmins);
210209

211-
/**
212-
* Whether to use the newer, and preferred, container-relative style of URLs of the form
213-
* /contextPath/container/controller-action.view, or the older controller-relative style like
214-
* /contextPath/controller/container/action.view
215-
*/
216-
boolean getUseContainerRelativeURL();
217-
218210
boolean isAllowApiKeys();
219211

220212
int getApiKeyExpirationSeconds();

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,6 @@ public double getSchemaVersion()
548548
return version;
549549
}
550550

551-
@Override
552-
public boolean getUseContainerRelativeURL()
553-
{
554-
return !OptionalFeatureService.get().isFeatureEnabled(AppProps.GENERATE_CONTROLLER_FIRST_URLS);
555-
}
556-
557551
@Override
558552
public boolean isAllowApiKeys()
559553
{

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ public void setValue(WriteableAppProps writeable, String value)
3535
}
3636
}
3737
},
38-
useContainerRelativeURL("Use \"path first\" urls (/home/project-begin.view)")
39-
{
40-
@Override
41-
public void setValue(WriteableAppProps writeable, String value)
42-
{
43-
writeable.setUseContainerRelativeURL(Boolean.parseBoolean(value));
44-
}
45-
},
4638
usageReportingLevel("Check for updates and report usage statistics to the LabKey team. Valid values: " + Arrays.toString(UsageReportingLevel.values()))
4739
{
4840
@Override

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@ public static void incrementLookAndFeelRevisionAndSave()
213213
app.save(null);
214214
}
215215

216-
public void setUseContainerRelativeURL(boolean b)
217-
{
218-
OptionalFeatureService.get().setFeatureEnabled(GENERATE_CONTROLLER_FIRST_URLS, !b, null);
219-
}
220-
221216
public void setAllowApiKeys(boolean b)
222217
{
223218
storeBooleanValue(allowApiKeys, b);

api/src/org/labkey/api/util/HttpUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ else if (userAgent.startsWith("LabKey SAS API"))
336336
try
337337
{
338338
ActionURL url = new ActionURL(referer);
339-
return url.toContainerRelativeURL();
339+
return url.toRelativeURL();
340340
}
341341
catch (Exception e)
342342
{

api/src/org/labkey/api/util/PageFlowUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ public static JSONObject jsInitObject(ContainerUser context, @Nullable PageConfi
21742174
// Expose some experimental flags to the client
21752175
// Note: If you update this set of flags please update enum on client in @labkey/api
21762176
JSONObject experimental = new JSONObject();
2177-
experimental.put("containerRelativeURL", appProps.getUseContainerRelativeURL());
2177+
experimental.put("containerRelativeURL", true);
21782178
experimental.put(AppProps.EXPERIMENTAL_NO_GUESTS, AppProps.getInstance().isOptionalFeatureEnabled(AppProps.EXPERIMENTAL_NO_GUESTS));
21792179
json.put("experimental", experimental);
21802180

api/src/org/labkey/api/view/ActionURL.java

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@
7070
/// @see ViewServlet
7171
public class ActionURL extends URLHelper implements Cloneable
7272
{
73-
private static boolean useContainerRelativeURL()
74-
{
75-
return AppProps.getInstance().getUseContainerRelativeURL();
76-
}
77-
7873
public enum Param implements SafeToRenderEnum
7974
{
8075
returnUrl,
@@ -224,41 +219,20 @@ public ActionURL(Class<? extends Controller> actionClass, Container container)
224219
}
225220

226221
/** @return just the controller-action.view?parameters#fragment part of the URL, omitting the server name, context path, and container path */
227-
public String toContainerRelativeURL()
222+
public String toRelativeURL()
228223
{
229-
StringBuilder result = new StringBuilder(toPathStringNew(Path.emptyPath, _controller, _action, Path.emptyPath));
224+
StringBuilder result = new StringBuilder(toPathString(Path.emptyPath, _controller, _action, Path.emptyPath));
230225
appendParamsAndFragment(result, false);
231226
return result.toString();
232227
}
233228

234-
private String toPathString(Path contextPath, String controller, String action, Path extraPath)
235-
{
236-
if (useContainerRelativeURL())
237-
return toPathStringNew(contextPath, controller, action, extraPath);
238-
else
239-
return toPathStringOld(contextPath, controller, action, extraPath);
240-
}
241-
242-
/** Generates in the format of /contextPath/controller/containerPath/action.view */
243-
private static String toPathStringOld(Path contextPath, String controller, String action, Path extraPath)
244-
{
245-
Path path = contextPath.append(controller).append(extraPath);
246-
if (null != action)
247-
{
248-
if (-1 == action.indexOf('.'))
249-
action = action + ".view";
250-
path = path.append(action, false);
251-
}
252-
return path.encode();
253-
}
254-
255229
/** Generates in the format of /contextPath/containerPath/controller-action.view */
256-
private static String toPathStringNew(Path contextPath, String pageFlow, String action, Path extraPath)
230+
private String toPathString(Path contextPath, String controller, String action, Path extraPath)
257231
{
258232
Path path = contextPath.append(extraPath);
259-
if (null != action && null != pageFlow)
233+
if (null != action && null != controller)
260234
{
261-
action = pageFlow + "-" + action + (-1 == action.indexOf('.') ? ".view" : "");
235+
action = controller + "-" + action + (-1 == action.indexOf('.') ? ".view" : "");
262236
path = path.append(action, false);
263237
}
264238
return path.encode();
@@ -573,14 +547,14 @@ public ActionURL setPath(Path path)
573547
{
574548
controller = action.substring(0, dash);
575549
action = action.substring(dash+1);
576-
setIsCanonical(useContainerRelativeURL());
550+
setIsCanonical(true);
577551
}
578552
else
579553
{
580554
// Reject controller-first URLs if that experimental feature is enabled AND the generate controller-first URLs option is NOT enabled. Otherwise, admin would end up in a very bad state.
581-
if (OptionalFeatureService.get().isFeatureEnabled(AppProps.REJECT_CONTROLLER_FIRST_URLS) && !OptionalFeatureService.get().isFeatureEnabled(AppProps.GENERATE_CONTROLLER_FIRST_URLS))
555+
if (OptionalFeatureService.get().isFeatureEnabled(AppProps.REJECT_CONTROLLER_FIRST_URLS))
582556
throw new IllegalArgumentException("Controller-first URLs are not allowed! (" + savedPath +")");
583-
setIsCanonical(!useContainerRelativeURL());
557+
setIsCanonical(false);
584558
}
585559

586560
// parse controller
@@ -706,10 +680,7 @@ public void test()
706680

707681
ActionURL parse = new ActionURL("/Controller/path/action.view?foo=bar");
708682
String toString = parse.getLocalURIString();
709-
if (useContainerRelativeURL())
710-
assertEquals(parse.getContextPath() + "/path/controller-action.view?foo=bar", toString);
711-
else
712-
assertEquals(parse.getContextPath() + "/controller/path/action.view?foo=bar", toString);
683+
assertEquals(parse.getContextPath() + "/path/controller-action.view?foo=bar", toString);
713684
}
714685

715686
@Test

core/resources/scripts/labkey/ActionURL.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,7 @@ that points back to the current page:
266266
action += '.view';
267267
var query = LABKEY.ActionURL.queryString(parameters);
268268

269-
var newUrl;
270-
if (LABKEY.experimental && LABKEY.experimental.containerRelativeURL)
271-
newUrl = LABKEY.contextPath + containerPath + controller + "-" + action;
272-
else
273-
newUrl = LABKEY.contextPath + "/" + controller + containerPath + action;
269+
var newUrl = LABKEY.contextPath + containerPath + controller + "-" + action;
274270
if (query)
275271
newUrl += '?' + query;
276272
return newUrl;

core/src/org/labkey/core/CoreModule.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,6 @@ public QuerySchema createSchema(DefaultSchema schema, Module module)
540540
"Short-circuit robots",
541541
"Save resources by not rendering pages marked as 'noindex' for robots. This is experimental as not all robots are search engines.",
542542
false);
543-
OptionalFeatureService.get().addFeatureFlag(new OptionalFeatureFlag(AppProps.GENERATE_CONTROLLER_FIRST_URLS,
544-
"Restore controller-first URLs",
545-
"Generate URLs in a legacy format that puts the controller name before the folder path. This option will be removed in LabKey Server 26.3.",
546-
false, false, OptionalFeatureService.FeatureType.Deprecated
547-
));
548543
OptionalFeatureService.get().addExperimentalFeatureFlag(AppProps.REJECT_CONTROLLER_FIRST_URLS,
549544
"Reject controller-first URLs",
550545
"Require standard path-first URLs. Note: This option will be ignored if the deprecated feature for generating controller-first URLs is enabled.",
@@ -1202,7 +1197,6 @@ public void moduleStartupComplete(ServletContext servletContext)
12021197
customLog4JConfig = Boolean.parseBoolean(ModuleLoader.getServletContext().getInitParameter("org.labkey.customLog4JConfig"));
12031198
}
12041199
results.put("customLog4JConfig", customLog4JConfig);
1205-
results.put("containerRelativeURL", AppProps.getInstance().getUseContainerRelativeURL());
12061200
results.put("runtimeMode", AppProps.getInstance().isDevMode() ? "development" : "production");
12071201
Set<String> deployedApps = new HashSet<>(CoreWarningProvider.collectAllDeployedApps());
12081202
deployedApps.remove(labkeyContextPath);

0 commit comments

Comments
 (0)