summaryrefslogtreecommitdiff
path: root/src/main/java/com/geedge/common/util/TsgUtil.java
diff options
context:
space:
mode:
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)