增加httpClien公共类
This commit is contained in:
BIN
lib/hk2-api-2.4.0-b34.jar
Normal file
BIN
lib/hk2-api-2.4.0-b34.jar
Normal file
Binary file not shown.
BIN
lib/hk2-locator-2.4.0-b34.jar
Normal file
BIN
lib/hk2-locator-2.4.0-b34.jar
Normal file
Binary file not shown.
BIN
lib/hk2-utils-2.4.0-b34.jar
Normal file
BIN
lib/hk2-utils-2.4.0-b34.jar
Normal file
Binary file not shown.
BIN
lib/jackson-jaxrs-base-2.5.4.jar
Normal file
BIN
lib/jackson-jaxrs-base-2.5.4.jar
Normal file
Binary file not shown.
BIN
lib/jackson-jaxrs-json-provider-2.5.4.jar
Normal file
BIN
lib/jackson-jaxrs-json-provider-2.5.4.jar
Normal file
Binary file not shown.
BIN
lib/javax.annotation-api-1.2.jar
Normal file
BIN
lib/javax.annotation-api-1.2.jar
Normal file
Binary file not shown.
BIN
lib/javax.inject-2.4.0-b34.jar
Normal file
BIN
lib/javax.inject-2.4.0-b34.jar
Normal file
Binary file not shown.
BIN
lib/javax.ws.rs-api-2.0.1.jar
Normal file
BIN
lib/javax.ws.rs-api-2.0.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-client-2.23.1.jar
Normal file
BIN
lib/jersey-client-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-common-2.23.1.jar
Normal file
BIN
lib/jersey-common-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-entity-filtering-2.23.1.jar
Normal file
BIN
lib/jersey-entity-filtering-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-guava-2.23.1.jar
Normal file
BIN
lib/jersey-guava-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-media-json-jackson-2.23.1.jar
Normal file
BIN
lib/jersey-media-json-jackson-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jersey-media-multipart-2.23.1.jar
Normal file
BIN
lib/jersey-media-multipart-2.23.1.jar
Normal file
Binary file not shown.
BIN
lib/jna-4.1.0.jar
Normal file
BIN
lib/jna-4.1.0.jar
Normal file
Binary file not shown.
BIN
lib/jna-platform-4.1.0.jar
Normal file
BIN
lib/jna-platform-4.1.0.jar
Normal file
Binary file not shown.
BIN
lib/mchange-commons-java-0.2.11.jar
Normal file
BIN
lib/mchange-commons-java-0.2.11.jar
Normal file
Binary file not shown.
BIN
lib/mimepull-1.9.6.jar
Normal file
BIN
lib/mimepull-1.9.6.jar
Normal file
Binary file not shown.
35
pom.xml
35
pom.xml
@@ -589,6 +589,35 @@
|
||||
<artifactId>hive-jdbc</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>1.9</version>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>1.9</version>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<version>1.9</version>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-guice</artifactId>
|
||||
<version>1.9</version>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>1.9</version>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-1.2-api</artifactId>
|
||||
@@ -648,7 +677,11 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency> -->
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
|
||||
179
src/main/java/com/nis/util/ConfigServiceUtil.java
Normal file
179
src/main/java/com/nis/util/ConfigServiceUtil.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||
|
||||
import com.nis.util.httpclient.ClientUtil;
|
||||
|
||||
public class ConfigServiceUtil {
|
||||
/**
|
||||
* 从后台服务获取compileid,groupid,regionid
|
||||
* @param type 1是compileid,2是groupid,3是regionid
|
||||
* @return
|
||||
*/
|
||||
public static String getId(int type,int num) throws Exception {
|
||||
String result = null;
|
||||
String url = "";
|
||||
if (type == 1) {
|
||||
url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES+"?sourceName=CONFIG_COMPILE&num="+num;
|
||||
} else if (type == 2) {
|
||||
url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES+"?sourceName=CONFIG_GROUP&num="+num;
|
||||
} else if (type == 3) {
|
||||
url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES+"?sourceName=CONFIG_REGION&num="+num;
|
||||
}
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}
|
||||
if(result == null){
|
||||
return "0";
|
||||
}else{
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* MAAT配置提交
|
||||
* @param params
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String postMaatCfg(String params) throws Exception{
|
||||
String result = null;
|
||||
String url = Constants.SERVICE_URL+Constants.MAAT_CFG;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
/**
|
||||
* 回调配置提交
|
||||
* @param params
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String postCallbackCfg(String params) throws Exception{
|
||||
String result = null;
|
||||
String url = Constants.SERVICE_URL+Constants.CALLBACK_CFG;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
/**
|
||||
* 文件配置提交
|
||||
* @param params
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String postFileCfg(String params,File file,Map<String, Object> fileDesc) throws Exception{
|
||||
String result = null;
|
||||
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
FormDataMultiPart formDataMultiPart=new FormDataMultiPart();
|
||||
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
||||
formDataMultiPart.bodyPart(bodyPart);
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",ClientUtil.formatFileDesc(fileDesc) );
|
||||
Response response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
/**
|
||||
* 配置删除
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String delete(String params){
|
||||
String result = "";
|
||||
return result;
|
||||
|
||||
}
|
||||
/**
|
||||
* 配置文件上传
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String put(String params){
|
||||
String result = "";
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 信息获取
|
||||
* @param params
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getFileDigest(String params,File file,Map<String, Object> fileDesc) throws Exception{
|
||||
String result = null;
|
||||
String url = Constants.SERVICE_URL+Constants.FILE_DIGEST_CFG;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
FormDataMultiPart formDataMultiPart=new FormDataMultiPart();
|
||||
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
||||
formDataMultiPart.bodyPart(bodyPart);
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",ClientUtil.formatFileDesc(fileDesc) );
|
||||
Response response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger("http://10.0.6.30:8080/maatRest/service/cfg/v1/getCompileId?sourceName=CONFIG_COMPILE&num=1");
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
String result= response.readEntity(String.class);
|
||||
}else{
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
@@ -274,5 +276,11 @@ public final class Constants {
|
||||
public static final String CALLBACK_CFG = Configurations.getStringProperty("callbackCfg","commonSources");
|
||||
public static final String FILE_UPLOAD_CFG = Configurations.getStringProperty("fileUploadCfg","fileUploadSources");
|
||||
public static final String FILE_DIGEST_CFG=Configurations.getStringProperty("fileDigestCfg","fileDigestSources");
|
||||
public static final String CONFIG_ID_SOURCES=Configurations.getStringProperty("configIdSources","configPzIdSources");
|
||||
/**请求头参数*/
|
||||
public static final Map<String,Object> REQUEST_HEADER = new HashMap<String,Object>();
|
||||
public static final Integer CLIENT_CONNECT_TIMEOUT = Configurations.getIntProperty("client_connect_timeout",1000);
|
||||
public static final Integer CLIENT_READ_TIMEOUT = Configurations.getIntProperty("client_read_timeout",1000);
|
||||
public static final Integer CLIENT_SOCKET_TIMEOUT = Configurations.getIntProperty("client_socket_timeout",1000);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.nis.util.httpclient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.client.ClientRequestContext;
|
||||
import javax.ws.rs.client.ClientRequestFilter;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import com.nis.util.Constants;
|
||||
/**
|
||||
* 请求过滤器,每次请求时自动配置requestHeader信息
|
||||
*/
|
||||
public class ClientRequestHeaderFilter implements ClientRequestFilter{
|
||||
|
||||
@Override
|
||||
public void filter(ClientRequestContext context) throws IOException {
|
||||
MultivaluedMap<String,Object> header = context.getHeaders();
|
||||
Map<String,Object> h = Constants.REQUEST_HEADER;//请求头参数
|
||||
if(h != null && h.size() > 0){
|
||||
for(Map.Entry<String, Object> temp : h.entrySet()){
|
||||
header.add(temp.getKey(), temp.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
113
src/main/java/com/nis/util/httpclient/ClientUtil.java
Normal file
113
src/main/java/com/nis/util/httpclient/ClientUtil.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.nis.util.httpclient;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.glassfish.jersey.client.ClientProperties;
|
||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
|
||||
import com.nis.util.Constants;
|
||||
|
||||
|
||||
public class ClientUtil {
|
||||
|
||||
private static Client client;//客户端
|
||||
private static Logger logger = Logger.getLogger(ClientUtil.class);
|
||||
/**
|
||||
* 初始化https client
|
||||
* @throws Exception
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static void initClient(){
|
||||
try{
|
||||
client = ClientBuilder.newBuilder().register(ClientRequestHeaderFilter.class)//请求过滤器,自动添加header信息
|
||||
.register(JacksonFeature.class)//json支持
|
||||
.register(MultiPartFeature.class)//文件上传支持
|
||||
.property(ClientProperties.CONNECT_TIMEOUT, Constants.CLIENT_CONNECT_TIMEOUT)//连接超时时间
|
||||
.property(ClientProperties.READ_TIMEOUT, Constants.CLIENT_READ_TIMEOUT)//读取超时时间
|
||||
.build();
|
||||
logger.info("客户端初始化成功");
|
||||
}catch (Exception e) {
|
||||
logger.error("初始化客户端失败,请检查证书是否正确!",e);
|
||||
System.exit(1);//程序退出
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*path 以https://或http:// 开始不做处理,否则在path前加上 Constants.BASE_URL + Constants.VERSION
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static WebTarget getWebTarger(String path){
|
||||
initClient();
|
||||
if(StringUtils.isNotBlank(path)){
|
||||
path = formatHttpStr(path);//格式化url字符串
|
||||
return client.target(path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化url字符串
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String formatHttpStr(String path){
|
||||
if( ! path.startsWith("https://") && ! path.startsWith("http://")){
|
||||
path = Constants.SERVICE_URL + "/" + path;
|
||||
}
|
||||
path = path.replaceAll("/{2,}", "/");
|
||||
int i = path.indexOf(":/") + 2;
|
||||
String prefix = path.substring(0, i);
|
||||
path =prefix +"/"+ path.substring(i);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public static void setClient(Client client) {
|
||||
ClientUtil.client = client;
|
||||
}
|
||||
/**
|
||||
*文件上传header增加Content-fileDesc属性
|
||||
*格式:Content-Filedesc:json格式的字段描述
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject formatFileDesc(Map<String, Object> map){
|
||||
Map<String,Object> newMap = new HashMap();
|
||||
|
||||
return JSONObject.fromObject(newMap);
|
||||
}
|
||||
public static void main(String[] args) throws ClientProtocolException, IOException {
|
||||
String url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
Response response= header.get();
|
||||
if( response.getStatus() == 200){
|
||||
String result= response.readEntity(String.class);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,11 +219,14 @@ clusterBStartTime=1503504000725
|
||||
isCommit=true
|
||||
############################################################################################################################################
|
||||
############################################################################################################################################
|
||||
httpUrl=http://127.0.0.1:8080/gk/service/cfg/v1/
|
||||
httpUrl=http://10.0.6.30:8080/maatRest/service/cfg/v1/
|
||||
maatCfg=configSources
|
||||
fileUploadCfg=fileUploadSources
|
||||
callbackCfg=commonSources
|
||||
fileDigestCfg=fileDigestSources
|
||||
configIdSources=getCompileId
|
||||
client_connect_timeout=1000
|
||||
client_read_timeout=1000
|
||||
#use elasticsearch or not#
|
||||
isUseES=false
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
cache-period="31536000" />
|
||||
<mvc:resources mapping="/upload/**" location="/upload/"
|
||||
cache-period="31536000" />
|
||||
<mvc:resources mapping="/sampleFile/**" location="/sampleFile/"
|
||||
cache-period="31536000" />
|
||||
<mvc:resources mapping="/srcFile/**" location="/srcFile/"
|
||||
cache-period="31536000" />
|
||||
<!-- <mvc:resources mapping="/swagger/**" location="/swagger/"
|
||||
cache-period="31536000" /> -->
|
||||
|
||||
@@ -258,7 +262,7 @@
|
||||
<bean id="multipartResolver"
|
||||
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<property name="defaultEncoding" value="utf-8"></property>
|
||||
<property name="maxUploadSize" value="10485760"></property>
|
||||
<property name="maxUploadSize" value="10737418240"></property>
|
||||
<!--<property name="maxInMemorySize" value="1000"></property> -->
|
||||
</bean>
|
||||
|
||||
|
||||
486
src/main/webapp/WEB-INF/views/cfg/ipCfgDemoForm.jsp
Normal file
486
src/main/webapp/WEB-INF/views/cfg/ipCfgDemoForm.jsp
Normal file
@@ -0,0 +1,486 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8"%>
|
||||
<%@ include file="/WEB-INF/include/taglib.jsp"%>
|
||||
<html>
|
||||
<head>
|
||||
<title><spring:message code="${cfgName}"></spring:message></title>
|
||||
<link
|
||||
href="${pageContext.request.contextPath}/static/global/plugins/bootstrap-select/css/bootstrap-select.min.css"
|
||||
rel="stylesheet" />
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
switchIpType($("select[name$='ipType']"));
|
||||
areaControlInit();
|
||||
$("select[name='cfgType']").on('change', function() {
|
||||
var val = $(this).val();
|
||||
if (val == 1) {
|
||||
$("#srcIp").val("0.0.0.0/32");
|
||||
} else {
|
||||
$("#srcIp").val("0.0.0.0-0.0.0.0");
|
||||
}
|
||||
});
|
||||
$("input[name='isAreaEffective']").on('change', function() {
|
||||
var val = $(this).val();
|
||||
if (val == 1) {
|
||||
$(".areaType").removeClass("hidden");
|
||||
if ($("input[name='areaType']:checked").val() == 1) {//areaISP
|
||||
$("#areaIsp").removeClass("hidden");
|
||||
} else if ($("input[name='areaType']:checked").val() == 0) {//areaIp
|
||||
$("#areaIp").removeClass("hidden");
|
||||
}
|
||||
} else {
|
||||
$(".areaType").addClass("hidden");
|
||||
$("#areaIp").addClass("hidden");
|
||||
$("#areaIsp").addClass("hidden");
|
||||
}
|
||||
});
|
||||
$("input[name='areaType']").on('change', function() {
|
||||
var val = $(this).val();
|
||||
if ($(this).is(":visible")) {
|
||||
if (val == 0) {
|
||||
$("#areaIp").removeClass("hidden");
|
||||
$("#areaIsp").addClass("hidden");
|
||||
} else {
|
||||
$("#areaIsp").removeClass("hidden");
|
||||
$("#areaIp").addClass("hidden");
|
||||
}
|
||||
} else {
|
||||
$("#areaIsp").addClass("hidden");
|
||||
$("#areaIp").addClass("hidden");
|
||||
}
|
||||
});
|
||||
$("#cancel").on("click", function() {
|
||||
window.history.back();
|
||||
});
|
||||
$("select[name$='ipType']").on("change", function() {
|
||||
switchIpType($(this));
|
||||
});
|
||||
$("#ipCfgFrom").validate(
|
||||
{
|
||||
errorPlacement : function(error, element) {
|
||||
$(element).parents(".form-group").find(
|
||||
"div[for='" + element.attr("name") + "']")
|
||||
.append(error);
|
||||
},
|
||||
submitHandler : function(form) {
|
||||
//loading('onloading...');
|
||||
form.submit();
|
||||
},
|
||||
errorContainer : "#messageBox",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-content">
|
||||
<h3 class="page-title">
|
||||
<spring:message code="ip address"></spring:message>
|
||||
</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="portlet box blue">
|
||||
<div class="portlet-title">
|
||||
<div class="caption">
|
||||
<i class="fa fa-gift"></i>
|
||||
<c:if test="${empty _cfg.cfgId}">
|
||||
<spring:message code="add"></spring:message>
|
||||
</c:if>
|
||||
<c:if test="${not empty _cfg.cfgId}">
|
||||
<spring:message code="edit"></spring:message>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-body form">
|
||||
<!-- BEGIN FORM-->
|
||||
<form id="ipCfgFrom" action="${ctx}/cfg/ip/saveOrUpdateCfg"
|
||||
method="post" class="form-horizontal">
|
||||
<div class="form-body">
|
||||
<h3 class="form-section">
|
||||
<spring:message code="service configuration" />
|
||||
</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><spring:message
|
||||
code="config_describe" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control" type="text" id="cfgDesc"
|
||||
name="cfgDesc" value="${_cfg.cfgDesc}">
|
||||
</div>
|
||||
<div for="cfgDesc"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="IP类型" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="ipType"
|
||||
class="selectpicker show-tick form-control required">
|
||||
<option value="4"
|
||||
<c:if test="${_cfg.ipType==4}">selected</c:if>>V4</option>
|
||||
<option value="6"
|
||||
<c:if test="${_cfg.ipType==6}">selected</c:if>>V6</option>
|
||||
</select>
|
||||
<!-- <input class="form-control" type="text" value="${_cfg.ipType}">-->
|
||||
</div>
|
||||
<div for="ipType"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="源IP格式" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="cfgType"
|
||||
class="selectpicker show-tick form-control required">
|
||||
<option value="1">Subnet</option>
|
||||
<option value="2">IP Range</option>
|
||||
</select>
|
||||
<!-- <input class="form-control" type="text" value="${_cfg.ipType}">-->
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="源IP" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required ipCheck" type="text"
|
||||
name="srcIp" id="srcIp" value="0.0.0.0/32">
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="目的IP格式" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="cfgType"
|
||||
class="selectpicker show-tick form-control required">
|
||||
<option value="1">Subnet</option>
|
||||
<option value="2">IP Range</option>
|
||||
</select>
|
||||
<!-- <input class="form-control" type="text" value="${_cfg.ipType}">-->
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="目的IP" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required ipCheck" type="text"
|
||||
name="srcIp" id="destIp" value="0.0.0.0/32">
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="源端口" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required ipCheck" type="text"
|
||||
name="srcPort" id="srcPort" value="0-65535">
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="目的端口" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required ipCheck" type="text"
|
||||
name="destPort" id="destPort" value="0-65535">
|
||||
</div>
|
||||
<div for="cfgType"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="direction" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="direction"
|
||||
class="selectpicker show-tick form-control required">
|
||||
<option value="0"
|
||||
<c:if test="${_cfg.direction==0}">selected</c:if>>both</option>
|
||||
<option value="1"
|
||||
<c:if test="${_cfg.direction==1}">selected</c:if>><spring:message
|
||||
code="ingress to egress" /></option>
|
||||
<option value="2"
|
||||
<c:if test="${_cfg.direction==1}">selected</c:if>><spring:message
|
||||
code="egress to ingress" /></option>
|
||||
</select>
|
||||
</div>
|
||||
<div for="direction"></div>
|
||||
</div>
|
||||
</div>
|
||||
<c:if test="${type eq 'bgp' }">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="ASN" /></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control" type="text" id="cfgDesc"
|
||||
name="cfgDesc" value="${_cfg.cfgDesc}">
|
||||
</div>
|
||||
<div for="direction"></div>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="传输层协议" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="protocol"
|
||||
class="selectpicker show-tick form-control required"
|
||||
title="<spring:message code="select"/>">
|
||||
<option value="6"
|
||||
<c:if test="${_cfg.protocol==6}">selected</c:if>>TCP</option>
|
||||
<option value="17"
|
||||
<c:if test="${_cfg.protocol==17}">selected</c:if>>UDP</option>
|
||||
</select>
|
||||
<%-- <input class="form-control" type="text" name="protocol" value="${_cfg.protocol}"> --%>
|
||||
</div>
|
||||
<div for="protocol"></div>
|
||||
</div>
|
||||
</div>
|
||||
<c:if test="${type ne 'bgp' }">
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="应用层协议" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="protocol"
|
||||
class="selectpicker show-tick form-control required"
|
||||
title="<spring:message code="select"/>">
|
||||
<option value="1"
|
||||
<c:if test="${_cfg.protocol==1}">selected</c:if>>HTTP</option>
|
||||
<option value="2"
|
||||
<c:if test="${_cfg.protocol==2}">selected</c:if>>HTTPS</option>
|
||||
<option value="3"
|
||||
<c:if test="${_cfg.protocol==3}">selected</c:if>>FTP</option>
|
||||
<option value="4"
|
||||
<c:if test="${_cfg.protocol==4}">selected</c:if>>FTPS</option>
|
||||
<option value="5"
|
||||
<c:if test="${_cfg.protocol==5}">selected</c:if>>SMTP</option>
|
||||
<option value="6"
|
||||
<c:if test="${_cfg.protocol==6}">selected</c:if>>POP3</option>
|
||||
<option value="7"
|
||||
<c:if test="${_cfg.protocol==7}">selected</c:if>>SSH</option>
|
||||
<option value="8"
|
||||
<c:if test="${_cfg.protocol==8}">selected</c:if>>SSL</option>
|
||||
<option value="9"
|
||||
<c:if test="${_cfg.protocol==9}">selected</c:if>>DNS</option>
|
||||
<option value="10"
|
||||
<c:if test="${_cfg.protocol==10}">selected</c:if>>VPN</option>
|
||||
<option value="11"
|
||||
<c:if test="${_cfg.protocol==11}">selected</c:if>>PPTP</option>
|
||||
<option value="12"
|
||||
<c:if test="${_cfg.protocol==12}">selected</c:if>>L2TP</option>
|
||||
<option value="13"
|
||||
<c:if test="${_cfg.protocol==13}">selected</c:if>>MMS</option>
|
||||
<option value="14"
|
||||
<c:if test="${_cfg.protocol==14}">selected</c:if>>RTSP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>RTMP</option>
|
||||
<option value="16"
|
||||
<c:if test="${_cfg.protocol==16}">selected</c:if>>GRE</option>
|
||||
<option value="17"
|
||||
<c:if test="${_cfg.protocol==17}">selected</c:if>>ICMP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>IKE</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>IMAP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>IMAPS</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>IPSEC</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>XMPP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>NTP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>POP3
|
||||
SSL</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>QUIC</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>SIP</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>SMB</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>SMTPS</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>SPDY</option>
|
||||
<option value="15"
|
||||
<c:if test="${_cfg.protocol==15}">selected</c:if>>SOCKS</option>
|
||||
</select>
|
||||
<%-- <input class="form-control" type="text" name="protocol" value="${_cfg.protocol}"> --%>
|
||||
</div>
|
||||
<div for="protocol"></div>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="action" /></label>
|
||||
<div class="col-md-6">
|
||||
<select name="action"
|
||||
class="selectpicker show-tick form-control required">
|
||||
<option value="1"
|
||||
<c:if test="${_cfg.action==1}">selected</c:if>><spring:message
|
||||
code="drop" /></option>
|
||||
<option value="2"
|
||||
<c:if test="${_cfg.action==2}">selected</c:if>><spring:message
|
||||
code="reject" /></option>
|
||||
<option value="3"
|
||||
<c:if test="${_cfg.action==3}">selected</c:if>><spring:message
|
||||
code="redirect" /></option>
|
||||
<option value="4"
|
||||
<c:if test="${_cfg.action==4}">selected</c:if>><spring:message
|
||||
code="mirroring" /></option>
|
||||
<option value="5"
|
||||
<c:if test="${_cfg.action==5}">selected</c:if>><spring:message
|
||||
code="steering" /></option>
|
||||
<option value="6"
|
||||
<c:if test="${_cfg.action==6}">selected</c:if>><spring:message
|
||||
code="ratelimit" /></option>
|
||||
<option value="7"
|
||||
<c:if test="${_cfg.action==7}">selected</c:if>><spring:message
|
||||
code="replace content" /></option>
|
||||
<option value="8"
|
||||
<c:if test="${_cfg.action==8}">selected</c:if>><spring:message
|
||||
code="monitor" /></option>
|
||||
</select>
|
||||
</div>
|
||||
<div for="action"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="isAreaEffective" value="0"> <input
|
||||
type="hidden" name="areaEffectiveIds" value="">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="whether_area_block" /></label>
|
||||
<div class="col-md-6" id="areaCheck">
|
||||
<label class="radio-inline"> <input type="radio"
|
||||
name="isAreaEffective" value="1" class="required"<c:if test="${_cfg.isAreaEffective==1}">checked</c:if>
|
||||
<%-- <c:if test="${action==2}">disabled</c:if> --%>
|
||||
>
|
||||
<spring:message code="yes" />
|
||||
</label> <label class="radio-inline"> <input type="radio"
|
||||
name="isAreaEffective" value="0" class="required"<c:if test="${_cfg.isAreaEffective==0}">checked</c:if>
|
||||
<%-- <c:if test="${action==2}">disabled</c:if> --%>
|
||||
>
|
||||
<spring:message code="no" />
|
||||
</label>
|
||||
<%-- <c:if test="${action==2}">
|
||||
<input class="form-control" type="hidden" name="isAreaEffective" value="${_cfg.isAreaEffective}">
|
||||
</c:if> --%>
|
||||
</div>
|
||||
<div for="isAreaEffective"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden areaType col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font
|
||||
color="red">*</font>
|
||||
<spring:message code="area_control_type" /></label>
|
||||
<div class="col-md-6">
|
||||
<label class="radio-inline"> <input type="radio"
|
||||
name="areaType" value="1" class="required">
|
||||
<spring:message code="area" /> <spring:message code="isp" />
|
||||
</label> <label class="radio-inline"> <input type="radio"
|
||||
name="areaType" value="0" class="required">
|
||||
<spring:message code="area" /> ip
|
||||
</label>
|
||||
</div>
|
||||
<div for="areaType"></div>
|
||||
<input class="form-control" type="hidden"
|
||||
name="areaEffectiveIds" value="${_cfg.areaEffectiveIds}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<c:if test="${not empty _cfg.cfgId}">
|
||||
<input type="hidden" name="cfgId" value="${_cfg.cfgId}">
|
||||
</c:if>
|
||||
<c:if test="${not empty _cfg.compileId}">
|
||||
<input type="hidden" name="compileId" value="${_cfg.compileId}">
|
||||
</c:if>
|
||||
<input type="hidden" name="tableName" value="${_cfg.tableName}">
|
||||
<input type="hidden" name="serviceId" value="${serviceId}">
|
||||
<input type="hidden" name="cfgName" value="${cfgName}">
|
||||
<input type="hidden" name="action" value="${action}"> <input
|
||||
type="hidden" name="protocolId" value="${_cfg.protocolId}">
|
||||
<div id="areaInfo">
|
||||
<%@include file="/WEB-INF/include/form/areaDemoInfo.jsp"%>
|
||||
<%@include file="/WEB-INF/include/form/basicInfo.jsp"%>
|
||||
</div>
|
||||
<input type="hidden" name=requestId value="0">
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="row">
|
||||
<div class="col-md-offset-3 col-md-8">
|
||||
<button id="save" type="submit" class="btn green">
|
||||
<spring:message code="submit" />
|
||||
</button>
|
||||
<button id="cancel" type="button" class="btn default">
|
||||
<spring:message code="cancel" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!-- END FORM-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user