Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java
#	src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java
This commit is contained in:
geek 2018-04-24 17:53:59 +09:00
commit 7dd6526d93
57 changed files with 479 additions and 1831 deletions

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.central.commons.utils; package com.loafle.overflow.central.commons.utils;
import com.loafle.overflow.central.commons.model.PageParams; import com.loafle.overflow.core.model.PageParams;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.apikey.dao; package com.loafle.overflow.central.module.apikey.dao;
import com.loafle.overflow.central.module.apikey.model.ApiKey;
import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.model.apikey.ApiKey;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,81 +0,0 @@
package com.loafle.overflow.central.module.apikey.model;
import com.loafle.overflow.central.module.domain.model.Domain;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "API_KEY", schema = "public")
public class ApiKey {
private long id;
private String apiKey;
private Date createDate;
private Domain domain;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Column(name = "API_KEY", nullable = false, unique = true,length = 50)
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@ManyToOne
@JoinColumn(name = "DOMAIN_ID", nullable=false)
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// TblApiKey tblApiKey = (TblApiKey) o;
//
// if (id != tblApiKey.id) return false;
// if (domainId != tblApiKey.domainId) return false;
// if (apiKey != null ? !apiKey.equals(tblApiKey.apiKey) : tblApiKey.apiKey != null) return false;
// if (createDate != null ? !createDate.equals(tblApiKey.createDate) : tblApiKey.createDate != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (id ^ (id >>> 32));
// result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0);
// result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
// result = 31 * result + (int) (domainId ^ (domainId >>> 32));
// return result;
// }
}

View File

