@sapui5/sap.ushell_abap 1.146.0 → 1.147.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/package.json +4 -4
  2. package/src/main/js/sap/ushell_abap/.library +1 -1
  3. package/src/main/js/sap/ushell_abap/adapters/abap/AdapterContainer.js +4 -5
  4. package/src/main/js/sap/ushell_abap/adapters/abap/AppStateAdapter.js +1 -1
  5. package/src/main/js/sap/ushell_abap/adapters/abap/ClientSideTargetResolutionAdapter.js +10 -8
  6. package/src/main/js/sap/ushell_abap/adapters/abap/CommonDataModelAdapter.js +1 -1
  7. package/src/main/js/sap/ushell_abap/adapters/abap/ConfigurationDefaultsAdapter.js +7 -4
  8. package/src/main/js/sap/ushell_abap/adapters/abap/ContainerAdapter.js +8 -10
  9. package/src/main/js/sap/ushell_abap/adapters/abap/FlpLaunchPageAdapter.js +148 -109
  10. package/src/main/js/sap/ushell_abap/adapters/abap/LaunchPageAdapter.js +1 -1
  11. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionAdapter.js +1 -1
  12. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionInternalAdapter.js +1 -1
  13. package/src/main/js/sap/ushell_abap/adapters/abap/PageBuildingAdapter.js +1 -1
  14. package/src/main/js/sap/ushell_abap/adapters/abap/PagePersistenceAdapter.js +1 -1
  15. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationAdapter.js +1 -1
  16. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationV2Adapter.js +1 -1
  17. package/src/main/js/sap/ushell_abap/adapters/abap/SearchAdapter.js +1 -1
  18. package/src/main/js/sap/ushell_abap/adapters/abap/SupportTicketAdapter.js +1 -1
  19. package/src/main/js/sap/ushell_abap/adapters/abap/Ui5ComponentLoaderAdapter.js +1 -1
  20. package/src/main/js/sap/ushell_abap/adapters/hana/ContainerAdapter.js +1 -1
  21. package/src/main/js/sap/ushell_abap/bootstrap/BootTask/PrepareDirectAppStart.js +20 -0
  22. package/src/main/js/sap/ushell_abap/bootstrap/BootTask/RequestGroups.js +51 -0
  23. package/src/main/js/sap/ushell_abap/bootstrap/BootTask/RequestTargetMappings.js +29 -0
  24. package/src/main/js/sap/ushell_abap/bootstrap/BootTask.js +47 -0
  25. package/src/main/js/sap/ushell_abap/bootstrap/ConfigurationProvider.js +87 -0
  26. package/src/main/js/sap/ushell_abap/bootstrap/DirectAppStart.js +231 -0
  27. package/src/main/js/sap/ushell_abap/bootstrap/LoadLaunchpad/CreateRenderer.js +43 -0
  28. package/src/main/js/sap/ushell_abap/bootstrap/LoadLaunchpad/InitXhrLogon.js +148 -0
  29. package/src/main/js/sap/ushell_abap/bootstrap/LoadLaunchpad/RequestPages.js +86 -0
  30. package/src/main/js/sap/ushell_abap/bootstrap/LoadLaunchpad.js +63 -0
  31. package/src/main/js/sap/ushell_abap/bootstrap/LoadLaunchpadModule.js +11 -0
  32. package/src/main/js/sap/ushell_abap/bootstrap/PageSetsRequestHandler.js +247 -0
  33. package/src/main/js/sap/ushell_abap/bootstrap/PlatformConfig.js +385 -0
  34. package/src/main/js/sap/ushell_abap/bootstrap/{evo/SAPCompanionConditionSetter.js → SAPCompanionConditionSetter.js} +6 -4
  35. package/src/main/js/sap/ushell_abap/bootstrap/StartupRequestHandler.js +145 -0
  36. package/src/main/js/sap/ushell_abap/bootstrap/ThemeHandler.js +276 -0
  37. package/src/main/js/sap/ushell_abap/bootstrap/XhrFactory.js +69 -0
  38. package/src/main/js/sap/ushell_abap/bootstrap/{evo/XhrLogonEventHandler.js → XhrLogonEventHandler.js} +13 -7
  39. package/src/main/js/sap/ushell_abap/bootstrap/XhrLogonLibLoader.js +51 -0
  40. package/src/main/js/sap/ushell_abap/bootstrap/abap-def-dev.js +20 -0
  41. package/src/main/js/sap/ushell_abap/bootstrap/{evo/abap-def-loader.js → abap-def-loader.js} +2 -2
  42. package/src/main/js/sap/ushell_abap/bootstrap/abap-def.js +22 -0
  43. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.js +1 -1
  44. package/src/main/js/sap/ushell_abap/components/TCodeNavigation.js +3 -3
  45. package/src/main/js/sap/ushell_abap/library.js +1 -1
  46. package/src/main/js/sap/ushell_abap/pbServices/ui2/Contracts.js +33 -0
  47. package/ui5.yaml +7 -6
  48. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-dev.js +0 -42
  49. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def.js +0 -45
  50. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.bootstrap.utils.js +0 -172
  51. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.theme.js +0 -28
  52. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.ushell.js +0 -181
  53. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.load.launchpad.js +0 -72
  54. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.pageset.js +0 -219
  55. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.startup.js +0 -154
  56. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.theme.handler.js +0 -79
  57. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhrlogon.LibLoader.js +0 -21
  58. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhrlogon.configure.js +0 -62
  59. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhrlogon.handler.js +0 -82
  60. package/src/main/js/sap/ushell_abap/bootstrap/evo/boottask.js +0 -944
  61. /package/src/main/js/sap/ushell_abap/bootstrap/{evo/abap.constants.js → abapConstants.js} +0 -0
