From b9ae09c7d6fe0e2c2245e7e3d8f62a7e7d3c14bb Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Mon, 8 May 2023 14:52:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=9F=E5=90=8D=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2bright=20cloud=E6=97=B6cats=E4=BF=A1=E6=81=AF=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mesasoft/cn/sketch/api/BrightCloud.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/mesasoft/cn/sketch/api/BrightCloud.java b/src/main/java/com/mesasoft/cn/sketch/api/BrightCloud.java index fd614ed..d600e3b 100644 --- a/src/main/java/com/mesasoft/cn/sketch/api/BrightCloud.java +++ b/src/main/java/com/mesasoft/cn/sketch/api/BrightCloud.java @@ -27,7 +27,7 @@ public class BrightCloud { private final HashMap> catId2Info = new HashMap<>(); private HttpURLConnection con; - private static BrightCloudConfig bcConfig = (BrightCloudConfig) SpringContextUtil.getBean("brightCloudConfig"); + private static BrightCloudConfig bcConfig = (BrightCloudConfig) SpringContextUtil.getBean("brightCloudConfig"); public List getBrightCloudDomainCategory(List domains) { JSONObject queryResults = getQueryResults(domains); @@ -106,10 +106,15 @@ public class BrightCloud { // json处理 JSONObject queries = jo.getJSONObject("queries"); JSONObject getInfo = queries.getJSONObject(bcConfig.getQueryType()); - - JSONObject cat = getInfo.getJSONArray("cats").getJSONObject(0); - Integer catId = cat.getInteger("catid"); String fqdn = jo.getString("url"); + int catId = 0; + int catConf = 0; + + if (getInfo.getJSONArray("cats") != null && getInfo.getJSONArray("cats").size() > 0) { + JSONObject cat = getInfo.getJSONArray("cats").getJSONObject(0); + catId = cat.getInteger("catid"); + catConf = cat.getInteger("conf"); + } domainFiles.add(new DomainCategory( fqdn, "brightcloud", @@ -120,8 +125,9 @@ public class BrightCloud { catId, getCatInfo(catId).get(0), getCatInfo(catId).get(1), - cat.getInteger("conf"), + catConf, getInfo.getBoolean("a1cat"))); + } } return domainFiles;