@ -1,8 +1,11 @@
package com.loafle.overflow.central.module.apikey.service; package com.loafle.overflow.central.module.apikey.service;
import com.loafle.overflow.central.commons.exception.OverflowException;
import com.loafle.overflow.central.module.apikey.dao.ApiKeyDAO; import com.loafle.overflow.central.module.apikey.dao.ApiKeyDAO;
import com.loafle.overflow.central.module.apikey.model.ApiKey;
import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.model.apikey.ApiKey;
import com.loafle.overflow.service.central.apikey.ApiKeyService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -10,23 +13,23 @@ import org.springframework.stereotype.Service;
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */
@Service("ApiKeyService") @Service("ApiKeyService")
public class ApiKeyService { public class CentralApiKeyService implements ApiKeyService {
@Autowired @Autowired
private ApiKeyDAO apiKeyDAO; private ApiKeyDAO apiKeyDAO;
public ApiKey regist(ApiKey apiKey) { public ApiKey regist(ApiKey apiKey) throws OverflowException {
return this.apiKeyDAO.save(apiKey); return this.apiKeyDAO.save(apiKey);
} }
public ApiKey readByDomain(Domain domain) { public ApiKey readByDomain(Domain domain) throws OverflowException {
return this.apiKeyDAO.findByDomain(domain); return this.apiKeyDAO.findByDomain(domain);
} }
public boolean check(String apiKey) { public boolean check(String apiKey) throws OverflowException {
ApiKey retApiKey = this.apiKeyDAO.findByApiKey(apiKey); ApiKey retApiKey = this.apiKeyDAO.findByApiKey(apiKey);
@ -37,7 +40,7 @@ public class ApiKeyService {
return true; return true;
} }
public ApiKey readByApiKey(String apiKey) { public ApiKey readByApiKey(String apiKey) throws OverflowException{
return this.apiKeyDAO.findByApiKey(apiKey); return this.apiKeyDAO.findByApiKey(apiKey);
} }

View File

@ -1,8 +1,9 @@
package com.loafle.overflow.central.module.auth.dao; package com.loafle.overflow.central.module.auth.dao;
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
import com.loafle.overflow.central.module.meta.model.MetaCrawler; import com.loafle.overflow.central.module.meta.model.MetaCrawler;
import com.loafle.overflow.central.module.target.model.Target; import com.loafle.overflow.central.module.target.model.Target;
import com.loafle.overflow.model.auth.AuthCrawler;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,72 +0,0 @@
package com.loafle.overflow.central.module.auth.model;
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
import com.loafle.overflow.central.module.target.model.Target;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.persistence.*;
import java.util.Date;
/**
* Created by snoop on 17. 8. 30.
*/
@Entity
@Table(name = "AUTH_CRAWLER", schema = "public")
public class AuthCrawler {
private long id;
private MetaCrawler crawler;
private Target target;
private String authJson;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
@JoinColumn(name = "CRAWLER_ID", nullable = false)
public MetaCrawler getCrawler() {
return crawler;
}
public void setCrawler(MetaCrawler crawler) {
this.crawler = crawler;
}
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "TARGET_ID", nullable = false)
public Target getTarget() {
return target;
}
public void setTarget(Target target) {
this.target = target;
}
@Column(name = "AUTH_JSON", nullable = false)
public String getAuthJson() {
return authJson;
}
public void setAuthJson(String authJson) {
this.authJson = authJson;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}

View File

@ -1,11 +1,14 @@
package com.loafle.overflow.central.module.auth.service; package com.loafle.overflow.central.module.auth.service;
import com.loafle.overflow.central.commons.exception.OverflowException;
import com.loafle.overflow.central.module.auth.dao.AuthCrawlerDAO; import com.loafle.overflow.central.module.auth.dao.AuthCrawlerDAO;
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
import com.loafle.overflow.central.module.infra.model.Infra; import com.loafle.overflow.central.module.infra.model.Infra;
import com.loafle.overflow.central.module.infra.service.InfraService; import com.loafle.overflow.central.module.infra.service.InfraService;
import com.loafle.overflow.central.module.meta.model.MetaCrawler; import com.loafle.overflow.central.module.meta.model.MetaCrawler;
import com.loafle.overflow.central.module.target.model.Target; import com.loafle.overflow.central.module.target.model.Target;
import com.loafle.overflow.model.auth.AuthCrawler;
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,7 +16,7 @@ import org.springframework.stereotype.Service;
* Created by snoop on 17. 8. 30. * Created by snoop on 17. 8. 30.
*/ */
@Service("AuthCrawlerService") @Service("AuthCrawlerService")
public class AuthCrawlerService { public class CentralAuthCrawlerService implements AuthCrawlerService {
@Autowired @Autowired
private AuthCrawlerDAO authCrawlerDAO; private AuthCrawlerDAO authCrawlerDAO;
@ -21,7 +24,7 @@ public class AuthCrawlerService {
@Autowired @Autowired
private InfraService infraService; private InfraService infraService;
public AuthCrawler regist(AuthCrawler authCrawler) { public AuthCrawler regist(AuthCrawler authCrawler) {
AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByCrawlerAndTarget(authCrawler.getCrawler(), authCrawler.getTarget()); AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByCrawlerAndTarget(authCrawler.getCrawler(), authCrawler.getTarget());
@ -36,7 +39,7 @@ public class AuthCrawlerService {
return this.authCrawlerDAO.save(dbAuthCrawler); return this.authCrawlerDAO.save(dbAuthCrawler);
} }
public boolean checkAuthCrawler(long infraId, MetaCrawler crawler, String authJson) { public boolean checkAuthCrawler(long infraId, MetaCrawler crawler, String authJson) throws OverflowException {
Infra infra = this.infraService.read(infraId); Infra infra = this.infraService.read(infraId);
@ -45,7 +48,7 @@ public class AuthCrawlerService {
return false; return false;
} }
public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) { public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) throws OverflowException {
return this.authCrawlerDAO.findByCrawlerAndTarget(metaCrawler, target); return this.authCrawlerDAO.findByCrawlerAndTarget(metaCrawler, target);
} }

View File

@ -1,52 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.List;
public class DiscoveryHost {
private String firstScanRange;
private String lastScanRange;
private List<String> excludeHosts;
private List<String> includeHosts;
private DiscoveryPort discoveryPort;
public String getFirstScanRange() {
return firstScanRange;
}
public void setFirstScanRange(String firstScanRange) {
this.firstScanRange = firstScanRange;
}
public String getLastScanRange() {
return lastScanRange;
}
public void setLastScanRange(String lastScanRange) {
this.lastScanRange = lastScanRange;
}
public List<String> getExcludeHosts() {
return excludeHosts;
}
public void setExcludeHosts(List<String> excludeHosts) {
this.excludeHosts = excludeHosts;
}
public List<String> getIncludeHosts() {
return includeHosts;
}
public void setIncludeHosts(List<String> includeHosts) {
this.includeHosts = includeHosts;
}
public DiscoveryPort getDiscoveryPort() {
return discoveryPort;
}
public void setDiscoveryPort(DiscoveryPort discoveryPort) {
this.discoveryPort = discoveryPort;
}
}

View File

@ -1,61 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.List;
public class DiscoveryPort {
private int firstScanRange;
private int lastScanRange;
private List<Integer> excludePorts;
private boolean includeTCP;
private boolean includeUDP;
private DiscoveryService discoveryService;
public int getFirstScanRange() {
return firstScanRange;
}
public void setFirstScanRange(int firstScanRange) {
this.firstScanRange = firstScanRange;
}
public int getLastScanRange() {
return lastScanRange;
}
public void setLastScanRange(int lastScanRange) {
this.lastScanRange = lastScanRange;
}
public List<Integer> getExcludePorts() {
return excludePorts;
}
public void setExcludePorts(List<Integer> excludePorts) {
this.excludePorts = excludePorts;
}
public boolean isIncludeTCP() {
return includeTCP;
}
public void setIncludeTCP(boolean includeTCP) {
this.includeTCP = includeTCP;
}
public boolean isIncludeUDP() {
return includeUDP;
}
public void setIncludeUDP(boolean includeUDP) {
this.includeUDP = includeUDP;
}
public DiscoveryService getDiscoveryService() {
return discoveryService;
}
public void setDiscoveryService(DiscoveryService discoveryService) {
this.discoveryService = discoveryService;
}
}

View File

@ -1,15 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.List;
public class DiscoveryService {
private List<String> includeServices;
public List<String> getIncludeServices() {
return includeServices;
}
public void setIncludeServices(List<String> includeServices) {
this.includeServices = includeServices;
}
}

View File

@ -1,25 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.List;
public class DiscoveryZone {
private List<String> excludePatterns;
private DiscoveryHost discoveryHost;
public List<String> getExcludePatterns() {
return excludePatterns;
}
public void setExcludePatterns(List<String> excludePatterns) {
this.excludePatterns = excludePatterns;
}
public DiscoveryHost getDiscoveryHost() {
return discoveryHost;
}
public void setDiscoveryHost(DiscoveryHost discoveryHost) {
this.discoveryHost = discoveryHost;
}
}

View File

@ -1,67 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.Date;
/**
* Created by root on 17. 6. 4.
*/
public class Host {
private long id;
private String ip;
private String mac;
private String os;
private Date discoveredDate;
private Zone zone;
public Host(){}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
public Date getDiscoveredDate() {
return discoveredDate;
}
public void setDiscoveredDate(Date discoveredDate) {
this.discoveredDate = discoveredDate;
}
public Zone getZone() {
return zone;
}
public void setZone(Zone zone) {
this.zone = zone;
}
}

View File

@ -1,68 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
/**
* Created by snoop on 17. 6. 27.
*/
import com.loafle.overflow.central.module.discovery.type.PortType;
import java.util.Date;
/**
* Created by root on 17. 6. 4.
*/
public class Port {
private long id;
private PortType portType;
private int portNumber;
private Date discoveredDate;
private Host host;
public Port() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public PortType getPortType() {
return portType;
}
public void setPortType(PortType portType) {
this.portType = portType;
}
public int getPortNumber() {
return portNumber;
}
public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}
public Date getDiscoveredDate() {
return discoveredDate;
}
public void setDiscoveredDate(Date discoveredDate) {
this.discoveredDate = discoveredDate;
}
public Host getHost() {
return host;
}
public void setHost(Host host) {
this.host = host;
}
}

View File

@ -1,60 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.Date;
/**
* Created by root on 17. 6. 4.
*/
public class Service {
private long id;
private String cryptoType;
private String serviceName;
private Date discoveredDate;
private Port port;
public Service() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getCryptoType() {
return cryptoType;
}
public void setCryptoType(String cryptoType) {
this.cryptoType = cryptoType;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public Date getDiscoveredDate() {
return discoveredDate;
}
public void setDiscoveredDate(Date discoveredDate) {
this.discoveredDate = discoveredDate;
}
public Port getPort() {
return port;
}
public void setPort(Port port) {
this.port = port;
}
}

View File

@ -1,63 +0,0 @@
package com.loafle.overflow.central.module.discovery.model;
import java.util.Date;
/**
* Created by snoop on 17. 10. 31.
*/
public class Zone {
private long id;
private String network;
private String ip;
private String iface;
private String mac;
private Date discoveredDate;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNetwork() {
return network;
}
public void setNetwork(String network) {
this.network = network;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getIface() {
return iface;
}
public void setIface(String iface) {
this.iface = iface;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public Date getDiscoveredDate() {
return discoveredDate;
}
public void setDiscoveredDate(Date discoveredDate) {
this.discoveredDate = discoveredDate;
}
}

View File

@ -1,16 +1,16 @@
package com.loafle.overflow.central.module.discovery.service; package com.loafle.overflow.central.module.discovery.service;
import com.loafle.overflow.central.commons.model.SessionMetadata; import com.loafle.overflow.central.commons.model.SessionMetadata;
import com.loafle.overflow.central.commons.service.MessagePublisher; import com.loafle.overflow.central.commons.service.MessagePublisher;
import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
import com.loafle.overflow.central.module.discovery.model.DiscoveryHost;
import com.loafle.overflow.central.module.discovery.model.DiscoveryPort;
import com.loafle.overflow.central.module.discovery.model.DiscoveryStartInfo; import com.loafle.overflow.central.module.discovery.model.DiscoveryStartInfo;
import com.loafle.overflow.central.module.discovery.model.DiscoveryZone; import com.loafle.overflow.core.annotation.ProbeAPI;
import com.loafle.overflow.central.module.discovery.model.Host; import com.loafle.overflow.core.annotation.WebappAPI;
import com.loafle.overflow.central.module.discovery.model.Port; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.central.module.discovery.model.Zone; import com.loafle.overflow.model.discovery.*;
import com.loafle.overflow.service.central.discovery.DiscoveryService;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,12 +22,12 @@ import java.util.Date;
* Created by snoop on 17. 9. 28. * Created by snoop on 17. 9. 28.
*/ */
@Service("DiscoveryService") @Service("DiscoveryService")
public class DiscoveryService { public class CentralDiscoveryService implements DiscoveryService {
@Autowired @Autowired
private MessagePublisher messagePublisher; private MessagePublisher messagePublisher;
public void startDiscovery(DiscoveryStartInfo startInfo) throws IOException { public void startDiscovery(DiscoveryStartInfo startInfo) throws OverflowException,IOException {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
@ -61,40 +61,40 @@ public class DiscoveryService {
// } // }
@WebappAPI @WebappAPI
public void discoverZone(String probeID, DiscoveryZone discoveryZone) { public void discoverZone(String probeID, DiscoverZone discoveryZone) {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverZone", requesterSessionID, discoveryZone); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverZone", requesterSessionID, discoveryZone);
} }
@WebappAPI @WebappAPI
public void discoverHost(String probeID, Zone zone, DiscoveryHost discoveryHost) { public void discoverHost(String probeID, Zone zone, DiscoverHost discoveryHost) {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverHost", requesterSessionID, zone, discoveryHost); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverHost", requesterSessionID, zone, discoveryHost);
} }
@WebappAPI @WebappAPI
public void discoverPort(String probeID, Host host, DiscoveryPort discoveryPort) { public void discoverPort(String probeID, Host host, DiscoverPort discoveryPort) {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverPort", requesterSessionID, host, discoveryPort); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverPort", requesterSessionID, host, discoveryPort);
} }
@WebappAPI @WebappAPI
public void discoverService(String probeID, Port port, com.loafle.overflow.central.module.discovery.model.DiscoveryService discoveryService) { public void discoverService(String probeID, Port port, com.loafle.overflow.model.discovery.DiscoverService discoveryService) {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port, discoveryService); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port, discoveryService);
} }
@ProbeAPI @ProbeAPI
public void discoveryStart(String requesterSessionID, Date startDate) { public void discoverStart(String requesterSessionID, Date startDate) {
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStart", startDate); messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStart", startDate);
} }
@ProbeAPI @ProbeAPI
public void discoveryStop(String requesterSessionID, Date stopDate) { public void discoverStop(String requesterSessionID, Date stopDate) {
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStop", stopDate); messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStop", stopDate);
} }
@ -114,7 +114,7 @@ public class DiscoveryService {
} }
@ProbeAPI @ProbeAPI
public void discoveredService(String requesterSessionID, com.loafle.overflow.central.module.discovery.model.Service service) { public void discoveredService(String requesterSessionID, com.loafle.overflow.model.discovery.Service service) {
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredService", service); messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredService", service);
} }

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.central.module.domain.dao; package com.loafle.overflow.central.module.domain.dao;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.model.domain.Domain;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,8 +1,9 @@
package com.loafle.overflow.central.module.domain.dao; package com.loafle.overflow.central.module.domain.dao;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.domain.model.DomainMember;
import com.loafle.overflow.central.module.member.model.Member; import com.loafle.overflow.central.module.member.model.Member;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.domain.DomainMember;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;

View File

@ -1,52 +0,0 @@
package com.loafle.overflow.central.module.domain.model;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "DOMAIN", schema = "public")
public class Domain {
private long id;
private String name;
private Date createDate;
public Domain() {
}
public Domain(long id) {
this.id = id;
}
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "NAME", nullable = true, length = 50)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}

View File

@ -1,59 +0,0 @@
package com.loafle.overflow.central.module.domain.model;
import com.loafle.overflow.central.module.member.model.Member;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "DOMAIN_MEMBER", schema = "public")
public class DomainMember {
private long id;
private Timestamp createDate;
private Member member;
private Domain domain;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Timestamp getCreateDate() {
return createDate;
}
public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
}
@ManyToOne
@JoinColumn(name = "MEMBER_ID", nullable = false)
public Member getMember() {
return member;
}
public void setMember(Member member) {
this.member = member;
}
@ManyToOne
@JoinColumn(name = "DOMAIN_ID", nullable = false)
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
}

