From ee5f6ddd99d3a91c4a633e6a5c708200f133b731 Mon Sep 17 00:00:00 2001 From: geek Date: Fri, 29 Jun 2018 18:42:03 +0900 Subject: [PATCH] email token duplication check --- .../infra/service/CentralInfraService.java | 17 ++++++++++ .../dao/MetaCollectionItemMappingDAO.java | 15 ++++++++ ...ntralMetaCollectionItemMappingService.java | 32 +++++++++++++++++ .../service/CentralInfraServiceTest.java | 34 +++++++++++-------- 4 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCollectionItemMappingDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaCollectionItemMappingService.java 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 ad48341..50ce0e5 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 @@ -317,6 +317,23 @@ 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/main/java/com/loafle/overflow/central/module/meta/dao/MetaCollectionItemMappingDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCollectionItemMappingDAO.java new file mode 100644 index 0000000..66bbb47 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCollectionItemMappingDAO.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.meta.MetaCollectionItemMapping; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface MetaCollectionItemMappingDAO extends JpaRepository { + List findAllByMetaDisplayItemMappingId(Long metaDisplayItemMappingID) throws OverflowException; + + List findAllByMetaCollectionItemId(Long metaCollectionItemID) throws OverflowException; +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaCollectionItemMappingService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaCollectionItemMappingService.java new file mode 100644 index 0000000..c00d0bf --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaCollectionItemMappingService.java @@ -0,0 +1,32 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaCollectionItemMappingDAO; +import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.meta.MetaCollectionItemMapping; +import com.loafle.overflow.service.central.meta.MetaCollectionItemMappingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service("MetaCollectionItemMappingService") +public class CentralMetaCollectionItemMappingService implements MetaCollectionItemMappingService { + + @Autowired + MetaCollectionItemMappingDAO metaCollectionItemMappingDAO; + + @Override + public List readAll() throws OverflowException { + return this.metaCollectionItemMappingDAO.findAll(); + } + + @Override + public List readAllByMetaDisplayItemMappingID(Long metaDisplayItemMappingID) throws OverflowException { + return this.metaCollectionItemMappingDAO.findAllByMetaDisplayItemMappingId(metaDisplayItemMappingID); + } + + @Override + public List readAllByMetaCollectionItemID(Long metaCollectionItemID) throws OverflowException { + return this.metaCollectionItemMappingDAO.findAllByMetaCollectionItemId(metaCollectionItemID); + } +} 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 73b01f4..9f2b82f 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 @@ -12,6 +12,7 @@ import com.loafle.overflow.model.meta.MetaIPType; import com.loafle.overflow.model.meta.MetaPortType; import com.loafle.overflow.service.central.infra.InfraService; import com.loafle.overflow.service.central.meta.MetaCryptoTypeService; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -26,11 +27,15 @@ import java.util.List; @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("test") @ContextConfiguration(classes = { AppConfigTest.class }) +@Ignore public class CentralInfraServiceTest { @Autowired InfraService infraService; + @Autowired + CentralInfraService centralInfraService; + @Autowired MetaCryptoTypeService metaCryptoTypeService; @@ -47,50 +52,49 @@ public class CentralInfraServiceTest { MetaCryptoType cryptoType = null; Zone zone = new Zone(); - zone.setAddress("192.168.10.101/24"); + zone.setAddress("192.168.1.103/24"); zone.setDiscoveredDate(new Date()); zone.setIface("enf03"); zone.setMac("44:8a:5b:44:8c:e4"); zone.setMetaIPType(MetaIPType.Enum.V4.to()); - zone.setNetwork("192.168.10.0/24"); + zone.setNetwork("192.168.1.0/24"); // for (int i = 1; i < 6; i++) { host = new Host(); host.setMetaIPType(MetaIPType.Enum.V4.to()); host.getMetaIPType().setKey("V4"); - host.setAddress("192.168.10.12"); - host.setMac("44:8a:5b:44:8c:e7"); + host.setAddress("192.168.1.103"); + host.setMac("44:8a:5b:44:8c:e4"); host.setDiscoveredDate(new Date()); host.setZone(zone); - for (int j = 24; j < 25; j++) { +// 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(j); + port.setPortNumber(22); - for (int x = 24; x < 25; x++) { +// for (int x = 24; x < 25; x++) { service = new Service(); cryptoType = new MetaCryptoType(); - cryptoType.setKey("UNKNOWN"); - cryptoType.setId(Short.valueOf((short) 2)); - cryptoType.setName("Unknown"); + cryptoType.setKey("TLS"); + cryptoType.setId(Short.valueOf((short) 17)); + cryptoType.setName("TLS"); service.setMetaCryptoType(cryptoType); service.setPort(port); service.setDiscoveredDate(new Date()); - service.setKey("Unknown"); + service.setKey("SSH"); services.add(service); - } +// } port.setServiceList(services); ports.add(port); - } +// } host.setPortList(ports); hosts.add(host); // } - // List infras = this.infraService.registDiscoverd(Long.valueOf((long)1), - // hosts, services); + List infras = this.centralInfraService.testRegistDiscoverd(Long.valueOf((long)1), hosts, services); // System.out.println("CentralInfraServiceTest Infra List Size: " + // infras.size()); }