@@ -0,0 +1,148 @@
1
+ // Copyright (c) 2009-2026 SAP SE, All Rights Reserved
2
+ sap.ui.define([
3
+ "sap/ushell_abap/bootstrap/XhrLogonLibLoader", // triggers loading of the XHR logon lib, once required
4
+ "sap/ushell_abap/bootstrap/XhrLogonEventHandler",
5
+ "sap/ushell/bootstrap/Config",
6
+ "sap/base/Log",
7
+ "sap/ushell/Container"
8
+ ], (
9
+ XhrLogonLibLoader,
10
+ XhrLogonEventHandler,
11
+ BootstrapConfig,
12
+ Log,
13
+ Container
14
+ ) => {
15
+ "use strict";
16
+
17
+ class InitXhrLogon {
18
+ async run () {
19
+ await Promise.all([
20
+ this.#initXhrLogon(),
21
+ this.#initFrameLogonManager()
22
+ ]);
23
+ }
24
+
25
+ /**
26
+ * Determines the XHR logon mode based on the bootstrap configuration
27
+ * and the URL parameters sap-ushell-xhrLogon-mode and saml2.
28
+ * @returns {string} the logon mode
29
+ */
30
+ #getLogonMode () {
31
+ const oUshellConfig = BootstrapConfig.get();
32
+ const sSearch = this.getWindowLocationSearch();
33
+ const oUrlParameters = new URLSearchParams(sSearch);
34
+
35
+ return oUrlParameters.get("sap-ushell-xhrLogon-mode")
36
+ || (oUrlParameters.get("saml2")?.toLowerCase() === "disabled" ? "logoffAndRedirect" : undefined)
37
+ || oUshellConfig?.xhrLogon?.mode
38
+ || "frame";
39
+ }
40
+
41
+ /**
42
+ * Initializes and starts XHR logon lib based on a given configuration.
43
+ * <p>
44
+ *
45
+ * @private
46
+ */
47
+ async #initXhrLogon () {
48
+ const oXhrLogonLib = await XhrLogonLibLoader.getLib();
49
+
50
+ const sLogonMode = this.#getLogonMode();
51
+ const oXhrLogonEventHandler = this.createXhrLogonEventHandler(window, sLogonMode);
52
+ const oLogonManager = oXhrLogonLib.LogonManager.getInstance();
53
+ const oXHRLogonManager = oXhrLogonLib.XHRLogonManager.getInstance();
54
+ const oXhrLibConfig = {
55
+ explicitMatchOnCORS: true // avoids to send XHRLib HTTP headers to thirdparty services
56
+ };
57
+
58
+ oXhrLogonLib.start(oXhrLibConfig);
59
+
60
+ if (sLogonMode === "reload" || sLogonMode === "logoffAndRedirect") {
61
+ oLogonManager.unregisterAllHandlers();
62
+ oLogonManager.registerAuthHandler("*", (oEvent) => {
63
+ oXhrLogonEventHandler.handleEvent(oEvent);
64
+ });
65
+ } else if (sLogonMode !== "frame") {
66
+ Log.warning(`Unknown setting for xhrLogonMode: '${sLogonMode}'. Using default mode 'frame'.`, null, "sap.ushell_abap.bootstrap.XhrLogon");
67
+ }
68
+
69
+ oXhrLogonLib.Log.set(this.#createUi5ConnectedXhrLogger());
70
+ this.#initXhrLogonIgnoreList(oXHRLogonManager);
71
+ }
72
+
73
+ async #initFrameLogonManager () {
74
+ const oXhrLogonLib = await XhrLogonLibLoader.getLib();
75
+ const oFrameLogonManager = oXhrLogonLib.FrameLogonManager.getInstance();
76
+ Container.oFrameLogonManager = oFrameLogonManager;
77
+ }
78
+
79
+ /**
80
+ * Creates a logger for XMLHttpRequest(s) that logs errors, warnings, info
81
+ * and debug messages via Log.
82
+ *
83
+ * @returns {object}
84
+ * A logger that can be assigned to XMLHttpRequest.
85
+ *
86
+ * @private
87
+ */
88
+ #createUi5ConnectedXhrLogger () {
89
+ return ["error", "warning", "info", "debug"].reduce((oXhrLogger, sLevel) => {
90
+ oXhrLogger[sLevel] = function (sMsg) {
91
+ return Log[sLevel](sMsg);
92
+ };
93
+ return oXhrLogger;
94
+ }, {});
95
+ }
96
+
97
+ /**
98
+ * Initializes the ignore list of the XHR logon manager.
99
+ * <p>
100
+ * If the UI5 resources (including the own bootstrap script) are loaded from an absolute URL
101
+ * (in case CDN is activated),
102
+ * this URL is added to the ignore list to prevent CORS preflight requests due to the X headers.
103
+ * We expect that all resources can be loaded without authentication in this case.
104
+ *
105
+ * @param {object} oXHRLogonManager
106
+ * the logon frame manager instance to use
107
+ *
108
+ * @private
109
+ */
110
+ #initXhrLogonIgnoreList (oXHRLogonManager) {
111
+ const sOrigin = this.getLocationOrigin();
112
+ const sUi5ResourceRootUrl = sap.ui.require.toUrl("");
113
+
114
+ // add "/" to origin, as otherwise the following use case will match:
115
+ // sUi5ResourceRootUrl: http://sap.com:123
116
+ // sOrigin: http://sap.com
117
+ if (sUi5ResourceRootUrl && sUi5ResourceRootUrl.indexOf(`${sOrigin}/`) === -1) {
118
+ // In case UI5 is loaded from a different domain (CDN / AKAMAI), that URL
119
+ // needs to be ignored for the XHR logon, as we expect that the resources
120
+ // are not protected.
121
+ oXHRLogonManager.ignore.add(sUi5ResourceRootUrl);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * We expose a factory method for the tests and allow to pass a test double for the window object
127
+ *
128
+ * @param {object} oWindow the window object
129
+ * @param {string} sXhrLogonMode logon mode
130
+ * @returns {XhrLogonEventHandler} a new XhrLogonEventHandler
131
+ *
132
+ * @private
133
+ */
134
+ createXhrLogonEventHandler (oWindow, sXhrLogonMode) {
135
+ return new XhrLogonEventHandler(oWindow, sXhrLogonMode);
136
+ }
137
+
138
+ getWindowLocationSearch () {
139
+ return window.location.search;
140
+ }
141
+
142
+ getLocationOrigin () {
143
+ return window.location.origin;
144
+ }
145
+ }
146
+
147
+ return new InitXhrLogon();
148
+ });
@@ -0,0 +1,86 @@
1
+ // Copyright (c) 2009-2026 SAP SE, All Rights Reserved
2
+ sap.ui.define([
3
+ "sap/base/util/ObjectPath",
4
+ "sap/ushell/bootstrap/Config",
5
+ "sap/ushell/Container",
6
+ "sap/ushell/components/pages/controller/PagesAndSpaceId",
7
+ "sap/ushell/resources"
8
+ ], (
9
+ ObjectPath,
10
+ BootstrapConfig,
11
+ Container,
12
+ PagesAndSpaceId,
13
+ ushellResources
14
+ ) => {
15
+ "use strict";
16
+
17
+ class RequestPages {
18
+ #aInternTargets = [
19
+ "Shell-home",
20
+ "Launchpad-openFLPPage"
21
+ ];
22
+
23
+ #isRelevant () {
24
+ const oUshellConfig = BootstrapConfig.get();
25
+ if (!ObjectPath.get("ushell.spaces.enabled", oUshellConfig)) {
26
+ return false;
27
+ }
28
+
29
+ let sHash = this.getLocationHash();
30
+ sHash = sHash.startsWith("#") ? sHash.slice(1) : sHash;
31
+
32
+ return !sHash || this.#aInternTargets.some((sTarget) => sHash.startsWith(sTarget));
33
+ }
34
+
35
+ async run () {
36
+ if (!this.#isRelevant()) {
37
+ return;
38
+ }
39
+
40
+ await Promise.all([
41
+ this.#requestPagesPersonalization(),
42
+ this.#requestPagesContent()
43
+ ]);
44
+ }
45
+
46
+ async #requestPagesPersonalization () {
47
+ const PersonalizationV2 = await Container.getServiceAsync("PersonalizationV2");
48
+ const oPersId = {
49
+ container: "sap.ushell.cdm3-1.personalization",
50
+ item: "data"
51
+ };
52
+
53
+ const oScope = {
54
+ validity: "Infinity",
55
+ keyCategory: PersonalizationV2.KeyCategory.GENERATED_KEY,
56
+ writeFrequency: PersonalizationV2.WriteFrequency.HIGH,
57
+ clientStorageAllowed: false
58
+ };
59
+ const oPersonalizer = await PersonalizationV2.getPersonalizer(oPersId, oScope);
60
+ return oPersonalizer.getPersData();
61
+ }
62
+
63
+ async #requestPagesContent () {
64
+ await ushellResources.awaitResourceBundle();
65
+
66
+ const pId = PagesAndSpaceId.getPageAndSpaceId(this.getLocationHash());
67
+ const pPagePersistenceService = Container.getServiceAsync("PagePersistence");
68
+
69
+ const [
70
+ oIds,
71
+ PagePersistence
72
+ ] = await Promise.all([
73
+ pId,
74
+ pPagePersistenceService
75
+ ]);
76
+
77
+ await PagePersistence.getPage(oIds.pageId);
78
+ }
79
+
80
+ getLocationHash () {
81
+ return window.location.hash;
82
+ }
83
+ }
84
+
85
+ return new RequestPages();
86
+ });
@@ -0,0 +1,63 @@
1
+ // Copyright (c) 2009-2026 SAP SE, All Rights Reserved
2
+
3
+ sap.ui.define([
4
+ "sap/base/Log",
5
+ "sap/ushell_abap/bootstrap/PlatformConfig",
6
+ "sap/ushell_abap/bootstrap/ThemeHandler",
7
+ "sap/ushell_abap/bootstrap/SAPCompanionConditionSetter",
8
+ "sap/ushell_abap/bootstrap/LoadLaunchpad/CreateRenderer",
9
+ "sap/ushell_abap/bootstrap/LoadLaunchpad/InitXhrLogon",
10
+ "sap/ushell_abap/bootstrap/LoadLaunchpad/RequestPages",
11
+ "sap/ushell_abap/bootstrap/DirectAppStart",
12
+ "sap/ushell/Container",
13
+ "sap/ushell/iconfonts",
14
+ "sap/ushell_abap/pbServices/ui2/Contracts"
15
+ ], (
16
+ Log,
17
+ PlatformConfig,
18
+ ThemeHandler,
19
+ SAPCompanionConditionSetter,
20
+ CreateRenderer,
21
+ InitXhrLogon,
22
+ RequestPages,
23
+ DirectAppStart,
24
+ Container,
25
+ IconFonts,
26
+ Contracts
27
+ ) => {
28
+ "use strict";
29
+
30
+ class LoadLaunchpad {
31
+ async run () {
32
+ const aParallelPromises = [];
33
+
34
+ // Call UI5 Core APIs only after the core is initialized
35
+ aParallelPromises.push(ThemeHandler.updateUnsafeBootTheme());
36
+ await PlatformConfig.setUI5Settings();
37
+
38
+ await Container.init("abap", {
39
+ abap: "sap.ushell_abap.adapters.abap",
40
+ hana: "sap.ushell_abap.adapters.hana"
41
+ });
42
+
43
+ aParallelPromises.push(Contracts.load());
44
+
45
+ aParallelPromises.push(CreateRenderer.run());
46
+
47
+ IconFonts.registerFiori2IconFont();
48
+
49
+ aParallelPromises.push(SAPCompanionConditionSetter.run().catch(() => {
50
+ Log.info("SAPCompanion conditions could not be set.");
51
+ }));
52
+
53
+ aParallelPromises.push(DirectAppStart.startApp());
54
+ aParallelPromises.push(RequestPages.run());
55
+
56
+ aParallelPromises.push(InitXhrLogon.run());
57
+
58
+ await Promise.all(aParallelPromises);
59
+ }
60
+ }
61
+
62
+ return new LoadLaunchpad();
63
+ });
@@ -0,0 +1,11 @@
1
+ // Copyright (c) 2009-2026 SAP SE, All Rights Reserved
2
+
3
+ sap.ui.define([
4
+ "sap/ushell_abap/bootstrap/LoadLaunchpad"
5
+ ], (
6
+ LoadLaunchpad
7
+ ) => {
8
+ "use strict";
9
+
10
+ LoadLaunchpad.run();
11
+ });
@@ -0,0 +1,247 @@
1
+ // Copyright (c) 2009-2026 SAP SE, All Rights Reserved
2
+
3
+ sap.ui.define([
4
+ "sap/ushell_abap/bootstrap/XhrFactory",
5
+ "sap/ui/thirdparty/jquery",
6
+ "sap/ushell_abap/pbServices/ui2/Utils",
7
+ "sap/base/Log"
8
+ ], (
9
+ XhrFactory,
10
+ jQuery,
11
+ ui2Utils,
12
+ Log
13
+ ) => {
14
+ "use strict";
15
+
16
+ /* global OData */
17
+
18
+ const S_PAGE_SETS_FALLBACK_URL_BASE = "/sap/opu/odata/UI2/PAGE_BUILDER_PERS";
19
+ const S_PAGE_SETS_FALLBACK_EXPAND = "Pages/PageChipInstances/Chip/ChipBags/ChipProperties,"
20
+ + "Pages/PageChipInstances/RemoteCatalog,"
21
+ + "Pages/PageChipInstances/ChipInstanceBags/ChipInstanceProperties,"
22
+ + "AssignedPages,DefaultPage";
23
+ const S_PAGE_SETS_FALLBACK_URL_RELATIVE = "PageSets('%2FUI2%2FFiori2LaunchpadHome')";
24
+
25
+ class PageSetsRequestHandler {
26
+ // Check (only once for this file) if sap-statistics is set in query parameter or local storage
27
+ #bSapStatistics = this.#isSapStatisticsSet();
28
+
29
+ /**
30
+ * Determines the URL for the PageSets OData service from the startup service result. If the URL is not set
31
+ * a hard-coded fallback URL is returned and set in the startupResult.
32
+ *
33
+ * @param {object} oStartupCallResult
34
+ * the startup service result object
35
+ * @param {string} sServicePropertyName
36
+ * the name of the service property in the startup result
37
+ * @param {string} sFallbackBaseUrl
38
+ * the fallback base URL to be used if the service URL is not set
39
+ * @param {string} sFallbackRelativeUrl
40
+ * the fallback relative URL to be used if the service URL is not set
41
+ * @param {string} sFallbackExpand
42
+ * the fallback expand parameter to be used if the service URL is not set
43
+ * @returns {string}
44
+ * the URL for the service, adjusted with the fallback values if necessary
45
+ */
46
+ #getAndAdjustServiceURL (oStartupCallResult, sServicePropertyName, sFallbackBaseUrl, sFallbackRelativeUrl, sFallbackExpand) {
47
+ let sServiceUrl;
48
+ let oServiceData; // shortcut for oStartupCallResult.services[sServicePropertyName]
49
+ let bFallbackApplied = false;
50
+
51
+ if (oStartupCallResult.services) {
52
+ if (oStartupCallResult.services[sServicePropertyName]) {
53
+ oServiceData = oStartupCallResult.services[sServicePropertyName];
54
+ } else {
55
+ oServiceData = {};
56
+ oStartupCallResult.services[sServicePropertyName] = oServiceData;
57
+ bFallbackApplied = true;
58
+ }
59
+ } else {
60
+ oServiceData = {};
61
+ oStartupCallResult.services = {};
62
+ oStartupCallResult.services[sServicePropertyName] = oServiceData;
63
+ bFallbackApplied = true;
64
+ }
65
+
66
+ if (!oServiceData.baseUrl || !oServiceData.relativeUrl) {
67
+ oServiceData.baseUrl = sFallbackBaseUrl;
68
+ oServiceData.relativeUrl = sFallbackRelativeUrl;
69
+ bFallbackApplied = true;
70
+ }
71
+
72
+ if (bFallbackApplied) {
73
+ Log.warning(
74
+ `URL for ${sServicePropertyName} service not found in startup service result; fallback to default; cache invalidation might fail`,
75
+ null,
76
+ "sap.ushell_abap.bootstrap"
77
+ );
78
+ }
79
+
80
+ // clean trailing and leading slashes
81
+ if (oServiceData.baseUrl.lastIndexOf("/") !== oServiceData.baseUrl.length - 1) {
82
+ // modify the startUpResult, to simplify the adapter code later
83
+ oServiceData.baseUrl += "/";
84
+ }
85
+ if (oServiceData.relativeUrl[0] === "/") {
86
+ // modify the startUpResult, to simplify the adapter code later
87
+ oServiceData.relativeUrl = oServiceData.relativeUrl.slice(1);
88
+ }
89
+
90
+ sServiceUrl = oServiceData.baseUrl + oServiceData.relativeUrl;
91
+
92
+ // add parameters if needed
93
+ // Note: order should always be 1. $expand, 2. sap-cache-id=, 3. additional params;
94
+ // as OData.read.$cache may otherwise not work properly
95
+ if (!/\$expand=/.test(sServiceUrl) && sFallbackExpand) {
96
+ // no expand, add fallback expand (if not "")
97
+ sServiceUrl += `${sServiceUrl.indexOf("?") < 0 ? "?" : "&"}$expand=${sFallbackExpand}`;
98
+ }
99
+ if (oServiceData.cacheId) {
100
+ sServiceUrl += `${sServiceUrl.indexOf("?") < 0 ? "?" : "&"}sap-cache-id=${oServiceData.cacheId}`;
101
+ }
102
+ if (oServiceData["sap-ui2-cache-disable"]) {
103
+ sServiceUrl += `${sServiceUrl.indexOf("?") < 0 ? "?" : "&"}sap-ui2-cache-disable=${oServiceData["sap-ui2-cache-disable"]}`;
104
+ }
105
+
106
+ return sServiceUrl;
107
+ }
108
+
109
+ /**
110
+ * Processes the OData response.
111
+ * @param {jQuery.Deferred} oDeferred
112
+ * the deferred object updating the cache in OData.read
113
+ * @param {int} iStatus
114
+ * the status code
115
+ * @param {string} sCsrfToken
116
+ * the CSRF token
117
+ * @param {string} sResponse
118
+ * the response message
119
+ */
120
+ #processOData (oDeferred, iStatus, sCsrfToken, sResponse) {
121
+ if (iStatus === 200) {
122
+ oDeferred.resolve(JSON.parse(sResponse).d, sCsrfToken);
123
+ } else {
124
+ // rejecting the deferred will make the request later (in the ushell adapter) fail, so
125
+ // the error handling there takes effect
126
+ oDeferred.reject(new Error(`PageSet request failed: ${sResponse}`));
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Determines the URL for the PageSets OData service from the startup service result. If the URL is not set
132
+ * a hard-coded fallback URL is returned and set in the startupResult.
133
+ *
134
+ * @param {object} oStartupCallResult
135
+ * the startup service result object
136
+ * @returns {string}
137
+ * the URL for the PageSets OData service
138
+ */
139
+ #getAndAdjustPageSetServiceURL (oStartupCallResult) {
140
+ const sSearch = this.getWindowLocationSearch();
141
+ const oUrlParameters = new URLSearchParams(sSearch);
142
+
143
+ const sUI2CacheDisable = oUrlParameters.get("sap-ui2-cache-disable");
144
+ if (sUI2CacheDisable && oStartupCallResult && oStartupCallResult.services && oStartupCallResult.services.pbFioriHome) {
145
+ oStartupCallResult.services.pbFioriHome["sap-ui2-cache-disable"] = sUI2CacheDisable;
146
+ }
147
+ return this.#getAndAdjustServiceURL(
148
+ oStartupCallResult,
149
+ "pbFioriHome",
150
+ S_PAGE_SETS_FALLBACK_URL_BASE,
151
+ S_PAGE_SETS_FALLBACK_URL_RELATIVE,
152
+ S_PAGE_SETS_FALLBACK_EXPAND
153
+ );
154
+ }
155
+
156
+ /**
157
+ * Creates the Deferred in the OData.read cache to keep the result of the request with the
158
+ * given URL.
159
+ * @param {string} sUrl
160
+ * the URL to be requested
161
+ * @returns {jQuery.Deferred}
162
+ * the deferred object which will be resolved with the response of the request
163
+ *
164
+ * @private
165
+ */
166
+ #createODataDeferred (sUrl) {
167
+ const oDeferred = new jQuery.Deferred();
168
+ // creating the deferred objects here should ensure that the ushell adapters later read
169
+ // the responses from the "cache", even if UI5 bootstrap is faster than the
170
+ // OData requests
171
+ sap.ui.require(["sap/ui/thirdparty/datajs"], (datajs) => {
172
+ OData.read.$cache = OData.read.$cache || new ui2Utils.Map();
173
+ OData.read.$cache.put(sUrl, oDeferred.promise());
174
+ });
175
+ return oDeferred;
176
+ }
177
+
178
+ /**
179
+ * Performs an OData GET request using a plain XHR.
180
+ * @param {string} sUrl
181
+ * the url to be requested
182
+ * @param {object} oStartupResult
183
+ * the startup result object, containing the base URL and the CSRF token
184
+ * @param {function(number, object, function)} fnCallback
185
+ * callback function to be called when the request finished, taking the status code, the
186
+ * CSRF token and the response message
187
+ */
188
+ #requestOData (sUrl, oStartupResult, fnCallback) {
189
+ const oXhr = XhrFactory.createAndOpen(sUrl, oStartupResult);
190
+ // set sap-statistics header, see
191
+ // http://help.sap.com/saphelp_nw74/helpdata/de/40/93b81292194d6a926e105c10d5048d/content.htm
192
+ if (this.#bSapStatistics) {
193
+ oXhr.setRequestHeader("sap-statistics", "true");
194
+ }
195
+ oXhr.onreadystatechange = function () {
196
+ if (this.readyState !== /* DONE */4) {
197
+ return; // not yet DONE
198
+ }
199
+ fnCallback(oXhr.status, undefined /* csrf token */, oXhr.responseText);
200
+ };
201
+ oXhr.send();
202
+ }
203
+
204
+ requestPageSets (oStartupResult) {
205
+ const sPageSetServiceUrl = this.#getAndAdjustPageSetServiceURL(oStartupResult);
206
+ const oDeferred = this.#createODataDeferred(sPageSetServiceUrl);// TODO make as Promise.all
207
+
208
+ this.#requestOData(sPageSetServiceUrl, oStartupResult, (iStatus, sCsrfToken, sResponse) => {
209
+ this.#processOData(oDeferred, iStatus, sCsrfToken, sResponse);
210
+ });
211
+ }
212
+
213
+ /**
214
+ * Checks if the sap-statistics setting as query parameter or via local storage, as
215
+ * UI5 does it in some cases.
216
+ * @returns {boolean} true if the sap-statistics is set as query parameter or via local storage
217
+ * @private
218
+ */
219
+ #isSapStatisticsSet () {
220
+ const sWindowLocationSearch = this.getWindowLocationSearch();
221
+ let bSapStatistics = /sap-statistics=(true|x|X)/.test(sWindowLocationSearch);
222
+ if (!bSapStatistics) {
223
+ try {
224
+ // UI5's config cannot be used here, so check local storage
225
+ bSapStatistics = window.localStorage.getItem("sap-ui-statistics") === "X";
226
+ } catch (oError) {
227
+ Log.warning(
228
+ "failed to read sap-statistics setting from local storage",
229
+ oError,
230
+ "sap.ushell_abap.bootstrap.PageSetsRequestHandler"
231
+ );
232
+ }
233
+ }
234
+ return !!bSapStatistics; // needed for tests only
235
+ }
236
+
237
+ getWindowLocationSearch () {
238
+ return window.location.search;
239
+ }
240
+
241
+ reset () {
242
+ this.#bSapStatistics = this.#isSapStatisticsSet();
243
+ }
244
+ }
245
+
246
+ return new PageSetsRequestHandler();
247
+ });