View File

@ -1,10 +1,12 @@
package com.loafle.overflow.central.module.domain.service; package com.loafle.overflow.central.module.domain.service;
import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO; import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.domain.model.DomainMember;
import com.loafle.overflow.central.module.member.dao.MemberDAO; import com.loafle.overflow.central.module.member.dao.MemberDAO;
import com.loafle.overflow.central.module.member.model.Member; import com.loafle.overflow.central.module.member.model.Member;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.domain.DomainMember;
import com.loafle.overflow.service.central.domain.DomainMemberService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,7 +16,7 @@ import java.util.List;
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */
@Service("DomainMemberService") @Service("DomainMemberService")
public class DomainMemberService { public class CentralDomainMemberService implements DomainMemberService {
@Autowired @Autowired
private DomainMemberDAO domainMemberDAO; private DomainMemberDAO domainMemberDAO;

View File

@ -1,7 +1,10 @@
package com.loafle.overflow.central.module.domain.service; package com.loafle.overflow.central.module.domain.service;
import com.loafle.overflow.central.module.domain.dao.DomainDAO; import com.loafle.overflow.central.module.domain.dao.DomainDAO;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.service.central.domain.DomainService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -9,12 +12,12 @@ import org.springframework.stereotype.Service;
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */
@Service("DomainService") @Service("DomainService")
public class DomainService { public class CentralDomainService implements DomainService {
@Autowired @Autowired
private DomainDAO domainDAO; private DomainDAO domainDAO;
public void regist(Domain domain) { public void regist(Domain domain) throws OverflowException {
this.domainDAO.save(domain); this.domainDAO.save(domain);
} }
} }

View File

@ -1,9 +1,9 @@
package com.loafle.overflow.central.module.history.dao; package com.loafle.overflow.central.module.history.dao;
import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.central.module.history.model.History; import com.loafle.overflow.model.history.History;
import com.loafle.overflow.central.module.meta.model.MetaHistoryType; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.central.module.probe.model.Probe;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@ -21,10 +21,10 @@ public interface HistoryDAO extends JpaRepository<History, Long> {
Page<History> findAllByProbe(Probe probe, Pageable pageable); Page<History> findAllByProbe(Probe probe, Pageable pageable);
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}") @Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable); Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageable);
Page<History> findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest); Page<History> findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest);
@Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}") @Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}")
Page<History> findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest); Page<History> findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageRequest);
} }

View File

@ -1,116 +0,0 @@
package com.loafle.overflow.central.module.history.model;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.member.model.Member;
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
import com.loafle.overflow.central.module.probe.model.Probe;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "HISTORY", schema = "public")
public class History {
private long id;
private Date createDate;
private MetaHistoryType type;
private String message;
private Probe probe;
private Member member;
private Domain domain;
//private MetaResultType resultType; // i'm not sure this is necessary
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@ManyToOne
@JoinColumn(name = "TYPE_ID", nullable = false)
public MetaHistoryType getType() {
return type;
}
public void setType(MetaHistoryType type) {
this.type = type;
}
@Column(name = "MESSAGE", nullable = false, length = 255)
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@ManyToOne
@JoinColumn(name = "PROBE_ID", nullable = false)
public Probe getProbe() {
return probe;
}
public void setProbe(Probe probe) {
this.probe = probe;
}
@ManyToOne
@JoinColumn(name = "MEMBER_ID", nullable = false)
public Member getMember() {
return member;
}
public void setMember(Member member) {
this.member = member;
}
@ManyToOne
@JoinColumn(name = "DOMAIN_ID", nullable = false)
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
History that = (History) o;
if (id != that.id) return false;
if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
return true;
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
return result;
}
}

View File

@ -1,18 +1,20 @@
package com.loafle.overflow.central.module.history.service; package com.loafle.overflow.central.module.history.service;
import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.history.dao.HistoryDAO; import com.loafle.overflow.central.module.history.dao.HistoryDAO;
import com.loafle.overflow.central.module.history.model.History; import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.central.module.meta.model.MetaHistoryType; import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.model.history.History;
import com.loafle.overflow.model.meta.MetaHistoryType;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.service.central.history.HistoryService;
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;
@Service("HistoryService") @Service("HistoryService")
public class HistoryService { public class CentralHistoryService implements HistoryService {
@Autowired @Autowired
private HistoryDAO historyDAO; private HistoryDAO historyDAO;
@ -26,7 +28,7 @@ public class HistoryService {
return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams)); return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams));
} }
public Page<History> readAllByProbe(Probe probe, PageParams pageParams) { public Page<History> readAllByProbe(Probe probe, com.loafle.overflow.core.model.PageParams pageParams) {
return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams)); return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams));
} }

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.noauthprobe.dao; package com.loafle.overflow.central.module.noauthprobe.dao;
import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.noauthprobe.NoAuthProbe; import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@ -14,12 +15,14 @@ import java.util.List;
*/ */
@Repository @Repository
public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> { public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
NoAuthProbe findByTempProbeKey(String tempProbeKey); NoAuthProbe findByTempProbeKey(String tempProbeKey);
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
@Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :#{#domain.id} and n.status.id = 3") // 3 = Process @Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :#{#domain.id} and n.status.id = 3") // 3 = Process
List<NoAuthProbe> findAllByDomain(@Param("domain") Domain domain); List<NoAuthProbe> findAllByDomain(@Param("domain") Domain domain);
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
} }

View File

