diff --git a/pom.xml b/pom.xml
index 907969d..c96278a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
com.loafle.overflow
commons-java
- 1.0.24-SNAPSHOT
+ 1.0.26-SNAPSHOT
diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraZoneDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraZoneDAO.java
index 791723e..dc3a0e1 100644
--- a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraZoneDAO.java
+++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraZoneDAO.java
@@ -12,6 +12,8 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface InfraZoneDAO extends JpaRepository {
+ InfraZone findByProbeIdAndNetwork(Long probeId, String network);
+
List findAllByProbeDomainId(Long probeDomainId);
List findAllByProbeId(Long probeId);
}
\ No newline at end of file
diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java
deleted file mode 100644
index 5ee5ea7..0000000
--- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.loafle.overflow.central.module.infra.service;
-
-import com.loafle.overflow.central.module.infra.dao.InfraHostDAO;
-import com.loafle.overflow.core.exception.OverflowException;
-import com.loafle.overflow.model.infra.InfraHost;
-import com.loafle.overflow.service.central.infra.InfraHostService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * Created by insanity on 17. 6. 28.
- */
-
-@Service("InfraHostService")
-public class CentralInfraHostService implements InfraHostService {
- @Autowired
- InfraHostDAO infraHostDAO;
-
- public InfraHost regist(InfraHost infraHost) throws OverflowException {
- return this.infraHostDAO.save(infraHost);
- }
-
- public InfraHost read(Long id) throws OverflowException {
- return this.infraHostDAO.findById(id).get();
- }
-
- public InfraHost readByProbeIdAndIpv4(Long probeId, String ip) throws OverflowException {
- return this.infraHostDAO.findByProbeIdAndIpv4(probeId, ip);
- }
-
- @Override
- public InfraHost readByProbeIdAndInfraHostIPsAddressAndMetaIPTypeKey(String probeID, String address, String ipTypeKey)
- throws OverflowException {
- return null;
- }
-
-}
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 6bce25d..1d6adca 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
@@ -2,6 +2,9 @@ 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.InfraServiceDAO;
+import com.loafle.overflow.central.module.infra.dao.InfraZoneDAO;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.core.exception.OverflowException;
@@ -18,7 +21,6 @@ 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.InfraService;
-import com.loafle.overflow.service.central.probe.ProbeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@@ -33,45 +35,51 @@ public class CentralInfraService implements InfraService {
InfraDAO infraDAO;
@Autowired
- private ProbeService probeService;
+ InfraZoneDAO infraZoneDAO;
+ @Autowired
+ InfraHostDAO infraHostDAO;
+
+ @Autowired
+ InfraServiceDAO infraServiceDAO;
+
+ @Override
public Infra regist(Infra infra) throws OverflowException {
return this.infraDAO.save(infra);
}
- public Infra read(Long id) throws OverflowException {
- return this.infraDAO.findById(id).get();
- }
-
- public Page readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
- return this.infraDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
- }
-
- public Page readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
- List probeList = this.probeService.readAllByDomainID(domainID);
-
- if (probeList == null || probeList.size() <= 0) {
- throw new OverflowException("ProbeNotFoundException", new Throwable());
+ @Override
+ public InfraZone registZone(Long probeID, Zone zone) throws OverflowException {
+ InfraZone infraZone = this.infraZoneDAO.findByProbeIdAndNetwork(probeID, zone.getNetwork());
+ if (null != infraZone) {
+ return infraZone;
}
- Page infraList = this.infraDAO.findAllByProbeIn(probeList, PageUtil.getPageRequest(pageParams));
- return infraList;
- }
+ infraZone = new InfraZone();
+ infraZone.setMetaInfraType(MetaInfraType.Enum.ZONE.to());
- public InfraZone regist(Long probeID, Zone zone) throws OverflowException {
return null;
}
- public InfraHost regist(Long probeID, Host host) throws OverflowException {
+ @Override
+ public InfraHost registHost(Long probeID, Host host) throws OverflowException {
return null;
}
- public InfraService regist(Long probeID, com.loafle.overflow.model.discovery.Service service)
+ @Override
+ public InfraService registService(Long probeID, com.loafle.overflow.model.discovery.Service service)
throws OverflowException {
return null;
}
- public InfraHost regist(Long probeID, NoAuthProbeDescription noAuthProbeDescription) throws OverflowException {
+ @Override
+ public List registDiscoverd(Long probeID, List hosts,
+ List services) throws OverflowException {
+ return null;
+ }
+
+ public InfraHost registByNoAuthProbe(Long probeID, NoAuthProbeDescription noAuthProbeDescription)
+ throws OverflowException {
NoAuthProbeDescriptionNetwork networkInfo = noAuthProbeDescription.getNetwork();
InfraHostIP infraHostIP = new InfraHostIP();
// FIXME getting IPType from networkInfo
@@ -90,4 +98,19 @@ public class CentralInfraService implements InfraService {
return this.infraDAO.save(infraHost);
}
+ @Override
+ public Infra read(Long id) throws OverflowException {
+ return this.infraDAO.findById(id).get();
+ }
+
+ @Override
+ public Page readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
+ return this.infraDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
+ }
+
+ @Override
+ public Page readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
+ return this.infraDAO.findAllByProbeDomainId(domainID, PageUtil.getPageRequest(pageParams));
+ }
+
}
diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceService.java
deleted file mode 100644
index 7b1d48b..0000000
--- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraServiceService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.loafle.overflow.central.module.infra.service;
-
-import com.loafle.overflow.central.module.infra.dao.InfraServiceDAO;
-import com.loafle.overflow.core.exception.OverflowException;
-import com.loafle.overflow.model.infra.InfraService;
-import com.loafle.overflow.service.central.infra.InfraServiceService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * Created by insanity on 17. 6. 28.
- */
-@Service("InfraServiceService")
-public class CentralInfraServiceService implements InfraServiceService {
-
- @Autowired
- InfraServiceDAO infraServiceDAO;
-
- public com.loafle.overflow.model.infra.InfraService regist(InfraService infraService) throws OverflowException {
- return this.infraServiceDAO.save(infraService);
- }
-
- public com.loafle.overflow.model.infra.InfraService read(Long id) throws OverflowException {
- return this.infraServiceDAO.findById(id).get();
- }
-
- public com.loafle.overflow.model.infra.InfraService readByInfraHostIDAndPortAndPortType(Long infraHostID, int port, String portType)
- throws OverflowException {
- return this.infraServiceDAO.findByInfraHostIdAndPortAndPortType(infraHostID, port, portType);
- }
-}
diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraZoneService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraZoneService.java
deleted file mode 100644
index 8f5549b..0000000
--- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraZoneService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.loafle.overflow.central.module.infra.service;
-
-import com.loafle.overflow.central.module.infra.dao.InfraZoneDAO;
-import com.loafle.overflow.core.exception.OverflowException;
-import com.loafle.overflow.model.infra.InfraZone;
-import com.loafle.overflow.service.central.infra.InfraZoneService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-
-@Service("InfraZoneService")
-public class CentralInfraZoneService implements InfraZoneService {
-
- @Autowired
- InfraZoneDAO infraZoneDAO;
-
- public InfraZone regist(InfraZone infraZone) throws OverflowException {
- return this.infraZoneDAO.save(infraZone);
- }
-
- public InfraZone read(Long id) throws OverflowException {
- return this.infraZoneDAO.findById(id).get();
- }
-
- public List readAllByProbeID(Long probeID) throws OverflowException {
- return this.infraZoneDAO.findAllByProbeId(probeID);
- }
-
- public List readAllByDomainID(Long domainID) throws OverflowException {
- return this.infraZoneDAO.findAllByProbeDomainId(domainID);
- }
-}