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