tubemq-server/src/main/java/org/apache/tubemq/server/master/web/handler/WebAdminFlowRuleHandler.java
// translate rule info to json format string
translate rule info to json format string
translate rule info to json format string
private int checkAndGetFlowRules(String inFlowCtrlInfo,
                                     int opType,
                                     StringBuilder strBuffer) throws Exception {
        int ruleCnt = 0;
        strBuffer.append("[");
        if (TStringUtils.isNotBlank(inFlowCtrlInfo)) {
            List<Integer> ruleTypes = Arrays.asList(0, 1, 2, 3);
            inFlowCtrlInfo = inFlowCtrlInfo.trim();
            FlowCtrlRuleHandler flowCtrlRuleHandler =
                new FlowCtrlRuleHandler(true);
            Map<Integer, List<FlowCtrlItem>> flowCtrlItemMap =
                    flowCtrlRuleHandler.parseFlowCtrlInfo(inFlowCtrlInfo);
            for (Integer typeId : ruleTypes) {
                if (typeId != null) {
                    int rules = 0;
                    List<FlowCtrlItem> flowCtrlItems = flowCtrlItemMap.get(typeId);
                    if (flowCtrlItems != null) {
                        if (ruleCnt++ > 0) {
                            strBuffer.append(",");
                        }
                        strBuffer.append("{\"type\":").append(typeId.intValue()).append(",\"rule\":[");
                        for (FlowCtrlItem flowCtrlItem : flowCtrlItems) {
                            if (flowCtrlItem != null) {
                                if (rules++ > 0) {
                                    strBuffer.append(",");
                                }
                                strBuffer = flowCtrlItem.toJsonString(strBuffer);
                            }
                        }
                        strBuffer.append("]}");
                    }
                }
            }
        }
        strBuffer.append("]");
        return ruleCnt;
    }
private int checkAndGetFlowRules ( String inFlowCtrlInfo , int opType , StringBuilder strBuffer ) throws Exception { int ruleCnt = 0 ; strBuffer . append ( "[" ) ; if ( TStringUtils . isNotBlank ( inFlowCtrlInfo ) ) { List < Integer > ruleTypes = Arrays . asList ( 0 , 1 , 2 , 3 ) ; inFlowCtrlInfo = inFlowCtrlInfo . trim ( ) ; FlowCtrlRuleHandler flowCtrlRuleHandler = new FlowCtrlRuleHandler ( true ) ; Map < Integer , List < FlowCtrlItem > > flowCtrlItemMap = flowCtrlRuleHandler . parseFlowCtrlInfo ( inFlowCtrlInfo ) ; for ( Integer typeId : ruleTypes ) { if ( typeId != null ) { int rules = 0 ; List < FlowCtrlItem > flowCtrlItems = flowCtrlItemMap . get ( typeId ) ; if ( flowCtrlItems != null ) { if ( ruleCnt ++ > 0 ) { strBuffer . append ( "," ) ; } strBuffer . append ( "{\"type\":" ) . append ( typeId . intValue ( ) ) . append ( ",\"rule\":[" ) ; for ( FlowCtrlItem flowCtrlItem : flowCtrlItems ) { if ( flowCtrlItem != null ) { if ( rules ++ > 0 ) { strBuffer . append ( "," ) ; } strBuffer = flowCtrlItem . toJsonString ( strBuffer ) ; } } strBuffer . append ( "]}" ) ; } } } } strBuffer . append ( "]" ) ; return ruleCnt ; }
translate rule info to json format string
translate rule info to json format string