|
70 | 70 | /// @see ViewServlet |
71 | 71 | public class ActionURL extends URLHelper implements Cloneable |
72 | 72 | { |
73 | | - private static boolean useContainerRelativeURL() |
74 | | - { |
75 | | - return AppProps.getInstance().getUseContainerRelativeURL(); |
76 | | - } |
77 | | - |
78 | 73 | public enum Param implements SafeToRenderEnum |
79 | 74 | { |
80 | 75 | returnUrl, |
@@ -224,41 +219,20 @@ public ActionURL(Class<? extends Controller> actionClass, Container container) |
224 | 219 | } |
225 | 220 |
|
226 | 221 | /** @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() |
228 | 223 | { |
229 | | - StringBuilder result = new StringBuilder(toPathStringNew(Path.emptyPath, _controller, _action, Path.emptyPath)); |
| 224 | + StringBuilder result = new StringBuilder(toPathString(Path.emptyPath, _controller, _action, Path.emptyPath)); |
230 | 225 | appendParamsAndFragment(result, false); |
231 | 226 | return result.toString(); |
232 | 227 | } |
233 | 228 |
|
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 | | - |
255 | 229 | /** 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) |
257 | 231 | { |
258 | 232 | Path path = contextPath.append(extraPath); |
259 | | - if (null != action && null != pageFlow) |
| 233 | + if (null != action && null != controller) |
260 | 234 | { |
261 | | - action = pageFlow + "-" + action + (-1 == action.indexOf('.') ? ".view" : ""); |
| 235 | + action = controller + "-" + action + (-1 == action.indexOf('.') ? ".view" : ""); |
262 | 236 | path = path.append(action, false); |
263 | 237 | } |
264 | 238 | return path.encode(); |
@@ -573,14 +547,14 @@ public ActionURL setPath(Path path) |
573 | 547 | { |
574 | 548 | controller = action.substring(0, dash); |
575 | 549 | action = action.substring(dash+1); |
576 | | - setIsCanonical(useContainerRelativeURL()); |
| 550 | + setIsCanonical(true); |
577 | 551 | } |
578 | 552 | else |
579 | 553 | { |
580 | 554 | // 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)) |
582 | 556 | throw new IllegalArgumentException("Controller-first URLs are not allowed! (" + savedPath +")"); |
583 | | - setIsCanonical(!useContainerRelativeURL()); |
| 557 | + setIsCanonical(false); |
584 | 558 | } |
585 | 559 |
|
586 | 560 | // parse controller |
@@ -706,10 +680,7 @@ public void test() |
706 | 680 |
|
707 | 681 | ActionURL parse = new ActionURL("/Controller/path/action.view?foo=bar"); |
708 | 682 | 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); |
713 | 684 | } |
714 | 685 |
|
715 | 686 | @Test |
|
0 commit comments