This commit is contained in:
crusader 2018-06-11 17:13:20 +09:00
parent ad2030c7af
commit b4f91ed964
6 changed files with 48 additions and 126 deletions

View File

@ -50,7 +50,7 @@
<dependency> <dependency>
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId> <artifactId>commons-java</artifactId>
<version>1.0.24-SNAPSHOT</version> <version>1.0.26-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -12,6 +12,8 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface InfraZoneDAO extends JpaRepository<InfraZone, Long> { public interface InfraZoneDAO extends JpaRepository<InfraZone, Long> {
InfraZone findByProbeIdAndNetwork(Long probeId, String network);
List<InfraZone> findAllByProbeDomainId(Long probeDomainId); List<InfraZone> findAllByProbeDomainId(Long probeDomainId);
List<InfraZone> findAllByProbeId(Long probeId); List<InfraZone> findAllByProbeId(Long probeId);
} }

View File

@ -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;
}
}

View File

@ -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.commons.utils.PageUtil;
import com.loafle.overflow.central.module.infra.dao.InfraDAO; 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.core.model.PageParams;
import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.core.exception.OverflowException; 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.NoAuthProbeDescriptionHost;
import com.loafle.overflow.model.noauthprobe.NoAuthProbeDescriptionNetwork; import com.loafle.overflow.model.noauthprobe.NoAuthProbeDescriptionNetwork;
import com.loafle.overflow.service.central.infra.InfraService; 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.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -33,45 +35,51 @@ public class CentralInfraService implements InfraService {
InfraDAO infraDAO; InfraDAO infraDAO;
@Autowired @Autowired
private ProbeService probeService; InfraZoneDAO infraZoneDAO;
@Autowired
InfraHostDAO infraHostDAO;
@Autowired
InfraServiceDAO infraServiceDAO;
@Override
public Infra regist(Infra infra) throws OverflowException { public Infra regist(Infra infra) throws OverflowException {
return this.infraDAO.save(infra); return this.infraDAO.save(infra);
} }
public Infra read(Long id) throws OverflowException { @Override
return this.infraDAO.findById(id).get(); public InfraZone registZone(Long probeID, Zone zone) throws OverflowException {
} InfraZone infraZone = this.infraZoneDAO.findByProbeIdAndNetwork(probeID, zone.getNetwork());
if (null != infraZone) {
public Page<Infra> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException { return infraZone;
return this.infraDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
}
public Page<Infra> readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
List<Probe> probeList = this.probeService.readAllByDomainID(domainID);
if (probeList == null || probeList.size() <= 0) {
throw new OverflowException("ProbeNotFoundException", new Throwable());
} }
Page<Infra> infraList = this.infraDAO.findAllByProbeIn(probeList, PageUtil.getPageRequest(pageParams)); infraZone = new InfraZone();
return infraList; infraZone.setMetaInfraType(MetaInfraType.Enum.ZONE.to());
}
public InfraZone regist(Long probeID, Zone zone) throws OverflowException {
return null; return null;
} }
public InfraHost regist(Long probeID, Host host) throws OverflowException { @Override
public InfraHost registHost(Long probeID, Host host) throws OverflowException {
return null; 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 { throws OverflowException {
return null; return null;
} }
public InfraHost regist(Long probeID, NoAuthProbeDescription noAuthProbeDescription) throws OverflowException { @Override
public List<Infra> registDiscoverd(Long probeID, List<Host> hosts,
List<com.loafle.overflow.model.discovery.Service> services) throws OverflowException {
return null;
}
public InfraHost registByNoAuthProbe(Long probeID, NoAuthProbeDescription noAuthProbeDescription)
throws OverflowException {
NoAuthProbeDescriptionNetwork networkInfo = noAuthProbeDescription.getNetwork(); NoAuthProbeDescriptionNetwork networkInfo = noAuthProbeDescription.getNetwork();
InfraHostIP infraHostIP = new InfraHostIP(); InfraHostIP infraHostIP = new InfraHostIP();
// FIXME getting IPType from networkInfo // FIXME getting IPType from networkInfo
@ -90,4 +98,19 @@ public class CentralInfraService implements InfraService {
return this.infraDAO.save(infraHost); return this.infraDAO.save(infraHost);
} }
@Override
public Infra read(Long id) throws OverflowException {
return this.infraDAO.findById(id).get();
}
@Override
public Page<Infra> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
return this.infraDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
}
@Override
public Page<Infra> readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
return this.infraDAO.findAllByProbeDomainId(domainID, PageUtil.getPageRequest(pageParams));
}
} }

View File

@ -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);
}
}

View File

@ -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<InfraZone> readAllByProbeID(Long probeID) throws OverflowException {
return this.infraZoneDAO.findAllByProbeId(probeID);
}
public List<InfraZone> readAllByDomainID(Long domainID) throws OverflowException {
return this.infraZoneDAO.findAllByProbeDomainId(domainID);
}
}