ing
This commit is contained in:
		
							parent
							
								
									847300b3b0
								
							
						
					
					
						commit
						c03a4585a4
					
				
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @ -50,7 +50,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>com.loafle.overflow</groupId> | ||||
|             <artifactId>commons-java</artifactId> | ||||
|             <version>1.0.33-SNAPSHOT</version> | ||||
|             <version>1.0.34-SNAPSHOT</version> | ||||
|         </dependency> | ||||
| 
 | ||||
|         <dependency> | ||||
|  | ||||
| @ -12,9 +12,10 @@ import org.springframework.stereotype.Repository; | ||||
|  */ | ||||
| @Repository | ||||
| public interface InfraHostIPDAO extends JpaRepository<InfraHostIP, Long> { | ||||
|   InfraHostIP findByInfraHostIdAndMetaIPTypeKeyAndAddress(Long infraHostId, String metaIPTypeKey, String address); | ||||
|   InfraHostIP findByInfraHostInfraZoneIdAndMetaIPTypeKeyAndAddress(Long infraHostInfraZoneId, String metaIPTypeKey, String address); | ||||
| 
 | ||||
|   List<InfraHostIP> findAllByInfraHostId(Long infraHostId); | ||||
|   List<InfraHostIP> findAllByInfraHostIdAndMetaIPTypeKey(Long infraHostId, String metaIPTypeKey); | ||||
|   List<InfraHostIP> findAllByInfraHostIdAndMac(Long infraHostId, String mac); | ||||
|   InfraHostIP findByInfraHostIdAndMetaIPTypeKeyAndAddress(Long infraHostId, String metaIPTypeKey, String address); | ||||
|   InfraHostIP findByInfraHostInfraZoneIdAndMetaIPTypeKeyAndAddress(Long infraHostInfraZoneId, String metaIPTypeKey, String address); | ||||
| } | ||||
| @ -13,6 +13,12 @@ import org.springframework.stereotype.Repository; | ||||
| @Repository | ||||
| public interface InfraHostPortDAO extends JpaRepository<InfraHostPort, Long> { | ||||
|   List<InfraHostPort> findAllByInfraHostId(Long infraHostId); | ||||
| 
 | ||||
|   List<InfraHostPort> findAllByInfraHostIdAndMetaPortTypeId(Long infraHostId, Short metaPortTypeId); | ||||
|   InfraHostPort findByInfraHostIdAndMetaPortTypeIdAndPort(Long infraHostId, Short metaPortTypeId, Integer port); | ||||
| 
 | ||||
|   InfraHostPort findByInfraHostIdAndMetaPortTypeKeyAndPort(Long infraHostId, String metaPortTypeKey, Integer port); | ||||
| 
 | ||||
|   InfraHostPort findByInfraHostInfraZoneIdAndMetaPortTypeKeyAndPort(Long infraHostInfraZoneId, String metaPortTypeKey, | ||||
|       Integer port); | ||||
| 
 | ||||
| } | ||||
| @ -11,7 +11,7 @@ import org.springframework.stereotype.Service; | ||||
|  * Created by insanity on 17. 6. 28. | ||||
|  */ | ||||
| 
 | ||||
