1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jakarta.faces.context;
20
21 import jakarta.faces.lifecycle.ClientWindow;
22
23 import java.io.IOException;
24 import java.io.OutputStream;
25 import java.io.Writer;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.Locale;
29 import java.util.Map;
30 import java.util.Set;
31
32
33
34
35 public abstract class ExternalContext
36 {
37 public static final String BASIC_AUTH = "BASIC";
38 public static final String CLIENT_CERT_AUTH = "CLIENT_CERT";
39 public static final String DIGEST_AUTH = "DIGEST";
40 public static final String FORM_AUTH = "FORM";
41
42
43
44
45
46
47
48
49
50 public void addResponseCookie(String name, String value, Map<String, Object> properties)
51 {
52 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
53
54 if (ctx == null)
55 {
56 throw new UnsupportedOperationException();
57 }
58
59 ctx.addResponseCookie(name, value, properties);
60 }
61
62
63
64
65
66
67
68
69 public void addResponseHeader(String name, String value)
70 {
71 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
72
73 if (ctx == null)
74 {
75 throw new UnsupportedOperationException();
76 }
77
78 ctx.addResponseHeader(name, value);
79 }
80
81 public abstract void dispatch(String path) throws IOException;
82
83 public abstract String encodeActionURL(String url);
84
85
86
87
88
89
90
91
92 public String encodeBookmarkableURL(String baseUrl, Map<String,List<String>> parameters)
93 {
94 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
95
96 if (ctx == null)
97 {
98 throw new UnsupportedOperationException();
99 }
100
101 return ctx.encodeBookmarkableURL(baseUrl, parameters);
102 }
103
104 public abstract String encodeNamespace(String name);
105
106
107
108
109
110 public String encodePartialActionURL(String url)
111 {
112
113 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
114
115 if (ctx == null)
116 {
117 throw new UnsupportedOperationException();
118 }
119
120 return ctx.encodePartialActionURL(url);
121 }
122
123
124
125
126
127
128
129
130 public String encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
131 {
132 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
133
134 if (ctx == null)
135 {
136 throw new UnsupportedOperationException();
137 }
138
139 return ctx.encodeRedirectURL(baseUrl, parameters);
140 }
141
142 public abstract String encodeResourceURL(String url);
143
144 public abstract Map<String, Object> getApplicationMap();
145
146 public abstract String getAuthType();
147
148 public abstract Object getContext();
149
150
151
152
153
154
155
156
157 public String getContextName()
158 {
159 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
160
161 if (ctx == null)
162 {
163 throw new UnsupportedOperationException();
164 }
165
166 return ctx.getContextName();
167 }
168
169
170
171
172 public Flash getFlash()
173 {
174 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
175
176 if (ctx == null)
177 {
178 throw new UnsupportedOperationException();
179 }
180
181 return ctx.getFlash();
182 }
183
184 public abstract String getInitParameter(String name);
185
186 public abstract Map<String,String> getInitParameterMap();
187
188
189
190
191 public String getMimeType(String file)
192 {
193 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
194
195 if (ctx == null)
196 {
197 throw new UnsupportedOperationException();
198 }
199
200 return ctx.getMimeType(file);
201 }
202
203
204
205
206 public String getRealPath(String path)
207 {
208 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
209
210 if (ctx == null)
211 {
212 throw new UnsupportedOperationException();
213 }
214
215 return ctx.getRealPath(path);
216 }
217
218 public abstract String getRemoteUser();
219
220 public abstract Object getRequest();
221
222 public String getRequestCharacterEncoding()
223 {
224 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
225
226 if (ctx == null)
227 {
228 throw new UnsupportedOperationException();
229 }
230
231 return ctx.getRequestCharacterEncoding();
232 }
233
234
235
236
237
238
239
240 public int getRequestContentLength()
241 {
242 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
243
244 if (ctx == null)
245 {
246 throw new UnsupportedOperationException();
247 }
248
249 return ctx.getRequestContentLength();
250 }
251
252 public String getRequestContentType()
253 {
254 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
255
256 if (ctx == null)
257 {
258 throw new UnsupportedOperationException();
259 }
260
261 return ctx.getRequestContentType();
262 }
263
264 public abstract String getRequestContextPath();
265
266 public abstract Map<String, Object> getRequestCookieMap();
267
268 public abstract Map<String, String> getRequestHeaderMap();
269
270 public abstract Map<String, String[]> getRequestHeaderValuesMap();
271
272 public abstract Locale getRequestLocale();
273
274 public abstract Iterator<Locale> getRequestLocales();
275
276 public abstract Map<String, Object> getRequestMap();
277
278 public abstract Map<String, String> getRequestParameterMap();
279
280 public abstract Iterator<String> getRequestParameterNames();
281
282 public abstract Map<String, String[]> getRequestParameterValuesMap();
283
284 public abstract String getRequestPathInfo();
285
286
287
288
289 public String getRequestScheme()
290 {
291 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
292
293 if (ctx == null)
294 {
295 throw new UnsupportedOperationException();
296 }
297
298 return ctx.getRequestScheme();
299 }
300
301
302
303
304 public String getRequestServerName()
305 {
306 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
307
308 if (ctx == null)
309 {
310 throw new UnsupportedOperationException();
311 }
312
313 return ctx.getRequestServerName();
314 }
315
316
317
318
319 public int getRequestServerPort()
320 {
321 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
322
323 if (ctx == null)
324 {
325 throw new UnsupportedOperationException();
326 }
327
328 return ctx.getRequestServerPort();
329 }
330
331 public abstract String getRequestServletPath();
332
333 public abstract java.net.URL getResource(String path) throws java.net.MalformedURLException;
334
335 public abstract java.io.InputStream getResourceAsStream(String path);
336
337 public abstract Set<String> getResourcePaths(String path);
338
339 public abstract Object getResponse();
340
341
342
343
344
345
346
347 public int getResponseBufferSize()
348 {
349 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
350
351 if (ctx == null)
352 {
353 throw new UnsupportedOperationException();
354 }
355
356 return ctx.getResponseBufferSize();
357 }
358
359 public String getResponseCharacterEncoding()
360 {
361 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
362
363 if (ctx == null)
364 {
365 throw new UnsupportedOperationException("JSF 1.2 : figure out how to tell if this is a Portlet request");
366 }
367
368 return ctx.getResponseCharacterEncoding();
369 }
370
371
372
373
374
375
376 public String getResponseContentType()
377 {
378 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
379
380 if (ctx == null)
381 {
382 throw new UnsupportedOperationException();
383 }
384
385 return ctx.getResponseContentType();
386 }
387
388
389
390
391 public OutputStream getResponseOutputStream() throws IOException
392 {
393 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
394
395 if (ctx == null)
396 {
397 throw new UnsupportedOperationException();
398 }
399
400 return ctx.getResponseOutputStream();
401 }
402
403
404
405
406 public Writer getResponseOutputWriter() throws IOException
407 {
408 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
409
410 if (ctx == null)
411 {
412 throw new UnsupportedOperationException();
413 }
414
415 return ctx.getResponseOutputWriter();
416 }
417
418 public abstract Object getSession(boolean create);
419
420 public abstract Map<String, Object> getSessionMap();
421
422 public abstract java.security.Principal getUserPrincipal();
423
424
425
426
427 public void invalidateSession()
428 {
429 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
430
431 if (ctx == null)
432 {
433 throw new UnsupportedOperationException();
434 }
435
436 ctx.invalidateSession();
437 }
438
439
440
441
442 public boolean isResponseCommitted()
443 {
444 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
445
446 if (ctx == null)
447 {
448 throw new UnsupportedOperationException();
449 }
450
451 return ctx.isResponseCommitted();
452 }
453
454 public abstract boolean isUserInRole(String role);
455
456
457
458
459 public abstract void log(String message);
460
461
462
463
464 public abstract void log(String message, Throwable exception);
465
466 public abstract void redirect(String url) throws java.io.IOException;
467
468
469
470
471
472
473
474 public void responseFlushBuffer() throws IOException
475 {
476 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
477
478 if (ctx == null)
479 {
480 throw new UnsupportedOperationException();
481 }
482
483 ctx.responseFlushBuffer();
484 }
485
486
487
488
489
490 public void responseReset()
491 {
492 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
493
494 if (ctx == null)
495 {
496 throw new UnsupportedOperationException();
497 }
498
499 ctx.responseReset();
500 }
501
502
503
504
505
506
507
508
509
510 public void responseSendError(int statusCode, String message) throws IOException
511 {
512 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
513
514 if (ctx == null)
515 {
516 throw new UnsupportedOperationException();
517 }
518
519 ctx.responseSendError(statusCode, message);
520 }
521
522
523
524
525
526
527
528 public void setRequest(Object request)
529 {
530 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
531
532 if (ctx == null)
533 {
534 throw new UnsupportedOperationException();
535 }
536
537 ctx.setRequest(request);
538 }
539
540
541
542
543
544
545
546
547 public void setRequestCharacterEncoding(java.lang.String encoding)
548 throws java.io.UnsupportedEncodingException
549 {
550 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
551
552 if (ctx == null)
553 {
554 throw new UnsupportedOperationException();
555 }
556
557 ctx.setRequestCharacterEncoding(encoding);
558 }
559
560
561
562
563
564
565
566 public void setResponse(Object response)
567 {
568 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
569
570 if (ctx == null)
571 {
572 throw new UnsupportedOperationException();
573 }
574
575 ctx.setResponse(response);
576 }
577
578
579
580
581
582
583
584 public void setResponseBufferSize(int size)
585 {
586 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
587
588 if (ctx == null)
589 {
590 throw new UnsupportedOperationException();
591 }
592
593 ctx.setResponseBufferSize(size);
594 }
595
596
597
598
599
600
601
602 public void setResponseCharacterEncoding(String encoding)
603 {
604 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
605
606 if (ctx == null)
607 {
608 throw new UnsupportedOperationException();
609 }
610
611 ctx.setResponseCharacterEncoding(encoding);
612 }
613
614
615
616
617
618
619
620 public void setResponseContentLength(int length)
621 {
622 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
623
624 if (ctx == null)
625 {
626 throw new UnsupportedOperationException();
627 }
628
629 ctx.setResponseContentLength(length);
630 }
631
632
633
634
635
636
637
638 public void setResponseContentType(String contentType)
639 {
640 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
641
642 if (ctx == null)
643 {
644 throw new UnsupportedOperationException();
645 }
646
647 ctx.setResponseContentType(contentType);
648 }
649
650
651
652
653
654
655
656
657 public void setResponseHeader(String name, String value)
658 {
659 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
660
661 if (ctx == null)
662 {
663 throw new UnsupportedOperationException();
664 }
665
666 ctx.setResponseHeader(name, value);
667 }
668
669
670
671
672
673
674
675 public void setResponseStatus(int statusCode)
676 {
677 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
678
679 if (ctx == null)
680 {
681 throw new UnsupportedOperationException();
682 }
683
684 ctx.setResponseStatus(statusCode);
685 }
686
687
688
689
690
691
692 public boolean isSecure()
693 {
694 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
695
696 if (ctx == null)
697 {
698 throw new UnsupportedOperationException();
699 }
700
701 return ctx.isSecure();
702 }
703
704
705
706
707
708
709 public int getSessionMaxInactiveInterval()
710 {
711 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
712
713 if (ctx == null)
714 {
715 throw new UnsupportedOperationException();
716 }
717
718 return ctx.getSessionMaxInactiveInterval();
719 }
720
721
722
723
724
725
726 public void setSessionMaxInactiveInterval(int interval)
727 {
728 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
729
730 if (ctx == null)
731 {
732 throw new UnsupportedOperationException();
733 }
734
735 ctx.setSessionMaxInactiveInterval(interval);
736 }
737
738
739
740
741
742 public ClientWindow getClientWindow()
743 {
744 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
745
746 if (ctx == null)
747 {
748
749
750
751 return null;
752 }
753
754 return ctx.getClientWindow();
755 }
756
757
758
759
760
761 public void setClientWindow(ClientWindow window)
762 {
763
764
765
766
767
768
769
770
771
772
773
774 }
775
776
777
778
779
780
781 public String getSessionId(boolean create)
782 {
783 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
784
785 if (ctx == null)
786 {
787 throw new UnsupportedOperationException();
788 }
789
790 return ctx.getSessionId(create);
791 }
792
793
794
795
796
797 public String getApplicationContextPath()
798 {
799 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
800
801 if (ctx == null)
802 {
803 throw new UnsupportedOperationException();
804 }
805
806 return ctx.getApplicationContextPath();
807 }
808
809
810
811
812
813
814 public abstract String encodeWebsocketURL(String url);
815
816 }