From afa93db77efcea41dc09df8b6653cb5440b5bb70 Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 24 Apr 2018 17:22:42 +0900 Subject: [PATCH 1/3] fixed service --- .../central/module/apikey/dao/ApiKeyDAO.java | 3 +- .../central/module/apikey/model/ApiKey.java | 81 ------------------- ...Service.java => CentralApiKeyService.java} | 15 ++-- .../module/auth/dao/AuthCrawlerDAO.java | 3 +- .../module/auth/model/AuthCrawler.java | 72 ----------------- ...ce.java => CentralAuthCrawlerService.java} | 13 +-- .../module/discovery/model/DiscoveryHost.java | 52 ------------ .../module/discovery/model/DiscoveryPort.java | 61 -------------- .../discovery/model/DiscoveryService.java | 15 ---- .../module/discovery/model/DiscoveryZone.java | 25 ------ .../central/module/discovery/model/Host.java | 67 --------------- .../central/module/discovery/model/Port.java | 68 ---------------- .../module/discovery/model/Service.java | 60 -------------- .../central/module/discovery/model/Zone.java | 63 --------------- ...vice.java => CentralDiscoveryService.java} | 40 ++++----- .../central/module/domain/dao/DomainDAO.java | 3 +- .../module/domain/dao/DomainMemberDAO.java | 5 +- .../central/module/domain/model/Domain.java | 52 ------------ .../module/domain/model/DomainMember.java | 59 -------------- ...e.java => CentralDomainMemberService.java} | 8 +- ...Service.java => CentralDomainService.java} | 9 ++- .../service/TargetDiscoveryService.java | 13 --- .../service/TargetDiscoveryServiceTest.java | 1 - 23 files changed, 57 insertions(+), 731 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java rename src/main/java/com/loafle/overflow/central/module/apikey/service/{ApiKeyService.java => CentralApiKeyService.java} (58%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java rename src/main/java/com/loafle/overflow/central/module/auth/service/{AuthCrawlerService.java => CentralAuthCrawlerService.java} (78%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java rename src/main/java/com/loafle/overflow/central/module/discovery/service/{DiscoveryService.java => CentralDiscoveryService.java} (76%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java rename src/main/java/com/loafle/overflow/central/module/domain/service/{DomainMemberService.java => CentralDomainMemberService.java} (83%) rename src/main/java/com/loafle/overflow/central/module/domain/service/{DomainService.java => CentralDomainService.java} (56%) diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java b/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java index aa6e5dd..6871925 100644 --- a/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java @@ -1,7 +1,8 @@ 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.model.apikey.ApiKey; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java b/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java deleted file mode 100644 index e14cf14..0000000 --- a/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java +++ /dev/null @@ -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; -// } -} diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java b/src/main/java/com/loafle/overflow/central/module/apikey/service/CentralApiKeyService.java similarity index 58% rename from src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java rename to src/main/java/com/loafle/overflow/central/module/apikey/service/CentralApiKeyService.java index d9bff23..1837354 100644 --- a/src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java +++ b/src/main/java/com/loafle/overflow/central/module/apikey/service/CentralApiKeyService.java @@ -1,8 +1,11 @@ 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.model.ApiKey; + 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.stereotype.Service; @@ -10,23 +13,23 @@ import org.springframework.stereotype.Service; * Created by snoop on 17. 6. 28. */ @Service("ApiKeyService") -public class ApiKeyService { +public class CentralApiKeyService implements ApiKeyService { @Autowired private ApiKeyDAO apiKeyDAO; - public ApiKey regist(ApiKey apiKey) { + public ApiKey regist(ApiKey apiKey) throws OverflowException { return this.apiKeyDAO.save(apiKey); } - public ApiKey readByDomain(Domain domain) { + public ApiKey readByDomain(Domain domain) throws OverflowException { return this.apiKeyDAO.findByDomain(domain); } - public boolean check(String apiKey) { + public boolean check(String apiKey) throws OverflowException { ApiKey retApiKey = this.apiKeyDAO.findByApiKey(apiKey); @@ -37,7 +40,7 @@ public class ApiKeyService { return true; } - public ApiKey readByApiKey(String apiKey) { + public ApiKey readByApiKey(String apiKey) throws OverflowException{ return this.apiKeyDAO.findByApiKey(apiKey); } diff --git a/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java b/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java index 6cee4cc..0e0c18d 100644 --- a/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java @@ -1,8 +1,9 @@ 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.target.model.Target; +import com.loafle.overflow.model.auth.AuthCrawler; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java b/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java deleted file mode 100644 index ec7f8ac..0000000 --- a/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java b/src/main/java/com/loafle/overflow/central/module/auth/service/CentralAuthCrawlerService.java similarity index 78% rename from src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java rename to src/main/java/com/loafle/overflow/central/module/auth/service/CentralAuthCrawlerService.java index 67903ba..28da92d 100644 --- a/src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java +++ b/src/main/java/com/loafle/overflow/central/module/auth/service/CentralAuthCrawlerService.java @@ -1,11 +1,14 @@ 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.model.AuthCrawler; + import com.loafle.overflow.central.module.infra.model.Infra; import com.loafle.overflow.central.module.infra.service.InfraService; import com.loafle.overflow.central.module.meta.model.MetaCrawler; 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.stereotype.Service; @@ -13,7 +16,7 @@ import org.springframework.stereotype.Service; * Created by snoop on 17. 8. 30. */ @Service("AuthCrawlerService") -public class AuthCrawlerService { +public class CentralAuthCrawlerService implements AuthCrawlerService { @Autowired private AuthCrawlerDAO authCrawlerDAO; @@ -21,7 +24,7 @@ public class AuthCrawlerService { @Autowired private InfraService infraService; - public AuthCrawler regist(AuthCrawler authCrawler) { + public AuthCrawler regist(AuthCrawler authCrawler) { AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByCrawlerAndTarget(authCrawler.getCrawler(), authCrawler.getTarget()); @@ -36,7 +39,7 @@ public class AuthCrawlerService { 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); @@ -45,7 +48,7 @@ public class AuthCrawlerService { return false; } - public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) { + public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) throws OverflowException { return this.authCrawlerDAO.findByCrawlerAndTarget(metaCrawler, target); } diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java deleted file mode 100644 index 9bf0453..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java +++ /dev/null @@ -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 excludeHosts; - private List 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 getExcludeHosts() { - return excludeHosts; - } - - public void setExcludeHosts(List excludeHosts) { - this.excludeHosts = excludeHosts; - } - - public List getIncludeHosts() { - return includeHosts; - } - - public void setIncludeHosts(List includeHosts) { - this.includeHosts = includeHosts; - } - - public DiscoveryPort getDiscoveryPort() { - return discoveryPort; - } - - public void setDiscoveryPort(DiscoveryPort discoveryPort) { - this.discoveryPort = discoveryPort; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java deleted file mode 100644 index 22d2608..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java +++ /dev/null @@ -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 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 getExcludePorts() { - return excludePorts; - } - - public void setExcludePorts(List 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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java deleted file mode 100644 index ef565f5..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.loafle.overflow.central.module.discovery.model; - -import java.util.List; - -public class DiscoveryService { - private List includeServices; - - public List getIncludeServices() { - return includeServices; - } - - public void setIncludeServices(List includeServices) { - this.includeServices = includeServices; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java deleted file mode 100644 index 7b00c6a..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.loafle.overflow.central.module.discovery.model; - -import java.util.List; - -public class DiscoveryZone { - private List excludePatterns; - - private DiscoveryHost discoveryHost; - - public List getExcludePatterns() { - return excludePatterns; - } - - public void setExcludePatterns(List excludePatterns) { - this.excludePatterns = excludePatterns; - } - - public DiscoveryHost getDiscoveryHost() { - return discoveryHost; - } - - public void setDiscoveryHost(DiscoveryHost discoveryHost) { - this.discoveryHost = discoveryHost; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java deleted file mode 100644 index e887f35..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java deleted file mode 100644 index 8cb7e2c..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java deleted file mode 100644 index 59eb988..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java +++ /dev/null @@ -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; - } - - -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java deleted file mode 100644 index 834dd17..0000000 --- a/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/discovery/service/CentralDiscoveryService.java similarity index 76% rename from src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java rename to src/main/java/com/loafle/overflow/central/module/discovery/service/CentralDiscoveryService.java index 794d931..863d81e 100644 --- a/src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java +++ b/src/main/java/com/loafle/overflow/central/module/discovery/service/CentralDiscoveryService.java @@ -1,16 +1,16 @@ package com.loafle.overflow.central.module.discovery.service; + + import com.loafle.overflow.central.commons.model.SessionMetadata; 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.DiscoveryZone; -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.model.Zone; +import com.loafle.overflow.core.annotation.ProbeAPI; +import com.loafle.overflow.core.annotation.WebappAPI; +import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.discovery.*; + +import com.loafle.overflow.service.central.discovery.DiscoveryService; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,12 +22,12 @@ import java.util.Date; * Created by snoop on 17. 9. 28. */ @Service("DiscoveryService") -public class DiscoveryService { +public class CentralDiscoveryService implements DiscoveryService { @Autowired private MessagePublisher messagePublisher; - public void startDiscovery(DiscoveryStartInfo startInfo) throws IOException { + public void startDiscovery(DiscoveryStartInfo startInfo) throws OverflowException,IOException { ObjectMapper objectMapper = new ObjectMapper(); @@ -61,40 +61,40 @@ public class DiscoveryService { // } @WebappAPI - public void discoverZone(String probeID, DiscoveryZone discoveryZone) { + public void discoverZone(String probeID, DiscoverZone discoveryZone) { String requesterSessionID = SessionMetadata.getSessionID(); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverZone", requesterSessionID, discoveryZone); } - + @WebappAPI - public void discoverHost(String probeID, Zone zone, DiscoveryHost discoveryHost) { + public void discoverHost(String probeID, Zone zone, DiscoverHost discoveryHost) { String requesterSessionID = SessionMetadata.getSessionID(); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverHost", requesterSessionID, zone, discoveryHost); } @WebappAPI - public void discoverPort(String probeID, Host host, DiscoveryPort discoveryPort) { + public void discoverPort(String probeID, Host host, DiscoverPort discoveryPort) { String requesterSessionID = SessionMetadata.getSessionID(); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverPort", requesterSessionID, host, discoveryPort); } - + @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(); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port, discoveryService); } @ProbeAPI - public void discoveryStart(String requesterSessionID, Date startDate) { + public void discoverStart(String requesterSessionID, Date startDate) { messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStart", startDate); } @ProbeAPI - public void discoveryStop(String requesterSessionID, Date stopDate) { + public void discoverStop(String requesterSessionID, Date stopDate) { messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStop", stopDate); } @@ -112,9 +112,9 @@ public class DiscoveryService { public void discoveredPort(String requesterSessionID, Port port) { messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredPort", port); } - + @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); } diff --git a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java index cb896eb..a12a2da 100644 --- a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java @@ -1,6 +1,7 @@ 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.stereotype.Repository; diff --git a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java index f5d3c8f..8265f2a 100644 --- a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java @@ -1,8 +1,9 @@ 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.model.domain.Domain; +import com.loafle.overflow.model.domain.DomainMember; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java b/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java deleted file mode 100644 index 88f220a..0000000 --- a/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java b/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java deleted file mode 100644 index 2422f63..0000000 --- a/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java b/src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainMemberService.java similarity index 83% rename from src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java rename to src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainMemberService.java index 58d61a6..0abed4d 100644 --- a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java +++ b/src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainMemberService.java @@ -1,10 +1,12 @@ package com.loafle.overflow.central.module.domain.service; 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.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.stereotype.Service; @@ -14,7 +16,7 @@ import java.util.List; * Created by snoop on 17. 6. 28. */ @Service("DomainMemberService") -public class DomainMemberService { +public class CentralDomainMemberService implements DomainMemberService { @Autowired private DomainMemberDAO domainMemberDAO; diff --git a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java b/src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainService.java similarity index 56% rename from src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java rename to src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainService.java index 286e54e..1677cf0 100644 --- a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java +++ b/src/main/java/com/loafle/overflow/central/module/domain/service/CentralDomainService.java @@ -1,7 +1,10 @@ package com.loafle.overflow.central.module.domain.service; 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.stereotype.Service; @@ -9,12 +12,12 @@ import org.springframework.stereotype.Service; * Created by snoop on 17. 6. 28. */ @Service("DomainService") -public class DomainService { +public class CentralDomainService implements DomainService { @Autowired private DomainDAO domainDAO; - public void regist(Domain domain) { + public void regist(Domain domain) throws OverflowException { this.domainDAO.save(domain); } } diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java index 81ce02a..9da481b 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java +++ b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java @@ -1,22 +1,9 @@ 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 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.stereotype.Service; -import javax.transaction.Transactional; -import java.util.List; - /** * Created by snoop on 17. 6. 28. */ diff --git a/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java b/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java index 05e5200..568d2e7 100644 --- a/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java @@ -1,6 +1,5 @@ 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.spring.AppConfigTest; import org.codehaus.jackson.map.DeserializationConfig; From 0d444fc58e29cd12ad200f64e2bc7a1bda0f93bf Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 24 Apr 2018 17:36:40 +0900 Subject: [PATCH 2/3] model change --- .../central/commons/utils/PageUtil.java | 3 +- .../noauthprobe/dao/NoAuthProbeDAO.java | 15 +- .../module/noauthprobe/model/NoAuthProbe.java | 138 ----------- ...ce.java => CentralNoAuthProbeService.java} | 37 +-- .../notification/dao/NotificationDAO.java | 5 +- .../notification/model/Notification.java | 89 ------- ...e.java => CentralNotificationService.java} | 26 ++- .../central/module/probe/dao/ProbeDAO.java | 7 +- .../module/probe/dao/ProbeHostDAO.java | 6 +- .../module/probe/dao/ProbeTaskDAO.java | 6 +- .../exception/ProbeNotFoundException.java | 4 +- .../central/module/probe/model/Probe.java | 190 --------------- .../central/module/probe/model/ProbeHost.java | 48 ---- .../central/module/probe/model/ProbeTask.java | 143 ------------ ...vice.java => CentralProbeHostService.java} | 13 +- .../probe/service/CentralProbeService.java | 47 ++++ ...vice.java => CentralProbeTaskService.java} | 13 +- .../module/probe/service/ProbeService.java | 53 ----- .../central/module/sensor/dao/SensorDAO.java | 8 +- .../module/sensor/dao/SensorItemDAO.java | 5 +- .../sensor/dao/SensorItemDependencyDAO.java | 3 +- .../central/module/sensor/model/Sensor.java | 104 --------- .../module/sensor/model/SensorItem.java | 62 ----- .../sensor/model/SensorItemDependency.java | 48 ---- ...> CentralSensorItemDependencyService.java} | 5 +- ...ice.java => CentralSensorItemService.java} | 13 +- ...Service.java => CentralSensorService.java} | 65 +++--- .../central/module/target/dao/TargetDAO.java | 12 +- .../exception/TargetNotFoundException.java | 4 +- .../central/module/target/model/Target.java | 98 -------- .../CentralTargetDiscoveryService.java | 220 ++++++++++++++++++ ...Service.java => CentralTargetService.java} | 21 +- 32 files changed, 406 insertions(+), 1105 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java rename src/main/java/com/loafle/overflow/central/module/noauthprobe/service/{NoAuthProbeService.java => CentralNoAuthProbeService.java} (79%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java rename src/main/java/com/loafle/overflow/central/module/notification/service/{NotificationService.java => CentralNotificationService.java} (68%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java rename src/main/java/com/loafle/overflow/central/module/probe/service/{ProbeHostService.java => CentralProbeHostService.java} (52%) create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeService.java rename src/main/java/com/loafle/overflow/central/module/probe/service/{ProbeTaskService.java => CentralProbeTaskService.java} (53%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java delete mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java rename src/main/java/com/loafle/overflow/central/module/sensor/service/{SensorItemDependencyService.java => CentralSensorItemDependencyService.java} (92%) rename src/main/java/com/loafle/overflow/central/module/sensor/service/{SensorItemService.java => CentralSensorItemService.java} (83%) rename src/main/java/com/loafle/overflow/central/module/sensor/service/{SensorService.java => CentralSensorService.java} (61%) delete mode 100644 src/main/java/com/loafle/overflow/central/module/target/model/Target.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetDiscoveryService.java rename src/main/java/com/loafle/overflow/central/module/target/service/{TargetService.java => CentralTargetService.java} (54%) diff --git a/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java b/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java index 4d348ee..ba77ebb 100644 --- a/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java +++ b/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java @@ -1,6 +1,7 @@ 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.Sort; diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java index 59c2ac6..734c95b 100644 --- a/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java @@ -1,7 +1,8 @@ package com.loafle.overflow.central.module.noauthprobe.dao; -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe; +import com.loafle.overflow.model.domain.Domain; +import com.loafle.overflow.model.noauthprobe.NoAuthProbe; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -14,12 +15,14 @@ import java.util.List; */ @Repository public interface NoAuthProbeDAO extends JpaRepository { -// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent); -// List findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent); -// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :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 List findAllByDomain(@Param("domain") Domain domain); + +// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent); +// List findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent); +// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") +// @Query("select m from Member m WHERE m.email = :#{#m2.email}") } diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java deleted file mode 100644 index b6ecc12..0000000 --- a/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.loafle.overflow.central.module.noauthprobe.model; - - -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; -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 = "NOAUTH_PROBE", schema = "public") -public class NoAuthProbe { - private long id; - private String description; - private MetaNoAuthProbeStatus status; - private String tempProbeKey; - private Date createDate; - private String apiKey; - private Domain domain; - private Probe probe; - - @Id - @GeneratedValue(strategy= GenerationType.IDENTITY) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Column(name = "DESCRIPTION", nullable = true, length = 1000) - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @ManyToOne - @JoinColumn(name = "STATUS", nullable = false) - public MetaNoAuthProbeStatus getStatus() { - return status; - } - - public void setStatus(MetaNoAuthProbeStatus status) { - this.status = status; - } - - @Column(name = "TEMP_PROBE_KEY", nullable = false, length = 50, unique = true) - public String getTempProbeKey() { - return tempProbeKey; - } - - public void setTempProbeKey(String tempProbeKey) { - this.tempProbeKey = tempProbeKey; - } - - @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 = "API_KEY", nullable = true, length = 50) - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - @ManyToOne - @JoinColumn(name = "DOMAIN_ID", nullable=false) - public Domain getDomain() { - return domain; - } - - public void setDomain(Domain domain) { - this.domain = domain; - } - - @ManyToOne - @JoinColumn(name = "PROBE_ID", nullable = true) - public Probe getProbe() { - return probe; - } - - public void setProbe(Probe probe) { - this.probe = probe; - } - -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (o == null || getClass() != o.getClass()) return false; -// -// NoAuthProbe that = (NoAuthProbe) o; -// -// if (id != that.id) return false; -// if (domainId != that.domainId) return false; -// if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false; -// if (macAddress != null ? !macAddress.equals(that.macAddress) : that.macAddress != null) return false; -// if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) return false; -// if (status != null ? !status.equals(that.status) : that.status != null) return false; -// if (tempProbeKey != null ? !tempProbeKey.equals(that.tempProbeKey) : that.tempProbeKey != null) return false; -// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; -// if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) return false; -// if (probeId != null ? !probeId.equals(that.probeId) : that.probeId != null) return false; -// -// return true; -// } -// -// @Override -// public int hashCode() { -// int result = (int) (id ^ (id >>> 32)); -// result = 31 * result + (hostName != null ? hostName.hashCode() : 0); -// result = 31 * result + (macAddress != null ? macAddress.hashCode() : 0); -// result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); -// result = 31 * result + (status != null ? status.hashCode() : 0); -// result = 31 * result + (tempProbeKey != null ? tempProbeKey.hashCode() : 0); -// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); -// result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0); -// result = 31 * result + (int) (domainId ^ (domainId >>> 32)); -// result = 31 * result + (probeId != null ? probeId.hashCode() : 0); -// return result; -// } -} diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java similarity index 79% rename from src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java rename to src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java index 7b31efa..6ac6a6d 100644 --- a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java @@ -5,19 +5,22 @@ 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.commons.utils.GenerateKey; -import com.loafle.overflow.central.module.apikey.model.ApiKey; -import com.loafle.overflow.central.module.apikey.service.ApiKeyService; -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.domain.model.DomainMember; -import com.loafle.overflow.central.module.domain.service.DomainMemberService; -import com.loafle.overflow.central.module.member.model.Member; import com.loafle.overflow.central.module.member.service.MemberService; -import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; -import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO; -import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe; -import com.loafle.overflow.central.module.probe.model.Probe; -import com.loafle.overflow.central.module.probe.service.ProbeService; +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.probe.ProbeService; + import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +37,7 @@ import java.util.UUID; * Created by snoop on 17. 6. 28. */ @Service("NoAuthProbeService") -public class NoAuthProbeService { +public class CentralNoAuthProbeService implements NoAuthProbeService{ @Autowired private NoAuthProbeDAO noAuthProbeDAO; @@ -55,7 +58,7 @@ public class NoAuthProbeService { private DomainMemberService domainMemberService; @ProbeAPI - public NoAuthProbe regist(NoAuthProbe noAuthProbe) { + public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException{ ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey()); noAuthProbe.setDomain(apiKey.getDomain()); @@ -69,17 +72,17 @@ public class NoAuthProbeService { } - public List readAllByDomain(Domain domain) { + public List readAllByDomain(Domain domain) throws OverflowException { return this.noAuthProbeDAO.findAllByDomain(domain); } - public NoAuthProbe read(long id) { + public NoAuthProbe read(long id) throws OverflowException { return this.noAuthProbeDAO.findOne(id); } @WebappAPI - public List acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException { + public List acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws OverflowException { String memberEmail = SessionMetadata.getTargetID(); // Todo domain injection & member injection @@ -125,7 +128,7 @@ public class NoAuthProbeService { } @WebappAPI - public List denyNoauthProbe(NoAuthProbe noAuthProbe) { + public List denyNoauthProbe(NoAuthProbe noAuthProbe) throws OverflowException { noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2)); this.noAuthProbeDAO.save(noAuthProbe); diff --git a/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java b/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java index 524c925..d9c4a4d 100644 --- a/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java @@ -1,7 +1,8 @@ package com.loafle.overflow.central.module.notification.dao; -import com.loafle.overflow.central.module.member.model.Member; -import com.loafle.overflow.central.module.notification.model.Notification; +import com.loafle.overflow.model.member.Member; +import com.loafle.overflow.model.notification.Notification; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java b/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java deleted file mode 100644 index a557e21..0000000 --- a/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java b/src/main/java/com/loafle/overflow/central/module/notification/service/CentralNotificationService.java similarity index 68% rename from src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java rename to src/main/java/com/loafle/overflow/central/module/notification/service/CentralNotificationService.java index b262a88..07b90f9 100644 --- a/src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java +++ b/src/main/java/com/loafle/overflow/central/module/notification/service/CentralNotificationService.java @@ -1,10 +1,13 @@ 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.module.member.model.Member; 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.data.domain.Page; import org.springframework.stereotype.Service; @@ -16,28 +19,28 @@ import java.util.List; * Created by insanity on 17. 8. 25. */ @Service("NotificationService") -public class NotificationService { +public class CentralNotificationService implements NotificationService { @Autowired private NotificationDAO notificationDAO; - public Notification regist(Notification notification) { + public Notification regist(Notification notification) throws OverflowException { return this.notificationDAO.save(notification); } - public Page readAllByMember(Member member, PageParams pageParams) { + public Page readAllByMember(Member member, PageParams pageParams) throws OverflowException { return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams)); } - public Page readAllUnconfirmedByMember(Member member, PageParams pageParams) { + public Page readAllUnconfirmedByMember(Member member, PageParams pageParams) throws OverflowException { 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); } - public Page markAllAsRead(Member member, PageParams pageParams) { + public Page markAllAsRead(Member member, PageParams pageParams) throws OverflowException { List list = this.notificationDAO.findAllByMember(member); for (Notification n : list) { n.setConfirmDate(new Date()); @@ -46,7 +49,7 @@ public class NotificationService { return this.readAllByMember(member, pageParams); } - public Page markAllAsUnread(Member member, PageParams pageParams) { + public Page markAllAsUnread(Member member, PageParams pageParams) throws OverflowException { List list = this.notificationDAO.findAllByMember(member); for (Notification n : list) { n.setConfirmDate(null); @@ -55,8 +58,9 @@ public class NotificationService { return this.readAllByMember(member, pageParams); } - public Notification markAsRead(Notification notification) { + public Notification markAsRead(Notification notification) throws OverflowException { notification.setConfirmDate(new Date()); return this.notificationDAO.save(notification); } + } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java index 34fafee..269225c 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java @@ -1,7 +1,8 @@ package com.loafle.overflow.central.module.probe.dao; -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.model.domain.Domain; +import com.loafle.overflow.model.probe.Probe; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -13,9 +14,7 @@ import java.util.List; */ @Repository public interface ProbeDAO extends JpaRepository { -// public List findAgentListByMemberId(Member member); Probe findByProbeKey(String probeKey); - List findAllByDomainOrderByIdDesc(Domain domain); } \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java index 6ebcd63..52cd495 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java @@ -1,7 +1,8 @@ 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.ProbeHost; +import com.loafle.overflow.model.probe.Probe; +import com.loafle.overflow.model.probe.ProbeHost; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -10,6 +11,5 @@ import org.springframework.stereotype.Repository; */ @Repository public interface ProbeHostDAO extends JpaRepository { - ProbeHost findByProbe(Probe probe); } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java index 914e5c5..38f8b23 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java @@ -1,17 +1,17 @@ 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.stereotype.Repository; 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. */ @Repository public interface ProbeTaskDAO extends JpaRepository { - List findAllByProbe(Probe probe); } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java b/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java index b164e2f..206f5d4 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java @@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; * Created by snoop on 17. 9. 14. */ public class ProbeNotFoundException extends OverflowRuntimeException { - public ProbeNotFoundException() { + private static final long serialVersionUID = 1L; + + public ProbeNotFoundException() { super(); } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java b/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java deleted file mode 100644 index f4b79e4..0000000 --- a/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java +++ /dev/null @@ -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 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 getTargets() { - return targets; - } - - public void setTargets(List 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; -// } -} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java deleted file mode 100644 index 7746473..0000000 --- a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java deleted file mode 100644 index ad2533e..0000000 --- a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java +++ /dev/null @@ -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; -// } -} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java similarity index 52% rename from src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java rename to src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java index 1a48c23..0e468e4 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java @@ -1,8 +1,11 @@ package com.loafle.overflow.central.module.probe.service; import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO; -import com.loafle.overflow.central.module.probe.model.Probe; -import com.loafle.overflow.central.module.probe.model.ProbeHost; +import com.loafle.overflow.core.exception.OverflowException; +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.stereotype.Service; @@ -10,16 +13,16 @@ import org.springframework.stereotype.Service; * Created by snoop on 17. 8. 21. */ @Service("ProbeHostService") -public class ProbeHostService { +public class CentralProbeHostService implements ProbeHostService { @Autowired private ProbeHostDAO probeHostDAO; - public ProbeHost readByProbe(Probe probe) { + public ProbeHost readByProbe(Probe probe) throws OverflowException { return this.probeHostDAO.findByProbe(probe); } - public ProbeHost regist(ProbeHost probeHost) { + public ProbeHost regist(ProbeHost probeHost) throws OverflowException { return this.probeHostDAO.save(probeHost); } } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeService.java new file mode 100644 index 0000000..a63f2e8 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeService.java @@ -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 regist(List probes) throws OverflowException { + return this.probeDAO.save(probes); + } + + public List readAllByDomain(Domain domain) throws OverflowException { + List 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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeTaskService.java similarity index 53% rename from src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java rename to src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeTaskService.java index 51bee6f..9c60ab2 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeTaskService.java @@ -1,8 +1,11 @@ package com.loafle.overflow.central.module.probe.service; import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO; -import com.loafle.overflow.central.module.probe.model.Probe; -import com.loafle.overflow.central.module.probe.model.ProbeTask; +import com.loafle.overflow.core.exception.OverflowException; +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.stereotype.Service; @@ -12,16 +15,16 @@ import java.util.List; * Created by snoop on 17. 6. 28. */ @Service("ProbeTaskService") -public class ProbeTaskService { +public class CentralProbeTaskService implements ProbeTaskService{ @Autowired private ProbeTaskDAO probeTaskDAO; - public ProbeTask regist(ProbeTask probeTask) { + public ProbeTask regist(ProbeTask probeTask) throws OverflowException { return this.probeTaskDAO.save(probeTask); } - public List readAllByProbe(Probe probe) { + public List readAllByProbe(Probe probe) throws OverflowException { return this.probeTaskDAO.findAllByProbe(probe); } } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java deleted file mode 100644 index 3f21543..0000000 --- a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java +++ /dev/null @@ -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 regist(List probes) { - return this.probeDAO.save(probes); - } - - public List readAllByDomain(Domain domain) { - List 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); - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java index 235a7fd..998ca3f 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java @@ -1,8 +1,6 @@ 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.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,18 +10,18 @@ import org.springframework.stereotype.Repository; 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. */ @Repository public interface SensorDAO extends JpaRepository { - Page findAllByTarget(Target target, Pageable pageable); List findAllByTarget(Target target); @Query("SELECT s from Sensor s WHERE s.target in (:targetList)") Page findAllByTargetList(@Param("targetList") List targetList, Pageable pageable); -// List findAllByTargetList(List targets); - } diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java index b9d847c..594c227 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java @@ -1,7 +1,8 @@ package com.loafle.overflow.central.module.sensor.dao; -import com.loafle.overflow.central.module.sensor.model.Sensor; -import com.loafle.overflow.central.module.sensor.model.SensorItem; +import com.loafle.overflow.model.sensor.Sensor; +import com.loafle.overflow.model.sensor.SensorItem; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java index 797a307..aa62f75 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java @@ -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.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.stereotype.Repository; diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java deleted file mode 100644 index ec2e376..0000000 --- a/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java deleted file mode 100644 index 278d0d6..0000000 --- a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java deleted file mode 100644 index 9f077f3..0000000 --- a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemDependencyService.java similarity index 92% rename from src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java rename to src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemDependencyService.java index 646b793..5629e92 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemDependencyService.java @@ -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.MetaSensorItemKey; 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.stereotype.Service; @@ -16,7 +17,7 @@ import java.util.Map; */ @Service("SensorItemDependencyService") -public class SensorItemDependencyService { +public class CentralSensorItemDependencyService { @Autowired private SensorItemDependencyDAO sensorItemDependencyDAO; diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java similarity index 83% rename from src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java rename to src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java index a3ed86e..7f49f4c 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java @@ -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.module.sensor.dao.SensorDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO; -import com.loafle.overflow.central.module.sensor.model.Sensor; -import com.loafle.overflow.central.module.sensor.model.SensorItem; +import com.loafle.overflow.model.sensor.Sensor; +import com.loafle.overflow.model.sensor.SensorItem; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -17,7 +18,7 @@ import java.util.List; * Created by insanity on 17. 6. 28. */ @Service("SensorItemService") -public class SensorItemService { +public class CentralSensorItemService { @Autowired private SensorItemDAO sensorItemDAO; @@ -27,7 +28,7 @@ public class SensorItemService { @Transactional public SensorItem regist(SensorItem sensorItem) { Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId()); - s.setItemCount((short)(s.getItemCount() + 1)); + // s.setItemCount((short)(s.getItemCount() + 1)); this.sensorDAO.save(s); return this.sensorItemDAO.save(sensorItem); } @@ -35,7 +36,7 @@ public class SensorItemService { @Transactional public boolean registAll(List sensorItemList) { Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId()); - s.setItemCount((short)sensorItemList.size()); + // s.setItemCount((short)sensorItemList.size()); this.sensorDAO.save(s); this.sensorItemDAO.save(sensorItemList); return true; @@ -52,7 +53,7 @@ public class SensorItemService { @Transactional public void remove(SensorItem sensorItem) { Sensor s = sensorItem.getSensor(); - s.setItemCount((short)(s.getItemCount() - 1)); + // s.setItemCount((short)(s.getItemCount() - 1)); this.sensorDAO.save(s); this.sensorItemDAO.delete(sensorItem); } diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java similarity index 61% rename from src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java rename to src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java index 18ef432..0df4a99 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java @@ -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.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.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.meta.model.MetaSensorStatus; 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.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.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.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.data.domain.Page; import org.springframework.stereotype.Service; @@ -29,7 +32,7 @@ import java.util.List; * Created by insanity on 17. 6. 28. */ @Service("SensorService") -public class SensorService { +public class CentralSensorService implements SensorService { @Autowired SensorDAO sensorDAO; @@ -41,10 +44,7 @@ public class SensorService { private InfraService infraService; @Autowired - private SensorItemService sensorItemService; - - @Autowired - private MetaSensorItemKeyService metaSensorItemKeyService; + private CentralSensorItemService sensorItemService; @Autowired private SensorConfigGenerator sensorConfigGenerator; @@ -53,67 +53,63 @@ public class SensorService { return this.sensorDAO.save(sensor); } -// public List readAllByTarget(Target target, PageParams pageParams) { -// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams)); -// } - - public Page readAllByDomain(Domain domain, PageParams pageParams) { + public Page readAllByDomain(Domain domain, PageParams pageParams) throws OverflowException { List probeList = this.probeService.readAllByDomain(domain); - if(probeList == null || probeList.size() <= 0) { + if (probeList == null || probeList.size() <= 0) { throw new ProbeNotFoundException(); } List targetList = this.infraService.readAllTargetByProbeList(probeList); - if(targetList == null || targetList.size() <= 0) { + if (targetList == null || targetList.size() <= 0) { throw new TargetNotFoundException(); } return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams)); } - public Page readAllByInfra(long infraId, PageParams pageParams) { + public Page readAllByInfra(long infraId, PageParams pageParams) throws OverflowException { Infra dbInfra = this.infraService.read(infraId); - if(dbInfra == null || dbInfra.getTarget() == null) { + if (dbInfra == null || dbInfra.getTarget() == null) { throw new InfraNotFoundException(); } return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams)); } - public Page readAllByTarget(Target target, PageParams pageParams) { + public Page readAllByTarget(Target target, PageParams pageParams) throws OverflowException { 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)); } - public void remove(Sensor sensor) { + public void remove(Sensor sensor) throws OverflowException { this.sensorDAO.delete(sensor); } - public Sensor start(Sensor sensor) { - MetaSensorStatus status = new MetaSensorStatus((short)1); + public Sensor start(Sensor sensor) throws OverflowException { + MetaSensorStatus status = new MetaSensorStatus((short) 1); sensor.setStatus(status); return this.sensorDAO.save(sensor); } - public Sensor stop(Sensor sensor) { - MetaSensorStatus status = new MetaSensorStatus((short)2); + public Sensor stop(Sensor sensor) throws OverflowException { + MetaSensorStatus status = new MetaSensorStatus((short) 2); sensor.setStatus(status); return this.sensorDAO.save(sensor); } @Transactional - public Sensor registSensorConfig(Sensor sensor, List sensorItemList, String etcJson) { + public Sensor registSensorConfig(Sensor sensor, List sensorItemList, String etcJson) throws OverflowException { this.sensorDAO.save(sensor); - for(SensorItem sensorItem : sensorItemList) { + for (SensorItem sensorItem : sensorItemList) { sensorItem.setSensor(sensor); } @@ -122,10 +118,13 @@ public class SensorService { 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 readAllByTarget(Target target, PageParams pageParams) { + // return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams)); + // } } diff --git a/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java b/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java index 1aa85c0..59da4a3 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java @@ -1,22 +1,12 @@ package com.loafle.overflow.central.module.target.dao; -import com.loafle.overflow.central.module.infra.model.Infra; -import com.loafle.overflow.central.module.probe.model.Probe; -import com.loafle.overflow.central.module.target.model.Target; +import com.loafle.overflow.model.target.Target; 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 java.util.List; - - /** * Created by root on 17. 6. 5. */ @Repository public interface TargetDAO extends JpaRepository { -// List findAllByProbe(Probe probe);] - - } diff --git a/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java b/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java index 3bfe1b4..f09d820 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java +++ b/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java @@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; * Created by snoop on 17. 9. 14. */ public class TargetNotFoundException extends OverflowRuntimeException { - public TargetNotFoundException() { + private static final long serialVersionUID = 1L; + + public TargetNotFoundException() { super(); } diff --git a/src/main/java/com/loafle/overflow/central/module/target/model/Target.java b/src/main/java/com/loafle/overflow/central/module/target/model/Target.java deleted file mode 100644 index 871af7d..0000000 --- a/src/main/java/com/loafle/overflow/central/module/target/model/Target.java +++ /dev/null @@ -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 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 getSensors() { - return sensors; - } - - public void setSensors(List sensors) { - this.sensors = sensors; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetDiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetDiscoveryService.java new file mode 100644 index 0000000..1819eb3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetDiscoveryService.java @@ -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 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; + // } + + + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java similarity index 54% rename from src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java rename to src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java index 256ed70..9b8e999 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java +++ b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java @@ -1,36 +1,31 @@ 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.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.stereotype.Service; -import java.util.List; - /** * Created by insanity on 17. 6. 28. */ @Service("TargetService") -public class TargetService { +public class CentralTargetService implements TargetService { @Autowired private TargetDAO targetDAO; - public Target regist(Target target) { + public Target regist(Target target) throws OverflowException { return this.targetDAO.save(target); } - public Target read(String id) { + public Target read(String id) throws OverflowException { return this.targetDAO.findOne(Long.valueOf(id)); } -// public List readAllByProbe(Probe probe) { -// return this.targetDAO.findAllByProbe(probe); -// } - - public void remove(Target target) { + public void remove(Target target) throws OverflowException { this.targetDAO.delete(target); } - } From ea236aa2791f7249514a67e01a8d6ec2b0073d5e Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 24 Apr 2018 17:41:08 +0900 Subject: [PATCH 3/3] history model change --- .../module/history/dao/HistoryDAO.java | 12 +- .../central/module/history/model/History.java | 116 ------------------ ...ervice.java => CentralHistoryService.java} | 16 +-- 3 files changed, 15 insertions(+), 129 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/central/module/history/model/History.java rename src/main/java/com/loafle/overflow/central/module/history/service/{HistoryService.java => CentralHistoryService.java} (71%) diff --git a/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java index 8fc6ed3..99303b5 100644 --- a/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java @@ -1,9 +1,9 @@ package com.loafle.overflow.central.module.history.dao; -import com.loafle.overflow.central.module.domain.model.Domain; -import com.loafle.overflow.central.module.history.model.History; -import com.loafle.overflow.central.module.meta.model.MetaHistoryType; -import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.model.domain.Domain; +import com.loafle.overflow.model.history.History; +import com.loafle.overflow.model.probe.Probe; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -21,10 +21,10 @@ public interface HistoryDAO extends JpaRepository { Page findAllByProbe(Probe probe, Pageable pageable); @Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}") - Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable); + Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageable); Page 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}") - Page findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest); + Page findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageRequest); } diff --git a/src/main/java/com/loafle/overflow/central/module/history/model/History.java b/src/main/java/com/loafle/overflow/central/module/history/model/History.java deleted file mode 100644 index 2a80826..0000000 --- a/src/main/java/com/loafle/overflow/central/module/history/model/History.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java b/src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java similarity index 71% rename from src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java rename to src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java index b733721..c72be13 100644 --- a/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java +++ b/src/main/java/com/loafle/overflow/central/module/history/service/CentralHistoryService.java @@ -1,18 +1,20 @@ 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.module.domain.model.Domain; import com.loafle.overflow.central.module.history.dao.HistoryDAO; -import com.loafle.overflow.central.module.history.model.History; -import com.loafle.overflow.central.module.meta.model.MetaHistoryType; -import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.core.model.PageParams; +import com.loafle.overflow.model.domain.Domain; +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.data.domain.Page; import org.springframework.stereotype.Service; @Service("HistoryService") -public class HistoryService { +public class CentralHistoryService implements HistoryService { @Autowired private HistoryDAO historyDAO; @@ -26,7 +28,7 @@ public class HistoryService { return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams)); } - public Page readAllByProbe(Probe probe, PageParams pageParams) { + public Page readAllByProbe(Probe probe, com.loafle.overflow.core.model.PageParams pageParams) { return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams)); }