diff --git a/pom.xml b/pom.xml index 887ab1b..a763419 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ com.loafle.overflow commons-java - 1.0.45-SNAPSHOT + 1.0.47-SNAPSHOT diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java index 4ee5aed..1808348 100644 --- a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java @@ -12,6 +12,8 @@ import com.loafle.overflow.model.apikey.ApiKey; import com.loafle.overflow.model.domain.Domain; import com.loafle.overflow.model.domain.DomainMember; import com.loafle.overflow.model.infra.InfraHost; +import com.loafle.overflow.model.infra.InfraHostIP; +import com.loafle.overflow.model.infra.InfraZone; import com.loafle.overflow.model.member.Member; import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus; import com.loafle.overflow.model.meta.MetaProbeStatus; @@ -95,14 +97,30 @@ public class CentralNoAuthProbeService implements NoAuthProbeService { @Transactional public List acceptNoAuthProbe(Long noAuthProbeID, String zoneCIDR) throws OverflowException { NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findById(noAuthProbeID).get(); + if (null == noAuthProbe) { + throw new OverflowException(String.format("ID(%s) of NoAuthProbe is not exist", noAuthProbeID)); + } - InfraHost infraHost = null; + InfraHost oriInfraHost = null; try { - infraHost = this.objectMapper.readValue(noAuthProbe.getInfraHostMeta(), InfraHost.class); + oriInfraHost = this.objectMapper.readValue(noAuthProbe.getInfraHostMeta(), InfraHost.class); } catch (IOException e) { throw new OverflowException("json error", e); } + if (null == oriInfraHost.getInfraHostIPs()) { + throw new OverflowException("IP of Probe InfraHost is not valild"); + } + + for (InfraHostIP infraHostIP : oriInfraHost.getInfraHostIPs()) { + + } + + + InfraZone infraZone = new InfraZone(); + InfraHost infraHost = new InfraHost(); + + Probe probe = this.newProbe(noAuthProbe, infraHost); InfraHost host = this.infraService.registByNoAuthProbe(probe.getId(), infraHost); this.newProbeHost(host, probe); @@ -132,7 +150,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService { probe.setDomain(new Domain(apiKey.getDomain().getId())); probe.setAuthorizeMember(new Member(domainMember.getMember().getId())); probe.setTargetCount(0); - probe.setMetaProbeStatus(new MetaProbeStatus((short) 1)); + probe.setMetaProbeStatus(MetaProbeStatus.Enum.INITIAL.to()); String name = infraHost.getInfraHostOS().getName(); name += " probe";