Skip to content
Permalink
Browse files
[INLONG-4239][Manager] Remove fastjson dependency (#4242)
  • Loading branch information
leosanqing authored and healchow committed May 18, 2022
1 parent cc508f5 commit 838d84296deebbefc4fc3e3e1107396b5eb746b8
Showing 7 changed files with 38 additions and 34 deletions.
@@ -47,10 +47,6 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
@@ -17,10 +17,11 @@

package org.apache.inlong.manager.client.api.auth;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.inlong.manager.client.api.util.AssertUtil;
import org.apache.inlong.manager.common.util.JsonUtils;

import java.util.Map;

@@ -59,9 +60,9 @@ public void configure(Map<String, String> properties) {

@Override
public String toString() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(USER_NAME, this.getUserName());
jsonObject.put(PASSWORD, this.getPassword());
return jsonObject.toString();
ObjectNode objectNode = JsonUtils.OBJECT_MAPPER.createObjectNode();
objectNode.put(USER_NAME, this.getUserName());
objectNode.put(PASSWORD, this.getPassword());
return objectNode.toString();
}
}
@@ -17,10 +17,11 @@

package org.apache.inlong.manager.client.api.auth;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.inlong.manager.client.api.util.AssertUtil;
import org.apache.inlong.manager.common.util.JsonUtils;

import java.util.Map;

@@ -59,9 +60,9 @@ public void configure(Map<String, String> properties) {

@Override
public String toString() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(SECRET_ID, this.getSecretId());
jsonObject.put(SECRET_KEY, this.getSecretKey());
return jsonObject.toString();
ObjectNode objectNode = JsonUtils.OBJECT_MAPPER.createObjectNode();
objectNode.put(SECRET_ID, this.getSecretId());
objectNode.put(SECRET_KEY, this.getSecretKey());
return objectNode.toString();
}
}
@@ -17,10 +17,11 @@

package org.apache.inlong.manager.client.api.auth;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import org.apache.inlong.manager.common.util.JsonUtils;

import java.util.Map;

@@ -55,11 +56,11 @@ public void configure(Map<String, String> properties) {
@SneakyThrows
@Override
public String toString() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(SECRET_ID, this.getSecretId());
jsonObject.put(SECRET_KEY, this.getSecretKey());
jsonObject.put(SECRET_TOKEN, this.getSToken());
return jsonObject.toString();
ObjectNode objectNode = JsonUtils.OBJECT_MAPPER.createObjectNode();
objectNode.put(SECRET_ID, this.getSecretId());
objectNode.put(SECRET_KEY, this.getSecretKey());
objectNode.put(SECRET_TOKEN, this.getSToken());
return objectNode.toString();
}

}
@@ -17,10 +17,11 @@

package org.apache.inlong.manager.client.api.auth;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.inlong.manager.client.api.util.AssertUtil;
import org.apache.inlong.manager.common.util.JsonUtils;

import java.util.Map;

@@ -52,8 +53,8 @@ public void configure(Map<String, String> properties) {

@Override
public String toString() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TOKEN, this.getToken());
return jsonObject.toString();
ObjectNode objectNode = JsonUtils.OBJECT_MAPPER.createObjectNode();
objectNode.put(TOKEN, this.getToken());
return objectNode.toString();
}
}
@@ -17,8 +17,9 @@

package org.apache.inlong.manager.client.api.inner;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@@ -167,12 +168,12 @@ public PageInfo<InlongGroupListResponse> listGroups(String keyword, int status,
pageNum = 1;
}

JSONObject groupQuery = new JSONObject();
ObjectNode groupQuery = JsonUtils.OBJECT_MAPPER.createObjectNode();
groupQuery.put("keyword", keyword);
groupQuery.put("status", status);
groupQuery.put("pageNum", pageNum);
groupQuery.put("pageSize", pageSize);
String operationData = GsonUtil.toJson(groupQuery);
String operationData = groupQuery.toString();

RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), operationData);
String path = HTTP_PATH + "/group/list";
@@ -756,17 +757,18 @@ public WorkflowResult initInlongGroup(InlongGroupRequest groupInfo) {
public WorkflowResult startInlongGroup(int taskId,
Pair<InlongGroupApproveRequest, List<InlongStreamApproveRequest>> initMsg) {

JSONObject workflowTaskOperation = new JSONObject();
workflowTaskOperation.put("transferTo", Lists.newArrayList());
ObjectMapper objectMapper = JsonUtils.OBJECT_MAPPER;
ObjectNode workflowTaskOperation = objectMapper.createObjectNode();
workflowTaskOperation.putPOJO("transferTo", Lists.newArrayList());
workflowTaskOperation.put("remark", "approved by system");

JSONObject inlongGroupApproveForm = new JSONObject();
inlongGroupApproveForm.put("groupApproveInfo", initMsg.getKey());
inlongGroupApproveForm.put("streamApproveInfoList", initMsg.getValue());
ObjectNode inlongGroupApproveForm = objectMapper.createObjectNode();
inlongGroupApproveForm.putPOJO("groupApproveInfo", initMsg.getKey());
inlongGroupApproveForm.putPOJO("streamApproveInfoList", initMsg.getValue());
inlongGroupApproveForm.put("formName", "InlongGroupApproveForm");
workflowTaskOperation.put("form", inlongGroupApproveForm);
workflowTaskOperation.set("form", inlongGroupApproveForm);

String operationData = GsonUtil.toJson(workflowTaskOperation);
String operationData = workflowTaskOperation.toString();

final String path = HTTP_PATH + "/workflow/approve/" + taskId;
final String url = formatUrl(path);
@@ -26,6 +26,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.inlong.manager.common.exceptions.JsonException;
@@ -38,6 +39,7 @@
* JSON utils
*/
@Slf4j
@UtilityClass
public class JsonUtils {

public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

0 comments on commit 838d842

Please sign in to comment.