summaryrefslogtreecommitdiff
path: root/src/main/java/com/geedge/common/util/TsgUtil.java
diff options
context:
space:
mode:
authorwangwei <[email protected]>2024-01-29 17:42:16 +0800
committerwangwei <[email protected]>2024-01-29 17:42:16 +0800
commitdb3d90b505175a05265a39d35a4afe13a853df69 (patch)
tree5a4baef52827d0e34d9509ca373a0a6d5b4c913c /src/main/java/com/geedge/common/util/TsgUtil.java
parenta7aad6e357599db0c570d1c862d9e3335c4c3efe (diff)
删除程序增加防止Object被清空处理逻辑HEAD24.01mainbr-24.01
Diffstat (limited to 'src/main/java/com/geedge/common/util/TsgUtil.java')
-rw-r--r--src/main/java/com/geedge/common/util/TsgUtil.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/com/geedge/common/util/TsgUtil.java b/src/main/java/com/geedge/common/util/TsgUtil.java
index 3e5b995..9bf9134 100644
--- a/src/main/java/com/geedge/common/util/TsgUtil.java
+++ b/src/main/java/com/geedge/common/util/TsgUtil.java
@@ -57,6 +57,25 @@ public class TsgUtil {
throw new IllegalArgumentException("failed to get TSG system token.");
}
+ public static JSONObject getObjectItemList(Integer objectId, String objectType) {
+ Stopwatch watch = Stopwatch.createStarted();
+ String response = HttpRequest.get(TSG_URL + "/v1/policy/object/" + objectId + "/item?page_no=1&page_size=1&type=" + objectType)
+ .header(Header.AUTHORIZATION, getToken())
+ .timeout(httpTimeOut)
+ .execute().body();
+ log.info("get tsg-api, cost {} seconds", watch.elapsed(TimeUnit.SECONDS));
+ if (StrUtil.isBlank(response)) {
+ log.error("get {} Object error, response: {}", objectId, response);
+ throw new RuntimeException("get " + objectId + " Object error, response: " + response);
+ }
+ JSONObject jsonObject = JSONUtil.parseObj(response);
+ if (!"200".equals(jsonObject.get("code").toString())) {
+ log.error("get {} Object error, response: {}", objectId, response);
+ throw new RuntimeException("get " + objectId + " Object error, response: " + response);
+ }
+ return jsonObject;
+ }
+
public static void updateObjectById(Integer id, Map<String, Object> body) {
Stopwatch watch = Stopwatch.createStarted();
String response = HttpRequest.put(TSG_URL + "/v1/policy/object/" + id)