Unverified Commit 11c4c583 authored by gabry.wu's avatar gabry.wu Committed by GitHub
Browse files

Merge pull request #2960 from simon824/dev

Using Jackson instead of Fastjson
parents f56ae9e6 3eb36709
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -66,11 +66,6 @@
            <artifactId>commons-email</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
+6 −11
Original line number Diff line number Diff line
@@ -16,13 +16,15 @@
 */
package org.apache.dolphinscheduler.alert.template.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.dolphinscheduler.alert.template.AlertTemplate;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.JSONUtils;
import org.apache.dolphinscheduler.common.enums.ShowType;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.dolphinscheduler.common.utils.*;

import java.util.*;

@@ -107,18 +109,11 @@ public class DefaultHTMLTemplate implements AlertTemplate {
    private String getTextTypeMessage(String content,boolean showAll){

        if (StringUtils.isNotEmpty(content)){
            List<String> list;
            try {
                list = JSONUtils.toList(content,String.class);
            }catch (Exception e){
                logger.error("json format exception",e);
                return null;
            }

            ArrayNode list = JSONUtils.parseArray(content);
            StringBuilder contents = new StringBuilder(100);
            for (String str : list){
            for (JsonNode jsonNode : list){
                contents.append(Constants.TR);
                contents.append(Constants.TD).append(str).append(Constants.TD_END);
                contents.append(Constants.TD).append(jsonNode.toString()).append(Constants.TD_END);
                contents.append(Constants.TR_END);
            }

+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package org.apache.dolphinscheduler.alert.utils;


import com.alibaba.fastjson.JSON;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
@@ -129,7 +129,7 @@ public class DingTalkUtils {
        textContent.put("content", txt);
        items.put("text", textContent);

        return JSON.toJSONString(items);
        return JSONUtils.toJsonString(items);

    }

+44 −33
Original line number Diff line number Diff line
@@ -18,9 +18,8 @@ package org.apache.dolphinscheduler.alert.utils;

import org.apache.dolphinscheduler.common.enums.ShowType;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import com.alibaba.fastjson.JSON;
import org.apache.dolphinscheduler.common.utils.*;

import com.google.common.reflect.TypeToken;
import org.apache.dolphinscheduler.plugin.model.AlertData;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -64,6 +63,7 @@ public class EnterpriseWeChatUtils {

    /**
     * get Enterprise WeChat is enable
     *
     * @return isEnable
     */
    public static boolean isEnable() {
@@ -81,6 +81,7 @@ public class EnterpriseWeChatUtils {

    /**
     * get Enterprise WeChat token info
     *
     * @return token string info
     * @throws IOException the IOException
     */
@@ -99,10 +100,12 @@ public class EnterpriseWeChatUtils {
                response.close();
            }

            Map<String, Object> map = JSON.parseObject(resp,
                    new TypeToken<Map<String, Object>>() {
                    }.getType());
            return map.get("access_token").toString();
            Map<String, String> map = JSONUtils.toMap(resp);
            if (map != null) {
                return map.get("access_token");
            } else {
                return null;
            }
        } finally {
            httpClient.close();
        }
@@ -110,6 +113,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team single Enterprise WeChat message
     *
     * @param toParty the toParty
     * @param agentId the agentId
     * @param msg     the msg
@@ -123,6 +127,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team multi Enterprise WeChat message
     *
     * @param toParty the toParty
     * @param agentId the agentId
     * @param msg     the msg
@@ -137,6 +142,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team single user message
     *
     * @param toUser  the toUser
     * @param agentId the agentId
     * @param msg     the msg
@@ -150,6 +156,7 @@ public class EnterpriseWeChatUtils {

    /**
     * make team multi user message
     *
     * @param toUser  the toUser
     * @param agentId the agentId
     * @param msg     the msg
@@ -164,6 +171,7 @@ public class EnterpriseWeChatUtils {

    /**
     * send Enterprise WeChat
     *
     * @param charset the charset
     * @param data    the data
     * @param token   the token
@@ -196,6 +204,7 @@ public class EnterpriseWeChatUtils {

    /**
     * convert table to markdown style
     *
     * @param title   the title
     * @param content the content
     * @return markdown table content
@@ -225,6 +234,7 @@ public class EnterpriseWeChatUtils {

    /**
     * convert text to markdown style
     *
     * @param title   the title
     * @param content the content
     * @return markdown text
@@ -255,6 +265,7 @@ public class EnterpriseWeChatUtils {

    /**
     * Determine the mardown style based on the show type of the alert
     *
     * @return the markdown alert table/text
     */
    public static String markdownByAlert(AlertData alert) {
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import org.apache.dolphinscheduler.common.utils.*;

/**
 * excel utils
Loading