@ -1,34 +1,33 @@
package com.loafle.overflow.central.module.noauthprobe.service; package com.loafle.overflow.central.module.noauthprobe.service;
import com.loafle.overflow.model.apikey.ApiKey;
import com.loafle.overflow.model.domain.DomainMember;
import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
import com.loafle.overflow.model.meta.MetaProbeStatus;
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
import com.loafle.overflow.central.commons.model.SessionMetadata; import com.loafle.overflow.central.commons.model.SessionMetadata;
import com.loafle.overflow.central.commons.service.MessagePublisher; import com.loafle.overflow.central.commons.service.MessagePublisher;
import com.loafle.overflow.central.commons.stereotype.ProbeAPI; import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
import com.loafle.overflow.central.commons.stereotype.WebappAPI; import com.loafle.overflow.central.commons.stereotype.WebappAPI;
import com.loafle.overflow.central.commons.utils.GenerateKey; import com.loafle.overflow.central.commons.utils.GenerateKey;
import com.loafle.overflow.central.module.member.service.MemberService;
import com.loafle.overflow.central.module.apikey.service.ApiKeyService;
import com.loafle.overflow.central.module.domain.service.DomainMemberService;
import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO; import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO;
import com.loafle.overflow.central.module.probe.service.ProbeService;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
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.member.Member;
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
import com.loafle.overflow.model.meta.MetaProbeStatus;
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.service.central.apikey.ApiKeyService;
import com.loafle.overflow.service.central.domain.DomainMemberService;
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService; import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
import com.loafle.overflow.service.central.probe.ProbeService;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,7 +37,7 @@ import java.util.UUID;
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */
@Service("NoAuthProbeService") @Service("NoAuthProbeService")
public class CentralNoAuthProbeService implements NoAuthProbeService { public class CentralNoAuthProbeService implements NoAuthProbeService{
@Autowired @Autowired
private NoAuthProbeDAO noAuthProbeDAO; private NoAuthProbeDAO noAuthProbeDAO;
@ -59,7 +58,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
private DomainMemberService domainMemberService; private DomainMemberService domainMemberService;
@ProbeAPI @ProbeAPI
public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException { public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException{
ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey()); ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey());
noAuthProbe.setDomain(apiKey.getDomain()); noAuthProbe.setDomain(apiKey.getDomain());
@ -72,17 +71,18 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
return this.noAuthProbeDAO.save(noAuthProbe); return this.noAuthProbeDAO.save(noAuthProbe);
} }
@Override
public List<NoAuthProbe> readAllByDomain(Domain domain) throws OverflowException { public List<NoAuthProbe> readAllByDomain(Domain domain) throws OverflowException {
return this.noAuthProbeDAO.findAllByDomain(domain); return this.noAuthProbeDAO.findAllByDomain(domain);
} }
public NoAuthProbe read(long id) throws OverflowException { public NoAuthProbe read(long id) {
return this.noAuthProbeDAO.findOne(id); return this.noAuthProbeDAO.findOne(id);
} }
@WebappAPI @WebappAPI
public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws OverflowException { public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException {
String memberEmail = SessionMetadata.getTargetID(); String memberEmail = SessionMetadata.getTargetID();
// Todo domain injection & member injection // Todo domain injection & member injection
@ -128,7 +128,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
} }
@WebappAPI @WebappAPI
public List<NoAuthProbe> denyNoauthProbe(NoAuthProbe noAuthProbe) throws OverflowException{ public List<NoAuthProbe> denyNoauthProbe(NoAuthProbe noAuthProbe) throws OverflowException {
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2)); noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2));
this.noAuthProbeDAO.save(noAuthProbe); this.noAuthProbeDAO.save(noAuthProbe);
@ -137,7 +137,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
return this.readAllByDomain(noAuthProbe.getDomain()); return this.readAllByDomain(noAuthProbe.getDomain());
} }
public NoAuthProbe readByTempKey(String tempKey) throws OverflowException { public NoAuthProbe readByTempKey(String tempKey) {
return this.noAuthProbeDAO.findByTempProbeKey(tempKey); return this.noAuthProbeDAO.findByTempProbeKey(tempKey);
} }
} }

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.notification.dao; package com.loafle.overflow.central.module.notification.dao;
import com.loafle.overflow.central.module.member.model.Member; import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.central.module.notification.model.Notification; import com.loafle.overflow.model.notification.Notification;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;

View File

@ -1,89 +0,0 @@
package com.loafle.overflow.central.module.notification.model;
import com.loafle.overflow.central.module.member.model.Member;
import javax.persistence.*;
import java.util.Date;
/**
* Created by insanity on 17. 8. 25.
*/
@Entity
@Table(name = "NOTIFICATION", schema = "public")
public class Notification {
private long id;
private Date createDate;
private String title;
private String message;
private Member member;
private Date confirmDate;
private String url;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Column(name = "TITLE", nullable = false, length = 50)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Column(name = "MESSAGE", nullable = false, length = 255)
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@ManyToOne
@JoinColumn(name = "MEMBER_ID", nullable = false)
public Member getMember() {
return member;
}
public void setMember(Member member) {
this.member = member;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CONFIRM_DATE", nullable = true)
public Date getConfirmDate() {
return confirmDate;
}
public void setConfirmDate(Date confirmDate) {
this.confirmDate = confirmDate;
}
@Column(name = "URL", nullable = false, length = 255)
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}

View File

@ -1,10 +1,13 @@
package com.loafle.overflow.central.module.notification.service; package com.loafle.overflow.central.module.notification.service;
import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.member.model.Member;
import com.loafle.overflow.central.module.notification.dao.NotificationDAO; import com.loafle.overflow.central.module.notification.dao.NotificationDAO;
import com.loafle.overflow.central.module.notification.model.Notification; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.model.notification.Notification;
import com.loafle.overflow.service.central.notification.NotificationService;
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;
@ -16,28 +19,28 @@ import java.util.List;
* Created by insanity on 17. 8. 25. * Created by insanity on 17. 8. 25.
*/ */
@Service("NotificationService") @Service("NotificationService")
public class NotificationService { public class CentralNotificationService implements NotificationService {
@Autowired @Autowired
private NotificationDAO notificationDAO; private NotificationDAO notificationDAO;
public Notification regist(Notification notification) { public Notification regist(Notification notification) throws OverflowException {
return this.notificationDAO.save(notification); return this.notificationDAO.save(notification);
} }
public Page<Notification> readAllByMember(Member member, PageParams pageParams) { public Page<Notification> readAllByMember(Member member, PageParams pageParams) throws OverflowException {
return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams)); return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams));
} }
public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) { public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) throws OverflowException {
return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams)); return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams));
} }
public int readUnconfirmedCount(Member member) { public int readUnconfirmedCount(Member member) throws OverflowException {
return this.notificationDAO.findAllUnconfirmedCountByMember(member); return this.notificationDAO.findAllUnconfirmedCountByMember(member);
} }
public Page<Notification> markAllAsRead(Member member, PageParams pageParams) { public Page<Notification> markAllAsRead(Member member, PageParams pageParams) throws OverflowException {
List<Notification> list = this.notificationDAO.findAllByMember(member); List<Notification> list = this.notificationDAO.findAllByMember(member);
for (Notification n : list) { for (Notification n : list) {
n.setConfirmDate(new Date()); n.setConfirmDate(new Date());
@ -46,7 +49,7 @@ public class NotificationService {
return this.readAllByMember(member, pageParams); return this.readAllByMember(member, pageParams);
} }
public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) { public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) throws OverflowException {
List<Notification> list = this.notificationDAO.findAllByMember(member); List<Notification> list = this.notificationDAO.findAllByMember(member);
for (Notification n : list) { for (Notification n : list) {
n.setConfirmDate(null); n.setConfirmDate(null);
@ -55,8 +58,9 @@ public class NotificationService {
return this.readAllByMember(member, pageParams); return this.readAllByMember(member, pageParams);
} }
public Notification markAsRead(Notification notification) { public Notification markAsRead(Notification notification) throws OverflowException {
notification.setConfirmDate(new Date()); notification.setConfirmDate(new Date());
return this.notificationDAO.save(notification); return this.notificationDAO.save(notification);
} }
} }

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.probe.dao; package com.loafle.overflow.central.module.probe.dao;
import com.loafle.overflow.central.module.domain.model.Domain; import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.model.probe.Probe;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -13,9 +14,7 @@ import java.util.List;
*/ */
@Repository @Repository
public interface ProbeDAO extends JpaRepository<Probe, Long> { public interface ProbeDAO extends JpaRepository<Probe, Long> {
// public List<Agent> findAgentListByMemberId(Member member);
Probe findByProbeKey(String probeKey); Probe findByProbeKey(String probeKey);
List<Probe> findAllByDomainOrderByIdDesc(Domain domain); List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
} }

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.probe.dao; package com.loafle.overflow.central.module.probe.dao;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.central.module.probe.model.ProbeHost; import com.loafle.overflow.model.probe.ProbeHost;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -10,6 +11,5 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> { public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> {
ProbeHost findByProbe(Probe probe); ProbeHost findByProbe(Probe probe);
} }

View File

@ -1,17 +1,17 @@
package com.loafle.overflow.central.module.probe.dao; package com.loafle.overflow.central.module.probe.dao;
import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.module.probe.model.ProbeTask;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.probe.ProbeTask;
/** /**
* Created by snoop on 17. 6. 26. * Created by snoop on 17. 6. 26.
*/ */
@Repository @Repository
public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> { public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> {
List<ProbeTask> findAllByProbe(Probe probe); List<ProbeTask> findAllByProbe(Probe probe);
} }

View File

@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
* Created by snoop on 17. 9. 14. * Created by snoop on 17. 9. 14.
*/ */
public class ProbeNotFoundException extends OverflowRuntimeException { public class ProbeNotFoundException extends OverflowRuntimeException {
public ProbeNotFoundException() { private static final long serialVersionUID = 1L;
public ProbeNotFoundException() {
super(); super();
} }

View File

@ -1,190 +0,0 @@
package com.loafle.overflow.central.module.probe.model;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.infra.model.Infra;
import com.loafle.overflow.central.module.member.model.Member;
import com.loafle.overflow.central.module.meta.model.MetaProbeStatus;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "PROBE", schema = "public")
public class Probe {
private long id;
private MetaProbeStatus status;
private String description;
private Date createDate;
private Domain domain;
private String probeKey;
private String encryptionKey;
private String displayName;
private String cidr;
private Date authorizeDate;
private Member authorizeMember;
private List<Infra> targets;
// private InfraHost host;
// private int targetCount;
// private int sensorCount;
public Probe() {
}
public Probe(long id) {
this.id = id;
}
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
@JoinColumn(name = "STATUS", nullable = false)
public MetaProbeStatus getStatus() {
return status;
}
public void setStatus(MetaProbeStatus status) {
this.status = status;
}
@Column(name = "DESCRIPTION", nullable = true, length = 50)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@ManyToOne
@JoinColumn(name = "DOMAIN_ID", nullable = false)
public Domain getDomain() {
return domain;
}
public void setDomain(Domain domain) {
this.domain = domain;
}
@Column(name = "PROBE_KEY", nullable = false, unique = true)
public String getProbeKey() {
return probeKey;
}
public void setProbeKey(String probeKey) {
this.probeKey = probeKey;
}
@Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true)
public String getEncryptionKey() {
return encryptionKey;
}
public void setEncryptionKey(String encryptionKey) {
this.encryptionKey = encryptionKey;
}
@Transient
public List<Infra> getTargets() {
return targets;
}
public void setTargets(List<Infra> targets) {
this.targets = targets;
}
// @Column(name = "TARGET_COUNT", nullable = false)
// public int getTargetCount() {
// return targetCount;
// }
//
// public void setTargetCount(int targetCount) {
// this.targetCount = targetCount;
// }
//
// @Column(name = "SENSOR_COUNT", nullable = false)
// public int getSensorCount() {
// return sensorCount;
// }
//
// public void setSensorCount(int sensorCount) {
// this.sensorCount = sensorCount;
// }
@Column(name = "DISPLAY_NAME")
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Column(name = "CIDR")
public String getCidr() {
return cidr;
}
public void setCidr(String cidr) {
this.cidr = cidr;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "AUTHORIZE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getAuthorizeDate() {
return authorizeDate;
}
public void setAuthorizeDate(Date authorizeDate) {
this.authorizeDate = authorizeDate;
}
@ManyToOne
@JoinColumn(name = "AUTHORIZE_MEMBER_ID", nullable = false)
public Member getAuthorizeMember() {
return authorizeMember;
}
public void setAuthorizeMember(Member authorizeMember) {
this.authorizeMember = authorizeMember;
}
//
// @ManyToOne
// @JoinColumn(name = "HOST_ID", nullable = false)
// public InfraHost getHost() {
// return host;
// }
//
// public void setHost(InfraHost host) {
// this.host = host;
// }
}

View File

@ -1,48 +0,0 @@
package com.loafle.overflow.central.module.probe.model;
import com.loafle.overflow.central.module.infra.model.InfraHost;
import javax.persistence.*;
/**
* Created by insanity on 17. 8. 21.
*/
@Entity
@Table(name = "PROBE_INFRAHOST", schema = "public")
public class ProbeHost {
private long id;
private Probe probe;
private InfraHost host;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@OneToOne
@JoinColumn(name = "PROBE_ID", nullable = false)
public Probe getProbe() {
return probe;
}
public void setProbe(Probe probe) {
this.probe = probe;
}
@OneToOne
@JoinColumn(name = "HOST_ID", nullable = false)
public InfraHost getHost() {
return host;
}
public void setHost(InfraHost infraHost) {
this.host = infraHost;
}
}

View File

@ -1,143 +0,0 @@
package com.loafle.overflow.central.module.probe.model;
import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "PROBE_TASK", schema = "public")
public class ProbeTask {
private long id;
private MetaProbeTaskType taskType;
private Probe probe;
private String data;
private Date createDate;
private Date sendDate;
private Date startDate;
private Date endDate;
private Boolean succeed;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
@JoinColumn(name = "TYPE_ID", nullable = false)
public MetaProbeTaskType getTaskType() {
return taskType;
}
public void setTaskType(MetaProbeTaskType taskType) {
this.taskType = taskType;
}
@ManyToOne
@JoinColumn(name = "PROBE_ID", nullable = false)
public Probe getProbe() {
return probe;
}
public void setProbe(Probe probe) {
this.probe = probe;
}
@Column(name = "DATA", nullable = true, length = 255)
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Column(name = "SEND_DATE", nullable = true)
public Date getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
this.sendDate = sendDate;
}
@Column(name = "START_DATE", nullable = true)
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
@Column(name = "END_DATE", nullable = true)
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
@Column(name = "SUCCEED", nullable = true)
public Boolean getSucceed() {
return succeed;
}
public void setSucceed(Boolean succeed) {
this.succeed = succeed;
}
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// ProbeTask that = (ProbeTask) o;
//
// if (id != that.id) return false;
// if (typeId != that.typeId) return false;
// if (probeId != that.probeId) return false;
// if (data != null ? !data.equals(that.data) : that.data != null) return false;
// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
// if (sendDate != null ? !sendDate.equals(that.sendDate) : that.sendDate != null) return false;
// if (startDate != null ? !startDate.equals(that.startDate) : that.startDate != null) return false;
// if (endDate != null ? !endDate.equals(that.endDate) : that.endDate != null) return false;
// if (succeed != null ? !succeed.equals(that.succeed) : that.succeed != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = (int) (id ^ (id >>> 32));
// result = 31 * result + (int) typeId;
// result = 31 * result + (int) (probeId ^ (probeId >>> 32));
// result = 31 * result + (data != null ? data.hashCode() : 0);
// result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
// result = 31 * result + (sendDate != null ? sendDate.hashCode() : 0);
// result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
// result = 31 * result + (endDate != null ? endDate.hashCode() : 0);
// result = 31 * result + (succeed != null ? succeed.hashCode() : 0);
// return result;
// }
}

View File

@ -1,8 +1,11 @@
package com.loafle.overflow.central.module.probe.service; package com.loafle.overflow.central.module.probe.service;
import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO; import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.central.module.probe.model.ProbeHost; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.probe.ProbeHost;
import com.loafle.overflow.service.central.probe.ProbeHostService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -10,16 +13,16 @@ import org.springframework.stereotype.Service;
* Created by snoop on 17. 8. 21. * Created by snoop on 17. 8. 21.
*/ */
@Service("ProbeHostService") @Service("ProbeHostService")
public class ProbeHostService { public class CentralProbeHostService implements ProbeHostService {
@Autowired @Autowired
private ProbeHostDAO probeHostDAO; private ProbeHostDAO probeHostDAO;
public ProbeHost readByProbe(Probe probe) { public ProbeHost readByProbe(Probe probe) throws OverflowException {
return this.probeHostDAO.findByProbe(probe); return this.probeHostDAO.findByProbe(probe);
} }
public ProbeHost regist(ProbeHost probeHost) { public ProbeHost regist(ProbeHost probeHost) throws OverflowException {
return this.probeHostDAO.save(probeHost); return this.probeHostDAO.save(probeHost);
} }
} }

View File

@ -0,0 +1,47 @@
package com.loafle.overflow.central.module.probe.service;
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.service.central.probe.ProbeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by snoop on 17. 6. 28.
*/
@Service("ProbeService")
public class CentralProbeService implements ProbeService {
@Autowired
private ProbeDAO probeDAO;
public Probe regist(Probe probe) throws OverflowException {
return this.probeDAO.save(probe);
}
public List<Probe> regist(List<Probe> probes) throws OverflowException {
return this.probeDAO.save(probes);
}
public List<Probe> readAllByDomain(Domain domain) throws OverflowException {
List<Probe> probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain);
return probes;
}
public Probe read(long id) throws OverflowException {
return this.probeDAO.findOne(id);
}
public Probe readByProbeKey(String probeKey) throws OverflowException {
return this.probeDAO.findByProbeKey(probeKey);
}
public Probe modify(Probe probe) throws OverflowException {
return this.probeDAO.save(probe);
}
}

View File

@ -1,8 +1,11 @@
package com.loafle.overflow.central.module.probe.service; package com.loafle.overflow.central.module.probe.service;
import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO; import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.central.module.probe.model.ProbeTask; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.probe.ProbeTask;
import com.loafle.overflow.service.central.probe.ProbeTaskService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -12,16 +15,16 @@ import java.util.List;
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */
@Service("ProbeTaskService") @Service("ProbeTaskService")
public class ProbeTaskService { public class CentralProbeTaskService implements ProbeTaskService{
@Autowired @Autowired
private ProbeTaskDAO probeTaskDAO; private ProbeTaskDAO probeTaskDAO;
public ProbeTask regist(ProbeTask probeTask) { public ProbeTask regist(ProbeTask probeTask) throws OverflowException {
return this.probeTaskDAO.save(probeTask); return this.probeTaskDAO.save(probeTask);
} }
public List<ProbeTask> readAllByProbe(Probe probe) { public List<ProbeTask> readAllByProbe(Probe probe) throws OverflowException {
return this.probeTaskDAO.findAllByProbe(probe); return this.probeTaskDAO.findAllByProbe(probe);
} }
} }

View File

@ -1,53 +0,0 @@
package com.loafle.overflow.central.module.probe.service;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.infra.dao.InfraDAO;
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
import com.loafle.overflow.central.module.probe.model.Probe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by snoop on 17. 6. 28.
*/
@Service("ProbeService")
public class ProbeService {
@Autowired
private ProbeDAO probeDAO;
@Autowired
private InfraDAO infraDAO;
public Probe regist(Probe probe) {
return this.probeDAO.save(probe);
}
public List<Probe> regist(List<Probe> probes) {
return this.probeDAO.save(probes);
}
public List<Probe> readAllByDomain(Domain domain) {
List<Probe> probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain);
for(Probe probe : probes) {
probe.setTargets(this.infraDAO.findAllByProbe(probe));
}
return probes;
}
public Probe read(long id) {
Probe probe = this.probeDAO.findOne(id);
probe.setTargets(this.infraDAO.findAllByProbe(probe));
return probe;
}
public Probe readByProbeKey(String probeKey) {
return this.probeDAO.findByProbeKey(probeKey);
}
public Probe modify(Probe probe) {
return this.probeDAO.save(probe);
}
}

View File

@ -1,8 +1,6 @@
package com.loafle.overflow.central.module.sensor.dao; package com.loafle.overflow.central.module.sensor.dao;
import com.loafle.overflow.central.module.sensor.model.Sensor;
import com.loafle.overflow.central.module.target.model.Target;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@ -12,18 +10,18 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.target.Target;
/** /**
* Created by root on 17. 6. 9. * Created by root on 17. 6. 9.
*/ */
@Repository @Repository
public interface SensorDAO extends JpaRepository<Sensor, Long> { public interface SensorDAO extends JpaRepository<Sensor, Long> {
Page<Sensor> findAllByTarget(Target target, Pageable pageable); Page<Sensor> findAllByTarget(Target target, Pageable pageable);
List<Sensor> findAllByTarget(Target target); List<Sensor> findAllByTarget(Target target);
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)") @Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable); Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable);
// List<Sensor> findAllByTargetList(List<Target> targets);
} }

View File

@ -1,7 +1,8 @@
package com.loafle.overflow.central.module.sensor.dao; package com.loafle.overflow.central.module.sensor.dao;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;

View File

@ -2,7 +2,8 @@ package com.loafle.overflow.central.module.sensor.dao;
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.model.SensorItemDependency; import com.loafle.overflow.model.sensor.SensorItemDependency;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,104 +0,0 @@
package com.loafle.overflow.central.module.sensor.model;
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
import com.loafle.overflow.central.module.meta.model.MetaSensorStatus;
import com.loafle.overflow.central.module.target.model.Target;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "SENSOR", schema = "public")
public class Sensor {
private long id;
private Date createDate;
private String description;
private MetaSensorStatus status;
private Target target;
private MetaCrawler crawler;
private String crawlerInputItems;
private short itemCount = 0;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Column(name = "DESCRIPTION", nullable = true, length = 50)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@ManyToOne
@JoinColumn(name = "STATUS")
public MetaSensorStatus getStatus() {
return status;
}
public void setStatus(MetaSensorStatus status) {
this.status = status;
}
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "TARGET_ID", nullable = false)
public Target getTarget() {
return target;
}
public void setTarget(Target target) {
this.target = target;
}
@ManyToOne
@JoinColumn(name = "CRAWLER_ID", nullable = false)
public MetaCrawler getCrawler() {
return crawler;
}
public void setCrawler(MetaCrawler crawler) {
this.crawler = crawler;
}
@Column(name = "CRAWLER_INPUT_ITEMS", nullable = true, length = 50)
public String getCrawlerInputItems() {
return crawlerInputItems;
}
public void setCrawlerInputItems(String crawlerInputItems) {
this.crawlerInputItems = crawlerInputItems;
}
@Column(name = "ITEM_COUNT", nullable = false)
public short getItemCount() {
return itemCount;
}
public void setItemCount(short itemCount) {
this.itemCount = itemCount;
}
}

View File

@ -1,62 +0,0 @@
package com.loafle.overflow.central.module.sensor.model;
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "SENSOR_ITEM", schema = "public")
public class SensorItem {
private long id;
private Sensor sensor;
private MetaSensorDisplayItem item;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
@JoinColumn(name = "SENSOR_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
public Sensor getSensor() {
return this.sensor;
}
public void setSensor(Sensor sensor) {
this.sensor = sensor;
}
@ManyToOne
@JoinColumn(name = "ITEM_ID", nullable = false)
public MetaSensorDisplayItem getItem() {
return item;
}
public void setItem(MetaSensorDisplayItem item) {
this.item = item;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}

View File

@ -1,48 +0,0 @@
package com.loafle.overflow.central.module.sensor.model;
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
import javax.persistence.*;
/**
* Created by insanity on 17. 9. 20.
*/
@Entity
@Table(name = "SENSOR_ITEM_DEPENDENCY", schema = "public")
public class SensorItemDependency {
private long id;
private MetaSensorDisplayItem displayItem;
private MetaSensorItemKey sensorItem;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
@JoinColumn(name = "DISPLAY_ITEM_ID", nullable = false)
public MetaSensorDisplayItem getDisplayItem() {
return displayItem;
}
public void setDisplayItem(MetaSensorDisplayItem displayItem) {
this.displayItem = displayItem;
}
@ManyToOne
@JoinColumn(name = "SENSOR_ITEM_ID", nullable = false)
public MetaSensorItemKey getSensorItem() {
return sensorItem;
}
public void setSensorItem(MetaSensorItemKey sensorItem) {
this.sensorItem = sensorItem;
}
}

View File

@ -3,7 +3,8 @@ package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
import com.loafle.overflow.central.module.sensor.model.SensorItemDependency; import com.loafle.overflow.model.sensor.SensorItemDependency;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,7 +17,7 @@ import java.util.Map;
*/ */
@Service("SensorItemDependencyService") @Service("SensorItemDependencyService")
public class SensorItemDependencyService { public class CentralSensorItemDependencyService {
@Autowired @Autowired
private SensorItemDependencyDAO sensorItemDependencyDAO; private SensorItemDependencyDAO sensorItemDependencyDAO;

View File

@ -4,8 +4,9 @@ import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.sensor.dao.SensorDAO; import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
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;
@ -17,7 +18,7 @@ import java.util.List;
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
*/ */
@Service("SensorItemService") @Service("SensorItemService")
public class SensorItemService { public class CentralSensorItemService {
@Autowired @Autowired
private SensorItemDAO sensorItemDAO; private SensorItemDAO sensorItemDAO;
@ -27,7 +28,7 @@ public class SensorItemService {
@Transactional @Transactional
public SensorItem regist(SensorItem sensorItem) { public SensorItem regist(SensorItem sensorItem) {
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
s.setItemCount((short)(s.getItemCount() + 1)); // s.setItemCount((short)(s.getItemCount() + 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);
return this.sensorItemDAO.save(sensorItem); return this.sensorItemDAO.save(sensorItem);
} }
@ -35,7 +36,7 @@ public class SensorItemService {
@Transactional @Transactional
public boolean registAll(List<SensorItem> sensorItemList) { public boolean registAll(List<SensorItem> sensorItemList) {
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
s.setItemCount((short)sensorItemList.size()); // s.setItemCount((short)sensorItemList.size());
this.sensorDAO.save(s); this.sensorDAO.save(s);
this.sensorItemDAO.save(sensorItemList); this.sensorItemDAO.save(sensorItemList);
return true; return true;
@ -52,7 +53,7 @@ public class SensorItemService {
@Transactional @Transactional
public void remove(SensorItem sensorItem) { public void remove(SensorItem sensorItem) {
Sensor s = sensorItem.getSensor(); Sensor s = sensorItem.getSensor();
s.setItemCount((short)(s.getItemCount() - 1)); // s.setItemCount((short)(s.getItemCount() - 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);
this.sensorItemDAO.delete(sensorItem); this.sensorItemDAO.delete(sensorItem);
} }

View File

@ -2,21 +2,24 @@ package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.commons.model.PageParams; import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.domain.model.Domain;
import com.loafle.overflow.central.module.generator.service.SensorConfigGenerator; import com.loafle.overflow.central.module.generator.service.SensorConfigGenerator;
import com.loafle.overflow.central.module.infra.exception.InfraNotFoundException; import com.loafle.overflow.central.module.infra.exception.InfraNotFoundException;
import com.loafle.overflow.central.module.infra.model.Infra;
import com.loafle.overflow.central.module.infra.service.InfraService; import com.loafle.overflow.central.module.infra.service.InfraService;
import com.loafle.overflow.central.module.meta.model.MetaSensorStatus;
import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService; import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService;
import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException; import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException;
import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.module.probe.service.ProbeService;
import com.loafle.overflow.central.module.sensor.dao.SensorDAO; import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.central.module.sensor.model.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem;
import com.loafle.overflow.central.module.target.exception.TargetNotFoundException; import com.loafle.overflow.central.module.target.exception.TargetNotFoundException;
import com.loafle.overflow.central.module.target.model.Target; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.meta.MetaSensorStatus;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.probe.ProbeService;
import com.loafle.overflow.service.central.sensor.SensorService;
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;
@ -29,7 +32,7 @@ import java.util.List;
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
*/ */
@Service("SensorService") @Service("SensorService")
public class SensorService { public class CentralSensorService implements SensorService {
@Autowired @Autowired
SensorDAO sensorDAO; SensorDAO sensorDAO;
@ -41,10 +44,7 @@ public class SensorService {
private InfraService infraService; private InfraService infraService;
@Autowired @Autowired
private SensorItemService sensorItemService; private CentralSensorItemService sensorItemService;
@Autowired
private MetaSensorItemKeyService metaSensorItemKeyService;
@Autowired @Autowired
private SensorConfigGenerator sensorConfigGenerator; private SensorConfigGenerator sensorConfigGenerator;
@ -53,67 +53,63 @@ public class SensorService {
return this.sensorDAO.save(sensor); return this.sensorDAO.save(sensor);
} }
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) { public Page<Sensor> readAllByDomain(Domain domain, PageParams pageParams) throws OverflowException {
// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
// }
public Page<Sensor> readAllByDomain(Domain domain, PageParams pageParams) {
List<Probe> probeList = this.probeService.readAllByDomain(domain); List<Probe> probeList = this.probeService.readAllByDomain(domain);
if(probeList == null || probeList.size() <= 0) { if (probeList == null || probeList.size() <= 0) {
throw new ProbeNotFoundException(); throw new ProbeNotFoundException();
} }
List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList); List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList);
if(targetList == null || targetList.size() <= 0) { if (targetList == null || targetList.size() <= 0) {
throw new TargetNotFoundException(); throw new TargetNotFoundException();
} }
return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams)); return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams));
} }
public Page<Sensor> readAllByInfra(long infraId, PageParams pageParams) { public Page<Sensor> readAllByInfra(long infraId, PageParams pageParams) throws OverflowException {
Infra dbInfra = this.infraService.read(infraId); Infra dbInfra = this.infraService.read(infraId);
if(dbInfra == null || dbInfra.getTarget() == null) { if (dbInfra == null || dbInfra.getTarget() == null) {
throw new InfraNotFoundException(); throw new InfraNotFoundException();
} }
return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams)); return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams));
} }
public Page<Sensor> readAllByTarget(Target target, PageParams pageParams) { public Page<Sensor> readAllByTarget(Target target, PageParams pageParams) throws OverflowException {
return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams)); return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
} }
public Sensor read(String id) { public Sensor read(String id) throws OverflowException {
return this.sensorDAO.findOne(Long.valueOf(id)); return this.sensorDAO.findOne(Long.valueOf(id));
} }
public void remove(Sensor sensor) { public void remove(Sensor sensor) throws OverflowException {
this.sensorDAO.delete(sensor); this.sensorDAO.delete(sensor);
} }
public Sensor start(Sensor sensor) { public Sensor start(Sensor sensor) throws OverflowException {
MetaSensorStatus status = new MetaSensorStatus((short)1); MetaSensorStatus status = new MetaSensorStatus((short) 1);
sensor.setStatus(status); sensor.setStatus(status);
return this.sensorDAO.save(sensor); return this.sensorDAO.save(sensor);
} }
public Sensor stop(Sensor sensor) { public Sensor stop(Sensor sensor) throws OverflowException {
MetaSensorStatus status = new MetaSensorStatus((short)2); MetaSensorStatus status = new MetaSensorStatus((short) 2);
sensor.setStatus(status); sensor.setStatus(status);
return this.sensorDAO.save(sensor); return this.sensorDAO.save(sensor);
} }
@Transactional @Transactional
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson) { public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson) throws OverflowException {
this.sensorDAO.save(sensor); this.sensorDAO.save(sensor);
for(SensorItem sensorItem : sensorItemList) { for (SensorItem sensorItem : sensorItemList) {
sensorItem.setSensor(sensor); sensorItem.setSensor(sensor);
} }
@ -122,10 +118,13 @@ public class SensorService {
return sensor; return sensor;
} }
public String generateSensorConfig(Sensor sensor) throws IOException { public String generateSensorConfig(Sensor sensor) throws OverflowException {
return this.sensorConfigGenerator.generate(sensor); return this.sensorConfigGenerator.generate(sensor);
} }
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) {
// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
// }
} }

View File

@ -1,22 +1,12 @@
package com.loafle.overflow.central.module.target.dao; package com.loafle.overflow.central.module.target.dao;
import com.loafle.overflow.central.module.infra.model.Infra; import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.module.target.model.Target;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* Created by root on 17. 6. 5. * Created by root on 17. 6. 5.
*/ */
@Repository @Repository
public interface TargetDAO extends JpaRepository<Target, Long> { public interface TargetDAO extends JpaRepository<Target, Long> {
// List<Target> findAllByProbe(Probe probe);]
} }

View File

