From afa93db77efcea41dc09df8b6653cb5440b5bb70 Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 24 Apr 2018 17:22:42 +0900 Subject: [PATCH] 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;