提交 | 用户 | 时间
|
e7c126
|
1 |
/* |
H |
2 |
* Copyright 1999-2023 Alibaba Group Holding Ltd. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
|
|
17 |
package com.alibaba.nacos.console.paramcheck; |
|
18 |
|
|
19 |
import com.alibaba.nacos.common.paramcheck.ParamInfo; |
|
20 |
import com.alibaba.nacos.common.utils.StringUtils; |
|
21 |
import com.alibaba.nacos.core.paramcheck.AbstractHttpParamExtractor; |
|
22 |
|
|
23 |
import javax.servlet.http.HttpServletRequest; |
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
/** |
|
28 |
* Console default http param extractor. |
|
29 |
* |
|
30 |
* @author zhuoguang |
|
31 |
*/ |
|
32 |
public class ConsoleDefaultHttpParamExtractor extends AbstractHttpParamExtractor { |
|
33 |
|
|
34 |
@Override |
|
35 |
public List<ParamInfo> extractParam(HttpServletRequest request) { |
|
36 |
ParamInfo paramInfo = new ParamInfo(); |
|
37 |
paramInfo.setNamespaceId(getAliasNamespaceId(request)); |
|
38 |
paramInfo.setNamespaceShowName(getAliasNamespaceShowName(request)); |
|
39 |
ArrayList<ParamInfo> paramInfos = new ArrayList<>(); |
|
40 |
paramInfos.add(paramInfo); |
|
41 |
return paramInfos; |
|
42 |
} |
|
43 |
|
|
44 |
private String getAliasNamespaceId(HttpServletRequest request) { |
|
45 |
String namespaceId = request.getParameter("namespaceId"); |
|
46 |
if (StringUtils.isBlank(namespaceId)) { |
|
47 |
namespaceId = request.getParameter("customNamespaceId"); |
|
48 |
} |
|
49 |
return namespaceId; |
|
50 |
} |
|
51 |
|
|
52 |
private String getAliasNamespaceShowName(HttpServletRequest request) { |
|
53 |
String namespaceShowName = request.getParameter("namespaceName"); |
|
54 |
return namespaceShowName; |
|
55 |
} |
|
56 |
} |