parent
7bc5f2ef1a
commit
1f1abbfe4b
|
@ -1,5 +1,6 @@
|
||||||
package com.dispose.ability.impl;
|
package com.dispose.ability.impl;
|
||||||
|
|
||||||
|
import com.dispose.common.ConstValue;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import com.dispose.common.DpTechConfigValue;
|
import com.dispose.common.DpTechConfigValue;
|
||||||
import com.dispose.common.IpAddrType;
|
import com.dispose.common.IpAddrType;
|
||||||
|
@ -13,6 +14,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dp tech bypass ability.
|
* The type Dp tech bypass ability.
|
||||||
|
@ -79,7 +81,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public void getDisposeDeviceProtectObject() {
|
public void getDisposeDeviceProtectObject() {
|
||||||
try {
|
try {
|
||||||
log.info("++++Begging DPTech Get All Protection Objects");
|
log.debug("++++Begging DPTech Get All Protection Objects");
|
||||||
ArrayOfProtectionObjectDataForService ret = getCleanTypePort().getAllProtectionObjectFromUMC();
|
ArrayOfProtectionObjectDataForService ret = getCleanTypePort().getAllProtectionObjectFromUMC();
|
||||||
|
|
||||||
if (ret == null) {
|
if (ret == null) {
|
||||||
|
@ -103,32 +105,58 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
||||||
log.error("!!!!Remove Protection Object {} Error: {}", objName, rsp.getResultInfo().getValue());
|
log.error("!!!!Remove Protection Object {} Error: {}", objName, rsp.getResultInfo().getValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 缓存所有防护对象
|
DpProtectObject obj;
|
||||||
DpProtectObject obj = DpProtectObject.builder()
|
|
||||||
|
if (!umcObject.contains(objName)) {
|
||||||
|
// 获取防护对象
|
||||||
|
obj = umcObject.get(objName);
|
||||||
|
} else {
|
||||||
|
obj = DpProtectObject.builder()
|
||||||
.cleanupDevices(k.getCleaningDevices().getValue())
|
.cleanupDevices(k.getCleaningDevices().getValue())
|
||||||
.protectName(objName)
|
.protectName(objName)
|
||||||
.detectionDevices(k.getDetectionDevices().getValue())
|
.detectionDevices(k.getDetectionDevices().getValue())
|
||||||
.ipType(k.getIpType() == 0 ? IpAddrType.IPV4 : IpAddrType.IPV6)
|
.ipType(k.getIpType() == 0 ? IpAddrType.IPV4 : IpAddrType.IPV6)
|
||||||
.ipSegment(new Hashtable<>())
|
.ipSegment(new Hashtable<>())
|
||||||
.build();
|
.build();
|
||||||
|
// 添加到缓存
|
||||||
|
umcObject.put(objName, obj);
|
||||||
|
}
|
||||||
|
|
||||||
String ipSeg = k.getIpSegment().getValue();
|
String ipSeg = k.getIpSegment().getValue();
|
||||||
log.debug("DpTech response type: {}, value: {}", k.getIpType(), ipSeg);
|
log.debug("DpTech response type: {}, value: {}", k.getIpType(), ipSeg);
|
||||||
|
Hashtable<String, String> tmpTable = new Hashtable<>();
|
||||||
|
|
||||||
// 分割IP段
|
// 分割IP段
|
||||||
Arrays.stream(StringUtils.deleteWhitespace(ipSeg).split(",")).forEach(v -> {
|
Arrays.stream(StringUtils.deleteWhitespace(ipSeg).split(",")).forEach(v -> {
|
||||||
String ipValue = v.replaceAll("\\d+_", "");
|
String ipValue = v.replaceAll("\\d+_", "");
|
||||||
String key = v.replace(ipValue, "").replace("_", "");
|
String key = v.replace(ipValue, "").replace("_", "");
|
||||||
|
|
||||||
|
if (Pattern.matches(ConstValue.ipAddrSegmentReg(), ipValue)) {
|
||||||
// 添加到缓存
|
// 添加到缓存
|
||||||
obj.getIpSegment().put(key, ipValue);
|
tmpTable.put(key, ipValue);
|
||||||
|
} else {
|
||||||
|
// 删除异常段
|
||||||
|
NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectIPRangeForUMC(objName
|
||||||
|
, key);
|
||||||
|
|
||||||
|
if (rsp.getResultRetVal() == 0) {
|
||||||
|
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Succeed", objName, v);
|
||||||
|
} else {
|
||||||
|
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Error: {}", objName, v,
|
||||||
|
rsp.getResultInfo().getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 添加到缓存
|
// 判断是否需要更新IP段信息
|
||||||
umcObject.put(objName, obj);
|
if(!obj.getIpSegment().equals(tmpTable)) {
|
||||||
|
obj.setIpSegment(tmpTable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("----Finish DPTech Get All Protection Objects: {}", ret.getProtectionObjectDataForService()
|
log.debug("----Finish DPTech Get All Protection Objects Succeed");
|
||||||
.size());
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("----Exception DPTech Get All Protection Objects: {}", ex.getMessage());
|
log.error("----Exception DPTech Get All Protection Objects: {}", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue