REM:
1. 修复多处代码检测警告
This commit is contained in:
HuangXin 2021-10-09 11:05:53 +08:00
parent 31265036f0
commit 4c998bce48
13 changed files with 84 additions and 59 deletions

View File

@ -13,7 +13,7 @@ public class Constants {
/** /**
* DDoS具体攻击类型 * DDoS具体攻击类型
*/ */
public static Map<String, String> ATTACK_TYPE; public static final Map<String, String> ATTACK_TYPE;
static { static {
Map<String, String> attTypeMap = new HashMap<>(); Map<String, String> attTypeMap = new HashMap<>();
@ -79,7 +79,6 @@ public class Constants {
public static final int HIDEPEND = 3; public static final int HIDEPEND = 3;
/** /**
* /**
* 派单eoms模板 * 派单eoms模板
*/ */
public static final String DISPATCH_TEMPLATE = "<AlarmStart>\nMsgSerial:{0}\nSDN:{1}\nNeName:{2}\nEquipmentClass:99236\n" + public static final String DISPATCH_TEMPLATE = "<AlarmStart>\nMsgSerial:{0}\nSDN:{1}\nNeName:{2}\nEquipmentClass:99236\n" +
@ -97,15 +96,17 @@ public class Constants {
"LinkOnuNum: \n<AlarmEnd>"; "LinkOnuNum: \n<AlarmEnd>";
/** /**
0网元自动清除 --收到从采集源发送的清除告警 * 0网元自动清除 --收到从采集源发送的清除告警
*/ */
public static final int NE_AUTO_CLEARED_STATUS = 0; public static final int NE_AUTO_CLEARED_STATUS = 0;
/** /**
1活动告警---告警当前为活动状态 * 1活动告警---告警当前为活动状态
*/ */
public static final int ACTIVE_ALARM_STATUS = 1; public static final int ACTIVE_ALARM_STATUS = 1;
/** /**
2同步清除---已采集活动告警但采集平台从告警源同步时发现已经没有对应的活动告警由采集平台产生的清除告警 * 2同步清除---已采集活动告警但采集平台从告警源同步时发现已经没有对应的活动告警由采集平台产生的清除告警
*/ */
public static final int SYNCHRONIZATION_CLEAR_STATUS = 2; public static final int SYNCHRONIZATION_CLEAR_STATUS = 2;
} }

View File

@ -18,6 +18,8 @@ import java.util.Map;
/** /**
* The type Kafka configuration. * The type Kafka configuration.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/ */
@EnableKafka @EnableKafka
@ConfigurationProperties(prefix = "kafka") @ConfigurationProperties(prefix = "kafka")
@ -86,7 +88,7 @@ public class KafkaConfiguration {
} }
/** /**
* Producer factory. * Producer factory producer factory.
* *
* @return the producer factory * @return the producer factory
*/ */
@ -95,7 +97,7 @@ public class KafkaConfiguration {
} }
/** /**
* Kafka template. * Kafka template kafka template.
* *
* @return the kafka template * @return the kafka template
*/ */

View File

@ -8,8 +8,8 @@ import com.dispose.manager.AlarmInfoManager;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus; import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO; import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO; import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo;
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq; import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo;
import com.dispose.pojo.entity.AlarmInformation; import com.dispose.pojo.entity.AlarmInformation;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
import com.dispose.security.annotation.Decryption; import com.dispose.security.annotation.Decryption;
@ -47,7 +47,7 @@ import java.util.Objects;
@Validated @Validated
@Encryption @Encryption
@Decryption @Decryption
public class kafkaController { public class KafkaController {
/** /**
* The Kafka configuration. * The Kafka configuration.
*/ */
@ -141,8 +141,9 @@ public class kafkaController {
String vendorAlarmId; String vendorAlarmId;
if (type != null) { if (type != null) {
String[] arr = type.split("\\|"); String[] arr = type.split("\\|");
String bps = "bps";
vendorAlarmType = arr[0]; vendorAlarmType = arr[0];
if (alarmInfo.getBpspps().compareTo("bps") == 0) { if (bps.equals(alarmInfo.getBpspps())) {
vendorAlarmId = arr[1]; vendorAlarmId = arr[1];
} else { } else {
vendorAlarmId = arr[2]; vendorAlarmId = arr[2];
@ -156,7 +157,7 @@ public class kafkaController {
String alarmText = characterEncode(getAlarmText(alarmInfo)); String alarmText = characterEncode(getAlarmText(alarmInfo));
String alarmExplanation = characterEncode(getAlarmExplanation(alarmInfo)); String alarmExplanation = characterEncode(getAlarmExplanation(alarmInfo));
String content = MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp, return MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp,
dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime, dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime,
vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"), vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"),
characterEncode("DDos攻击事件"), alarmStatus, alarmText, characterEncode("DDos攻击事件"), alarmStatus, alarmText,
@ -164,7 +165,6 @@ public class kafkaController {
characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"), characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"),
characterEncode("安全告警"), characterEncode("DDOS告警"), characterEncode("安全告警"), characterEncode("DDOS告警"),
alarmExplanation, characterEncode("集中抗D")); alarmExplanation, characterEncode("集中抗D"));
return content;
} catch (Exception e) { } catch (Exception e) {
log.error("createSendContent告警消息异常详细信息{}", ExceptionUtils.getStackTrace(e)); log.error("createSendContent告警消息异常详细信息{}", ExceptionUtils.getStackTrace(e));
return null; return null;

View File

@ -69,8 +69,7 @@ public class GlobalExceptionHandler {
log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + log.error("Interface [{}] request <{}> from {}, token = <{}>\n" +
"+++ Request: {}\n" + "+++ Request: {}\n" +
"--- Verify params failed: {}", "--- Verify params failed: {}",
reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), sb);
sb.toString());
} catch (Exception ignored) { } catch (Exception ignored) {
} }

View File

@ -2,19 +2,24 @@ package com.dispose.manager;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
/**
* The interface Msg serial manager.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface MsgSerialManager { public interface MsgSerialManager {
/** /**
* Add user business error code. * Update msg serial number error code.
* *
* @param msgSerial the message serial * @param msgSerial the msg serial
* @return the error code * @return the error code
*/ */
ErrorCode updateMsgSerialNumber(Long msgSerial); ErrorCode updateMsgSerialNumber(Long msgSerial);
/** /**
* get new max message serial. * Gets max msg serial.
* *
* @return the long * @return the max msg serial
*/ */
Long getMaxMsgSerial(); Long getMaxMsgSerial();
} }

View File

@ -9,6 +9,11 @@ import lombok.EqualsAndHashCode;
import java.util.List; import java.util.List;
/**
* The type Emos alarm info.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode() @EqualsAndHashCode()
@Data @Data
@Builder @Builder
@ -18,67 +23,67 @@ import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class EmosAlarmInfo { public class EmosAlarmInfo {
/** /**
* 告警id. * The Alarm id.
*/ */
private String alarmId; private String alarmId;
/** /**
* 被攻击ip. * The Dst ip.
*/ */
private String dstIp; private String dstIp;
/** /**
* 攻击类型(类似HTTP Flood字符串形式). * The Attack type.
*/ */
private String attackType; private String attackType;
/** /**
* 被攻击ip. * The Bpspps.
*/ */
private String bpspps; private String bpspps;
/** /**
* 目的ip省份. * The Dst province.
*/ */
private String dstProvince; private String dstProvince;
/** /**
* 目的ip市. * The Dst city.
*/ */
private String dstCity; private String dstCity;
/** /**
* 告警源ip列表,没有就给empty的list. * The Src ip ls.
*/ */
private List<String> srcIpLs; private List<String> srcIpLs;
/** /**
* 告警开始时间. * The Start time.
*/ */
private String startTime; private String startTime;
/** /**
* 告警结束时间. * The End time.
*/ */
private String endTime; private String endTime;
/** /**
* 处置类型(1:清洗,2:黑洞,3:高防),默认清洗. * The Dispose type.
*/ */
private Integer disposeType; private Integer disposeType;
/** /**
* 处置时长. * The Dispose time.
*/ */
private Integer disposeTime; private Integer disposeTime;
/** /**
* 流量峰值(单位:bps). * The Max bps.
*/ */
private String maxBps; private String maxBps;
/** /**
* 包数峰值(单位:pps). * The Max pps.
*/ */
private String maxPps; private String maxPps;
} }

