1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.orchestra.requestParameterProvider.jsf;
20
21 import java.util.List;
22 import java.util.Map;
23
24 import javax.faces.context.ExternalContext;
25 import javax.faces.context.ExternalContextWrapper;
26
27 import org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterProviderManager;
28
29 public class RequestParameterExternalContextWrapper extends ExternalContextWrapper
30 {
31 private ExternalContext _delegate;
32
33 public RequestParameterExternalContextWrapper(ExternalContext delegate)
34 {
35 this._delegate = delegate;
36 }
37
38 @Override
39 public String encodeRedirectURL(String baseUrl,
40 Map<String, List<String>> parameters)
41 {
42 // Mojarra 2.1.3 does not call encodeURL internally, but MyFaces 2.0.x/2.1.x does.
43 // Anyway, the place to add Orchestra parameters for redirect should be here.
44 String url = super.encodeRedirectURL(baseUrl, parameters);
45 if (url != null)
46 {
47 url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
48 }
49 return url;
50 }
51
52 @Override
53 public ExternalContext getWrapped()
54 {
55 return _delegate;
56 }
57 }