From 29629b144fc0de6e94a7bec20a0557617a2dbb75 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 2 Jul 2018 17:15:18 +0900 Subject: [PATCH] ing --- pom.xml | 2 +- .../infra/service/CentralInfraService.java | 42 +--------------- .../service/CentralInfraServiceTest.java | 49 +++++++++---------- 3 files changed, 27 insertions(+), 66 deletions(-) diff --git a/pom.xml b/pom.xml index dada1fa..fdf3c75 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ com.loafle.overflow commons-java - 1.0.117-SNAPSHOT + 1.0.118-SNAPSHOT diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java index 50ce0e5..dc28e5e 100644 --- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java @@ -277,29 +277,8 @@ public class CentralInfraService implements InfraService { @Override @Transactional - public List registDiscoverd(Long probeID, String compressedHostsAndServices) throws OverflowException { - GZIPInputStream gis = null; - try { - byte[] compressed = Base64.getMimeDecoder().decode(compressedHostsAndServices); - ByteArrayInputStream bis = new ByteArrayInputStream(compressed); - gis = new GZIPInputStream(bis); - } catch (Exception e) { - throw new OverflowException("Cannot deflate", e); - } - - List hosts = null; - List services = null; - - try { - JsonNode node = this.objectMapper.readTree(gis); - hosts = this.objectMapper.readValue(node.get("hosts").traverse(), new TypeReference>() { - }); - services = this.objectMapper.readValue(node.get("services").traverse(), - new TypeReference>() { - }); - } catch (IOException e) { - throw new OverflowException("Cannot convert to json", e); - } + public List registDiscoverd(Long probeID, List hosts, + List services) throws OverflowException { List infras = new ArrayList<>(); @@ -317,23 +296,6 @@ public class CentralInfraService implements InfraService { return infras; } - public List testRegistDiscoverd(Long probeID, List hosts, List services) throws OverflowException { - - List infras = new ArrayList<>(); - - if (null != hosts) { - for (Host host : hosts) { - infras.add(this.registByHost(probeID, host)); - } - } - if (null != services) { - for (com.loafle.overflow.model.discovery.Service service : services) { - infras.add(this.registByService(probeID, service)); - } - } - - return infras; - } public InfraZone registInfraZoneByInfraHostIP(Long probeID, InfraHostIP infraHostIP) throws OverflowException { if (null == infraHostIP) { throw new OverflowException("InfraHostIP is not valid"); diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceTest.java index 9f2b82f..b5223e3 100644 --- a/src/test/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceTest.java @@ -67,34 +67,34 @@ public class CentralInfraServiceTest { host.setMac("44:8a:5b:44:8c:e4"); host.setDiscoveredDate(new Date()); host.setZone(zone); -// for (int j = 22; j < 25; j++) { - port = new Port(); - port.setDiscoveredDate(new Date()); - port.setHost(host); - port.setMetaPortType(MetaPortType.Enum.TCP.to()); - port.setPortNumber(22); + // for (int j = 22; j < 25; j++) { + port = new Port(); + port.setDiscoveredDate(new Date()); + port.setHost(host); + port.setMetaPortType(MetaPortType.Enum.TCP.to()); + port.setPortNumber(22); -// for (int x = 24; x < 25; x++) { - service = new Service(); - cryptoType = new MetaCryptoType(); - cryptoType.setKey("TLS"); - cryptoType.setId(Short.valueOf((short) 17)); - cryptoType.setName("TLS"); + // for (int x = 24; x < 25; x++) { + service = new Service(); + cryptoType = new MetaCryptoType(); + cryptoType.setKey("TLS"); + cryptoType.setId(Short.valueOf((short) 17)); + cryptoType.setName("TLS"); - service.setMetaCryptoType(cryptoType); - service.setPort(port); - service.setDiscoveredDate(new Date()); - service.setKey("SSH"); - services.add(service); -// } - port.setServiceList(services); - ports.add(port); -// } + service.setMetaCryptoType(cryptoType); + service.setPort(port); + service.setDiscoveredDate(new Date()); + service.setKey("SSH"); + services.add(service); + // } + port.setServiceList(services); + ports.add(port); + // } host.setPortList(ports); hosts.add(host); // } - List infras = this.centralInfraService.testRegistDiscoverd(Long.valueOf((long)1), hosts, services); + List infras = this.centralInfraService.registDiscoverd(Long.valueOf((long) 1), hosts, services); // System.out.println("CentralInfraServiceTest Infra List Size: " + // infras.size()); } @@ -119,9 +119,8 @@ public class CentralInfraServiceTest { public void registByHost() { } - -// Long probeID, -// com.loafle.overflow.model.discovery.Service service + // Long probeID, + // com.loafle.overflow.model.discovery.Service service @Test public void registByService() throws OverflowException { Host host = null;