View File

@ -3,19 +3,24 @@ package com.dispose.service;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
/**
* The interface Msg serial service.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface MsgSerialService { public interface MsgSerialService {
/** /**
* update message serial. * Update message serial mul return type.
* *
* @param msgSerial the message serial * @param msgSerial the msg serial
* @return the mul return type * @return the mul return type
*/ */
MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial); MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial);
/** /**
* get new max message serial. * Gets max message serial.
* *
* @return the long * @return the max message serial
*/ */
Long getMaxMessageSerial(); Long getMaxMessageSerial();

View File

@ -8,15 +8,23 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
/**
* The type Msg serial service.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Service @Service
public class MsgSerialServiceImpl implements MsgSerialService { public class MsgSerialServiceImpl implements MsgSerialService {
/**
* The Msg serial manager.
*/
@Resource @Resource
private MsgSerialManager msgSerialManager; private MsgSerialManager msgSerialManager;
/** /**
* add message serial. * Update message serial mul return type.
* *
* @param msgSerial the message serial * @param msgSerial the msg serial
* @return the mul return type * @return the mul return type
*/ */
@Override @Override
@ -37,9 +45,9 @@ public class MsgSerialServiceImpl implements MsgSerialService {
} }
/** /**
* get new max message serial. * Gets max message serial.
* *
* @return the long * @return the max message serial
*/ */
@Override @Override
public Long getMaxMessageSerial() { public Long getMaxMessageSerial() {

View File

@ -81,7 +81,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) { if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) {
List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList()); List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList());
errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val.toString()); errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val);
ret = false; ret = false;
} }
@ -106,7 +106,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation(); ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
return ret; return ret;
} }

View File

@ -58,7 +58,7 @@ public class ValidBaseEnumArrayImpl implements ConstraintValidator<ValidBaseEnum
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() .get(0).getPath().getLeafNode().getName()
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues.toString(); + " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();

View File

@ -61,7 +61,7 @@ public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Int
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() .get(0).getPath().getLeafNode().getName()
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues.toString(); + " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();

View File

@ -63,7 +63,7 @@ public class ValidDisposeObjectImpl implements ConstraintValidator<ValidDisposeO
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation(); ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
return ret; return ret;
} }

View File

@ -55,7 +55,7 @@ public class ValidSplitPageSizeImpl implements ConstraintValidator<ValidSplitPag
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() + .get(0).getPath().getLeafNode().getName() +
" 值 {" + integer + "} 错误, 字段取值范围:" + rang.toString(); " 值 {" + integer + "} 错误, 字段取值范围:" + rang;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();