@sitevision/api 2025.4.1 → 2025.5.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/common/events/index.d.ts +357 -0
- package/package.json +2 -2
- package/server/Utils/index.d.ts +14 -26
- package/server/VelocityRenderer/index.d.ts +9 -8
- package/types/senselogic/sitevision/api/render/velocity/VelocityAccess.ExceptionSuppressingProxyConstants/index.d.ts +2 -1
- package/types/senselogic/sitevision/api/render/velocity/VelocityEvaluator/index.d.ts +3 -34
- package/types/senselogic/sitevision/api/script/RequesterChainable/index.d.ts +2 -2
- package/types/senselogic/sitevision/api/script/proxy/ExceptionSuppressingCollection/index.d.ts +4 -83
- package/types/senselogic/sitevision/api/script/proxy/ExceptionSuppressingIterator/index.d.ts +7 -54
- package/types/senselogic/sitevision/api/script/proxy/ExceptionSuppressingProxy/index.d.ts +8 -71
package/common/events/index.d.ts
CHANGED
|
@@ -1,3 +1,332 @@
|
|
|
1
|
+
import type { Node } from '../../types/javax/jcr/Node';
|
|
2
|
+
|
|
3
|
+
/** Emitted when something (typically a page) is published. */
|
|
4
|
+
export type PublishingPublishOptions = {
|
|
5
|
+
/** The full name of the event */
|
|
6
|
+
event: 'sv:publishing:publish';
|
|
7
|
+
/** The JCR identifier of the emitting user */
|
|
8
|
+
emitter: string;
|
|
9
|
+
/** The timestamp when the event was emitted */
|
|
10
|
+
timestamp: number;
|
|
11
|
+
/** The JCR identifier of the node that was published */
|
|
12
|
+
node: string;
|
|
13
|
+
/** If the publishing comment feature is enabled and a comment has been provided */
|
|
14
|
+
publishingComment?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Emitted when something (typically a page) is unpublished. */
|
|
18
|
+
export type PublishingUnpublishOptions = {
|
|
19
|
+
/** The full name of the event */
|
|
20
|
+
event: 'sv:publishing:unpublish';
|
|
21
|
+
/** The JCR identifier of the emitting user */
|
|
22
|
+
emitter: string;
|
|
23
|
+
/** The timestamp when the event was emitted */
|
|
24
|
+
timestamp: number;
|
|
25
|
+
/** The JCR identifier of the node that was unpublished */
|
|
26
|
+
node: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Emitted when a simple user is created. */
|
|
30
|
+
export type SimpleUserCreateOptions = {
|
|
31
|
+
/** The full name of the event */
|
|
32
|
+
event: 'sv:simpleuser:create';
|
|
33
|
+
/** The JCR identifier of the emitting user */
|
|
34
|
+
emitter: string;
|
|
35
|
+
/** The timestamp when the event was emitted */
|
|
36
|
+
timestamp: number;
|
|
37
|
+
/** The JCR identifier of the simple user that was created */
|
|
38
|
+
user: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Emitted when a simple user is updated. */
|
|
42
|
+
export type SimpleUserUpdateOptions = {
|
|
43
|
+
/** The full name of the event */
|
|
44
|
+
event: 'sv:simpleuser:update';
|
|
45
|
+
/** The JCR identifier of the emitting user */
|
|
46
|
+
emitter: string;
|
|
47
|
+
/** The timestamp when the event was emitted */
|
|
48
|
+
timestamp: number;
|
|
49
|
+
/** The JCR identifier of the simple user that was updated */
|
|
50
|
+
user: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Emitted when the http session for a simple user is destroyed (e.g. session timed out). */
|
|
54
|
+
export type SimpleUserSessionDestroyOptions = {
|
|
55
|
+
/** The full name of the event */
|
|
56
|
+
event: 'sv:simpleuser:session:destroy';
|
|
57
|
+
/** No user is emitting the event */
|
|
58
|
+
emitter: 'anonymous',
|
|
59
|
+
/** The timestamp when the event was emitted */
|
|
60
|
+
timestamp: number;
|
|
61
|
+
/** The JCR identifier of the simple user whose session was destroyed */
|
|
62
|
+
user: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Emitted when something (typically a page) is moved. */
|
|
66
|
+
export type StructureMoveOptions = {
|
|
67
|
+
/** The full name of the event */
|
|
68
|
+
event: 'sv:structure:move';
|
|
69
|
+
/** The JCR identifier of the emitting user */
|
|
70
|
+
emitter: string;
|
|
71
|
+
/** The timestamp when the event was emitted */
|
|
72
|
+
timestamp: number;
|
|
73
|
+
/** The JCR identifier of the node that was moved */
|
|
74
|
+
node: string;
|
|
75
|
+
/** The JCR identifier of the old parent node */
|
|
76
|
+
from: string;
|
|
77
|
+
/** The JCR identifier of the new parent node */
|
|
78
|
+
to: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** Emitted when something (typically a page/article/file/image) is added to the trashcan. */
|
|
82
|
+
export type TrashcanAddOptions = {
|
|
83
|
+
/** The full name of the event */
|
|
84
|
+
event: 'sv:trashcan:add';
|
|
85
|
+
/** The JCR identifier of the emitting user */
|
|
86
|
+
emitter: string;
|
|
87
|
+
/** The timestamp when the event was emitted */
|
|
88
|
+
timestamp: number;
|
|
89
|
+
/** The JCR identifier of the node that was trashed */
|
|
90
|
+
node: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** Emitted when something (typically a page/article/file/image) is restored from the trashcan. */
|
|
94
|
+
export type TrashcanRestoreOptions = {
|
|
95
|
+
/** The full name of the event */
|
|
96
|
+
event: 'sv:trashcan:restore';
|
|
97
|
+
/** The JCR identifier of the emitting user */
|
|
98
|
+
emitter: string;
|
|
99
|
+
/** The timestamp when the event was emitted */
|
|
100
|
+
timestamp: number;
|
|
101
|
+
/** The JCR identifier of the node that was restored */
|
|
102
|
+
node: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Emitted when a file or an image is added to a repository or folder. */
|
|
106
|
+
export type BinaryCreateOptions = {
|
|
107
|
+
/** The full name of the event */
|
|
108
|
+
event: 'sv:binary:create';
|
|
109
|
+
/** The JCR identifier of the emitting user */
|
|
110
|
+
emitter: string;
|
|
111
|
+
/** The timestamp when the event was emitted */
|
|
112
|
+
timestamp: number;
|
|
113
|
+
/** The JCR identifier of the file that has been created */
|
|
114
|
+
node: string;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** Emitted when the content for a file or an image has been updated. */
|
|
118
|
+
export type BinaryUpdateContentOptions = {
|
|
119
|
+
/** The full name of the event */
|
|
120
|
+
event: 'sv:binary:update:content';
|
|
121
|
+
/** The JCR identifier of the emitting user */
|
|
122
|
+
emitter: string;
|
|
123
|
+
/** The timestamp when the event was emitted */
|
|
124
|
+
timestamp: number;
|
|
125
|
+
/** The JCR identifier of the file that was updated */
|
|
126
|
+
node: string;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Emitted when metadata for a file or an image has been updated. */
|
|
130
|
+
export type BinaryUpdateMetadataOptions = {
|
|
131
|
+
/** The full name of the event */
|
|
132
|
+
event: 'sv:binary:update:metadata';
|
|
133
|
+
/** The JCR identifier of the emitting user */
|
|
134
|
+
emitter: string;
|
|
135
|
+
/** The timestamp when the event was emitted */
|
|
136
|
+
timestamp: number;
|
|
137
|
+
/** The JCR identifier of the file that has updated metadata */
|
|
138
|
+
node: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** Emitted when the name of a file or an image has been changed. */
|
|
142
|
+
export type BinaryUpdateNameOptions = {
|
|
143
|
+
/** The full name of the event */
|
|
144
|
+
event: 'sv:binary:update:name';
|
|
145
|
+
/** The JCR identifier of the emitting user */
|
|
146
|
+
emitter: string;
|
|
147
|
+
/** The timestamp when the event was emitted */
|
|
148
|
+
timestamp: number;
|
|
149
|
+
/** The JCR identifier of the file that has been renamed */
|
|
150
|
+
node: string;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** Emitted when tags for a file or an image has been changed. */
|
|
154
|
+
export type BinaryUpdateTagsOptions = {
|
|
155
|
+
/** The full name of the event */
|
|
156
|
+
event: 'sv:binary:update:tags';
|
|
157
|
+
/** The JCR identifier of the emitting user */
|
|
158
|
+
emitter: string;
|
|
159
|
+
/** The timestamp when the event was emitted */
|
|
160
|
+
timestamp: number;
|
|
161
|
+
/** The JCR identifier of the file that was changed */
|
|
162
|
+
node: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** Emitted when a new version of a file has been created. */
|
|
166
|
+
export type BinaryUpdateVersionCreateOptions = {
|
|
167
|
+
/** The full name of the event */
|
|
168
|
+
event: 'sv:binary:update:version:create';
|
|
169
|
+
/** The JCR identifier of the emitting user */
|
|
170
|
+
emitter: string;
|
|
171
|
+
/** The timestamp when the event was emitted */
|
|
172
|
+
timestamp: number;
|
|
173
|
+
/** The JCR identifier of the file that has a new version */
|
|
174
|
+
node: string;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** Emitted when a version of a file has been deleted. */
|
|
178
|
+
export type BinaryUpdateVersionDeleteOptions = {
|
|
179
|
+
/** The full name of the event */
|
|
180
|
+
event: 'sv:binary:update:version:delete';
|
|
181
|
+
/** The JCR identifier of the emitting user */
|
|
182
|
+
emitter: string;
|
|
183
|
+
/** The timestamp when the event was emitted */
|
|
184
|
+
timestamp: number;
|
|
185
|
+
/** The JCR identifier of the file that has a deleted version */
|
|
186
|
+
node: string;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/** Emitted when a version of a file has been selected. */
|
|
190
|
+
export type BinaryUpdateVersionSelectOptions = {
|
|
191
|
+
/** The full name of the event */
|
|
192
|
+
event: 'sv:binary:update:version:select';
|
|
193
|
+
/** The JCR identifier of the emitting user */
|
|
194
|
+
emitter: string;
|
|
195
|
+
/** The timestamp when the event was emitted */
|
|
196
|
+
timestamp: number;
|
|
197
|
+
/** The JCR identifier of the file that has a new version selected */
|
|
198
|
+
node: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** Emitted when a folder whose metadata is updated. */
|
|
202
|
+
export type FolderUpdateMetadataOptions = {
|
|
203
|
+
/** The full name of the event */
|
|
204
|
+
event: 'sv:folder:update:metadata';
|
|
205
|
+
/** The JCR identifier of the emitting user */
|
|
206
|
+
emitter: string;
|
|
207
|
+
/** The timestamp when the event was emitted */
|
|
208
|
+
timestamp: number;
|
|
209
|
+
/** The JCR identifier of the folder that has been updated */
|
|
210
|
+
node: string;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/** Form field answer structure */
|
|
214
|
+
export type FormAnswer = {
|
|
215
|
+
/** Unique identifier for the form field */
|
|
216
|
+
id: string;
|
|
217
|
+
/** The question or prompt shown to the user */
|
|
218
|
+
question: string;
|
|
219
|
+
/** User's answer as a string or a [sv:temporaryFile](https://developer.sitevision.se/docs/public-api/node-types/node-types/2019-02-20-svtemporaryfile) for file uploads */
|
|
220
|
+
value: string | Node;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/** Emitted when Sitevision's email/question-form module is posted. */
|
|
224
|
+
export type FormPostOptions = {
|
|
225
|
+
/** The full name of the event */
|
|
226
|
+
event: 'sv:form:post';
|
|
227
|
+
/** The JCR identifier of the emitting user */
|
|
228
|
+
emitter: string;
|
|
229
|
+
/** The timestamp when the event was emitted */
|
|
230
|
+
timestamp: number;
|
|
231
|
+
/** The JCR identifier of the page the form was posted */
|
|
232
|
+
node: string;
|
|
233
|
+
/** Array of form field answers */
|
|
234
|
+
answers: FormAnswer[];
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/** Emitted every 5 minutes. */
|
|
238
|
+
export type Every5MinutesOptions = {
|
|
239
|
+
/** The full name of the event */
|
|
240
|
+
event: 'sv:every-5-minutes';
|
|
241
|
+
/** No user is emitting the event */
|
|
242
|
+
emitter: 'anonymous';
|
|
243
|
+
/** The timestamp when the event was emitted */
|
|
244
|
+
timestamp: number;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/** Emitted every 15 minutes. */
|
|
248
|
+
export type Every15MinutesOptions = {
|
|
249
|
+
/** The full name of the event */
|
|
250
|
+
event: 'sv:every-15-minutes';
|
|
251
|
+
/** No user is emitting the event */
|
|
252
|
+
emitter: 'anonymous';
|
|
253
|
+
/** The timestamp when the event was emitted */
|
|
254
|
+
timestamp: number;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/** Emitted every 30 minutes. */
|
|
258
|
+
export type Every30MinutesOptions = {
|
|
259
|
+
/** The full name of the event */
|
|
260
|
+
event: 'sv:every-30-minutes';
|
|
261
|
+
/** No user is emitting the event */
|
|
262
|
+
emitter: 'anonymous';
|
|
263
|
+
/** The timestamp when the event was emitted */
|
|
264
|
+
timestamp: number;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/** Emitted every hour. */
|
|
268
|
+
export type EveryHourOptions = {
|
|
269
|
+
/** The full name of the event */
|
|
270
|
+
event: 'sv:every-hour';
|
|
271
|
+
/** No user is emitting the event */
|
|
272
|
+
emitter: 'anonymous';
|
|
273
|
+
/** The timestamp when the event was emitted */
|
|
274
|
+
timestamp: number;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/** Emitted every day. */
|
|
278
|
+
export type EveryDayOptions = {
|
|
279
|
+
/** The full name of the event */
|
|
280
|
+
event: 'sv:every-day';
|
|
281
|
+
/** No user is emitting the event */
|
|
282
|
+
emitter: 'anonymous';
|
|
283
|
+
/** The timestamp when the event was emitted */
|
|
284
|
+
timestamp: number;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Union types for grouped events
|
|
288
|
+
/** All publishing-related event options */
|
|
289
|
+
export type PublishingOptions = PublishingPublishOptions | PublishingUnpublishOptions;
|
|
290
|
+
|
|
291
|
+
/** All simple user-related event options */
|
|
292
|
+
export type SimpleUserOptions =
|
|
293
|
+
| SimpleUserCreateOptions
|
|
294
|
+
| SimpleUserUpdateOptions
|
|
295
|
+
| SimpleUserSessionDestroyOptions;
|
|
296
|
+
|
|
297
|
+
/** All binary-related event options */
|
|
298
|
+
export type BinaryOptions =
|
|
299
|
+
| BinaryCreateOptions
|
|
300
|
+
| BinaryUpdateContentOptions
|
|
301
|
+
| BinaryUpdateMetadataOptions
|
|
302
|
+
| BinaryUpdateNameOptions
|
|
303
|
+
| BinaryUpdateTagsOptions
|
|
304
|
+
| BinaryUpdateVersionCreateOptions
|
|
305
|
+
| BinaryUpdateVersionDeleteOptions
|
|
306
|
+
| BinaryUpdateVersionSelectOptions;
|
|
307
|
+
|
|
308
|
+
/** All timer-related event options */
|
|
309
|
+
export type TimerOptions =
|
|
310
|
+
| Every5MinutesOptions
|
|
311
|
+
| Every15MinutesOptions
|
|
312
|
+
| Every30MinutesOptions
|
|
313
|
+
| EveryHourOptions
|
|
314
|
+
| EveryDayOptions;
|
|
315
|
+
|
|
316
|
+
/** All trashcan-related event options */
|
|
317
|
+
export type TrashcanOptions = TrashcanAddOptions | TrashcanRestoreOptions;
|
|
318
|
+
|
|
319
|
+
/** All possible system event options */
|
|
320
|
+
export type AllSystemOptions =
|
|
321
|
+
| PublishingOptions
|
|
322
|
+
| SimpleUserOptions
|
|
323
|
+
| BinaryOptions
|
|
324
|
+
| TimerOptions
|
|
325
|
+
| TrashcanOptions
|
|
326
|
+
| StructureMoveOptions
|
|
327
|
+
| FolderUpdateMetadataOptions
|
|
328
|
+
| FormPostOptions;
|
|
329
|
+
|
|
1
330
|
export interface Events {
|
|
2
331
|
/**
|
|
3
332
|
* Listen to a given event
|
|
@@ -6,6 +335,34 @@ export interface Events {
|
|
|
6
335
|
* @param callback The callback to trigger for the given event
|
|
7
336
|
*/
|
|
8
337
|
on(eventName: string, callback: (options: unknown) => void): void;
|
|
338
|
+
on(eventName: 'sv:publishing', callback: (options: PublishingOptions) => void): void;
|
|
339
|
+
on(eventName: 'sv:publishing:publish', callback: (options: PublishingPublishOptions) => void): void;
|
|
340
|
+
on(eventName: 'sv:publishing:unpublish', callback: (options: PublishingUnpublishOptions) => void): void;
|
|
341
|
+
on(eventName: 'sv:simpleuser', callback: (options: SimpleUserOptions) => void): void;
|
|
342
|
+
on(eventName: 'sv:simpleuser:create', callback: (options: SimpleUserCreateOptions) => void): void;
|
|
343
|
+
on(eventName: 'sv:simpleuser:update', callback: (options: SimpleUserUpdateOptions) => void): void;
|
|
344
|
+
on(eventName: 'sv:simpleuser:session:destroy', callback: (options: SimpleUserSessionDestroyOptions) => void): void;
|
|
345
|
+
on(eventName: 'sv:structure:move', callback: (options: StructureMoveOptions) => void): void;
|
|
346
|
+
on(eventName: 'sv:trashcan', callback: (options: TrashcanOptions) => void): void;
|
|
347
|
+
on(eventName: 'sv:trashcan:add', callback: (options: TrashcanAddOptions) => void): void;
|
|
348
|
+
on(eventName: 'sv:trashcan:restore', callback: (options: TrashcanRestoreOptions) => void): void;
|
|
349
|
+
on(eventName: 'sv:binary', callback: (options: BinaryOptions) => void): void;
|
|
350
|
+
on(eventName: 'sv:binary:create', callback: (options: BinaryCreateOptions) => void): void;
|
|
351
|
+
on(eventName: 'sv:binary:update:content', callback: (options: BinaryUpdateContentOptions) => void): void;
|
|
352
|
+
on(eventName: 'sv:binary:update:metadata', callback: (options: BinaryUpdateMetadataOptions) => void): void;
|
|
353
|
+
on(eventName: 'sv:binary:update:name', callback: (options: BinaryUpdateNameOptions) => void): void;
|
|
354
|
+
on(eventName: 'sv:binary:update:tags', callback: (options: BinaryUpdateTagsOptions) => void): void;
|
|
355
|
+
on(eventName: 'sv:binary:update:version:create', callback: (options: BinaryUpdateVersionCreateOptions) => void): void;
|
|
356
|
+
on(eventName: 'sv:binary:update:version:delete', callback: (options: BinaryUpdateVersionDeleteOptions) => void): void;
|
|
357
|
+
on(eventName: 'sv:binary:update:version:select', callback: (options: BinaryUpdateVersionSelectOptions) => void): void;
|
|
358
|
+
on(eventName: 'sv:folder:update:metadata', callback: (options: FolderUpdateMetadataOptions) => void): void;
|
|
359
|
+
on(eventName: 'sv:form:post', callback: (options: FormPostOptions) => void): void;
|
|
360
|
+
on(eventName: 'sv:every-5-minutes', callback: (options: Every5MinutesOptions) => void): void;
|
|
361
|
+
on(eventName: 'sv:every-15-minutes', callback: (options: Every15MinutesOptions) => void): void;
|
|
362
|
+
on(eventName: 'sv:every-30-minutes', callback: (options: Every30MinutesOptions) => void): void;
|
|
363
|
+
on(eventName: 'sv:every-hour', callback: (options: EveryHourOptions) => void): void;
|
|
364
|
+
on(eventName: 'sv:every-day', callback: (options: EveryDayOptions) => void): void;
|
|
365
|
+
|
|
9
366
|
/**
|
|
10
367
|
* Stop listening to a given event
|
|
11
368
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitevision/api",
|
|
3
|
-
"version": "2025.
|
|
3
|
+
"version": "2025.5.1",
|
|
4
4
|
"author": "Sitevision AB",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"access": "public",
|
|
31
31
|
"directory": "dist"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "28570281cd01424c7ed0772fb5a5f004c92712b1"
|
|
34
34
|
}
|
package/server/Utils/index.d.ts
CHANGED
|
@@ -405,46 +405,34 @@ export interface Utils {
|
|
|
405
405
|
getImageScaler(aMaxWidth: number, aMaxHeight: number): ImageScaler;
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* <strong>Note! </strong>Be aware of <code>null</code>'s. They are never proxied. If you try to proxy <code>null</code>, this method
|
|
412
|
-
* will just return <code>null</code>, not a proxy instance. In other words: even though you're trying to use a
|
|
413
|
-
* <code>ExceptionSuppressingProxy</code> to suppress exceptions,
|
|
414
|
-
* method invocations will of course still throw <code>NullPointerException</code>.
|
|
415
|
-
* </p>
|
|
416
|
-
* @param anObject an object to be proxied by an ExceptionSuppressingProxy
|
|
417
|
-
* @return anObject proxied by an ExceptionSuppressingProxy, or <code>null</code> if <code>anObject</code> is <code>null</code>.
 If <code>anObject</code> is a <code>ExceptionSuppressingProxy</code>),
 <code>anObject</code> will be returned "as-is" (no new instance will be created).
|
|
408
|
+
* Deprecated get method for deprecated ExceptionSuppressingProxy.
|
|
409
|
+
* @param aObject an object to be proxied by an ExceptionSuppressingProxy
|
|
410
|
+
* @return a deprecated ExceptionSuppressingProxy, or null if aObject is null.
|
|
418
411
|
* @since Sitevision 2.6.1_09
|
|
412
|
+
* @deprecated ExceptionSuppressingProxy is not supported, this method deprecated and will be removed in a future version of Sitevision
|
|
419
413
|
*/
|
|
420
|
-
getExceptionSuppressingProxy(
|
|
414
|
+
getExceptionSuppressingProxy(aObject: unknown): ExceptionSuppressingProxy;
|
|
421
415
|
|
|
422
416
|
/**
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
* <strong>Note!</strong> The sole purpose of the <code>ExceptionSuppressingCollection</code> is to provide easy access to a decorated iterator
|
|
427
|
-
* ({@link senselogic.sitevision.api.script.proxy.ExceptionSuppressingIterator}).
|
|
428
|
-
* You should <em>not</em> create a collection of object proxys (i.e. <code>Collection<ExceptionSuppressingProxy></code>) yourself.
|
|
429
|
-
* You should use <code>ExceptionSuppressingCollection</code>
|
|
430
|
-
* with your "regular" collection since the actual proxying is done by the iterator itself.
|
|
431
|
-
* </p>
|
|
432
|
-
* @param aCollection a collection to be decorated by a ExceptionSuppressingCollection. Note that this should be your "regular" collection,
 not a already proxied one (i.e. <code>Collection<ExceptionSuppressingProxy></code>).
|
|
433
|
-
* @return the collection decorated by a ExceptionSuppressingCollection, or <code>null</code> if <code>aCollection</code> is <code>null</code>.
 If <code>aCollection</code> is a <code>ExceptionSuppressingCollection</code>),
 <code>aCollection</code> will be returned "as-is" (no new instance will be created).
|
|
417
|
+
* Deprecated get method for deprecated ExceptionSuppressingCollection.
|
|
418
|
+
* @param aCollection a collection to be decorated by a ExceptionSuppressingCollection
|
|
419
|
+
* @return a deprecated ExceptionSuppressingCollection, or null if aCollection is null.
|
|
434
420
|
* @since Sitevision 2.6.1_09
|
|
421
|
+
* @deprecated ExceptionSuppressingCollection is not supported, this method deprecated and will be removed in a future version of Sitevision
|
|
435
422
|
*/
|
|
436
423
|
getExceptionSuppressingCollection(
|
|
437
424
|
aCollection: Collection | unknown[]
|
|
438
425
|
): ExceptionSuppressingCollection;
|
|
439
426
|
|
|
440
427
|
/**
|
|
441
|
-
*
|
|
442
|
-
* @param
|
|
443
|
-
* @return
|
|
428
|
+
* Deprecated get method for deprecated ExceptionSuppressingIterator.
|
|
429
|
+
* @param aIterator an iterator to be decorated by a ExceptionSuppressingIterator
|
|
430
|
+
* @return a deprecated ExceptionSuppressingIterator, or null if aIterator is null.
|
|
444
431
|
* @since Sitevision 2.6.1_09
|
|
432
|
+
* @deprecated ExceptionSuppressingIterator is not supported, this method deprecated and will be removed in a future version of Sitevision
|
|
445
433
|
*/
|
|
446
434
|
getExceptionSuppressingIterator(
|
|
447
|
-
|
|
435
|
+
aIterator: Iterator
|
|
448
436
|
): ExceptionSuppressingIterator;
|
|
449
437
|
|
|
450
438
|
/**
|
|
@@ -18,7 +18,7 @@ import type { String } from "../../types/java/lang/String";
|
|
|
18
18
|
* <p style="margin-top:0; margin-bottom:10px">
|
|
19
19
|
* <em>The upside of this is that you get caching and such "for free" and you don't have to include or use any Velocity jar
|
|
20
20
|
* when creating your portlet application (war file). You will also avoid possible Velocity.init() caveats and such.
|
|
21
|
-
* The possible downside is that the Velocity engine
|
|
21
|
+
* The possible downside is that the Velocity engine and its features potentially can be replaced at
|
|
22
22
|
* any time (i.e. whenever Sitevision is updated).</em>
|
|
23
23
|
* </p>
|
|
24
24
|
* <p style="margin-top:0; margin-bottom:10px">
|
|
@@ -50,13 +50,13 @@ import type { String } from "../../types/java/lang/String";
|
|
|
50
50
|
* super.init(portletConfig);
|
|
51
51
|
*
|
|
52
52
|
* template =
|
|
53
|
-
* " Current request is: $request <br
|
|
54
|
-
* " Utils is: $sitevisionUtils <br
|
|
55
|
-
* " Session is: $jcrSession <br
|
|
56
|
-
* " VelocityEvaluator is: $velocityEvaluator <br
|
|
57
|
-
* " <br
|
|
53
|
+
* " Current request is: $request <br> " +
|
|
54
|
+
* " Utils is: $sitevisionUtils <br> " +
|
|
55
|
+
* " Session is: $jcrSession <br> " +
|
|
56
|
+
* " VelocityEvaluator is: $velocityEvaluator <br> " +
|
|
57
|
+
* " <br> " +
|
|
58
58
|
* " #set($count = 1) " +
|
|
59
|
-
* " This is written with the VelocityEvaluator: <br
|
|
59
|
+
* " This is written with the VelocityEvaluator: <br> " +
|
|
60
60
|
* " <div style=\"margin:0 20px\"> " +
|
|
61
61
|
* " $velocityEvaluator.evaluate($evaluateThis) " +
|
|
62
62
|
* " </div> ";
|
|
@@ -105,6 +105,7 @@ import type { String } from "../../types/java/lang/String";
|
|
|
105
105
|
* </p>
|
|
106
106
|
* @author Magnus Lövgren
|
|
107
107
|
* @since Sitevision 3.0
|
|
108
|
+
* @deprecated portlet applications are the legacy way of extending Sitevision.
 WebApp/RESTApp technique should be used instead as of Sitevision 5. This class will be removed in a future version of Sitevision.
|
|
108
109
|
*/
|
|
109
110
|
export interface VelocityRenderer {
|
|
110
111
|
/**
|
|
@@ -190,7 +191,7 @@ export interface VelocityRenderer {
|
|
|
190
191
|
/**
|
|
191
192
|
* Renders a Velocity template string.
|
|
192
193
|
* @param aContext a context with mappings needed by aTemplate (Note! this must be an instance created via any of the methods above,
 a custom VelocityContext implementation is not allowed).
|
|
193
|
-
* @param aTemplate
|
|
194
|
+
* @param aTemplate a String containing the Velocity code to be evaluated
|
|
194
195
|
* @throws IllegalArgumentException if aTemplate is <code>null</code>, if aContext is <code>null</code> or not created via VelocityRenderer
|
|
195
196
|
* @throws VelocityException if parsing/evaluation of aTemplate fails
|
|
196
197
|
* @throws IOException if an I/O exception occurs during the rendering process
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get methods for accessing field constants defined in {@link senselogic.sitevision.api.script.proxy.ExceptionSuppressingProxy}.
|
|
2
|
+
* Get methods for accessing field constants defined in deprecated {@link senselogic.sitevision.api.script.proxy.ExceptionSuppressingProxy}.
|
|
3
3
|
*
|
|
4
4
|
* <p>
|
|
5
5
|
* The sole purpose of this interface is to provide access to {@link senselogic.sitevision.api.script.proxy.ExceptionSuppressingProxy}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* </p>
|
|
8
8
|
* @author Magnus Lövgren
|
|
9
9
|
* @since Sitevision 3.6.2
|
|
10
|
+
* @deprecated this interface is deprecated and will be removed in a future version of Sitevision
|
|
10
11
|
*/
|
|
11
12
|
export type ExceptionSuppressingProxyConstants = {
|
|
12
13
|
/**
|
|
@@ -8,48 +8,17 @@ import type { String } from "../../../../../../java/lang/String";
|
|
|
8
8
|
* context they were created for.
|
|
9
9
|
* </p>
|
|
10
10
|
* @author Magnus Lövgren
|
|
11
|
-
* @see VelocityRenderer
|
|
12
|
-
* @since Sitevision 2.7_06
|
|
13
11
|
* @since Sitevision 3.0
|
|
14
12
|
*/
|
|
15
13
|
export type VelocityEvaluator = {
|
|
16
14
|
/**
|
|
17
|
-
* Renders a template that is parsed/evaluated by Velocity.
|
|
15
|
+
* Renders a template string that is parsed/evaluated by Velocity.
|
|
18
16
|
*
|
|
19
17
|
* <p>
|
|
20
18
|
* <strong>Note!</strong> This method is intended for usage from within Velocity only
|
|
21
|
-
* (e.g. <code>$aVelocityEvaluatorInstance.evaluate($aTemplateString)</code>)
|
|
22
|
-
* see {@link VelocityRenderer} for an example.
|
|
19
|
+
* (e.g. <code>$aVelocityEvaluatorInstance.evaluate($aTemplateString)</code>).
|
|
23
20
|
* </p>
|
|
24
|
-
*
|
|
25
|
-
* <p>
|
|
26
|
-
* <em>
|
|
27
|
-
* <strong>Tip when evaluating velocity files in a custom portlet!</strong>
|
|
28
|
-
* The path to your portlet's velocity file(-s) are class loader dependant and therefore likely to have
|
|
29
|
-
* it's root from the "classes" folder of your war. An example, your portlet war looks like this:
|
|
30
|
-
* </em>
|
|
31
|
-
* </p>
|
|
32
|
-
* <pre><em>
|
|
33
|
-
* [META-INF]
|
|
34
|
-
* |- context.xml
|
|
35
|
-
* [WEB-INF]
|
|
36
|
-
* |- portlet.xml
|
|
37
|
-
* |- web.xml
|
|
38
|
-
* |- [classes]
|
|
39
|
-
* | |- [com]
|
|
40
|
-
* | |- [mycompany]
|
|
41
|
-
* | |- [myportlet]
|
|
42
|
-
* | |- MyPortlet.class
|
|
43
|
-
* |- [resources]
|
|
44
|
-
* |- myvelocityfile.vm
|
|
45
|
-
* </em></pre>
|
|
46
|
-
* <p>
|
|
47
|
-
* <em>
|
|
48
|
-
* If you want to use a VelocityEvaluator to evaluate the <code>myvelocityfile.vm</code> in the <code>MyPortlet.class</code>,
|
|
49
|
-
* your velocity file path would likely be <code>"../resources/myvelocityfile.vm"</code>.
|
|
50
|
-
* </em>
|
|
51
|
-
* </p>
|
|
52
|
-
* @param aTemplate a String containing the Velocity code to be parsed or a path to a velocity template file
 (suffix must be ".vm" and path must not contain any space character)
|
|
21
|
+
* @param aTemplate a String containing the Velocity code to be evaluated
|
|
53
22
|
*/
|
|
54
23
|
evaluate(aTemplate: String | string): void;
|
|
55
24
|
};
|
|
@@ -10,7 +10,7 @@ import type { Requester } from "../../../../../../server/Requester";
|
|
|
10
10
|
*/
|
|
11
11
|
export type RequesterChainable = Requester & {
|
|
12
12
|
/**
|
|
13
|
-
* Invoked when a {@link Requester} was successfully executed.
|
|
13
|
+
* Invoked when a {@link Requester} was successfully executed (response with a status in the 2xx series).
|
|
14
14
|
*
|
|
15
15
|
* <p>
|
|
16
16
|
* The callback is invoked with three optional arguments:
|
|
@@ -56,7 +56,7 @@ export type RequesterChainable = Requester & {
|
|
|
56
56
|
* </li>
|
|
57
57
|
* <li>
|
|
58
58
|
* <em>body</em> [@since Sitevision 4.2.3] - the potential JSON body of the response.
|
|
59
|
-
* <em>(Note! Will only be available for responses
|
|
59
|
+
* <em>(Note! Will only be available for responses with a Content-Type header indicating the JSON format)</em>
|
|
60
60
|
* </li>
|
|
61
61
|
* <li>
|
|
62
62
|
* <em>headers</em> [@since Sitevision 4.5.1] - the potential response headers.
|
package/types/senselogic/sitevision/api/script/proxy/ExceptionSuppressingCollection/index.d.ts
CHANGED
|
@@ -2,94 +2,15 @@ import type { Iterator } from "../../../../../../java/util/Iterator";
|
|
|
2
2
|
import type { Collection } from "../../../../../../java/util/Collection";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* iterator invocations.
|
|
7
|
-
*
|
|
8
|
-
* <p>
|
|
9
|
-
* The sole purpose of the <code>ExceptionSuppressingCollection</code> is to provide easy access to a decorated iterator
|
|
10
|
-
* (i.e. an {@link ExceptionSuppressingIterator}). You should <em>not</em> create a collection of exception suppressing proxys
|
|
11
|
-
* (i.e. <code>Collection<ExceptionSuppressingProxy></code>) yourself. You should use <code>ExceptionSuppressingCollection</code>
|
|
12
|
-
* with your "regular" collection since the actual proxying is done by the iterator itself.
|
|
13
|
-
* </p>
|
|
14
|
-
* <p>
|
|
15
|
-
* Note that the <code>next</code> method of the interator returns an instance of a <em>Dynamic proxy</em> so not all methods can be invoked
|
|
16
|
-
* directly on the returned object. To invoke a method that is not proxied (i.e. a method not declared in an interface the object implements),
|
|
17
|
-
* you must extract the "real" object from the proxy and use that reference when invoking the method. See {@link ExceptionSuppressingIterator}
|
|
18
|
-
* for more information about the iterator and {@link ExceptionSuppressingProxy} for more information about dynamic proxies and how to extract
|
|
19
|
-
* "real" object.
|
|
20
|
-
* </p>
|
|
21
|
-
*
|
|
22
|
-
* <p>
|
|
23
|
-
* <strong>Important note! </strong>This interface is intended to be used <em>only</em> in contexts where exceptions when iterating a
|
|
24
|
-
* collection will cause <em>serious</em> trouble if they arise and the context doesn't provide proper exception handling
|
|
25
|
-
* (e.g. when rendering a Velocity template). Suppressing exceptions is generally a bad idea and using this decorator will affect performance.
|
|
26
|
-
* Hence, this interface should only be used where the upsides with suppressing exceptions outweighs the downsides.
|
|
27
|
-
* This interface should be used only as a temporary patch/solution until the "real" problem causing the exception has been solved.
|
|
28
|
-
* </p>
|
|
29
|
-
*
|
|
30
|
-
* <p>
|
|
31
|
-
* An instance of the Sitevision class implementing this interface can be obtained via
|
|
32
|
-
* {@link senselogic.sitevision.api.Utils#getExceptionSuppressingCollection(java.util.Collection)}.
|
|
33
|
-
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the <code>Utils</code> interface.
|
|
34
|
-
* </p>
|
|
35
|
-
*
|
|
36
|
-
* <p>
|
|
37
|
-
* ----------------------------------------------------------------------------------------------------
|
|
38
|
-
* </p>
|
|
39
|
-
*
|
|
40
|
-
* <p>
|
|
41
|
-
* <strong>Example of how <code>ExceptionSuppressingCollection</code> could be used in Velocity:</strong>
|
|
42
|
-
* </p>
|
|
43
|
-
*
|
|
44
|
-
* <p>Case description:</p>
|
|
45
|
-
* <p>
|
|
46
|
-
* <em>You have a Velocity template where you iterate a collection. Sometimes a certain method throws an exception.
|
|
47
|
-
* The rendered output of the template gets corrupt whenever an exception is thrown and you have not yet tracked down the root
|
|
48
|
-
* cause of the exception. Until the root cause is found and the problem is fixed, you need a temporary solution that ignores
|
|
49
|
-
* exceptions to keep template output acceptable. Since the method is declared in an interface and implemented in the instance
|
|
50
|
-
* you're invoking, you're in sheer luck. You can decorate your collection with a <code>ExceptionSuppressingCollection</code>
|
|
51
|
-
* to get a decorated iterator. When interating, all returned elements are proxied by an <code>ExceptionSuppressingProxy</code>.
|
|
52
|
-
* Invoking the method through the proxy will suppress exceptions and you can diminish the output problems.
|
|
53
|
-
* Note that you should invoke the real object for all non-problematic methods and methods that can't be proxied
|
|
54
|
-
* (i.e. methods not declared in an interface). To get a reference to the real object,
|
|
55
|
-
* use {@link ExceptionSuppressingProxy#getProxiedObject()}.</em>
|
|
56
|
-
* </p>
|
|
57
|
-
* <p>
|
|
58
|
-
* This is what the code looks like before your temporary fix:
|
|
59
|
-
* </p>
|
|
60
|
-
* <pre><code>
|
|
61
|
-
* #foreach ($item in $myCollection)
|
|
62
|
-
* <p>
|
|
63
|
-
* $item.thisNeverThrowsExceptions()
|
|
64
|
-
* $item.thisMethodSometimesThrowsExceptions()
|
|
65
|
-
* </p>
|
|
66
|
-
* #end
|
|
67
|
-
* </code></pre>
|
|
68
|
-
* <p>
|
|
69
|
-
* This is how you could use an <code>ExceptionSuppressingCollection</code> to apply a temporary fix:
|
|
70
|
-
* </p>
|
|
71
|
-
* <pre><code>
|
|
72
|
-
* <em>## Decorate collection</em>
|
|
73
|
-
* #set ($decoratedCollection = $sitevisionUtils.getExceptionSuppressingCollection($myCollection))
|
|
74
|
-
*
|
|
75
|
-
* #foreach ($item in $decoratedCollection)
|
|
76
|
-
* <p>
|
|
77
|
-
* <em>## Get the real object and invoke non-problematic method as usual</em>
|
|
78
|
-
* #set ($realObject = $item.getProxiedObject())
|
|
79
|
-
*
|
|
80
|
-
* $realObject.thisNeverThrowsExceptions()
|
|
81
|
-
* $!item.thisMethodSometimesThrowsExceptions() <em>## Executed through a proxy, might return null</em>
|
|
82
|
-
* </p>
|
|
83
|
-
* #end
|
|
84
|
-
* </p>
|
|
85
|
-
* </code></pre>
|
|
5
|
+
* Deprecated interface that will be removed in a future version of Sitevision.
|
|
86
6
|
* @author Magnus Lövgren
|
|
87
7
|
* @since Sitevision 2.6.1_09
|
|
8
|
+
* @deprecated this interface is deprecated and will be removed in a future version of Sitevision
|
|
88
9
|
*/
|
|
89
10
|
export type ExceptionSuppressingCollection = Collection & {
|
|
90
11
|
/**
|
|
91
|
-
* Returns
|
|
92
|
-
* @return a {@link ExceptionSuppressingIterator}
|
|
12
|
+
* Returns a ExceptionSuppressingProxy Iterator for the decorated collection.
|
|
13
|
+
* @return a {@link ExceptionSuppressingIterator}
|
|
93
14
|
*/
|
|
94
15
|
iterator(): Iterator;
|
|
95
16
|
};
|
package/types/senselogic/sitevision/api/script/proxy/ExceptionSuppressingIterator/index.d.ts
CHANGED
|
@@ -3,32 +3,10 @@ import type { ExceptionSuppressingProxy } from "../ExceptionSuppressingProxy";
|
|
|
3
3
|
import type { Iterator } from "../../../../../../java/util/Iterator";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* invocation will throw an exception.
|
|
8
|
-
*
|
|
9
|
-
* <p>
|
|
10
|
-
* This iterator is of type <code>ExceptionSuppressingProxy</code> that is an implementation of a <em>Dynamic proxy</em> so not all
|
|
11
|
-
* methods can be directly invoked on objects retrieved by the <code>next</code> method. See {@link ExceptionSuppressingCollection}
|
|
12
|
-
* for an example of how this iterator can be used easily from Velocity and how to invoke methods not declared in an interface.
|
|
13
|
-
* See {@link ExceptionSuppressingProxy} for more information about dynamic proxies.
|
|
14
|
-
* </p>
|
|
15
|
-
* <p>
|
|
16
|
-
* <strong>Important note! </strong>This interface is intended to be used <em>only</em> in contexts where exceptions thrown during iteration will
|
|
17
|
-
* cause <em>serious</em> trouble if they arise and the context doesn't provide proper exception handling (e.g. when executing a Velocity template).
|
|
18
|
-
* Suppressing exceptions is generally a bad idea and using this iterator will affect performance.
|
|
19
|
-
* Hence, this interface should only be used where the upsides with suppressing exceptions far outweighs the downsides.
|
|
20
|
-
* This interface should be used only as a temporary patch/solution until the "real" problem causing the exception has been solved.
|
|
21
|
-
* </p>
|
|
22
|
-
*
|
|
23
|
-
* <p>
|
|
24
|
-
* An instance of the Sitevision class implementing this interface can be obtained directly via
|
|
25
|
-
* {@link senselogic.sitevision.api.Utils#getExceptionSuppressingIterator(java.util.Iterator)}
|
|
26
|
-
* or indirectly via {@link senselogic.sitevision.api.Utils#getExceptionSuppressingCollection(java.util.Collection)}.
|
|
27
|
-
* You would typically use the latter if you should iterate a collection with the Velocity #foreach loop.
|
|
28
|
-
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the <code>Utils</code> interface.
|
|
29
|
-
* </p>
|
|
6
|
+
* Deprecated interface that will be removed in a future version of Sitevision.
|
|
30
7
|
* @author Magnus Lövgren
|
|
31
8
|
* @since Sitevision 2.6.1_09
|
|
9
|
+
* @deprecated this interface is deprecated and will be removed in a future version of Sitevision
|
|
32
10
|
*/
|
|
33
11
|
export type ExceptionSuppressingIterator = Iterator & {
|
|
34
12
|
/**
|
|
@@ -36,47 +14,22 @@ export type ExceptionSuppressingIterator = Iterator & {
|
|
|
36
14
|
* if <code>next</code> would return an element rather than throwing an exception.)
|
|
37
15
|
*
|
|
38
16
|
* <p>
|
|
39
|
-
*
|
|
17
|
+
* This method will never throw an exception
|
|
40
18
|
* </p>
|
|
41
19
|
* @return <code>true</code> if the decorated iterator has more elements, <code>false</code> if not or if an exception is thrown
 by the decorated iterator
|
|
42
20
|
*/
|
|
43
21
|
hasNext(): boolean;
|
|
44
22
|
|
|
45
23
|
/**
|
|
46
|
-
* Returns a
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* <p>
|
|
50
|
-
* <strong>Note!</strong> The returned element will be embedded in an <code>ExceptionSuppressingProxy</code> that will be reused for
|
|
51
|
-
* <em>all</em> next() invocations on this iterator. In other words, the proxied item of the returned element will change,
|
|
52
|
-
* but never the returned element itself. This implies that you shouldn't keep references to an item retrieved from a next()
|
|
53
|
-
* invocation during iteration. If you do, don't be surprised if the element contains something else than it did when you set the reference...
|
|
54
|
-
* </p>
|
|
55
|
-
*
|
|
56
|
-
* <p>
|
|
57
|
-
* This method will never throw an exception.
|
|
58
|
-
* </p>
|
|
59
|
-
* <p>
|
|
60
|
-
* <strong>Note! </strong>Be aware of <code>null</code> items since they're never proxied. If the underlying collection contains a
|
|
61
|
-
* <code>null</code> item, this iterator will just return <code>null</code>, not a proxy. In other words: even though this method
|
|
62
|
-
* won't throw any exceptions, invoking a method on the returned object might throw a <code>NullPointerException</code>.
|
|
63
|
-
* </p>
|
|
64
|
-
* @return the next element, or <code>null</code> if an exception is thrown.
|
|
24
|
+
* Returns a ExceptionSuppressingProxy for the next element of the decorated iterator.
|
|
25
|
+
* @return the next element of the decorated iterator, or <code>null</code> if an exception is thrown.
|
|
65
26
|
*/
|
|
66
27
|
next(): ExceptionSuppressingProxy;
|
|
67
28
|
|
|
68
29
|
/**
|
|
69
|
-
* Tries to remove from the
|
|
70
|
-
* This method can be called only once per call to <code>next</code>. The behavior of an iterator is unspecified if
|
|
71
|
-
* the underlying collection is modified while the iteration is in progress in any way other than by calling this method.
|
|
72
|
-
*
|
|
73
|
-
* <p>
|
|
74
|
-
* This method will never throw an exception.
|
|
75
|
-
* </p>
|
|
30
|
+
* Tries to remove from the decorated iterator.
|
|
76
31
|
* <p>
|
|
77
|
-
*
|
|
78
|
-
* or if the underlying collection doesn't support removal (i.e. <code>UnsupportedOperationException</code> thrown by the
|
|
79
|
-
* decorated iterator is catched by this iterator).
|
|
32
|
+
* This method will never throw an exception.
|
|
80
33
|
* </p>
|
|
81
34
|
|
|
82
35
|
*/
|
|
@@ -3,90 +3,27 @@ import type { Object } from "../../../../../../java/lang/Object";
|
|
|
3
3
|
import type { ExceptionSuppressingProxyConstants } from "../../../render/velocity/VelocityAccess.ExceptionSuppressingProxyConstants";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* will throw an exception.
|
|
8
|
-
*
|
|
9
|
-
* <p>
|
|
10
|
-
* This interface is an exception suppressing implementation of a so called
|
|
11
|
-
* <em><a href="http://docs.oracle.com/javase/8/docs/technotes/guides/reflection/proxy.html">Dynamic proxy</a></em>.
|
|
12
|
-
* This means it will proxy all methods of an object that are declared in an interface implemented by the object.
|
|
13
|
-
* If a method invocation through this proxy throws an <code>Exception</code>, it will be catched and the default value will be returned
|
|
14
|
-
* (e.g. <code>null</code>, <code>0</code>, <code>false</code> etc).
|
|
15
|
-
* </p>
|
|
16
|
-
*
|
|
17
|
-
* <p>
|
|
18
|
-
* <strong>Important note! </strong>This interface is intended to be used <em>only</em> in contexts where exceptions will cause <em>serious</em>
|
|
19
|
-
* trouble if they arise and the context doesn't provide proper exception handling (e.g. when executing a Velocity template).
|
|
20
|
-
* Suppressing exceptions is generally a <em>really</em> bad idea and using this proxy will affect performance.
|
|
21
|
-
* Hence, this interface should only be used where the upsides with suppressing exceptions far outweighs the downsides.
|
|
22
|
-
* This interface should be used only as a temporary patch/solution until the "real" problem causing the exception has been solved.
|
|
23
|
-
* </p>
|
|
24
|
-
*
|
|
25
|
-
* <p>
|
|
26
|
-
* The state of an ExceptionSuppressingProxy is available at all times and updated for each method invocation
|
|
27
|
-
* (except for invocations of methods declared in this interface).
|
|
28
|
-
* If last method invocation resulted in a thrown exception the proxy status will be {@link #EXCEPTION_THROWN_STATUS}
|
|
29
|
-
* and the exception will be available via {@link #getCurrentException()}.
|
|
30
|
-
* </p>
|
|
31
|
-
*
|
|
32
|
-
* <p>
|
|
33
|
-
* An instance of the Sitevision class implementing this interface can be obtained via
|
|
34
|
-
* {@link senselogic.sitevision.api.Utils#getExceptionSuppressingProxy(Object)}.
|
|
35
|
-
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the <code>Utils</code> interface.
|
|
36
|
-
* </p>
|
|
37
|
-
*
|
|
38
|
-
* <p>
|
|
39
|
-
* ----------------------------------------------------------------------------------------------------
|
|
40
|
-
* </p>
|
|
41
|
-
*
|
|
42
|
-
* <p>
|
|
43
|
-
* <strong>Example of how <code>ExceptionSuppressingProxy</code> could be used in Velocity:</strong>
|
|
44
|
-
* </p>
|
|
45
|
-
*
|
|
46
|
-
* <p>Case description:</p>
|
|
47
|
-
* <p>
|
|
48
|
-
* <em>You have a Velocity template where a certain method invocation sometimes throws an exception.
|
|
49
|
-
* The rendered output of the template gets corrupt whenever an exception is thrown and you have not yet tracked down the root cause
|
|
50
|
-
* of the exception. Until the root cause is found and the problem is fixed, you need a temporary solution that ignores exceptions
|
|
51
|
-
* to keep template output acceptable. Since the method is declared in an interface and implemented in the instance you're invoking,
|
|
52
|
-
* you're in sheer luck. You can use an <code>ExceptionSuppressingProxy</code> to suppress exceptions in order to diminish output
|
|
53
|
-
* problems.</em><p>This is what the code looks like before your temporary fix:
|
|
54
|
-
* </p>
|
|
55
|
-
* <pre><code>
|
|
56
|
-
* <p>
|
|
57
|
-
* $myObject.thisNeverThrowsExceptions()
|
|
58
|
-
* $myObject.thisMethodSometimesThrowsExceptions() <em>## This method is declared in an interface, hence can be proxied</em>
|
|
59
|
-
* </p>
|
|
60
|
-
* </code></pre>
|
|
61
|
-
* This is how you could use an <code>ExceptionSuppressingProxy</code> to apply a temporary fix:<pre><code>
|
|
62
|
-
* <p>
|
|
63
|
-
* $myObject.thisNeverThrowsExceptions()
|
|
64
|
-
*
|
|
65
|
-
* <em>## Get an ExceptionSuppressingProxy instance for myObject</em>
|
|
66
|
-
* #set ($proxy = $sitevisionUtils.getExceptionSuppressingProxy($myObject))
|
|
67
|
-
*
|
|
68
|
-
* $!proxy.thisMethodSometimesThrowsExceptions() <em>## Method invoked through a proxy, might return null</em>
|
|
69
|
-
* </p>
|
|
70
|
-
* </code></pre>
|
|
6
|
+
* Deprecated interface that will be removed in a future version of Sitevision.
|
|
71
7
|
* @author Magnus Lövgren
|
|
72
8
|
* @since Sitevision 2.6.1_09
|
|
9
|
+
* @deprecated this interface is deprecated and will be removed in a future version of Sitevision
|
|
73
10
|
*/
|
|
74
11
|
export type ExceptionSuppressingProxy = ExceptionSuppressingProxyConstants & {
|
|
75
12
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @return {@link #
|
|
13
|
+
* Always returns {@link #NO_EXCEPTION_THROWN_STATUS}.
|
|
14
|
+
* @return {@link #NO_EXCEPTION_THROWN_STATUS}
|
|
78
15
|
*/
|
|
79
16
|
getCurrentStatus(): number;
|
|
80
17
|
|
|
81
18
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @return
|
|
19
|
+
* Always returns null.
|
|
20
|
+
* @return null
|
|
84
21
|
*/
|
|
85
22
|
getCurrentException(): Exception;
|
|
86
23
|
|
|
87
24
|
/**
|
|
88
|
-
* Returns the
|
|
89
|
-
* @return the
|
|
25
|
+
* Returns the object this ExceptionSuppressingProxy was created for.
|
|
26
|
+
* @return the decorated object
|
|
90
27
|
*/
|
|
91
28
|
getProxiedObject(): unknown;
|
|
92
29
|
|