vpn 用户管理修改新增修改和删除逻辑
ip地址池增加存在可用ip地址池才在策略展示
This commit is contained in:
@@ -5,7 +5,9 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
@@ -16,8 +18,10 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.utils.HttpClientUtils;
|
||||
import org.eclipse.jetty.util.ajax.JSON;
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||
import org.slf4j.Logger;
|
||||
@@ -624,6 +628,61 @@ public class ConfigServiceUtil {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static Map getCGIInfo(String url,String cmd,Map<String, Object> params) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
params.put("cmd", cmd);
|
||||
String recv = getCGI(url, params);
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
resultMap = (Map<String, Object>) JSON.parse(recv);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
public static String getCGI(String url, Map<String, Object> params) throws MaatConvertException{
|
||||
// if(StringUtils.isBlank(searchCondition.getSearchService())){
|
||||
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
// }
|
||||
Response response=null;
|
||||
String result = null;
|
||||
try {
|
||||
UriBuilder builder=UriBuilder.fromPath(url);
|
||||
if(params!=null) {
|
||||
for (String param : params.keySet()) {
|
||||
if(!StringUtil.isBlank(param)&¶ms.get(param)!=null) {
|
||||
builder.queryParam(param,params.get(param).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
URI uri=builder.build();
|
||||
logger.info("cgi url:"+uri.toString());
|
||||
//创建连接
|
||||
ClientUtil.initClient();
|
||||
Client client=ClientUtil.getClient();
|
||||
WebTarget wt = client.target(uri);
|
||||
Builder header = wt.request();
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
logger.info("cgi info:"+result);
|
||||
}else{
|
||||
if(response!= null) {
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}else {
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置全量更新指令下发
|
||||
|
||||
@@ -753,4 +753,6 @@ public final class Constants {
|
||||
|
||||
// IP复用模块调用相关CGI接口URL
|
||||
public static final String IP_REUSE_CALL_CGI_URL = Configurations.getStringProperty("ip_reuse_call_cgi_url","");
|
||||
public static final String ALL_IP_GET = Configurations.getStringProperty("allIpGet","AllIpGet");
|
||||
public static final String IP_NUM_GET = Configurations.getStringProperty("ipNumGet","IpNumGet");
|
||||
}
|
||||
|
||||
@@ -373,46 +373,4 @@ public class HttpClientUtil {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* CGI get 获取消息
|
||||
* @param destUrl 业务地址
|
||||
* @param params 参数列表
|
||||
* @return 查询结果数据json
|
||||
*/
|
||||
public static String getCGI(String destUrl, Map<String, Object> params, HttpServletRequest req) throws IOException {
|
||||
String result = null;
|
||||
Response response=null;
|
||||
String url = "";
|
||||
try {
|
||||
URIBuilder uriBuilder = new URIBuilder(destUrl);
|
||||
if(params!=null) {
|
||||
for (String param : params.keySet()) {
|
||||
if(!StringUtil.isBlank(param)&¶ms.get(param)!=null) {
|
||||
uriBuilder.addParameter(param, params.get(param).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
System.err.println(uriBuilder);
|
||||
url=uriBuilder.toString();
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
logger.info("getMsg url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
response= header.get();
|
||||
result= response.readEntity(String.class);
|
||||
//调用处理数据方法
|
||||
logger.info("获取消息成功,相应内容如下: " + result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取消息失败,相应内容如下: " + result);
|
||||
logger.error("获取消息失败 ", e);
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>:");
|
||||
}finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user