@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
* Created by snoop on 17. 9. 14. * Created by snoop on 17. 9. 14.
*/ */
public class TargetNotFoundException extends OverflowRuntimeException { public class TargetNotFoundException extends OverflowRuntimeException {
public TargetNotFoundException() { private static final long serialVersionUID = 1L;
public TargetNotFoundException() {
super(); super();
} }

View File

@ -1,98 +0,0 @@
package com.loafle.overflow.central.module.target.model;
import com.loafle.overflow.central.module.sensor.model.Sensor;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "TARGET", schema = "public")
public class Target {
private long id;
private Date createDate;
private String displayName;
private String description;
private List<Sensor> sensors;
/*
private long id;
private Date createDate;
private String displayName;
private String description;
*/
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Column(name = "DISPLAY_NAME")
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Column(name = "DESCRIPTION")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
// @ManyToOne
// @JoinColumn(name = "PROBE_ID", nullable = false)
// @OnDelete(action = OnDeleteAction.CASCADE)
// public Probe getProbe() {
// return probe;
// }
//
// public void setProbe(Probe probe) {
// this.probe = probe;
// }
//
// @ManyToOne
// @JoinColumn(name = "INFRA_ID", nullable = false)
// public Infra getInfra() {
// return infra;
// }
//
// public void setInfra(Infra infra) {
// this.infra = infra;
// }
@Transient
public List<Sensor> getSensors() {
return sensors;
}
public void setSensors(List<Sensor> sensors) {
this.sensors = sensors;
}
}

View File

@ -0,0 +1,220 @@
package com.loafle.overflow.central.module.target.service;
import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.central.module.discovery.model.Host;
import com.loafle.overflow.central.module.discovery.model.Port;
import com.loafle.overflow.central.module.discovery.type.PortType;
import com.loafle.overflow.central.module.infra.model.*;
import com.loafle.overflow.central.module.infra.model.InfraService;
import com.loafle.overflow.central.module.infra.service.*;
import com.loafle.overflow.central.module.meta.model.MetaInfraType;
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
/**
* Created by snoop on 17. 6. 28.
*/
@Service("TargetDiscoveryService")
public class CentralTargetDiscoveryService {
@Autowired
private CentralTargetService targetService;
@Autowired
private InfraMachineService infraMachineService;
@Autowired
private InfraOSService infraOSService;
@Autowired
private InfraHostService infraHostService;
@Autowired
private com.loafle.overflow.central.module.infra.service.InfraService infraService;
@Autowired
private InfraOSPortService infraOSPortService;
@Autowired
private InfraServiceService infraServiceService;
// @Transactional
// public boolean saveAllTarget(List<Host> hosts, Probe probe) {
// InfraHost infraHost = null;
// for(Host host : hosts) {
// infraHost = this.createAndReadHost(host, probe);
// this.createPort(infraHost, host, probe);
// }
// return true;
// }
// private void createService(InfraHost infraHost, Port port, Probe probe) {
// if(port.getServices() == null) {
// return;
// }
// MetaInfraType typeService = new MetaInfraType();
// typeService.setId(7);
// String portType = "UDP";
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
// portType = "TCP";
// }
// for(com.loafle.overflow.central.module.discovery.model.Service service : port.getServices()) {
// InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType);
// if(dbInfraService != null) {
// if(service.isTarget() && dbInfraService.getTarget() == null) {
// Target targetService = new Target();
// targetService.setDisplayName(service.getServiceName() + "-Service");
// this.targetService.regist(targetService);
// dbInfraService.setTarget(targetService);
// this.infraServiceService.regist(dbInfraService);
// }
// continue;
// }
// InfraService infraService = new InfraService();
// infraService.setHost(infraHost);
// infraService.setPort(port.getPortNumber());
// infraService.setPortType(portType);
// infraService.setInfraType(typeService);
// infraService.setProbe(probe);
// if (port.getPortType() == PortType.TLS) {
// infraService.setTlsType(true);
// }
// infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
// if(service.isTarget()) {
// Target targetService = new Target();
// targetService.setDisplayName(service.getServiceName() + "-Service");
// this.targetService.regist(targetService);
// infraService.setTarget(targetService);
// }
// this.infraServiceService.regist(infraService);
// }
// }
// private void createPort(InfraHost infraHost, Host host, Probe probe) {
// if(host.getPorts() == null) {
// return;
// }
// String portType = "UDP";
// MetaInfraType typePort = new MetaInfraType();
// typePort.setId(6);
// InfraOS infraOS = infraHost.getOs();
// for(Port port : host.getPorts()) {
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
// portType = "TCP";
// }
// InfraOSPort dbInfraOSPort = this.infraOSPortService.readByPort(infraOS.getId(), port.getPortNumber(), portType);
// if(dbInfraOSPort == null) {
// InfraOSPort infraOSPort = new InfraOSPort();
// infraOSPort.setOs(infraOS);
// infraOSPort.setPort(port.getPortNumber());
// infraOSPort.setPortType(portType);
// infraOSPort.setProbe(probe);
// infraOSPort.setInfraType(typePort);
// if (port.getPortType() == PortType.TLS) {
// infraOSPort.setTlsType(true);
// }
// infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
// this.infraOSPortService.regist(infraOSPort);
// }
// this.createService(infraHost, port, probe);
// }
// }
// private InfraHost createAndReadHost(Host host, Probe probe) {
// InfraHost infraHost = this.infraHostService.readByIp(host.getIp());
// if(infraHost != null) {
// if(host.isTarget() && infraHost.getTarget() == null) {
// Target target = new Target();
// target.setDisplayName(String.valueOf(host.getIp()) + "-Host");
// this.targetService.regist(target);
// infraHost.setTarget(target);
// this.infraHostService.regist(infraHost);
// }
// return infraHost;
// } else {
// MetaInfraType typeMachine = new MetaInfraType();
// typeMachine.setId(1); // 1 = Machine;
// MetaInfraType typeOS = new MetaInfraType();
// typeOS.setId(3); // 3 = Os
// MetaInfraType typeHost = new MetaInfraType();
// typeHost.setId(2); // 2 = Host
// InfraMachine infraMachine = new InfraMachine();
// infraMachine.setProbe(probe);
// infraMachine.setInfraType(typeMachine);
// infraMachine.setMeta(StringConvertor.intToIp(host.getIp())+"-MACHINE");
// this.infraMachineService.regist(infraMachine);
// InfraOS infraOS = new InfraOS();
// infraOS.setMachine(infraMachine);
// infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
// infraOS.setInfraType(typeOS);
// infraOS.setProbe(probe);
// infraOS.setMeta(StringConvertor.intToIp(host.getIp())+"-OS");
// this.infraOSService.regist(infraOS);
// InfraHost newInfraHost = new InfraHost();
// newInfraHost.setIp(host.getIp());
// newInfraHost.setMac(host.getMac());
// newInfraHost.setOs(infraOS);
// newInfraHost.setInfraType(typeHost);
// newInfraHost.setProbe(probe);
// if(host.isTarget()) {
// Target target = new Target();
// target.setDisplayName(StringConvertor.intToIp(host.getIp()) + "-Host");
// this.targetService.regist(target);
// newInfraHost.setTarget(target);
// }
// this.infraHostService.regist(newInfraHost);
// infraHost = newInfraHost;
// }
// return infraHost;
// }
}

View File

@ -1,36 +1,31 @@
package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.module.target.dao.TargetDAO; import com.loafle.overflow.central.module.target.dao.TargetDAO;
import com.loafle.overflow.central.module.target.model.Target; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
*/ */
@Service("TargetService") @Service("TargetService")
public class TargetService { public class CentralTargetService implements TargetService {
@Autowired @Autowired
private TargetDAO targetDAO; private TargetDAO targetDAO;
public Target regist(Target target) { public Target regist(Target target) throws OverflowException {
return this.targetDAO.save(target); return this.targetDAO.save(target);
} }
public Target read(String id) { public Target read(String id) throws OverflowException {
return this.targetDAO.findOne(Long.valueOf(id)); return this.targetDAO.findOne(Long.valueOf(id));
} }
// public List<Target> readAllByProbe(Probe probe) { public void remove(Target target) throws OverflowException {
// return this.targetDAO.findAllByProbe(probe);
// }
public void remove(Target target) {
this.targetDAO.delete(target); this.targetDAO.delete(target);
} }
} }

View File

@ -1,22 +1,9 @@
package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.central.module.discovery.model.Host;
import com.loafle.overflow.central.module.discovery.model.Port;
import com.loafle.overflow.central.module.discovery.type.PortType;
import com.loafle.overflow.central.module.infra.model.*;
import com.loafle.overflow.central.module.infra.model.InfraService;
import com.loafle.overflow.central.module.infra.service.*; import com.loafle.overflow.central.module.infra.service.*;
import com.loafle.overflow.central.module.meta.model.MetaInfraType;
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.module.target.model.Target;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
/** /**
* Created by snoop on 17. 6. 28. * Created by snoop on 17. 6. 28.
*/ */

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
import com.loafle.overflow.central.module.discovery.model.Host;
import com.loafle.overflow.central.module.probe.model.Probe; import com.loafle.overflow.central.module.probe.model.Probe;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.DeserializationConfig;