| @Service("InfraOSDaemonService") | ||||
| @Service("InfraHostDaemonService") | ||||
| public class CentralInfraHostDaemonService implements InfraHostDaemonService { | ||||
|   @Autowired | ||||
|   InfraHostDaemonDAO infraHostDaemonDAO; | ||||
|  | ||||
| @ -3,14 +3,11 @@ package com.loafle.overflow.central.module.infra.service; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraHostIPDAO; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraHostPortDAO; | ||||
| import com.loafle.overflow.central.module.meta.service.CentralMetaIPTypeService; | ||||
| import com.loafle.overflow.core.exception.OverflowException; | ||||
| import com.loafle.overflow.model.infra.InfraHostIP; | ||||
| import com.loafle.overflow.model.infra.InfraHostPort; | ||||
| import com.loafle.overflow.model.meta.MetaIPType; | ||||
| import com.loafle.overflow.service.central.infra.InfraHostIPService; | ||||
| import com.loafle.overflow.service.central.infra.InfraHostPortService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| @ -18,7 +15,7 @@ import org.springframework.stereotype.Service; | ||||
|  * Created by insanity on 17. 6. 28. | ||||
|  */ | ||||
| 
 | ||||
| @Service("InfraOSIPService") | ||||
| @Service("InfraHostIPService") | ||||
| public class CentralInfraHostIPService implements InfraHostIPService { | ||||
|   @Autowired | ||||
|   InfraHostIPDAO infraHostIPDAO; | ||||
| @ -26,23 +23,29 @@ public class CentralInfraHostIPService implements InfraHostIPService { | ||||
|   @Autowired | ||||
|   CentralMetaIPTypeService metaIPTypeService; | ||||
| 
 | ||||
|   @Override | ||||
|   public InfraHostIP regist(InfraHostIP infraHostIP) throws OverflowException { | ||||
|   public InfraHostIP validate(InfraHostIP infraHostIP) throws OverflowException { | ||||
|     if (null == infraHostIP) { | ||||
|       throw new OverflowException("InfraHostIP is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == infraHostIP.getInfraHost()) { | ||||
|       throw new OverflowException("InfraHost is not valid"); | ||||
|     } | ||||
|     MetaIPType metaIPType = infraHostIP.getMetaIPType(); | ||||
| 
 | ||||
|     if (null == infraHostIP.getMetaIPType()) { | ||||
|     if (null == metaIPType) { | ||||
|       throw new OverflowException("MetaIPType is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     MetaIPType metaIPType = this.metaIPTypeService.readByKey(infraHostIP.getMetaIPType().getKey()); | ||||
|     if (null == metaIPType.getId()) { | ||||
|       String metaIPTypeKey = metaIPType.getKey(); | ||||
|       if (null == metaIPTypeKey) { | ||||
|         throw new OverflowException("Key of MetaIPType is not valid"); | ||||
|       } | ||||
| 
 | ||||
|       metaIPType = this.metaIPTypeService.readByKey(metaIPTypeKey); | ||||
|       if (null == metaIPType) { | ||||
|       throw new OverflowException(String.format("MetaIPTypeKey[%s] is not valid", infraHostIP.getMetaIPType().getKey())); | ||||
|         throw new OverflowException( | ||||
|             String.format("MetaIPTypeKey[%s] is not valid", metaIPTypeKey)); | ||||
|       } | ||||
|       infraHostIP.setMetaIPType(metaIPType); | ||||
|     } | ||||
| 
 | ||||
|     if (null == infraHostIP.getAddress()) { | ||||
| @ -53,6 +56,17 @@ public class CentralInfraHostIPService implements InfraHostIPService { | ||||
|       throw new OverflowException("Mac is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     return infraHostIP; | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public InfraHostIP regist(InfraHostIP infraHostIP) throws OverflowException { | ||||
|     infraHostIP = this.validate(infraHostIP); | ||||
| 
 | ||||
|     if (null == infraHostIP.getInfraHost()) { | ||||
|       throw new OverflowException("InfraHost is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     return this.infraHostIPDAO.save(infraHostIP); | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -1,8 +1,10 @@ | ||||
| package com.loafle.overflow.central.module.infra.service; | ||||
| 
 | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraHostPortDAO; | ||||
| import com.loafle.overflow.central.module.meta.service.CentralMetaPortTypeService; | ||||
| import com.loafle.overflow.core.exception.OverflowException; | ||||
| import com.loafle.overflow.model.infra.InfraHostPort; | ||||
| import com.loafle.overflow.model.meta.MetaPortType; | ||||
| import com.loafle.overflow.service.central.infra.InfraHostPortService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| @ -11,12 +13,52 @@ import org.springframework.stereotype.Service; | ||||
|  * Created by insanity on 17. 6. 28. | ||||
|  */ | ||||
| 
 | ||||
| @Service("InfraOSPortService") | ||||
| @Service("InfraHostPortService") | ||||
| public class CentralInfraHostPortService implements InfraHostPortService { | ||||
|   @Autowired | ||||
|   InfraHostPortDAO infraHostPortDAO; | ||||
| 
 | ||||
|   @Autowired | ||||
|   CentralMetaPortTypeService metaPortTypeService; | ||||
| 
 | ||||
|   public InfraHostPort validate(InfraHostPort infraHostPort) throws OverflowException { | ||||
|     if (null == infraHostPort) { | ||||
|       throw new OverflowException("InfraHostPort is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     MetaPortType metaPortType = infraHostPort.getMetaPortType(); | ||||
| 
 | ||||
|     if (null == metaPortType) { | ||||
|       throw new OverflowException("MetaPortType is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == metaPortType.getId()) { | ||||
|       String metaPortTypeKey = metaPortType.getKey(); | ||||
|       if (null == metaPortTypeKey) { | ||||
|         throw new OverflowException("Key of MetaPortType is not valid"); | ||||
|       } | ||||
| 
 | ||||
|       metaPortType = this.metaPortTypeService.readByKey(metaPortTypeKey); | ||||
|       if (null == metaPortType) { | ||||
|         throw new OverflowException(String.format("Key[%s] of MetaPortType is not valid", metaPortTypeKey)); | ||||
|       } | ||||
|       infraHostPort.setMetaPortType(metaPortType); | ||||
|     } | ||||
| 
 | ||||
|     if (null == infraHostPort.getPort()) { | ||||
|       throw new OverflowException("Number of Port is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     return infraHostPort; | ||||
|   } | ||||
| 
 | ||||
|   public InfraHostPort regist(InfraHostPort infraHostPort) throws OverflowException { | ||||
|     infraHostPort = this.validate(infraHostPort); | ||||
| 
 | ||||
|     if (null == infraHostPort.getInfraHost()) { | ||||
|       throw new OverflowException("InfraHost is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     return this.infraHostPortDAO.save(infraHostPort); | ||||
|   } | ||||
| 
 | ||||
| @ -24,8 +66,13 @@ public class CentralInfraHostPortService implements InfraHostPortService { | ||||
|     return this.infraHostPortDAO.findById(id).get(); | ||||
|   } | ||||
| 
 | ||||
|   public InfraHostPort readByInfraOSIDAndPortAndPortType(Long infraOSID, Short metaPortTypeID, Integer port) | ||||
|       throws OverflowException { | ||||
|     return this.infraHostPortDAO.findByInfraHostIdAndMetaPortTypeIdAndPort(infraOSID, metaPortTypeID, port); | ||||
|   public InfraHostPort readByInfraHostIDAndMetaPortTypeKeyAndPort(Long infraHostID, String metaPortTypeKey, | ||||
|       Integer port) throws OverflowException { | ||||
|     return this.infraHostPortDAO.findByInfraHostIdAndMetaPortTypeKeyAndPort(infraHostID, metaPortTypeKey, port); | ||||
|   } | ||||
| 
 | ||||
|   public InfraHostPort readByInfraHostInfraZoneIDAndMetaPortTypeKeyAndPort(Long infraHostInfraZoneID, | ||||
|       String metaPortTypeKey, Integer port) throws OverflowException { | ||||
|     return this.infraHostPortDAO.findByInfraHostInfraZoneIdAndMetaPortTypeKeyAndPort(infraHostInfraZoneID, metaPortTypeKey, port); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -3,30 +3,29 @@ package com.loafle.overflow.central.module.infra.service; | ||||
| import com.loafle.overflow.central.commons.utils.PageUtil; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraDAO; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraHostDAO; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraHostIPDAO; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraServiceDAO; | ||||
| import com.loafle.overflow.central.module.infra.dao.InfraZoneDAO; | ||||
| import com.loafle.overflow.central.module.meta.dao.MetaIPTypeDAO; | ||||
| import com.loafle.overflow.central.module.meta.service.CentralMetaIPTypeService; | ||||
| import com.loafle.overflow.central.module.meta.service.CentralMetaCryptoTypeService; | ||||
| import com.loafle.overflow.core.model.PageParams; | ||||
| import com.loafle.overflow.model.probe.Probe; | ||||
| import com.loafle.overflow.core.exception.OverflowException; | ||||
| import com.loafle.overflow.model.discovery.Host; | ||||
| import com.loafle.overflow.model.discovery.Port; | ||||
| import com.loafle.overflow.model.discovery.Zone; | ||||
| import com.loafle.overflow.model.infra.Infra; | ||||
| import com.loafle.overflow.model.infra.InfraHost; | ||||
| import com.loafle.overflow.model.infra.InfraHostIP; | ||||
| import com.loafle.overflow.model.infra.InfraHostPort; | ||||
| import com.loafle.overflow.model.infra.InfraZone; | ||||
| import com.loafle.overflow.model.meta.MetaCryptoType; | ||||
| import com.loafle.overflow.model.meta.MetaIPType; | ||||
| import com.loafle.overflow.model.meta.MetaInfraType; | ||||
| import com.loafle.overflow.model.meta.MetaPortType; | ||||
| import com.loafle.overflow.model.meta.MetaTargetHostType; | ||||
| import com.loafle.overflow.model.meta.MetaTargetZoneType; | ||||
| import com.loafle.overflow.model.noauthprobe.NoAuthProbeDescription; | ||||
| import com.loafle.overflow.model.noauthprobe.NoAuthProbeDescriptionHost; | ||||
| import com.loafle.overflow.model.noauthprobe.NoAuthProbeDescriptionNetwork; | ||||
| import com.loafle.overflow.service.central.infra.InfraHostIPService; | ||||
| import com.loafle.overflow.service.central.infra.InfraService; | ||||
| import com.loafle.overflow.service.central.meta.MetaIPTypeService; | ||||
| import com.loafle.overflow.service.central.probe.ProbeService; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| @ -59,7 +58,10 @@ public class CentralInfraService implements InfraService { | ||||
|   CentralInfraHostIPService infraHostIPService; | ||||
| 
 | ||||
|   @Autowired | ||||
|   CentralMetaIPTypeService metaIPTypeService; | ||||
|   CentralInfraHostPortService infraHostPortService; | ||||
| 
 | ||||
|   @Autowired | ||||
|   CentralMetaCryptoTypeService metaCryptoTypeService; | ||||
| 
 | ||||
|   @Override | ||||
|   public Infra regist(Infra infra) throws OverflowException { | ||||
| @ -67,6 +69,7 @@ public class CentralInfraService implements InfraService { | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   @Transactional | ||||
|   public InfraZone registZone(Long probeID, Zone zone) throws OverflowException { | ||||
|     if (null == zone) { | ||||
|       throw new OverflowException("Zone is not valid"); | ||||
| @ -81,26 +84,19 @@ public class CentralInfraService implements InfraService { | ||||
|       throw new OverflowException("Network is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == zone.getAddress()) { | ||||
|       throw new OverflowException("IP is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == zone.getMac()) { | ||||
|       throw new OverflowException("Mac is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == zone.getIface()) { | ||||
|       throw new OverflowException("Iface is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == zone.getMetaIPTypeKey()) { | ||||
|       throw new OverflowException("MetaIPTypeKey is not valid"); | ||||
|     } | ||||
|     MetaIPType metaIPType = new MetaIPType(); | ||||
|     metaIPType.setKey(zone.getMetaIPTypeKey()); | ||||
| 
 | ||||
|     MetaIPType metaIPType = this.metaIPTypeService.readByKey(zone.getMetaIPTypeKey()); | ||||
|     if (null == metaIPType) { | ||||
|       throw new OverflowException(String.format("MetaIPTypeKey[%s] is not valid", zone.getMetaIPTypeKey())); | ||||
|     } | ||||
|     InfraHostIP infraHostIP = new InfraHostIP(); | ||||
|     infraHostIP.setMetaIPType(metaIPType); | ||||
|     infraHostIP.setAddress(zone.getAddress()); | ||||
|     infraHostIP.setMac(zone.getMac()); | ||||
| 
 | ||||
|     infraHostIP = infraHostIPService.validate(infraHostIP); | ||||
| 
 | ||||
|     InfraZone infraZone = this.infraZoneDAO.findByProbeIdAndNetwork(probeID, zone.getNetwork()); | ||||
|     if (null != infraZone) { | ||||
| @ -113,14 +109,15 @@ public class CentralInfraService implements InfraService { | ||||
|     infraZone.setMetaTargetZoneType(MetaTargetZoneType.Enum.ZONE.to()); | ||||
|     infraZone.setNetwork(zone.getNetwork()); | ||||
|     infraZone.setIface(zone.getIface()); | ||||
|     infraZone.setMetaIPType(metaIPType); | ||||
|     infraZone.setAddress(zone.getAddress()); | ||||
|     infraZone.setMac(zone.getMac()); | ||||
|     infraZone.setMetaIPType(infraHostIP.getMetaIPType()); | ||||
|     infraZone.setAddress(infraHostIP.getAddress()); | ||||
|     infraZone.setMac(infraHostIP.getMac()); | ||||
| 
 | ||||
|     return this.infraZoneDAO.save(infraZone); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   @Transactional | ||||
|   public InfraHost registHost(Long probeID, Host host) throws OverflowException { | ||||
|     if (null == host) { | ||||
|       throw new OverflowException("Host is not valid"); | ||||
| @ -138,33 +135,24 @@ public class CentralInfraService implements InfraService { | ||||
| 
 | ||||
|     InfraZone infraZone = this.registZone(probeID, zone); | ||||
| 
 | ||||
|     if (null == host.getMetaIPTypeKey()) { | ||||
|       throw new OverflowException("MetaIPTypeKey is not valid"); | ||||
|     } | ||||
|     MetaIPType metaIPType = new MetaIPType(); | ||||
|     metaIPType.setKey(host.getMetaIPTypeKey()); | ||||
| 
 | ||||
|     MetaIPType metaIPType = this.metaIPTypeService.readByKey(host.getMetaIPTypeKey()); | ||||
|     if (null == metaIPType) { | ||||
|       throw new OverflowException(String.format("MetaIPTypeKey[%s] is not valid", host.getMetaIPTypeKey())); | ||||
|     } | ||||
| 
 | ||||
|     if (null == host.getAddress()) { | ||||
|       throw new OverflowException("IP is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == host.getMac()) { | ||||
|       throw new OverflowException("Mac is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     InfraHostIP infraHostIP = this.infraHostIPService.readByInfraHostInfraZoneIDAndMetaIPTypeKeyAndAddress(infraZone.getId(), metaIPType.getKey(), host.getAddress()); | ||||
|     if (null != infraHostIP) { | ||||
|       throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is exist already", host.getAddress(), metaIPType.getName(), infraZone.getNetwork())); | ||||
|     } | ||||
| 
 | ||||
|     infraHostIP = new InfraHostIP(); | ||||
|     InfraHostIP infraHostIP = new InfraHostIP(); | ||||
|     infraHostIP.setMetaIPType(metaIPType); | ||||
|     infraHostIP.setAddress(host.getAddress()); | ||||
|     infraHostIP.setMac(host.getMac()); | ||||
| 
 | ||||
|     infraHostIP = infraHostIPService.validate(infraHostIP); | ||||
|     metaIPType = infraHostIP.getMetaIPType(); | ||||
| 
 | ||||
|     InfraHostIP eInfraHostIP = this.infraHostIPService.readByInfraHostInfraZoneIDAndMetaIPTypeKeyAndAddress( | ||||
|         infraZone.getId(), metaIPType.getKey(), host.getAddress()); | ||||
|     if (null != eInfraHostIP) { | ||||
|       throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is exist already", host.getAddress(), | ||||
|           metaIPType.getName(), infraZone.getNetwork())); | ||||
|     } | ||||
| 
 | ||||
|     InfraHost infraHost = new InfraHost(); | ||||
|     infraZone.setMetaInfraType(MetaInfraType.Enum.HOST.to()); | ||||
|     infraZone.setProbe(probe); | ||||
| @ -176,16 +164,111 @@ public class CentralInfraService implements InfraService { | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public InfraService registService(Long probeID, com.loafle.overflow.model.discovery.Service service) | ||||
|       throws OverflowException { | ||||
|     return null; | ||||
|   @Transactional | ||||
|   public com.loafle.overflow.model.infra.InfraService registService(Long probeID, | ||||
|       com.loafle.overflow.model.discovery.Service service) throws OverflowException { | ||||
| 
 | ||||
|     if (null == service) { | ||||
|       throw new OverflowException("Service is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     if (null == service.getMetaCryptoTypeKey()) { | ||||
|       throw new OverflowException("MetaCryptoTypeKey is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     MetaCryptoType metaCryptoType = this.metaCryptoTypeService.readByKey(service.getMetaCryptoTypeKey()); | ||||
|     if (null == metaCryptoType) { | ||||
|       throw new OverflowException(String.format("MetaCryptoTypeKey[%s] is not valid", service.getMetaCryptoTypeKey())); | ||||
|     } | ||||
| 
 | ||||
|     Probe probe = this.probeService.read(probeID); | ||||
|     if (null == probe) { | ||||
|       throw new OverflowException(String.format("ID[%d] of Probe is not valid", probeID)); | ||||
|     } | ||||
| 
 | ||||
|     Port port = service.getPort(); | ||||
|     if (null == port) { | ||||
|       throw new OverflowException("Port of Service is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     Host host = port.getHost(); | ||||
|     if (null == host) { | ||||
|       throw new OverflowException("Host of Service is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     Zone zone = host.getZone(); | ||||
|     if (null == zone) { | ||||
|       throw new OverflowException("Zone is not valid"); | ||||
|     } | ||||
| 
 | ||||
|     MetaIPType metaIPType = new MetaIPType(); | ||||
|     metaIPType.setKey(host.getMetaIPTypeKey()); | ||||
| 
 | ||||
|     InfraHostIP infraHostIP = new InfraHostIP(); | ||||
|     infraHostIP.setMetaIPType(metaIPType); | ||||
|     infraHostIP.setAddress(host.getAddress()); | ||||
|     infraHostIP.setMac(host.getMac()); | ||||
| 
 | ||||
|     infraHostIP = this.infraHostIPService.validate(infraHostIP); | ||||
|     metaIPType = infraHostIP.getMetaIPType(); | ||||
| 
 | ||||
|     MetaPortType metaPortType = new MetaPortType(); | ||||
|     metaPortType.setKey(port.getMetaPortTypeKey()); | ||||
| 
 | ||||
|     InfraHostPort infraHostPort = new InfraHostPort(); | ||||
|     infraHostPort.setMetaPortType(metaPortType); | ||||
|     infraHostPort.setPort(port.getPortNumber()); | ||||
| 
 | ||||
|     infraHostPort = this.infraHostPortService.validate(infraHostPort); | ||||
|     metaPortType = infraHostPort.getMetaPortType(); | ||||
| 
 | ||||
|     InfraZone infraZone = this.registZone(probeID, zone); | ||||
|     InfraHost infraHost = this.registHost(probeID, host); | ||||
| 
 | ||||
|     infraHostIP = this.infraHostIPService.readByInfraHostIDAndMetaIPTypeKeyAndAddress(infraHost.getId(), | ||||
|         metaIPType.getKey(), infraHostIP.getAddress()); | ||||
|     if (null == infraHostIP) { | ||||
|       throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is not exist", host.getAddress(), | ||||
|           metaIPType.getName(), infraZone.getNetwork())); | ||||
|     } | ||||
| 
 | ||||
|     InfraHostPort eInfraHostPort = this.infraHostPortService | ||||
|         .readByInfraHostIDAndMetaPortTypeKeyAndPort(infraHost.getId(), metaPortType.getKey(), infraHostPort.getPort()); | ||||
|     if (null != eInfraHostPort) { | ||||
|       throw new OverflowException( | ||||
|           String.format("Port[%d(%s)] of Zone[%s].Host[%s(%s)] is not exist", host.getAddress(), metaPortType.getName(), | ||||
|               infraZone.getNetwork(), infraHostIP.getAddress(), infraHostIP.getMetaIPType().getName())); | ||||
|     } | ||||
| 
 | ||||
|     infraHostPort = this.infraHostPortService.regist(infraHostPort); | ||||
| 
 | ||||
|     com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService(); | ||||
|     infraService.setInfraHostIP(infraHostIP); | ||||
|     infraService.setInfraHostPort(infraHostPort); | ||||
|     infraService.setMetaCryptoType(metaCryptoType); | ||||
| 
 | ||||
|     return this.infraServiceDAO.save(infraService); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   @Transactional | ||||
|   public List<Infra> registDiscoverd(Long probeID, List<Host> hosts, | ||||
|       List<com.loafle.overflow.model.discovery.Service> services) throws OverflowException { | ||||
|     return null; | ||||
| 
 | ||||
|     List<Infra> infras = new ArrayList<>(); | ||||
| 
 | ||||
|     if (null != hosts) { | ||||
|       for (Host host : hosts) { | ||||
|         infras.add(this.registHost(probeID, host)); | ||||
|       } | ||||
|     } | ||||
|     if (null != services) { | ||||
|       for (com.loafle.overflow.model.discovery.Service service : services) { | ||||
|         infras.add(this.registService(probeID, service)); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     return infras; | ||||
|   } | ||||
| 
 | ||||
|   public InfraHost registByNoAuthProbe(Long probeID, NoAuthProbeDescription noAuthProbeDescription) | ||||
| @ -201,7 +284,7 @@ public class CentralInfraService implements InfraService { | ||||
| 
 | ||||
|     InfraHost infraHost = new InfraHost(); | ||||
|     infraHost.setProbe(new Probe(probeID)); | ||||
|     infraHost.setMetaInfraType(new MetaInfraType(1)); | ||||
|     infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to()); | ||||
|     infraHost.setMetaTargetHostType(new MetaTargetHostType(1)); | ||||
|     infraHost.setInfraHostIPs(infraHostIPs); | ||||
| 
 | ||||
| @ -223,4 +306,8 @@ public class CentralInfraService implements InfraService { | ||||
|     return this.infraDAO.findAllByProbeDomainId(domainID, PageUtil.getPageRequest(pageParams)); | ||||
|   } | ||||
| 
 | ||||
|   public List<InfraZone> readAllInfraZoneByProbeDomainID(Long probeDomainID) throws OverflowException { | ||||
|     return null; | ||||
|   } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -83,24 +83,25 @@ INSERT INTO public.meta_ip_type (	id	,	key	,	"name"	) VALUES (	2	,	'IPV6'	,	'IP | ||||
| INSERT INTO public.meta_port_type (	id	,	key	,	"name"	) VALUES (	1	,	'TCP'	,	'TCP'	); | ||||
| INSERT INTO public.meta_port_type (	id	,	key	,	"name"	) VALUES (	2	,	'UDP'	,	'UDP'	); | ||||
| 
 | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	1	,	'UNKNOWN'	,	'Unknown'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	2	,	'AES'	,	'AES'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	3	,	'CIPHER'	,	'Cipher'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	4	,	'DES'	,	'DES'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	5	,	'DSA'	,	'DSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	6	,	'ECDSA'	,	'ECDSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	7	,	'ELLIPTIC'	,	'Elliptic'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	8	,	'HMAC'	,	'HMAC'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	9	,	'MD5'	,	'MD5'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	10	,	'RAND'	,	'RAND'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	11	,	'RC4'	,	'RC4'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	12	,	'RSA'	,	'RSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	13	,	'SHA1'	,	'SHA1'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	14	,	'SHA256'	,	'SHA512'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	15	,	'SUBTLE'	,	'SUBTLE'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	16	,	'TLS'	,	'TLS'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	17	,	'X509'	,	'X509'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	18	,	'PKIX'	,	'PKIX'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	1	,	'NONE'	,	'None'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	2	,	'UNKNOWN'	,	'Unknown'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	3	,	'AES'	,	'AES'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	4	,	'CIPHER'	,	'Cipher'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	5	,	'DES'	,	'DES'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	6	,	'DSA'	,	'DSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	7	,	'ECDSA'	,	'ECDSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	8	,	'ELLIPTIC'	,	'Elliptic'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	9	,	'HMAC'	,	'HMAC'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	10	,	'MD5'	,	'MD5'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	11	,	'RAND'	,	'RAND'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	12	,	'RC4'	,	'RC4'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	13	,	'RSA'	,	'RSA'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	14	,	'SHA1'	,	'SHA1'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	15	,	'SHA256'	,	'SHA512'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	16	,	'SUBTLE'	,	'SUBTLE'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	17	,	'TLS'	,	'TLS'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	18	,	'X509'	,	'X509'	); | ||||
| INSERT INTO public.meta_crypto_type (	id	,	key	,	"name"	) VALUES (	19	,	'PKIX'	,	'PKIX'	); | ||||
| 
 | ||||
| 
 | ||||
| INSERT INTO public.meta_history_type (	id	,	key	,	"name"	) VALUES (	1	,	'MEMBER'	,	'Member'	); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user