This commit is contained in:
insanity 2018-06-06 14:52:00 +09:00
parent cece514174
commit d4940105ff

View File

@ -82,20 +82,21 @@ public class CentralTargetService implements TargetService {
return this.targetDAO.save(t); return this.targetDAO.save(t);
} }
public Target readExistHostTarget(Long probeId, String ip) throws OverflowException { public Target readExistHostTarget(Long probeId, String ip) throws OverflowException {
InfraHost infraHost = this.infraHostService.readByProbeIdAndIpv4(probeId, ip); InfraHost infraHost = this.infraHostService.readByProbeIdAndIpv4(probeId, ip);
if (null == infraHost) return null; if (null == infraHost)
return null;
return this.targetDAO.findByInfraId(infraHost.getId()); return this.targetDAO.findByInfraId(infraHost.getId());
} }
public Target readExistServiceTarget(Long hostId, int portNumber, String portType) throws OverflowException { public Target readExistServiceTarget(Long hostId, int portNumber, String portType) throws OverflowException {
InfraService infraService = this.infraServiceService.readByInfraHostIDAndPortAndPortType(hostId, portNumber, portType); InfraService infraService = this.infraServiceService.readByInfraHostIDAndPortAndPortType(hostId, portNumber,
if (null == infraService) return null; portType);
if (null == infraService)
return null;
return this.targetDAO.findByInfraId(infraService.getId()); return this.targetDAO.findByInfraId(infraService.getId());
} }
@Transactional @Transactional
public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services) public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services)
throws OverflowException { throws OverflowException {
@ -113,7 +114,7 @@ public class CentralTargetService implements TargetService {
InfraHost infraHost = this.registInfraHostByDiscoveredHost(host, probeId); InfraHost infraHost = this.registInfraHostByDiscoveredHost(host, probeId);
Target target = new Target(); Target target = new Target();
target.setInfra(infraHost); target.setInfra(infraHost);
String displayName = (host.getIpv6() == null || host.getIpv6().trim().isEmpty() ? host.getIpv6() : host.getIpv4(); String displayName = (host.getIpv6() == null || host.getIpv6().trim().isEmpty()) ? host.getIpv6() : host.getIpv4();
target.setDisplayName(displayName); target.setDisplayName(displayName);
targets.add(this.targetDAO.save(target)); targets.add(this.targetDAO.save(target));
} }
@ -155,7 +156,8 @@ public class CentralTargetService implements TargetService {
return this.infraHostService.regist(infraHost); return this.infraHostService.regist(infraHost);
} }
private InfraService registInfraServiceByDiscoveredService(InfraHost infraHost, Service service, Long probeId) throws OverflowException { private InfraService registInfraServiceByDiscoveredService(InfraHost infraHost, Service service, Long probeId)
throws OverflowException {
InfraService infraService = new InfraService(); InfraService infraService = new InfraService();
infraHost.setMetaInfraType(new MetaInfraType(7)); infraHost.setMetaInfraType(new MetaInfraType(7));
infraService.setInfraHost(infraHost); infraService.setInfraHost(infraHost);