package com.doumee.core.conditoner;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.doumee.core.conditoner.model.ConditionerConstant;
|
import com.doumee.core.conditoner.model.request.*;
|
import com.doumee.core.conditoner.model.response.*;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.http.HttpResponse;
|
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.entity.StringEntity;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.util.EntityUtils;
|
|
import java.net.URLEncoder;
|
import java.nio.charset.StandardCharsets;
|
import java.math.BigDecimal;
|
import java.util.Collections;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 智精灵空调平台 HTTP 工具类。
|
* <p>
|
* 协议:GET 读取(Query 参数);POST 控制/写入(JSON Body)。
|
* 成功标识 {@code code=200}。登录后公共参数 {@code kt_token}、{@code kt_dwid}、{@code kt_sonid}。
|
* </p>
|
*/
|
@Slf4j
|
public class ConditionerUtil {
|
|
private static final int HTTP_RETRY = 3;
|
|
private ConditionerUtil() {
|
}
|
|
// ==================== 二、基础控制 ====================
|
|
public static ConditionerBaseResponse<LoginDataResponse> login() {
|
return login(null);
|
}
|
|
public static ConditionerBaseResponse<LoginDataResponse> login(LoginRequest req) {
|
LoginRequest r = req != null ? req : new LoginRequest();
|
JSONObject body = new JSONObject();
|
body.put("username", StringUtils.isNotBlank(r.getUsername()) ? r.getUsername() : ConditionerConstant.username);
|
body.put("password", StringUtils.isNotBlank(r.getPassword()) ? r.getPassword() : ConditionerConstant.password);
|
try {
|
String raw = doPostRaw("/login", body.toJSONString());
|
ConditionerBaseResponse<LoginDataResponse> resp = parseObjectResponse(raw, LoginDataResponse.class);
|
applyLoginSession(resp);
|
return resp;
|
} catch (Exception e) {
|
log.error("conditioner login failed", e);
|
return null;
|
}
|
}
|
|
public static ConditionerBaseResponse<List<DeviceStatusResponse>> getDevList(ConditionerSessionRequest req) {
|
return getList("/getDevList", req, DeviceStatusResponse.class);
|
}
|
|
public static ConditionerBaseResponse<DeviceStatusResponse> getDevOne(GetDevOneRequest req) {
|
if (req == null) {
|
return null;
|
}
|
req.fillSessionDefaults();
|
try {
|
String raw = doGetRaw("/getDevOne", toQueryMap(req));
|
return parseObjectResponse(raw, DeviceStatusResponse.class);
|
} catch (Exception e) {
|
log.error("conditioner getDevOne failed", e);
|
return null;
|
}
|
}
|
|
public static ConditionerBaseResponse<Object> devCtr(DevControlRequest req) {
|
return postJson("/devCtr", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> devManyCtr(DevManyControlRequest req) {
|
return postJson("/devManyCtr", req, Object.class);
|
}
|
public static ConditionerBaseResponse<Object> devLockManyCtr(DevLockControlRequest req) {
|
return postJson("/devManyCtr", req, Object.class);
|
}
|
|
// ==================== 三、设备管理 ====================
|
|
public static ConditionerBaseResponse<List<GatewayInfoResponse>> getWg(ConditionerSessionRequest req) {
|
return getList("/getWg", req, GatewayInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addWg(WgManageRequest req) {
|
return postJson("/addWg", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeWg(WgManageRequest req) {
|
return postJson("/changeWg", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delWg(WgManageRequest req) {
|
return postJson("/delWg", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> wgWithArea(WgWithAreaRequest req) {
|
return postJson("/wgWithArea", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<DeviceArchiveResponse>> getDev(ConditionerSessionRequest req) {
|
return getList("/getDev", req, DeviceArchiveResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addDev(DevManageRequest req) {
|
return postJson("/addDev", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeDev(DevManageRequest req) {
|
return postJson("/changeDev", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delDev(DevManageRequest req) {
|
return postJson("/delDev", req, Object.class);
|
}
|
|
// ==================== 四、区域管理 ====================
|
|
public static ConditionerBaseResponse<List<RoomInfoResponse>> getRoom(ConditionerSessionRequest req) {
|
return getList("/getRoom", req, RoomInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addRoom(RoomManageRequest req) {
|
return postJson("/addRoom", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeRoom(RoomManageRequest req) {
|
return postJson("/changeRoom", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delRoom(RoomManageRequest req) {
|
return postJson("/delRoom", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<FloorInfoResponse>> getFloor(ConditionerPageRequest req) {
|
return getList("/getFloor", req, FloorInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addFloor(FloorManageRequest req) {
|
return postJson("/addFloor", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeFloor(FloorManageRequest req) {
|
return postJson("/changeFloor", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delFloor(FloorManageRequest req) {
|
return postJson("/delFloor", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<UnitInfoResponse>> getUnit(ConditionerPageRequest req) {
|
return getList("/getUnit", req, UnitInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addUnit(UnitManageRequest req) {
|
return postJson("/addUnit", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeUnit(UnitManageRequest req) {
|
return postJson("/changeUnit", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delUnit(UnitManageRequest req) {
|
return postJson("/delUnit", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<BuildingInfoResponse>> getBuilding(ConditionerPageRequest req) {
|
return getList("/getBuilding", req, BuildingInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addBuilding(BuildingManageRequest req) {
|
return postJson("/addBuilding", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeBuilding(BuildingManageRequest req) {
|
return postJson("/changeBuilding", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delBuilding(BuildingManageRequest req) {
|
return postJson("/delBuilding", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<AreaInfoResponse>> getArea(ConditionerPageRequest req) {
|
return getList("/getArea", req, AreaInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addArea(AreaManageRequest req) {
|
return postJson("/addArea", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeArea(AreaManageRequest req) {
|
return postJson("/changeArea", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delArea(AreaManageRequest req) {
|
return postJson("/delArea", req, Object.class);
|
}
|
|
// ==================== 五、定时管理 ====================
|
|
public static ConditionerBaseResponse<List<TimingInfoResponse>> getTiming(ConditionerSessionRequest req) {
|
return getList("/getTiming", req, TimingInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addTiming(TimingManageRequest req) {
|
return postJson("/addTiming", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeTiming(TimingManageRequest req) {
|
return postJson("/changeTiming", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delTiming(TimingManageRequest req) {
|
return postJson("/delTiming", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> timingWithArea(TimingWithAreaRequest req) {
|
return postJson("/timingWithArea", req, Object.class);
|
}
|
|
// ==================== 六、数据查询 ====================
|
|
public static ConditionerBaseResponse<List<Object>> getLogWg(LogQueryRequest req) {
|
return getList("/getLogWg", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<Object>> getLogDev(LogQueryRequest req) {
|
return getList("/getLogDev", req, Object.class);
|
}
|
|
// ==================== 七、计量管理 ====================
|
|
public static ConditionerBaseResponse<List<DlSjXsResponse>> getDlSjXs(ConditionerSessionRequest req) {
|
return getList("/getDlSjXs", req, DlSjXsResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeDlSjXs(ChangeDlSjXsRequest req) {
|
return postJson("/changeDlSjXs", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<MeterDbInfoResponse>> getDb(MeterDbManageRequest req) {
|
return getList("/glDb/getDb", req, MeterDbInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addDb(MeterDbManageRequest req) {
|
return postJson("/glDb/addDb", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeDb(MeterDbManageRequest req) {
|
return postJson("/glDb/changeDb", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delDb(MeterDbManageRequest req) {
|
return postJson("/glDb/delDb", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<Object>> getDbDaySum(DbDaySumQueryRequest req) {
|
return getList("/getDbDaySum", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<Object>> getDayDl(DayDlQueryRequest req) {
|
return getList("/getDayDl", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<Object>> getMoonDl(MoonDlQueryRequest req) {
|
return getList("/getMoonDl", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<CompanyGsInfoResponse>> getGs(CompanyGsManageRequest req) {
|
return getList("/getGs", req, CompanyGsInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addGs(CompanyGsManageRequest req) {
|
if (req == null) {
|
return null;
|
}
|
req.fillSessionDefaults();
|
JSONObject body = new JSONObject(true);
|
putSessionFields(body, req);
|
body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1);
|
body.put("li_dev", req.getLi_dev() != null ? req.getLi_dev() : Collections.emptyList());
|
body.put("d_dev", req.getD_dev() != null ? req.getD_dev() : Collections.emptyMap());
|
body.put("gs_name", req.getGs_name());
|
body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0);
|
body.put("gs_bz", StringUtils.defaultString(req.getGs_bz()));
|
putStopMoney(body, req.getStop_money());
|
return postJsonBody("/addGs", body, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeGs(CompanyGsManageRequest req) {
|
if (req == null || req.getId() == null) {
|
return null;
|
}
|
req.fillSessionDefaults();
|
JSONObject body = new JSONObject(true);
|
putSessionFields(body, req);
|
body.put("id", req.getId());
|
body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1);
|
body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0);
|
body.put("gs_name", req.getGs_name());
|
if (req.getLeft_money() != null) {
|
body.put("left_money", req.getLeft_money());
|
}
|
body.put("is_stop", req.getIs_stop() != null ? req.getIs_stop() : 0);
|
body.put("li_dev", req.getLi_dev() != null ? req.getLi_dev() : Collections.emptyList());
|
body.put("d_dev", req.getD_dev() != null ? req.getD_dev() : Collections.emptyMap());
|
body.put("gs_bz", StringUtils.defaultString(req.getGs_bz()));
|
putStopMoney(body, req.getStop_money());
|
return postJsonBody("/changeGs", body, Object.class);
|
}
|
|
private static void putStopMoney(JSONObject body, Object stopMoney) {
|
if (stopMoney == null) {
|
body.put("stop_money", "0");
|
return;
|
}
|
if (stopMoney instanceof BigDecimal) {
|
body.put("stop_money", ((BigDecimal) stopMoney).toPlainString());
|
} else {
|
body.put("stop_money", String.valueOf(stopMoney));
|
}
|
}
|
|
public static ConditionerBaseResponse<Object> delGs(CompanyGsManageRequest req) {
|
return postJson("/delGs", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> gsWithArea(GsWithAreaRequest req) {
|
return postJson("/gsWithArea", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addMoney(AddMoneyRequest req) {
|
if (req == null) {
|
return null;
|
}
|
req.fillSessionDefaults();
|
JSONObject body = new JSONObject(true);
|
putSessionFields(body, req);
|
body.put("id", req.getId());
|
body.put("cz_money", req.getCz_money());
|
return postJsonBody("/addMoney", body, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> cleanMoney(CompanyGsManageRequest req) {
|
if (req == null || req.getId() == null) {
|
return null;
|
}
|
req.fillSessionDefaults();
|
JSONObject body = new JSONObject(true);
|
putSessionFields(body, req);
|
body.put("id", req.getId());
|
return postJsonBody("/cleanMoney", body, Object.class);
|
}
|
|
public static ConditionerBaseResponse<List<Object>> getCzLog(LogQueryRequest req) {
|
return getList("/getCzLog", req, Object.class);
|
}
|
|
// ==================== 八、账号管理 ====================
|
|
public static ConditionerBaseResponse<List<UserInfoResponse>> getUser(ConditionerSessionRequest req) {
|
return getList("/getUser", req, UserInfoResponse.class);
|
}
|
|
public static ConditionerBaseResponse<Object> addUser(UserManageRequest req) {
|
return postJson("/addUser", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeUser(UserManageRequest req) {
|
return postJson("/changeUser", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> changeUserPwd(UserManageRequest req) {
|
return postJson("/changeUserPwd", req, Object.class);
|
}
|
|
public static ConditionerBaseResponse<Object> delUser(UserManageRequest req) {
|
return postJson("/delUser", req, Object.class);
|
}
|
|
// ==================== 会话 ====================
|
|
public static void applyLoginSession(ConditionerBaseResponse<LoginDataResponse> resp) {
|
if (resp == null || !resp.isSuccess() || resp.getData() == null) {
|
return;
|
}
|
LoginDataResponse data = resp.getData();
|
if (StringUtils.isNotBlank(data.getKt_token())) {
|
ConditionerConstant.kt_token = data.getKt_token();
|
}
|
if (data.getKt_dwid() != null) {
|
ConditionerConstant.kt_dwid = String.valueOf(data.getKt_dwid());
|
}
|
if (data.getKt_sonid() != null) {
|
ConditionerConstant.kt_sonid = String.valueOf(data.getKt_sonid());
|
}
|
}
|
|
// ==================== HTTP / 解析 ====================
|
|
private static <T> ConditionerBaseResponse<List<T>> getList(String path, ConditionerSessionRequest req, Class<T> itemClass) {
|
if (req != null) {
|
req.fillSessionDefaults();
|
} else {
|
req = new ConditionerSessionRequest();
|
req.fillSessionDefaults();
|
}
|
try {
|
String raw = doGetRaw(path, toQueryMap(req));
|
return parseListResponse(raw, itemClass);
|
} catch (Exception e) {
|
log.error("conditioner GET {} failed", path, e);
|
return null;
|
}
|
}
|
|
private static <T> ConditionerBaseResponse<T> postJson(String path, ConditionerSessionRequest req, Class<T> dataClass) {
|
if (req != null) {
|
req.fillSessionDefaults();
|
}
|
try {
|
String raw = doPostRaw(path, JSON.toJSONString(req));
|
return parseObjectResponse(raw, dataClass);
|
} catch (Exception e) {
|
log.error("conditioner POST {} failed", path, e);
|
return null;
|
}
|
}
|
|
private static <T> ConditionerBaseResponse<T> postJsonBody(String path, JSONObject body, Class<T> dataClass) {
|
try {
|
String raw = doPostRaw(path, body.toJSONString());
|
return parseObjectResponse(raw, dataClass);
|
} catch (Exception e) {
|
log.error("conditioner POST {} failed", path, e);
|
return null;
|
}
|
}
|
|
private static void putSessionFields(JSONObject body, ConditionerSessionRequest req) {
|
body.put("kt_token", req.getKt_token());
|
body.put("kt_dwid", req.getKt_dwid());
|
body.put("kt_unit", StringUtils.defaultIfBlank(req.getKt_unit(), ConditionerConstant.DEFAULT_KT_UNIT));
|
body.put("kt_sonid", req.getKt_sonid());
|
}
|
|
private static String resolveUrl(String path) {
|
String base = StringUtils.defaultIfBlank(ConditionerConstant.base_url, ConditionerConstant.DEFAULT_BASE_URL);
|
if (base.endsWith("/")) {
|
base = base.substring(0, base.length() - 1);
|
}
|
if (!path.startsWith("/")) {
|
path = "/" + path;
|
}
|
return base + path;
|
}
|
|
private static String doGetRaw(String path, Map<String, String> params) throws Exception {
|
String url = buildGetUrl(path, params);
|
log.info("conditioner GET url={}", maskUrl(url));
|
HttpClient client = HttpClientBuilder.create().build();
|
HttpGet get = new HttpGet(url);
|
HttpResponse response = executeWithRetry(client, get);
|
String resp = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
log.info("conditioner GET response={}", abbreviate(resp));
|
return resp;
|
}
|
|
private static String doPostRaw(String path, String jsonBody) throws Exception {
|
String url = resolveUrl(path);
|
log.info("conditioner POST url={}, body={}", url, maskJson(jsonBody));
|
HttpClient client = HttpClientBuilder.create().build();
|
HttpPost post = new HttpPost(url);
|
post.setHeader("Content-Type", "application/json;charset=UTF-8");
|
post.setEntity(new StringEntity(jsonBody, StandardCharsets.UTF_8));
|
HttpResponse response = executeWithRetry(client, post);
|
String resp = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
log.info("conditioner POST response={}", abbreviate(resp));
|
return resp;
|
}
|
|
private static HttpResponse executeWithRetry(HttpClient client, org.apache.http.client.methods.HttpUriRequest request) throws Exception {
|
HttpResponse execute = null;
|
int retry = HTTP_RETRY;
|
while (retry-- > 0) {
|
try {
|
execute = client.execute(request);
|
break;
|
} catch (Exception e) {
|
if (retry <= 0) {
|
throw e;
|
}
|
Thread.sleep(5000);
|
}
|
}
|
if (execute == null) {
|
throw new Exception("conditioner http request failed");
|
}
|
return execute;
|
}
|
|
private static String buildGetUrl(String path, Map<String, String> params) throws Exception {
|
StringBuilder sb = new StringBuilder(resolveUrl(path));
|
if (params == null || params.isEmpty()) {
|
return sb.toString();
|
}
|
sb.append("?");
|
boolean first = true;
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
if (StringUtils.isBlank(entry.getValue())) {
|
continue;
|
}
|
if (!first) {
|
sb.append("&");
|
}
|
sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue()));
|
first = false;
|
}
|
return sb.toString();
|
}
|
|
private static Map<String, String> toQueryMap(Object obj) {
|
Map<String, String> map = new LinkedHashMap<>();
|
if (obj == null) {
|
return map;
|
}
|
JSONObject json = (JSONObject) JSON.toJSON(obj);
|
for (Map.Entry<String, Object> entry : json.entrySet()) {
|
Object val = entry.getValue();
|
if (val != null) {
|
map.put(entry.getKey(), String.valueOf(val));
|
}
|
}
|
return map;
|
}
|
|
private static <T> ConditionerBaseResponse<T> parseObjectResponse(String raw, Class<T> dataClass) {
|
if (StringUtils.isBlank(raw)) {
|
return null;
|
}
|
try {
|
JSONObject root = JSON.parseObject(raw);
|
ConditionerBaseResponse<T> resp = new ConditionerBaseResponse<>();
|
resp.setCode(root.getInteger("code"));
|
resp.setMessage(root.getString("message"));
|
Object data = root.get("data");
|
if (data != null && dataClass != null) {
|
if (data instanceof JSONObject) {
|
resp.setData(((JSONObject) data).toJavaObject(dataClass));
|
} else if (data instanceof String) {
|
String text = ((String) data).trim();
|
if (text.startsWith("{")) {
|
resp.setData(JSON.parseObject(text, dataClass));
|
}
|
} else if (!(data instanceof JSONArray)) {
|
resp.setData(JSON.parseObject(JSON.toJSONString(data), dataClass));
|
}
|
}
|
return resp;
|
} catch (Exception e) {
|
log.error("conditioner parse object response failed: {}", abbreviate(raw), e);
|
return null;
|
}
|
}
|
|
private static <T> ConditionerBaseResponse<List<T>> parseListResponse(String raw, Class<T> itemClass) {
|
if (StringUtils.isBlank(raw)) {
|
return null;
|
}
|
try {
|
JSONObject root = JSON.parseObject(raw);
|
ConditionerBaseResponse<List<T>> resp = new ConditionerBaseResponse<>();
|
resp.setCode(root.getInteger("code"));
|
resp.setMessage(root.getString("message"));
|
Object data = root.get("data");
|
if (data instanceof JSONArray) {
|
resp.setData(((JSONArray) data).toJavaList(itemClass));
|
} else if (data instanceof String) {
|
String text = ((String) data).trim();
|
if (text.startsWith("[")) {
|
resp.setData(JSON.parseArray(text, itemClass));
|
}
|
}
|
return resp;
|
} catch (Exception e) {
|
log.error("conditioner parse list response failed: {}", abbreviate(raw), e);
|
return null;
|
}
|
}
|
|
private static String urlEncode(String value) throws Exception {
|
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
|
}
|
|
private static String maskUrl(String url) {
|
if (url == null) {
|
return null;
|
}
|
return url.replaceAll("(kt_token=)[^&]+", "$1***");
|
}
|
|
private static String maskJson(String json) {
|
if (json == null) {
|
return null;
|
}
|
return json.replaceAll("(\\\"password\\\"\\s*:\\s*\\\")[^\\\"]+(\\\")", "$1***$2")
|
.replaceAll("(\\\"kt_token\\\"\\s*:\\s*\\\")[^\\\"]+(\\\")", "$1***$2");
|
}
|
|
private static String abbreviate(String text) {
|
if (text == null) {
|
return null;
|
}
|
return text.length() > 500 ? text.substring(0, 500) + "..." : text;
|
}
|
}
|