REM:
1. 修正SOAP库部分checkstyle警告
2. 数据库忽略添加重复的设备
This commit is contained in:
huangxin 2020-04-22 11:25:36 +08:00
parent e10168956c
commit cf5183d1e3
4 changed files with 2339 additions and 620 deletions

View File

@ -15,6 +15,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.wss4j.dom.WSConstants; import org.apache.wss4j.dom.WSConstants;
@ -23,6 +24,7 @@ import org.apache.wss4j.dom.handler.WSHandlerConstants;
/** /**
* The type Dp tech. * The type Dp tech.
*/ */
@Slf4j
public class DPTechImpl implements DisposeEntryManager { public class DPTechImpl implements DisposeEntryManager {
/** /**
* Gets version. * Gets version.
@ -63,39 +65,44 @@ public class DPTechImpl implements DisposeEntryManager {
public List<DisposeDeviceCapacity> getDeviceCapacity() { public List<DisposeDeviceCapacity> getDeviceCapacity() {
List<DisposeDeviceCapacity> capList = new ArrayList<>(); List<DisposeDeviceCapacity> capList = new ArrayList<>();
String devs = cleanTypePort.getAllDetectDevices(); try {
String devs = cleanTypePort.getAllDetectDevices();
if (devs != null && devs.length() > 0) { if (devs != null && devs.length() > 0) {
capList.add(DisposeDeviceCapacity.builder() capList.add(DisposeDeviceCapacity.builder()
.capacity(ConstValue.DeviceCapacity.DETECIVE.getCode()) .capacity(ConstValue.DeviceCapacity.DETECIVE.getCode())
.tolFlowCapacity(0) .tolFlowCapacity(0)
.build()); .build());
} }
devs = cleanTypePort.getAllProtectDevices(); devs = cleanTypePort.getAllProtectDevices();
if (devs != null && devs.length() > 0) { if (devs != null && devs.length() > 0) {
List<String> proIPv4 = new ArrayList<>(); List<String> proIPv4 = new ArrayList<>();
List<String> proIPv6 = new ArrayList<>(); List<String> proIPv6 = new ArrayList<>();
ArrayOfProtectionObjectDataForService objs = cleanTypePort.getAllProtectionObjectFromUMC(); ArrayOfProtectionObjectDataForService objs = cleanTypePort.getAllProtectionObjectFromUMC();
objs.getProtectionObjectDataForService().forEach(v -> { objs.getProtectionObjectDataForService().forEach(v -> {
String ipSeg = v.getIpSegment().getValue(); String ipSeg = v.getIpSegment().getValue();
if (v.getIpType() == 0 && ipSeg.length() > 0) { if (v.getIpType() == 0 && ipSeg.length() > 0) {
proIPv4.addAll(Arrays.asList(ipSeg.replaceAll("\\d{1,}_", "") proIPv4.addAll(Arrays.asList(ipSeg.replaceAll("\\d{1,}_", "")
.split(","))); .split(",")));
} else if (v.getIpType() == 1 && ipSeg.length() > 0) { } else if (v.getIpType() == 1 && ipSeg.length() > 0) {
proIPv6.addAll(Arrays.asList(ipSeg.replaceAll("\\d{1,}_", "") proIPv6.addAll(Arrays.asList(ipSeg.replaceAll("\\d{1,}_", "")
.split(","))); .split(",")));
} }
}); });
capList.add(DisposeDeviceCapacity.builder() capList.add(DisposeDeviceCapacity.builder()
.capacity(ConstValue.DeviceCapacity.CLEANUP.getCode()) .capacity(ConstValue.DeviceCapacity.CLEANUP.getCode())
.tolFlowCapacity(0) .tolFlowCapacity(0)
.protectIpV4(proIPv4.toArray(new String[0])) .protectIpV4(proIPv4.toArray(new String[0]))
.protectIpV6(proIPv6.toArray(new String[0])) .protectIpV6(proIPv6.toArray(new String[0]))
.build()); .build());
}
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
} }
return capList; return capList;
@ -108,9 +115,15 @@ public class DPTechImpl implements DisposeEntryManager {
*/ */
@Override @Override
public boolean getDeviceLinkStatus() { public boolean getDeviceLinkStatus() {
List<ArrayOfProtectionObjectDataForService> objs = getAllProtectionObject(); try {
List<ArrayOfProtectionObjectDataForService> objs = getAllProtectionObject();
return objs != null; return objs != null;
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return false;
}
} }
/** /**
@ -133,7 +146,13 @@ public class DPTechImpl implements DisposeEntryManager {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T getAllDetectionObject() { public <T> T getAllDetectionObject() {
return (T) cleanTypePort.getAllDetectionObjectFromUMC().getDetectionObjectDataForService(); try {
return (T) cleanTypePort.getAllDetectionObjectFromUMC().getDetectionObjectDataForService();
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return null;
}
} }
/** /**
@ -145,7 +164,13 @@ public class DPTechImpl implements DisposeEntryManager {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T getAllProtectionObject() { public <T> T getAllProtectionObject() {
return (T) cleanTypePort.getAllProtectionObjectFromUMC().getProtectionObjectDataForService(); try {
return (T) cleanTypePort.getAllProtectionObjectFromUMC().getProtectionObjectDataForService();
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return null;
}
} }
/** /**
@ -154,11 +179,16 @@ public class DPTechImpl implements DisposeEntryManager {
* @return the detection object device json * @return the detection object device json
* @throws JsonProcessingException the json processing exception * @throws JsonProcessingException the json processing exception
*/ */
public String getDetectionObjectDeviceJson() throws JsonProcessingException { public String getDetectionObjectDeviceJson(){
ArrayOfDetectionObjectDataForService typePort = cleanTypePort.getAllDetectionObjectFromUMC(); try {
ArrayOfDetectionObjectDataForService typePort = cleanTypePort.getAllDetectionObjectFromUMC();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(typePort); return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(typePort);
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return "{}";
}
} }
/** /**
@ -168,7 +198,13 @@ public class DPTechImpl implements DisposeEntryManager {
*/ */
@Override @Override
public String getProtectDevices() { public String getProtectDevices() {
return cleanTypePort.getAllProtectDevices(); try {
return cleanTypePort.getAllProtectDevices();
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return "";
}
} }
/** /**
@ -178,7 +214,13 @@ public class DPTechImpl implements DisposeEntryManager {
*/ */
@Override @Override
public String getDetectionDevices() { public String getDetectionDevices() {
return cleanTypePort.getAllDetectDevices(); try {
return cleanTypePort.getAllDetectDevices();
} catch (Exception ex) {
log.error(ex.getMessage());
ex.printStackTrace();
return "";
}
} }
/** /**

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dispose.mapper.DisposeDeviceMapper"> <mapper namespace="com.dispose.mapper.DisposeDeviceMapper">
<insert id="addNewDisposeDevice" useGeneratedKeys="true" keyProperty="id" parameterType="com.dispose.pojo.entity.DisposeDevice"> <insert id="addNewDisposeDevice" useGeneratedKeys="true" keyProperty="id" parameterType="com.dispose.pojo.entity.DisposeDevice">
INSERT INTO INSERT IGNORE INTO
dispose_device(ipAddr, type, dispose_device(ipAddr, type,
areaCode, name, manufacturer, areaCode, name, manufacturer,
model, version, readme, status) model, version, readme, status)

View File

@ -138,7 +138,7 @@ public class DisposeDeviceMapperTest extends InitTestEnvironment {
* @throws JsonProcessingException the json processing exception * @throws JsonProcessingException the json processing exception
*/ */
@Test @Test
public void t99_delDisposeDeviceByIp() throws JsonProcessingException { public void t0_delDisposeDeviceByIp() throws JsonProcessingException {
String ipAddr = "10.88.77.15"; String ipAddr = "10.88.77.15";
disposeDeviceMapper.delDisposeDeviceByIp(ipAddr); disposeDeviceMapper.delDisposeDeviceByIp(ipAddr);