configserviceutil中的response关闭放在最外层try中
This commit is contained in:
@@ -104,11 +104,13 @@ public class ConfigServiceUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<Integer> getId(int type,int num) throws MaatConvertException {
|
public static List<Integer> getId(int type,int num) throws MaatConvertException {
|
||||||
|
Response response=null;
|
||||||
|
List<Integer> list = new ArrayList();
|
||||||
|
try {
|
||||||
logger.warn("get ids start");
|
logger.warn("get ids start");
|
||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
String result = null;
|
String result = null;
|
||||||
String url = "";
|
String url = "";
|
||||||
List<Integer> list = new ArrayList();
|
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES+"?sourceName=CONFIG_COMPILE&num="+num;
|
url = Constants.SERVICE_URL+Constants.CONFIG_ID_SOURCES+"?sourceName=CONFIG_COMPILE&num="+num;
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
@@ -121,13 +123,9 @@ public class ConfigServiceUtil {
|
|||||||
logger.info("getId url:"+url);
|
logger.info("getId url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.get();
|
response= header.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response != null && response.getStatus() == 200){
|
if(response != null && response.getStatus() == 200){
|
||||||
@@ -142,52 +140,46 @@ public class ConfigServiceUtil {
|
|||||||
if(!StringUtil.isEmpty(bean.getData())){
|
if(!StringUtil.isEmpty(bean.getData())){
|
||||||
list = bean.getData().getPzIdList();
|
list = bean.getData().getPzIdList();
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
}
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
logger.warn("get ids finish,cost:"+(end-start));
|
logger.warn("get ids finish,cost:"+(end-start));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}finally {
|
||||||
|
if (response != null) {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* MAAT配置提交
|
* MAAT配置提交
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws MaatConvertException
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult postMaatCfg(String params) throws MaatConvertException{
|
public static ToMaatResult postMaatCfg(String params) throws MaatConvertException{
|
||||||
String result = null;
|
Response response=null;
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
try {
|
||||||
|
response.close();
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL+Constants.MAAT_CFG;
|
String url = Constants.SERVICE_URL+Constants.MAAT_CFG;
|
||||||
//创建连接
|
//创建连接
|
||||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||||
logger.info("postMaatCfg url:"+url);
|
logger.info("postMaatCfg url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response != null && response.getStatus() == 200){
|
if(response != null && response.getStatus() == 200){
|
||||||
@@ -198,38 +190,38 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 回调配置提交
|
* 回调配置提交
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws MaatConvertException
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult postCallbackCfg(String params) throws MaatConvertException{
|
public static ToMaatResult postCallbackCfg(String params) throws MaatConvertException{
|
||||||
String result = null;
|
Response response=null;
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
try {
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL+Constants.CALLBACK_CFG;
|
String url = Constants.SERVICE_URL+Constants.CALLBACK_CFG;
|
||||||
//创建连接
|
//创建连接
|
||||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||||
logger.info("postCallbackCfg url:"+url);
|
logger.info("postCallbackCfg url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response != null && response.getStatus() == 200){
|
if(response != null && response.getStatus() == 200){
|
||||||
@@ -237,14 +229,15 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result);
|
JSONObject resObject = JSONObject.fromObject(result);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -252,11 +245,13 @@ public class ConfigServiceUtil {
|
|||||||
* 文件配置提交
|
* 文件配置提交
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws MaatConvertException
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult postFileCfg(String params,File file,String fileDesc) throws Exception{
|
public static ToMaatResult postFileCfg(String params,File file,String fileDesc) throws MaatConvertException{
|
||||||
String result = null;
|
Response response=null;
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
try {
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
|
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
|
||||||
//创建连接
|
//创建连接
|
||||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||||
@@ -265,13 +260,9 @@ public class ConfigServiceUtil {
|
|||||||
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
||||||
formDataMultiPart.bodyPart(bodyPart);
|
formDataMultiPart.bodyPart(bodyPart);
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response != null && response.getStatus() == 200){
|
if(response != null && response.getStatus() == 200){
|
||||||
@@ -279,14 +270,15 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result);
|
JSONObject resObject = JSONObject.fromObject(result);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -296,9 +288,11 @@ public class ConfigServiceUtil {
|
|||||||
* @param type,1表示maat配置取消,2表示回调配置取消
|
* @param type,1表示maat配置取消,2表示回调配置取消
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult delete(String params,Integer type) throws Exception{
|
public static ToMaatResult delete(String params,Integer type) throws MaatConvertException{
|
||||||
String result = null;
|
Response response=null;
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
try {
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL;
|
String url = Constants.SERVICE_URL;
|
||||||
if(type==1){
|
if(type==1){
|
||||||
url = url+Constants.MAAT_CFG;
|
url = url+Constants.MAAT_CFG;
|
||||||
@@ -310,13 +304,9 @@ public class ConfigServiceUtil {
|
|||||||
logger.info("delete url:"+url);
|
logger.info("delete url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.delete();
|
response= header.delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response != null && response.getStatus() == 200){
|
if(response != null && response.getStatus() == 200){
|
||||||
@@ -324,14 +314,15 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result);
|
JSONObject resObject = JSONObject.fromObject(result);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -342,8 +333,10 @@ public class ConfigServiceUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult put(String params,Integer type) throws MaatConvertException{
|
public static ToMaatResult put(String params,Integer type) throws MaatConvertException{
|
||||||
String result = null;
|
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
Response response=null;
|
||||||
|
try {
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL;
|
String url = Constants.SERVICE_URL;
|
||||||
if(type==1){
|
if(type==1){
|
||||||
url = url+Constants.MAAT_CFG;
|
url = url+Constants.MAAT_CFG;
|
||||||
@@ -357,13 +350,9 @@ public class ConfigServiceUtil {
|
|||||||
logger.info("put url:"+url);
|
logger.info("put url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response !=null && response.getStatus() == 200){
|
if(response !=null && response.getStatus() == 200){
|
||||||
@@ -371,14 +360,15 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result);
|
JSONObject resObject = JSONObject.fromObject(result);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -389,7 +379,7 @@ public class ConfigServiceUtil {
|
|||||||
*/
|
*/
|
||||||
public static String patch(String params,Integer type) throws MaatConvertException{
|
public static String patch(String params,Integer type) throws MaatConvertException{
|
||||||
String result = null;
|
String result = null;
|
||||||
ToMaatResult bean = null;
|
try {
|
||||||
String url = Constants.SERVICE_URL;
|
String url = Constants.SERVICE_URL;
|
||||||
if(type==1){
|
if(type==1){
|
||||||
url = url+Constants.MAAT_CFG;
|
url = url+Constants.MAAT_CFG;
|
||||||
@@ -401,16 +391,16 @@ public class ConfigServiceUtil {
|
|||||||
logger.info("put url:"+url);
|
logger.info("put url:"+url);
|
||||||
//创建连接
|
//创建连接
|
||||||
try {
|
try {
|
||||||
ClientUtil.initClient();
|
|
||||||
Client client=ClientUtil.getClient();
|
|
||||||
result = HttpClientUtil.patch(url, params);
|
result = HttpClientUtil.patch(url, params);
|
||||||
// JSONObject resObject = JSONObject.fromObject(result);
|
// JSONObject resObject = JSONObject.fromObject(result);
|
||||||
// bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
// bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -418,11 +408,13 @@ public class ConfigServiceUtil {
|
|||||||
* 信息获取
|
* 信息获取
|
||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws MaatConvertException
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult getFileDigest(String params,File file,String fileDesc) throws MaatConvertException{
|
public static ToMaatResult getFileDigest(String params,File file,String fileDesc) throws MaatConvertException{
|
||||||
String result = null;
|
|
||||||
ToMaatResult bean = null;
|
ToMaatResult bean = null;
|
||||||
|
Response response=null;
|
||||||
|
try {
|
||||||
|
String result = null;
|
||||||
String url = Constants.SERVICE_URL+Constants.FILE_DIGEST_CFG;
|
String url = Constants.SERVICE_URL+Constants.FILE_DIGEST_CFG;
|
||||||
//创建连接
|
//创建连接
|
||||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||||
@@ -431,13 +423,9 @@ public class ConfigServiceUtil {
|
|||||||
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
||||||
formDataMultiPart.bodyPart(bodyPart);
|
formDataMultiPart.bodyPart(bodyPart);
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response !=null && response.getStatus() == 200){
|
if(response !=null && response.getStatus() == 200){
|
||||||
@@ -446,14 +434,15 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result);
|
JSONObject resObject = JSONObject.fromObject(result);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -463,23 +452,21 @@ public class ConfigServiceUtil {
|
|||||||
* @throws MaatConvertException
|
* @throws MaatConvertException
|
||||||
*/
|
*/
|
||||||
public static ToMaatResult postGroupReuseSources(String params) throws MaatConvertException{
|
public static ToMaatResult postGroupReuseSources(String params) throws MaatConvertException{
|
||||||
|
ToMaatResult bean = null;
|
||||||
|
Response response=null;
|
||||||
|
try {
|
||||||
logger.warn("postGroupReuseSources start");
|
logger.warn("postGroupReuseSources start");
|
||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
String result = null;
|
String result = null;
|
||||||
ToMaatResult bean = null;
|
|
||||||
String url = Constants.SERVICE_URL+Constants.GROUP_REUSE_SOURCES;
|
String url = Constants.SERVICE_URL+Constants.GROUP_REUSE_SOURCES;
|
||||||
//创建连接
|
//创建连接
|
||||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||||
logger.info("postGroupReuseSources url:"+url);
|
logger.info("postGroupReuseSources url:"+url);
|
||||||
//获取响应结果
|
//获取响应结果
|
||||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response !=null && response.getStatus() == 200){
|
if(response !=null && response.getStatus() == 200){
|
||||||
@@ -489,16 +476,17 @@ public class ConfigServiceUtil {
|
|||||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
}
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if (response != null) {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -517,10 +505,12 @@ public class ConfigServiceUtil {
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static String getReport(int type,String ids,String serviceIds,String searchReportStartTime,String searchReportEndTime) throws MaatConvertException{
|
public static String getReport(int type,String ids,String serviceIds,String searchReportStartTime,String searchReportEndTime) throws MaatConvertException{
|
||||||
|
String result = null;
|
||||||
|
Response response=null;
|
||||||
|
try {
|
||||||
if(StringUtils.isBlank(ids)||StringUtils.isBlank(serviceIds)){
|
if(StringUtils.isBlank(ids)||StringUtils.isBlank(serviceIds)){
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
String result = null;
|
|
||||||
UriBuilder builder=UriBuilder.fromPath(Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT);
|
UriBuilder builder=UriBuilder.fromPath(Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT);
|
||||||
builder.queryParam("searchBusinessType",type);
|
builder.queryParam("searchBusinessType",type);
|
||||||
builder.queryParam("searchService",serviceIds);
|
builder.queryParam("searchService",serviceIds);
|
||||||
@@ -538,33 +528,32 @@ public class ConfigServiceUtil {
|
|||||||
WebTarget wt = client.target(uri);
|
WebTarget wt = client.target(uri);
|
||||||
logger.info("getReport url:"+uri.toString());
|
logger.info("getReport url:"+uri.toString());
|
||||||
Builder header = wt.request();
|
Builder header = wt.request();
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.get();
|
response= header.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response !=null && response.getStatus() == 200){
|
if(response !=null && response.getStatus() == 200){
|
||||||
result= response.readEntity(String.class);
|
result= response.readEntity(String.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{
|
public static String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException{
|
||||||
// if(StringUtils.isBlank(searchCondition.getSearchService())){
|
// if(StringUtils.isBlank(searchCondition.getSearchService())){
|
||||||
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
// throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
// }
|
// }
|
||||||
|
Response response=null;
|
||||||
String result = null;
|
String result = null;
|
||||||
|
try {
|
||||||
UriBuilder builder=UriBuilder.fromPath(reportUrl);
|
UriBuilder builder=UriBuilder.fromPath(reportUrl);
|
||||||
builder.queryParam("searchBusinessType",searchCondition.getSearchBusinessType());
|
builder.queryParam("searchBusinessType",searchCondition.getSearchBusinessType());
|
||||||
if(StringUtils.isNotBlank(searchCondition.getSearchService())) {
|
if(StringUtils.isNotBlank(searchCondition.getSearchService())) {
|
||||||
@@ -601,26 +590,23 @@ public class ConfigServiceUtil {
|
|||||||
Client client=ClientUtil.getClient();
|
Client client=ClientUtil.getClient();
|
||||||
WebTarget wt = client.target(uri);
|
WebTarget wt = client.target(uri);
|
||||||
Builder header = wt.request();
|
Builder header = wt.request();
|
||||||
Response response=null;
|
|
||||||
try {
|
try {
|
||||||
response= header.get();
|
response= header.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||||
}
|
}
|
||||||
if(response !=null && response.getStatus() == 200){
|
if(response !=null && response.getStatus() == 200){
|
||||||
result= response.readEntity(String.class);
|
result= response.readEntity(String.class);
|
||||||
}else{
|
}else{
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public class ConfigureStatisticsController extends BaseController{
|
|||||||
//2、根据来函分页
|
//2、根据来函分页
|
||||||
RequestInfo requestInfo=new RequestInfo();
|
RequestInfo requestInfo=new RequestInfo();
|
||||||
requestInfo.setIsAudit(1);
|
requestInfo.setIsAudit(1);
|
||||||
|
requestInfo.setIsValid(1);
|
||||||
Page requestPage = requestInfoService.findRequestInfo(new Page(request, response,"r"),requestInfo);
|
Page requestPage = requestInfoService.findRequestInfo(new Page(request, response,"r"),requestInfo);
|
||||||
List<RequestInfo> requestInfos=requestPage.getList();
|
List<RequestInfo> requestInfos=requestPage.getList();
|
||||||
//3、根据当前页的requestInfo信息查询request统计信息
|
//3、根据当前页的requestInfo信息查询request统计信息
|
||||||
|
|||||||
@@ -563,25 +563,6 @@
|
|||||||
<div for="userRegion1"></div>
|
<div for="userRegion1"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 域名拦截增加拦截强度 -->
|
|
||||||
<c:if test="${_cfg.functionId eq 201}">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label col-md-3"><font color="red">*</font>
|
|
||||||
<spring:message code="intercept_intensity" />
|
|
||||||
</label>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<select name="userRegion5"
|
|
||||||
class="selectpicker show-tick form-control required">
|
|
||||||
<c:forEach items="${fns:getDictList('INTERCEPT_DOMAIN_INTENSITY')}" var="intensityC">
|
|
||||||
<option value="${intensityC.itemCode}" <c:if test="${_cfg.userRegion5==intensityC.itemCode || (empty _cfg.userRegion5 && intensityC.itemCode eq 1)}">selected</c:if>><spring:message code="${intensityC.itemValue}"/></option>
|
|
||||||
</c:forEach>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div for="userRegion5"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</c:if>
|
|
||||||
<div class="col-md-6 droprate">
|
<div class="col-md-6 droprate">
|
||||||
<div class="form-group ">
|
<div class="form-group ">
|
||||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ratelimit"/></label>
|
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ratelimit"/></label>
|
||||||
@@ -661,7 +642,7 @@
|
|||||||
<%-- action 为128 白名单时 --%>
|
<%-- action 为128 白名单时 --%>
|
||||||
<c:if test="${_cfg.functionId eq 201}">
|
<c:if test="${_cfg.functionId eq 201}">
|
||||||
<div class="row whiteListAction hidden">
|
<div class="row whiteListAction hidden">
|
||||||
<h4 class="form-section">
|
<%-- <h4 class="form-section">
|
||||||
<spring:message code="action_region" />
|
<spring:message code="action_region" />
|
||||||
<small></small>
|
<small></small>
|
||||||
</h4>
|
</h4>
|
||||||
@@ -681,7 +662,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div for="userRegion5"></div>
|
<div for="userRegion5"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> --%>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
<c:set var="ipCfgIndex" value="0"></c:set>
|
<c:set var="ipCfgIndex" value="0"></c:set>
|
||||||
|
|||||||
Reference in New Issue
Block a user