@sapui5/sap.ushell_abap 1.97.1 → 1.99.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.
- package/package.json +1 -1
- package/src/main/js/sap/ushell_abap/.library +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/AdapterContainer.js +1 -1
- package/src/main/js/sap/ushell_abap/adapters/abap/AppStateAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/ClientSideTargetResolutionAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/ConfigurationDefaultsAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/ContainerAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/LaunchPageAdapter.js +37 -4
- package/src/main/js/sap/ushell_abap/adapters/abap/MenuAdapter.js +1 -1
- package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/PageBuildingAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/PagePersistenceAdapter.js +35 -15
- package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/SearchAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/SupportTicketAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/Ui5ComponentLoaderAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/adapters/abap/UserInfoAdapter.js +1 -1
- package/src/main/js/sap/ushell_abap/adapters/hana/ContainerAdapter.js +2 -2
- package/src/main/js/sap/ushell_abap/bootstrap/evo/XhrLogonEventHandler.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-dev.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-loader.js +7 -0
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.bootstrap.utils.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.ushell.js +2 -2
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.constants.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.get.server.config.Urls.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.load.launchpad.js +2 -17
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.pageset.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.server.config.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.startup.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.theme.handler.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.ui5.boot.handler.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.validate.Url.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhr.handler.js +1 -1
- package/src/main/js/sap/ushell_abap/bootstrap/evo/boottask.js +6 -12
- package/src/main/js/sap/ushell_abap/library.js +3 -3
- package/src/main/js/sap/ushell_abap/pbServices/ui2/AllCatalogs.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Bag.js +1 -6
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Catalog.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Chip.js +127 -15
- package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipDefinition.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipInstance.js +14 -6
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Error.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Factory.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataService.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataWrapper.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Page.js +1 -8
- package/src/main/js/sap/ushell_abap/pbServices/ui2/PageBuildingService.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/PageSet.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/RemoteCatalogService.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/Utils.js +1 -8
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/actions.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/bag.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configuration.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configurationUi.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/fullscreen.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/preview.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/refresh.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/search.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/types.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/url.js +1 -1
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/visible.js +1 -1
- package/src/main/js/sap/ushell_abap/support/plugins/app-infra/AppInfraOnSapNetWeaverSupportPlugin.js +1 -1
- package/src/main/js/sap/ushell_abap/ui5appruntime/AppInfoAdapter.js +1 -1
- package/ui5.yaml +376 -30
- package/src/main/js/sap/ui2/srvc/ODataService.js +0 -267
- package/src/main/js/sap/ui2/srvc/ODataWrapper.js +0 -1283
- package/src/main/js/sap/ui2/srvc/PageBuildingService.js +0 -1508
- package/src/main/js/sap/ui2/srvc/RemoteCatalogService.js +0 -49
- package/src/main/js/sap/ui2/srvc/allcatalogs.js +0 -197
- package/src/main/js/sap/ui2/srvc/bag.js +0 -711
- package/src/main/js/sap/ui2/srvc/catalog.js +0 -946
- package/src/main/js/sap/ui2/srvc/chip.js +0 -1035
- package/src/main/js/sap/ui2/srvc/chipdefinition.js +0 -228
- package/src/main/js/sap/ui2/srvc/chipinstance.js +0 -944
- package/src/main/js/sap/ui2/srvc/contracts/actions.js +0 -239
- package/src/main/js/sap/ui2/srvc/contracts/bag.js +0 -145
- package/src/main/js/sap/ui2/srvc/contracts/configuration.js +0 -161
- package/src/main/js/sap/ui2/srvc/contracts/configurationUi.js +0 -326
- package/src/main/js/sap/ui2/srvc/contracts/fullscreen.js +0 -69
- package/src/main/js/sap/ui2/srvc/contracts/navigation.js +0 -48
- package/src/main/js/sap/ui2/srvc/contracts/preview.js +0 -289
- package/src/main/js/sap/ui2/srvc/contracts/refresh.js +0 -42
- package/src/main/js/sap/ui2/srvc/contracts/search.js +0 -109
- package/src/main/js/sap/ui2/srvc/contracts/searchProvider.js +0 -46
- package/src/main/js/sap/ui2/srvc/contracts/types.js +0 -9
- package/src/main/js/sap/ui2/srvc/contracts/url.js +0 -104
- package/src/main/js/sap/ui2/srvc/contracts/visible.js +0 -122
- package/src/main/js/sap/ui2/srvc/error.js +0 -54
- package/src/main/js/sap/ui2/srvc/factory.js +0 -656
- package/src/main/js/sap/ui2/srvc/page.js +0 -934
- package/src/main/js/sap/ui2/srvc/pageset.js +0 -466
- package/src/main/js/sap/ui2/srvc/utils.js +0 -923
- package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/navigation.js +0 -50
|
@@ -1,923 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2009-2020 SAP SE, All Rights Reserved
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @fileOverview This file contains miscellaneous utility functions.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
this.sap = this.sap || {};
|
|
10
|
-
|
|
11
|
-
(function () {
|
|
12
|
-
"use strict";
|
|
13
|
-
|
|
14
|
-
// ensure that Function.prototype.bind is available, even with iOS 5
|
|
15
|
-
// utils.js is used with startup service, shell API and page building services
|
|
16
|
-
if (!Function.prototype.bind) {
|
|
17
|
-
/**
|
|
18
|
-
* Replacement for ECMAScript 5 feature which might still be missing.
|
|
19
|
-
*
|
|
20
|
-
* @param {object} oThis
|
|
21
|
-
* The value to be passed as the <code>this</code> parameter to the target
|
|
22
|
-
* function when the bound function is called. The value is ignored if the
|
|
23
|
-
* bound function is constructed using the <code>new</code> operator.
|
|
24
|
-
* @param {...object} aVarArgs
|
|
25
|
-
* Arguments to prepend to arguments provided to the bound function when
|
|
26
|
-
* invoking the target function.
|
|
27
|
-
* @returns {function}
|
|
28
|
-
* A function with the bound arguments aVarArgs
|
|
29
|
-
*
|
|
30
|
-
* @see <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind">bind in ECMAScript 5</a>
|
|
31
|
-
*/
|
|
32
|
-
Function.prototype.bind = function (oThis) {
|
|
33
|
-
/* eslint-enable no-extend-native */
|
|
34
|
-
if (typeof this !== "function") {
|
|
35
|
-
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
|
36
|
-
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var aArgs = Array.prototype.slice.call(arguments, 1),
|
|
40
|
-
that = this,
|
|
41
|
-
NOP = function () { /* no-op c'tor */ },
|
|
42
|
-
fBound = function () {
|
|
43
|
-
return that.apply(
|
|
44
|
-
// passing "window" as "this" has been removed (cf. "use strict";)
|
|
45
|
-
this instanceof NOP ? this : oThis,
|
|
46
|
-
aArgs.concat(Array.prototype.slice.call(arguments))
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
NOP.prototype = this.prototype;
|
|
50
|
-
fBound.prototype = new NOP();
|
|
51
|
-
return fBound;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// namespace "sap.ui2.srvc" **************************************************
|
|
56
|
-
sap.ui2 = sap.ui2 || {};
|
|
57
|
-
sap.ui2.srvc = sap.ui2.srvc || {};
|
|
58
|
-
if (sap.ui2.srvc.log) {
|
|
59
|
-
return; // It's OK. Don't load twice.
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// cache for GET requests
|
|
63
|
-
var oCache;
|
|
64
|
-
|
|
65
|
-
if (typeof jQuery === "function" && jQuery.sap) {
|
|
66
|
-
jQuery.sap.declare("sap.ui2.srvc.utils");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// "private static" methods **************************************************
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Tells whether the package <code>jQuery.sap.log</code> currently exists.
|
|
73
|
-
*
|
|
74
|
-
* @returns {boolean}
|
|
75
|
-
* returns <code>true</code> if <code>jQuery.sap.log</code> exists
|
|
76
|
-
*/
|
|
77
|
-
function jQuerySapLogExists () {
|
|
78
|
-
return typeof jQuery === "function" && jQuery.sap && jQuery.sap.log;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Formats the message for a simple output to <code>window.console</code>.
|
|
83
|
-
* Mimics SAPUI5 log behavior for the three last parts:
|
|
84
|
-
* <code>
|
|
85
|
-
* var logText = oLogEntry.date + " " + oLogEntry.time + " " + sWindowName +
|
|
86
|
-
* oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
|
|
87
|
-
* </code>
|
|
88
|
-
* @param {string} sMessage
|
|
89
|
-
* message to be logged
|
|
90
|
-
* @param {string} sDetails
|
|
91
|
-
* message details to be logged
|
|
92
|
-
* @param {string} sComponent
|
|
93
|
-
* component which logged the message
|
|
94
|
-
* @returns {string}
|
|
95
|
-
* message in the format "message - details - component"
|
|
96
|
-
*/
|
|
97
|
-
function formatMessage (sMessage, sDetails, sComponent) {
|
|
98
|
-
return (sMessage || "") + " - " + (sDetails || "") + " " + (sComponent || "");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// "public static" methods ***************************************************
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @namespace The namespace for functions which log messages even if SAPUI5 is not present.
|
|
105
|
-
* @since 1.3.0
|
|
106
|
-
*/
|
|
107
|
-
sap.ui2.srvc.log = {
|
|
108
|
-
/**
|
|
109
|
-
* Wrapper function for <code>jQuery.sap.log.debug()</code>. Writes a simple log message to
|
|
110
|
-
* the console if SAPUI5 is not present.
|
|
111
|
-
*
|
|
112
|
-
* @param {string} sMessage
|
|
113
|
-
* the log message
|
|
114
|
-
* @param {string} sDetails
|
|
115
|
-
* the message details
|
|
116
|
-
* @param {string} sComponent
|
|
117
|
-
* the component which issues the message
|
|
118
|
-
* @since 1.3.0
|
|
119
|
-
*/
|
|
120
|
-
debug: function (sMessage, sDetails, sComponent) {
|
|
121
|
-
if (jQuerySapLogExists()) {
|
|
122
|
-
jQuery.sap.log.debug(sMessage, sDetails, sComponent);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (typeof console === "object") {
|
|
126
|
-
if (typeof console.debug === "function") { // e.g. Chrome
|
|
127
|
-
console.debug(formatMessage(sMessage, sDetails, sComponent));
|
|
128
|
-
} else { // e.g. IE9
|
|
129
|
-
console.log(formatMessage(sMessage, sDetails, sComponent));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Wrapper function for <code>jQuery.sap.log.error()</code>. Writes a simple error message to
|
|
136
|
-
* the console if SAPUI5 is not present.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} sMessage
|
|
139
|
-
* the log message
|
|
140
|
-
* @param {string} sDetails
|
|
141
|
-
* the message details
|
|
142
|
-
* @param {string} sComponent
|
|
143
|
-
* the component which issues the message
|
|
144
|
-
* @since 1.3.0
|
|
145
|
-
*/
|
|
146
|
-
error: function (sMessage, sDetails, sComponent) {
|
|
147
|
-
if (jQuerySapLogExists()) {
|
|
148
|
-
jQuery.sap.log.error(sMessage, sDetails, sComponent);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (typeof console === "object") {
|
|
152
|
-
console.error(formatMessage(sMessage, sDetails, sComponent));
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Wrapper function for <code>jQuery.sap.log.info()</code>. Writes a simple info message to
|
|
158
|
-
* the console if SAPUI5 is not present.
|
|
159
|
-
*
|
|
160
|
-
* @param {string} sMessage
|
|
161
|
-
* the log message
|
|
162
|
-
* @param {string} sDetails
|
|
163
|
-
* the message details
|
|
164
|
-
* @param {string} sComponent
|
|
165
|
-
* the component which issues the message
|
|
166
|
-
* @since 1.3.0
|
|
167
|
-
*/
|
|
168
|
-
info: function (sMessage, sDetails, sComponent) {
|
|
169
|
-
if (jQuerySapLogExists()) {
|
|
170
|
-
jQuery.sap.log.info(sMessage, sDetails, sComponent);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (typeof console === "object") {
|
|
174
|
-
console.info(formatMessage(sMessage, sDetails, sComponent));
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Wrapper function for <code>jQuery.sap.log.warning()</code>. Writes a simple warning message
|
|
180
|
-
* to the console if SAPUI5 is not present.
|
|
181
|
-
*
|
|
182
|
-
* @param {string} sMessage
|
|
183
|
-
* the log message
|
|
184
|
-
* @param {string} sDetails
|
|
185
|
-
* the message details
|
|
186
|
-
* @param {string} sComponent
|
|
187
|
-
* the component which issues the message
|
|
188
|
-
* @since 1.3.0
|
|
189
|
-
*/
|
|
190
|
-
warning: function (sMessage, sDetails, sComponent) {
|
|
191
|
-
if (jQuerySapLogExists()) {
|
|
192
|
-
jQuery.sap.log.warning(sMessage, sDetails, sComponent);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (typeof console === "object") {
|
|
196
|
-
console.warn(formatMessage(sMessage, sDetails, sComponent));
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Makes the given relative URL absolute. URLs containing host and/or protocol
|
|
203
|
-
* and URLs with an absolute path remain unchanged. The URL is in no way
|
|
204
|
-
* normalized; the function simply cuts off the file name from the base and
|
|
205
|
-
* appends the relative URL.
|
|
206
|
-
*
|
|
207
|
-
* @param {string} sUrl
|
|
208
|
-
* the (possibly server-relative) URL
|
|
209
|
-
* @param {string} [sBase=location.href]
|
|
210
|
-
* the base URL; it <b>must</b> at least be server-absolute
|
|
211
|
-
* @returns {string}
|
|
212
|
-
* the absolute URL
|
|
213
|
-
* @since 1.2.0
|
|
214
|
-
*/
|
|
215
|
-
sap.ui2.srvc.absoluteUrl = function (sUrl, sBase) {
|
|
216
|
-
/*jslint regexp: true */
|
|
217
|
-
|
|
218
|
-
// default base is the page location
|
|
219
|
-
sBase = sBase || location.href;
|
|
220
|
-
// base must be absolute
|
|
221
|
-
if (sBase.indexOf("://") < 0 && sBase.charAt(0) !== "/") {
|
|
222
|
-
throw new sap.ui2.srvc.Error("Illegal base URL: " + sBase, "sap.ui2.srvc");
|
|
223
|
-
}
|
|
224
|
-
// do not change empty or absolute URL
|
|
225
|
-
if (!sUrl || sUrl.indexOf("://") >= 0 || sUrl.charAt(0) === "/") {
|
|
226
|
-
return this.addCacheBusterTokenUsingUshellConfig(sUrl);
|
|
227
|
-
}
|
|
228
|
-
if (sBase.search(/^([^:]*:)?\/\/[^/]+$/) < 0) {
|
|
229
|
-
// not a pure server URL -> cut off the file name
|
|
230
|
-
sBase = sBase.replace(/\/[^/]*$/, "");
|
|
231
|
-
}
|
|
232
|
-
// append the relative path
|
|
233
|
-
return this.addCacheBusterTokenUsingUshellConfig(sBase + "/" + sUrl);
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Calls the given success handler (a)synchronously. Errors thrown in the success handler are
|
|
238
|
-
* caught and the error message is reported to the error handler; if an error stack is
|
|
239
|
-
* available, it is logged.
|
|
240
|
-
*
|
|
241
|
-
* @param {function ()} fnSuccess
|
|
242
|
-
* no-args success handler
|
|
243
|
-
* @param {function (string)} [fnFailure]
|
|
244
|
-
* error handler, taking an error message; MUST NOT throw any error itself!
|
|
245
|
-
* @param {boolean} [bAsync=false]
|
|
246
|
-
* whether the call shall be asynchronously
|
|
247
|
-
* @since 1.2.0
|
|
248
|
-
*/
|
|
249
|
-
sap.ui2.srvc.call = function (fnSuccess, fnFailure, bAsync) {
|
|
250
|
-
// see also redundant declaration in sap.ushell.utils.call which has to be in sync
|
|
251
|
-
var sMessage;
|
|
252
|
-
|
|
253
|
-
if (bAsync) {
|
|
254
|
-
setTimeout(function () {
|
|
255
|
-
sap.ui2.srvc.call(fnSuccess, fnFailure, false);
|
|
256
|
-
}, 0);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
try {
|
|
261
|
-
fnSuccess();
|
|
262
|
-
} catch (e) {
|
|
263
|
-
sMessage = e.message || e.toString();
|
|
264
|
-
sap.ui2.srvc.log.error("Call to success handler failed: " + sMessage,
|
|
265
|
-
e.stack, //may be undefined: only supported in Chrome, FF; as of now not in Safari, IE
|
|
266
|
-
"sap.ui2.srvc");
|
|
267
|
-
if (fnFailure) {
|
|
268
|
-
fnFailure(sMessage);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* GETs the given URL (as XML if indicated) and hands it to the given
|
|
275
|
-
* success handler. As this is a root cause for asynchronous behaviour,
|
|
276
|
-
* special precautions are taken: errors thrown in the success handler are
|
|
277
|
-
* caught and reported to the error handler!
|
|
278
|
-
*
|
|
279
|
-
* @param {string} sUrl
|
|
280
|
-
* URL for GET request
|
|
281
|
-
* @param {boolean} bXml
|
|
282
|
-
* whether the handler expects XML instead of plain text
|
|
283
|
-
* @param {function (*)} fnSuccess
|
|
284
|
-
* success handler, taking a DOM document or text string
|
|
285
|
-
* @param {function (string, string)} fnFailure
|
|
286
|
-
* error handler, taking an error message and (if http status is not OK) the GET response as
|
|
287
|
-
* text; MUST NOT throw any error itself!
|
|
288
|
-
* @param {object} [oXHR]
|
|
289
|
-
* the XMLHttpRequest object which may be predefined (e.g. by setting request headers). If
|
|
290
|
-
* <code>undefined</code>, a new XMLHttpRequest object is created.
|
|
291
|
-
* @param {boolean} [bCache]
|
|
292
|
-
* whether the response is cached for further calls (since 1.8.1). XML responses cannot be
|
|
293
|
-
* cached. An <code>sap.ui2.srvc.Error</code> is thrown if both <code>bXml</code> and
|
|
294
|
-
* <code>bCache</code> are set to <code>true</code>.
|
|
295
|
-
* @since 1.2.0
|
|
296
|
-
*/
|
|
297
|
-
sap.ui2.srvc.get = function (sUrl, bXml, fnSuccess, fnFailure, oXHR, bCache) {
|
|
298
|
-
if (typeof fnSuccess !== "function") {
|
|
299
|
-
throw new sap.ui2.srvc.Error("Missing success handler", "sap.ui2.srvc");
|
|
300
|
-
}
|
|
301
|
-
if (typeof fnFailure !== "function") {
|
|
302
|
-
throw new sap.ui2.srvc.Error("Missing error handler", "sap.ui2.srvc");
|
|
303
|
-
}
|
|
304
|
-
if (bXml && bCache) {
|
|
305
|
-
throw new sap.ui2.srvc.Error("Caching of XML responses not supported", "sap.ui2.srvc");
|
|
306
|
-
}
|
|
307
|
-
if (typeof sap.ui2.srvc.addCacheBusterTokenUsingUshellConfig === "function") {
|
|
308
|
-
sUrl = sap.ui2.srvc.addCacheBusterTokenUsingUshellConfig(sUrl);
|
|
309
|
-
}
|
|
310
|
-
oXHR = oXHR || new XMLHttpRequest();
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* @private
|
|
314
|
-
*/
|
|
315
|
-
oXHR.onreadystatechange = function () {
|
|
316
|
-
var oResult, oXml;
|
|
317
|
-
// Note: "this" refers to oXHR according to W3C
|
|
318
|
-
if (this.readyState !== /*DONE*/4) {
|
|
319
|
-
return; // not yet DONE
|
|
320
|
-
}
|
|
321
|
-
sap.ui2.srvc.get.pending -= 1;
|
|
322
|
-
if (this.status !== /*OK*/200) {
|
|
323
|
-
// HTTP status not OK
|
|
324
|
-
sap.ui2.srvc.log.error("Error " + this.status + " in response for URL " + sUrl,
|
|
325
|
-
null, "sap.ui2.srvc");
|
|
326
|
-
fnFailure(sUrl + ": " + this.status + " " + this.statusText, this.responseText);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
sap.ui2.srvc.log.debug("Received response for URL " + sUrl, null, "sap.ui2.srvc");
|
|
331
|
-
if (bXml) {
|
|
332
|
-
oXml = this.responseXML;
|
|
333
|
-
if (oXml === null || !oXml.documentElement) {
|
|
334
|
-
// in FF it is null, in IE it is a document with only an error message
|
|
335
|
-
fnFailure(sUrl + ": no valid XML");
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
oResult = oXml;
|
|
339
|
-
} else {
|
|
340
|
-
oResult = this.responseText;
|
|
341
|
-
if (bCache) {
|
|
342
|
-
oCache.put(sUrl, oResult);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
sap.ui2.srvc.call(fnSuccess.bind(null, oResult), fnFailure);
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
if (!bXml && oCache.containsKey(sUrl)) {
|
|
349
|
-
sap.ui2.srvc.log.debug("Return cached response for URL " + sUrl, null, "sap.ui2.srvc");
|
|
350
|
-
sap.ui2.srvc.call(fnSuccess.bind(null, oCache.get(sUrl)), fnFailure);
|
|
351
|
-
} else {
|
|
352
|
-
try {
|
|
353
|
-
// Given that the XHR request could be provided as a parameter, we must
|
|
354
|
-
// check that this was not already opened before calling open. One
|
|
355
|
-
// reason this could happen is header settings. Only after opening the
|
|
356
|
-
// request headers can be set. Calling open again will cause the
|
|
357
|
-
// previous request to be aborted (i.e., headers loss).
|
|
358
|
-
if (oXHR.readyState < XMLHttpRequest.OPENED) { // keep working on the opened request
|
|
359
|
-
oXHR.open("GET", sUrl, /*asynchronously*/true);
|
|
360
|
-
} else {
|
|
361
|
-
sap.ui2.srvc.log.debug("XHR Request was already opened for " + sUrl, null, "sap.ui2.srvc");
|
|
362
|
-
}
|
|
363
|
-
oXHR.send();
|
|
364
|
-
sap.ui2.srvc.get.pending += 1;
|
|
365
|
-
sap.ui2.srvc.log.debug("Sent request to URL " + sUrl, null, "sap.ui2.srvc");
|
|
366
|
-
} catch (e) {
|
|
367
|
-
sap.ui2.srvc.log.error("Error '" + (e.message || e) + "' in request to URL " + sUrl,
|
|
368
|
-
null, "sap.ui2.srvc");
|
|
369
|
-
throw e;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Gets an URL and adds the given cache buster token to it if no other token is already
|
|
376
|
-
* contained. In case the URL is no valid URL the token is not added.
|
|
377
|
-
*
|
|
378
|
-
* @param {string} sUrl
|
|
379
|
-
* e.g. "/sap/bc/ui5_ui5/application/path"
|
|
380
|
-
* URL to be changed
|
|
381
|
-
* @param {regEx} oPattern
|
|
382
|
-
* e.g /^\/sap\/bc\/ui5_ui5\//
|
|
383
|
-
* RegExp to determine if sUrl matches and needs to be extended by the cache buster token
|
|
384
|
-
* sToken
|
|
385
|
-
* @param {string} sReplacement
|
|
386
|
-
* e.g. "/sap/bc/ui5_ui5/[CacheBusterToken]/"
|
|
387
|
-
* The part of sUrl matched by oPattern will be exchanged by this. Before that is done sToken
|
|
388
|
-
* is inserted in sReplacement at the position indicated by [CacheBusterToken]
|
|
389
|
-
* The replacement may refer to capture groups of oPattern
|
|
390
|
-
* @param {string} sToken
|
|
391
|
-
* e.g. "~201412132350000~"
|
|
392
|
-
* token to be inserted in sUrl. It will be inserted as indicated in the final constructed URL!
|
|
393
|
-
* @returns {string}
|
|
394
|
-
* - if sUrl did not matched oPattern: unchanged sUrl
|
|
395
|
-
* - if sUrl matched oPattern: sUrl enhanced with sToken,
|
|
396
|
-
* e.g. "/sap/bc/ui5_ui5/~201412132350000~/application/path"
|
|
397
|
-
*
|
|
398
|
-
* @private
|
|
399
|
-
*/
|
|
400
|
-
sap.ui2.srvc.addCacheBusterToken = function (sUrl, oPattern, sReplacement, sToken) {
|
|
401
|
-
if (oPattern.test(sUrl)) { //url matches the pattern
|
|
402
|
-
sUrl = sUrl.replace(oPattern, sReplacement);
|
|
403
|
-
//replace the token placeholder globally in the final url (!)
|
|
404
|
-
// (also allow the token to be added elsewhere)
|
|
405
|
-
sUrl = sUrl.replace(/\[CacheBusterToken\]/g, sToken);
|
|
406
|
-
}
|
|
407
|
-
return sUrl;
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Removes a cache buster token (if available) of an Url and normalizes the url afterwards
|
|
412
|
-
* @param {string} sUrl
|
|
413
|
-
* the URL to be normalized
|
|
414
|
-
* @returns {string}
|
|
415
|
-
* normalized url (without a cache buster token)
|
|
416
|
-
* @since 1.28.1
|
|
417
|
-
*
|
|
418
|
-
* @private
|
|
419
|
-
*/
|
|
420
|
-
sap.ui2.srvc.removeCBAndNormalizeUrl = function (sUrl) {
|
|
421
|
-
var aMatches,
|
|
422
|
-
sUrlPrefix,
|
|
423
|
-
sCacheBusterSegment,
|
|
424
|
-
sUrlPostfix;
|
|
425
|
-
|
|
426
|
-
jQuery.sap.require("sap.ui.thirdparty.URI");
|
|
427
|
-
var URI = sap.ui.require("sap/ui/thirdparty/URI");
|
|
428
|
-
|
|
429
|
-
if (typeof sUrl !== "string" || sUrl === "" || isUriWithRelativeOrEmptyPath(sUrl)) {
|
|
430
|
-
return sUrl;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function isUriWithRelativeOrEmptyPath (sUrl0) {
|
|
434
|
-
var oUri = new URI(sUrl0),
|
|
435
|
-
sPath = oUri.path();
|
|
436
|
-
|
|
437
|
-
if (oUri.is("absolute")) {
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (sPath && sPath.charAt(0) === "/") {
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return true;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// split up the URL into 3 parts: prefix, cache-buster segment, postfix
|
|
449
|
-
// leading slashes are always part of the segment, the postfix might have a trailing slash
|
|
450
|
-
aMatches = sUrl.match(/(.*)(\/~[\w-]+~[A-Z0-9]?)(.*)/);
|
|
451
|
-
if (aMatches) {
|
|
452
|
-
sUrlPrefix = aMatches[1];
|
|
453
|
-
sCacheBusterSegment = aMatches[2];
|
|
454
|
-
sUrlPostfix = aMatches[3];
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function normalizePath (sUrl0) {
|
|
458
|
-
return new URI(sUrl0).normalizePathname().toString();
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function isRelativePathWithDotSegmentsThatGoOutside (sPath) {
|
|
462
|
-
var aSegments = new URI(sPath).segment(),
|
|
463
|
-
i,
|
|
464
|
-
iPos = 0;
|
|
465
|
-
|
|
466
|
-
for (i = 0; i < aSegments.length && iPos >= 0; i += 1) {
|
|
467
|
-
if (aSegments[i] === "..") {
|
|
468
|
-
iPos = iPos - 1;
|
|
469
|
-
} else {
|
|
470
|
-
iPos = iPos + 1;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
return iPos < 0;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// check if URL contains a cache-buster token
|
|
478
|
-
if (sCacheBusterSegment) {
|
|
479
|
-
// check if removal of cache-buster token is required
|
|
480
|
-
if (sUrlPostfix && isRelativePathWithDotSegmentsThatGoOutside(sUrlPostfix)) {
|
|
481
|
-
// remove the cache-buster token
|
|
482
|
-
sUrl = sUrlPrefix + sUrlPostfix;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// always normalize the URL path
|
|
487
|
-
return normalizePath(sUrl);
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Gets an URL and adds the given cache buster token to it if no other token is already
|
|
492
|
-
* contained. The rules to be applied are coming from the ushell configuration:
|
|
493
|
-
* sap-ushell-config.cacheBusting.patterns
|
|
494
|
-
* The rules are applied by there order property (lowest first) and the modified URL is returned
|
|
495
|
-
* as soon as the first rule matched.
|
|
496
|
-
* <p>
|
|
497
|
-
* If the query parameter <code>sap-ushell-nocb</code> is set to <code>true</code> or <code>X</code>,
|
|
498
|
-
* no cache buster tokens are added and existing cache buster tokens are removed from the specified URL.
|
|
499
|
-
*
|
|
500
|
-
* @param {string} sUrl
|
|
501
|
-
* e.g. "/sap/bc/ui5_ui5/application/path"
|
|
502
|
-
* URL to be changed
|
|
503
|
-
* @returns {string}
|
|
504
|
-
* - if sUrl already contained a cache buster token (e.g. ~00000~): unchanged sUrl
|
|
505
|
-
* - if sUrl did not match any pattern: unchanged sUrl
|
|
506
|
-
* - if sUrl matched pattern: sUrl enhanced with sToken,
|
|
507
|
-
* e.g. "/sap/bc/ui5_ui5/~201412132350000~/application/path"
|
|
508
|
-
* - if the modified sUrl (normalized and cache buster token was removed)
|
|
509
|
-
* is found as an attribute of the config
|
|
510
|
-
* (window["sap-ushell-config"].cacheBusting.urls),
|
|
511
|
-
* the cache buster token which is defined as the value of this attribute
|
|
512
|
-
* is going to be returned.
|
|
513
|
-
*
|
|
514
|
-
* @private
|
|
515
|
-
*/
|
|
516
|
-
sap.ui2.srvc.addCacheBusterTokenUsingUshellConfig = function (sUrl) {
|
|
517
|
-
//TODO move to sap.ushell.utils
|
|
518
|
-
var oCacheBusting = window["sap-ushell-config"] &&
|
|
519
|
-
window["sap-ushell-config"].cacheBusting,
|
|
520
|
-
oPatterns = oCacheBusting && oCacheBusting.patterns,
|
|
521
|
-
sCacheBusterUrl = sUrl,
|
|
522
|
-
aParameterMap = [],
|
|
523
|
-
sSapUshellNoCb,
|
|
524
|
-
aRules = [];
|
|
525
|
-
|
|
526
|
-
aParameterMap = sap.ui2.srvc.getParameterMap();
|
|
527
|
-
sSapUshellNoCb = aParameterMap["sap-ushell-nocb"] && aParameterMap["sap-ushell-nocb"][0];
|
|
528
|
-
|
|
529
|
-
// When URL disables Cache Busting return URL without cache busting token
|
|
530
|
-
// It can happen that we get a URL which already has a cache-buster token included (from the ABAP server), so we also remove
|
|
531
|
-
// an existing token here (this implementation is simpler than passing the URL parameter to the resolveLink service and evaluate it there)
|
|
532
|
-
if ((sSapUshellNoCb === "true" || sSapUshellNoCb === "X") && typeof sUrl === "string") {
|
|
533
|
-
sUrl = sUrl.replace(/\/~[\w-]+~[A-Z0-9]?/, "");
|
|
534
|
-
return sUrl;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// don't continue if the string is empty or a token is already present,
|
|
538
|
-
// either as path segment (e.g.: /~0123_-Abc~/) or as query parameter
|
|
539
|
-
// /e.g. ?cb=~xxxxxx~
|
|
540
|
-
// also consider URLs with query parameters and fragments
|
|
541
|
-
// this case happens during navigation, because this method is both called from
|
|
542
|
-
// NavTargetResolution service as well as from the stubbed jQuery.sap.registerModulePath method
|
|
543
|
-
//
|
|
544
|
-
// syntax for application cache-buster contains now an additional scope qualifier that can be
|
|
545
|
-
// either empty, "R" for resource, "5" for UI5 app, "W" for web app and "C" for custom
|
|
546
|
-
// see ABAP class /UI5/CL_UI5_APP_HTTP_HANDLER for details
|
|
547
|
-
if (!oCacheBusting
|
|
548
|
-
|| typeof sUrl !== "string"
|
|
549
|
-
|| sUrl === ""
|
|
550
|
-
|| /[/=]~[\w-]+~[A-Z0-9]?[/#?&]/.test(sUrl) // matches intermediate segment with cb-token; consider URLs with query string or fragment
|
|
551
|
-
|| /[/=]~[\w-]+~[A-Z0-9]?$/.test(sUrl)) { // matches last segment with cb-token (no trailing slash or further parameters)
|
|
552
|
-
return sUrl;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (oCacheBusting && oCacheBusting.urls) {
|
|
556
|
-
// Removing the last slash of the input url
|
|
557
|
-
if (sUrl.charAt(sUrl.length - 1) === "/") {
|
|
558
|
-
sUrl = sUrl.substr(0, sUrl.length - 1);
|
|
559
|
-
}
|
|
560
|
-
// Config contains the modified url (without a slash at the end)
|
|
561
|
-
if (oCacheBusting.urls.hasOwnProperty(sUrl)) {
|
|
562
|
-
return sUrl + "/" + oCacheBusting.urls[sUrl].cacheBusterToken;
|
|
563
|
-
}
|
|
564
|
-
// Config contains the modified url (having a slash at the end)
|
|
565
|
-
if (oCacheBusting.urls.hasOwnProperty(sUrl + "/")) {
|
|
566
|
-
return sUrl + "/" + oCacheBusting.urls[sUrl + "/"].cacheBusterToken;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (!oPatterns) {
|
|
571
|
-
return sUrl;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// put rules in aRules and sort them by oRule.order
|
|
575
|
-
Object.keys(oPatterns).forEach(function (sPattern) {
|
|
576
|
-
if (oPatterns.hasOwnProperty(sPattern)) {
|
|
577
|
-
var oRule = oPatterns[sPattern];
|
|
578
|
-
// the property name is the pattern to be used, copy it to the object itself for later
|
|
579
|
-
oRule.pattern = new RegExp(sPattern);
|
|
580
|
-
aRules.push(oRule);
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
aRules.sort(function (oRule1, oRule2) { return oRule1.order - oRule2.order; });
|
|
584
|
-
|
|
585
|
-
// apply rules
|
|
586
|
-
aRules.every(function (oRule) { // use every to be able to break
|
|
587
|
-
if (oRule.pattern.test(sUrl)) {
|
|
588
|
-
if (!oRule.cacheBusterToken) {
|
|
589
|
-
oRule.cacheBusterToken = oCacheBusting.cacheBusterToken;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
//url matches the pattern, note that this is not redundant
|
|
593
|
-
//one can define patterns without a replacement to match and end the matching process!
|
|
594
|
-
sCacheBusterUrl = sap.ui2.srvc.addCacheBusterToken(sUrl, oRule.pattern, oRule.replacement,
|
|
595
|
-
oRule.cacheBusterToken);
|
|
596
|
-
// break as soon as first rule matches (irrespective of alteration)
|
|
597
|
-
return false;
|
|
598
|
-
}
|
|
599
|
-
return true;
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
return sCacheBusterUrl;
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Clear cache for GET requests.
|
|
607
|
-
*
|
|
608
|
-
* @since 1.8.1
|
|
609
|
-
*/
|
|
610
|
-
sap.ui2.srvc.get.clearCache = function () {
|
|
611
|
-
oCache = new sap.ui2.srvc.Map();
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* Number of pending XHR requests.
|
|
616
|
-
*
|
|
617
|
-
* @type {number}
|
|
618
|
-
*/
|
|
619
|
-
sap.ui2.srvc.get.pending = 0;
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Gets the device's form factor. Based on <code>sap.ui.Device.system</code> from SAPUI5.
|
|
623
|
-
* @returns {string}
|
|
624
|
-
* the device's form factor ("desktop", "tablet" or "phone")
|
|
625
|
-
* @since 1.19.1
|
|
626
|
-
*/
|
|
627
|
-
sap.ui2.srvc.getFormFactor = function () {
|
|
628
|
-
// see also redundant declaration in sap.ushell.utils.getFormFactor which has to be in sync
|
|
629
|
-
var oSystem = sap.ui.Device.system;
|
|
630
|
-
|
|
631
|
-
if (oSystem.desktop) {
|
|
632
|
-
return oSystem.SYSTEMTYPE.DESKTOP;
|
|
633
|
-
}
|
|
634
|
-
if (oSystem.tablet) {
|
|
635
|
-
return oSystem.SYSTEMTYPE.TABLET;
|
|
636
|
-
}
|
|
637
|
-
if (oSystem.phone) {
|
|
638
|
-
return oSystem.SYSTEMTYPE.PHONE;
|
|
639
|
-
}
|
|
640
|
-
// returns undefined
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Returns a map of all search parameters present in the given search string
|
|
645
|
-
* or this window's current URL. To be precise, <code>location.search</code>
|
|
646
|
-
* is used as a default and any given search string must use the same syntax
|
|
647
|
-
* (start with a "?" and not include a "#").
|
|
648
|
-
*
|
|
649
|
-
* @param {string} [sSearchString=location.search]
|
|
650
|
-
* search string starting with a "?" (unless empty) and not including a "#"
|
|
651
|
-
* @returns {object}
|
|
652
|
-
* a <code>map<string, string[]></code> from key to array of values
|
|
653
|
-
* @since 1.2.0
|
|
654
|
-
*
|
|
655
|
-
* @see <a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()">
|
|
656
|
-
* javax.servlet.ServletRequest#getParameterMap()</a>
|
|
657
|
-
* @see <a href="https://sapui5.hana.ondemand.com/sdk/docs/api/symbols/jQuery.sap.util.UriParameters.html">
|
|
658
|
-
* Interface jQuery.sap.util.UriParameters</a>
|
|
659
|
-
*/
|
|
660
|
-
sap.ui2.srvc.getParameterMap = function (sSearchString) {
|
|
661
|
-
var i,
|
|
662
|
-
n,
|
|
663
|
-
mResult = {},
|
|
664
|
-
sKey,
|
|
665
|
-
sValue,
|
|
666
|
-
iIndexOfEquals,
|
|
667
|
-
aKeyValuePairs,
|
|
668
|
-
// Note: location.search starts with "?" if not empty
|
|
669
|
-
sSearch = arguments.length > 0 ? sSearchString : location.search;
|
|
670
|
-
|
|
671
|
-
if (sSearch && sSearch.charAt(0) !== "?") {
|
|
672
|
-
throw new sap.ui2.srvc.Error("Illegal search string " + sSearch, "sap.ui2.srvc");
|
|
673
|
-
}
|
|
674
|
-
if (!sSearch || sSearch === "?") {
|
|
675
|
-
return {}; // Note: split("") would return [""]
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// Note: W3C recommends that servers support ";" as well as "&"
|
|
679
|
-
// (http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2)
|
|
680
|
-
// http://unixpapa.com/js/querystring.html advocates this on the client-side also!
|
|
681
|
-
aKeyValuePairs = sSearch.substring(1).replace(/\+/g, " ").split(/[&;]/);
|
|
682
|
-
|
|
683
|
-
for (i = 0, n = aKeyValuePairs.length; i < n; i += 1) {
|
|
684
|
-
// decode key/value pair at first "=" character
|
|
685
|
-
sKey = aKeyValuePairs[i];
|
|
686
|
-
sValue = ""; // Note: empty value may be omitted altogether
|
|
687
|
-
iIndexOfEquals = sKey.indexOf("=");
|
|
688
|
-
if (iIndexOfEquals >= 0) {
|
|
689
|
-
sValue = sKey.slice(iIndexOfEquals + 1);
|
|
690
|
-
sValue = decodeURIComponent(sValue);
|
|
691
|
-
sKey = sKey.slice(0, iIndexOfEquals);
|
|
692
|
-
}
|
|
693
|
-
sKey = decodeURIComponent(sKey);
|
|
694
|
-
|
|
695
|
-
// map key to value(s)
|
|
696
|
-
// Note: beware of inherited functions!
|
|
697
|
-
if (!Object.prototype.hasOwnProperty.call(mResult, sKey)) {
|
|
698
|
-
mResult[sKey] = [];
|
|
699
|
-
}
|
|
700
|
-
mResult[sKey].push(sValue);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
return mResult;
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Returns the value of the given URL's GET parameter with the given name, properly decoded.
|
|
708
|
-
* Returns "" if no such parameter can be found.
|
|
709
|
-
*
|
|
710
|
-
* @param {string} sUrl
|
|
711
|
-
* any URL
|
|
712
|
-
* @param {string} sName
|
|
713
|
-
* the name of the GET parameter we are looking for
|
|
714
|
-
* @returns {string}
|
|
715
|
-
* the parameter value, properly decoded
|
|
716
|
-
*
|
|
717
|
-
* @private
|
|
718
|
-
* @since 1.17.0
|
|
719
|
-
*/
|
|
720
|
-
sap.ui2.srvc.getParameterValue = function (sUrl, sName) {
|
|
721
|
-
var oParameterMap, iQueryIndex;
|
|
722
|
-
|
|
723
|
-
if (typeof sName !== "string") {
|
|
724
|
-
// avoid surprises when sName would later be converted into a string
|
|
725
|
-
throw new sap.ui2.srvc.Error("Missing parameter name", "sap.ui2.srvc");
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
sUrl = sUrl.split("#")[0];
|
|
729
|
-
iQueryIndex = sUrl.indexOf("?");
|
|
730
|
-
if (iQueryIndex >= 0) {
|
|
731
|
-
oParameterMap = sap.ui2.srvc.getParameterMap(sUrl.slice(iQueryIndex));
|
|
732
|
-
if (oParameterMap[sName]) {
|
|
733
|
-
return oParameterMap[sName][0];
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return "";
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* Tells whether the given value is an array.
|
|
741
|
-
*
|
|
742
|
-
* @param {object} o
|
|
743
|
-
* any value
|
|
744
|
-
* @returns {boolean}
|
|
745
|
-
* <code>true</code> if and only if the given value is an array
|
|
746
|
-
* @since 1.2.0
|
|
747
|
-
*/
|
|
748
|
-
sap.ui2.srvc.isArray = function (o) {
|
|
749
|
-
// see Crockford page 61
|
|
750
|
-
return Object.prototype.toString.apply(o) === "[object Array]";
|
|
751
|
-
};
|
|
752
|
-
/**
|
|
753
|
-
* Tells whether the given value is a string.
|
|
754
|
-
*
|
|
755
|
-
* @param {object} o
|
|
756
|
-
* any value
|
|
757
|
-
* @returns {boolean}
|
|
758
|
-
* <code>true</code> if and only if the given value is a string
|
|
759
|
-
* @since 1.50.1
|
|
760
|
-
*/
|
|
761
|
-
sap.ui2.srvc.isString = function name (o) {
|
|
762
|
-
return /String/.test(Object.prototype.toString.call(o));
|
|
763
|
-
};
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Parses the given XML string and returns it as a document.
|
|
767
|
-
*
|
|
768
|
-
* @param {string} sXml
|
|
769
|
-
* the XML
|
|
770
|
-
* @returns {DOMDocument}
|
|
771
|
-
* a DOM document, or <code>null</code> in case of missing or empty XML string
|
|
772
|
-
* @throws {Error}
|
|
773
|
-
* in case of invalid XML string
|
|
774
|
-
* @since 1.2.0
|
|
775
|
-
*/
|
|
776
|
-
sap.ui2.srvc.parseXml = function (sXml) {
|
|
777
|
-
var oXml;
|
|
778
|
-
if (!sXml || typeof sXml !== "string") {
|
|
779
|
-
return null;
|
|
780
|
-
}
|
|
781
|
-
oXml = new DOMParser().parseFromString(sXml, "text/xml");
|
|
782
|
-
if (oXml.getElementsByTagName("parsererror").length) { // Chrome, Firefox
|
|
783
|
-
throw new sap.ui2.srvc.Error("Invalid XML: " + sXml, "sap.ui2.srvc");
|
|
784
|
-
}
|
|
785
|
-
return oXml;
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* Serves as a marker for functions that are to be exposed in QUnit tests. Calls to this function
|
|
790
|
-
* are expected to be placed directly before the named function declaration (even <b>after</b>
|
|
791
|
-
* the JSDoc). The function itself does nothing.
|
|
792
|
-
*
|
|
793
|
-
* @param {object} o
|
|
794
|
-
* the object to which this function will be attached in tests; must not be <code>this</code>
|
|
795
|
-
* (use <code>that</code> instead)
|
|
796
|
-
* @since 1.3.0
|
|
797
|
-
*/
|
|
798
|
-
sap.ui2.srvc.testPublishAt = function (o) {
|
|
799
|
-
// intentionally left blank
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
// "public classes" **********************************************************
|
|
803
|
-
|
|
804
|
-
if (sap.ui2.srvc.Error === undefined) {
|
|
805
|
-
sap.ui2.srvc.Error = function (sMessage, sComponent, bLogError) {
|
|
806
|
-
// see also redundant declaration in error.js which has to be in sync
|
|
807
|
-
var oError = new Error(sMessage); // reuse Error constructor to benefit from it (e.g. stack)
|
|
808
|
-
|
|
809
|
-
// by default the error should be logged (as always in this project)
|
|
810
|
-
bLogError = bLogError === undefined ? true : bLogError;
|
|
811
|
-
|
|
812
|
-
oError.name = "sap.ui2.srvc.Error";
|
|
813
|
-
if (bLogError === true) {
|
|
814
|
-
sap.ui2.srvc.log.error(sMessage, null, sComponent);
|
|
815
|
-
}
|
|
816
|
-
return oError;
|
|
817
|
-
};
|
|
818
|
-
// to avoid (new Error()) instanceof sap.ui2.srvc.Error === true we do not set the prototype,
|
|
819
|
-
// we also tolerate that (new sap.ui2.srvc.Error()) instanceof sap.ui2.srvc.Error === false now
|
|
820
|
-
// sap.ui2.srvc.Error.prototype = Error.prototype;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Creates an empty map. It is used for mapping from arbitrary string(!) keys (including "get" or
|
|
825
|
-
* "hasOwnProperty") to values of any type.
|
|
826
|
-
* @class
|
|
827
|
-
* @since 1.5.0
|
|
828
|
-
*/
|
|
829
|
-
sap.ui2.srvc.Map = function () {
|
|
830
|
-
this.entries = {};
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Associates the specified value with the specified key in this map. If the map previously
|
|
835
|
-
* contained a mapping for the key, the old value is replaced by the specified value. Returns
|
|
836
|
-
* the old value. Note: It might be a good idea to assert that the old value is
|
|
837
|
-
* <code>undefined</code> in case you expect your keys to be unique.
|
|
838
|
-
*
|
|
839
|
-
* @param {string} sKey
|
|
840
|
-
* key with which the specified value is to be associated
|
|
841
|
-
* @param {any} vValue
|
|
842
|
-
* value to be associated with the specified key
|
|
843
|
-
* @returns {any}
|
|
844
|
-
* the old value
|
|
845
|
-
* @since 1.5.0
|
|
846
|
-
*/
|
|
847
|
-
sap.ui2.srvc.Map.prototype.put = function (sKey, vValue) {
|
|
848
|
-
var vOldValue = this.get(sKey);
|
|
849
|
-
this.entries[sKey] = vValue;
|
|
850
|
-
return vOldValue;
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Returns <tt>true</tt> if this map contains a mapping for the specified key.
|
|
855
|
-
*
|
|
856
|
-
* @param {string} sKey
|
|
857
|
-
* key whose presence in this map is to be tested
|
|
858
|
-
* @returns {boolean}
|
|
859
|
-
* <tt>true</tt> if this map contains a mapping for the specified key
|
|
860
|
-
* @since 1.5.0
|
|
861
|
-
*/
|
|
862
|
-
sap.ui2.srvc.Map.prototype.containsKey = function (sKey) {
|
|
863
|
-
if (typeof sKey !== "string") {
|
|
864
|
-
throw new sap.ui2.srvc.Error("Not a string key: " + sKey, "sap.ui2.srvc");
|
|
865
|
-
}
|
|
866
|
-
return Object.prototype.hasOwnProperty.call(this.entries, sKey);
|
|
867
|
-
};
|
|
868
|
-
|
|
869
|
-
/**
|
|
870
|
-
* Returns the value to which the specified key is mapped, or <code>undefined</code> if this map
|
|
871
|
-
* contains no mapping for the key.
|
|
872
|
-
* @param {string} sKey
|
|
873
|
-
* the key whose associated value is to be returned
|
|
874
|
-
* @returns {any}
|
|
875
|
-
* the value to which the specified key is mapped, or <code>undefined</code> if this map
|
|
876
|
-
* contains no mapping for the key
|
|
877
|
-
* @since 1.5.0
|
|
878
|
-
*/
|
|
879
|
-
sap.ui2.srvc.Map.prototype.get = function (sKey) {
|
|
880
|
-
if (this.containsKey(sKey)) {
|
|
881
|
-
return this.entries[sKey];
|
|
882
|
-
}
|
|
883
|
-
//return undefined;
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* Returns an array of this map's keys. This array is a snapshot of the map; concurrent
|
|
888
|
-
* modifications of the map while iterating do not influence the sequence.
|
|
889
|
-
* @returns {string[]}
|
|
890
|
-
* this map's keys
|
|
891
|
-
* @since 1.5.0
|
|
892
|
-
*/
|
|
893
|
-
sap.ui2.srvc.Map.prototype.keys = function () {
|
|
894
|
-
return Object.keys(this.entries);
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Removes a key together with its value from the map.
|
|
899
|
-
* @param {string} sKey
|
|
900
|
-
* the map's key to be removed
|
|
901
|
-
* @since 1.11.0
|
|
902
|
-
*/
|
|
903
|
-
sap.ui2.srvc.Map.prototype.remove = function (sKey) {
|
|
904
|
-
delete this.entries[sKey];
|
|
905
|
-
};
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Returns this map's string representation.
|
|
909
|
-
*
|
|
910
|
-
* @returns {string}
|
|
911
|
-
* this map's string representation
|
|
912
|
-
* @since 1.5.0
|
|
913
|
-
*/
|
|
914
|
-
sap.ui2.srvc.Map.prototype.toString = function () {
|
|
915
|
-
var aResult = ["sap.ui2.srvc.Map("];
|
|
916
|
-
aResult.push(JSON.stringify(this.entries));
|
|
917
|
-
aResult.push(")");
|
|
918
|
-
return aResult.join("");
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
// initialize the cache for GET
|
|
922
|
-
sap.ui2.srvc.get.clearCache();
|
|
923
|
-
}());
|