ing
This commit is contained in:
parent
e8cd4eda7c
commit
07ef365ad3
27
pom.xml
27
pom.xml
|
@ -40,6 +40,18 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.loafle.overflow</groupId>
|
||||||
|
<artifactId>central-api</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.loafle.overflow</groupId>
|
||||||
|
<artifactId>commons-java</artifactId>
|
||||||
|
<version>1.0.6-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.loafle.commons</groupId>
|
<groupId>com.loafle.commons</groupId>
|
||||||
<artifactId>rpc-java</artifactId>
|
<artifactId>rpc-java</artifactId>
|
||||||
|
@ -185,21 +197,6 @@
|
||||||
<version>${caffeine.version}</version>
|
<version>${caffeine.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.loafle.overflow</groupId>
|
|
||||||
<artifactId>central-api</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.loafle.overflow</groupId>
|
|
||||||
<artifactId>commons-java</artifactId>
|
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.warrenstrange</groupId>
|
<groupId>com.warrenstrange</groupId>
|
||||||
<artifactId>googleauth</artifactId>
|
<artifactId>googleauth</artifactId>
|
||||||
|
|
|
@ -3,12 +3,19 @@ package com.loafle.overflow.central.commons.service;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
|
|
||||||
public interface MessagePublisher {
|
public interface MessagePublisher {
|
||||||
void publishToDomainMembers(final Long domainID, final String method, final Object... params) throws OverflowException;
|
void publishToDomainMembers(final Long domainID, final String method, final Object... params)
|
||||||
void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params) throws OverflowException;
|
throws OverflowException;
|
||||||
|
|
||||||
|
void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params)
|
||||||
|
throws OverflowException;
|
||||||
|
|
||||||
void publishToMember(final String memberID, final String method, final Object... params) throws OverflowException;
|
void publishToMember(final String memberID, final String method, final Object... params) throws OverflowException;
|
||||||
void publishToMemberSession(final String memberSessionID, final String method, final Object... params) throws OverflowException;
|
|
||||||
|
|
||||||
void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params) throws OverflowException;
|
void publishToMemberSession(final String memberSessionID, final String method, final Object... params)
|
||||||
|
throws OverflowException;
|
||||||
|
|
||||||
|
void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params)
|
||||||
|
throws OverflowException;
|
||||||
|
|
||||||
void publishToProbe(final String probeKey, final String method, final Object... params) throws OverflowException;
|
void publishToProbe(final String probeKey, final String method, final Object... params) throws OverflowException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.loafle.overflow.central.module.apikey.dao.ApiKeyDAO;
|
||||||
|
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.apikey.ApiKey;
|
import com.loafle.overflow.model.apikey.ApiKey;
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
|
||||||
import com.loafle.overflow.service.central.apikey.ApiKeyService;
|
import com.loafle.overflow.service.central.apikey.ApiKeyService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
package com.loafle.overflow.central.module.auth.dao;
|
package com.loafle.overflow.central.module.auth.dao;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
|
||||||
import com.loafle.overflow.model.target.Target;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -14,5 +9,5 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface AuthCrawlerDAO extends JpaRepository<AuthCrawler, Long> {
|
public interface AuthCrawlerDAO extends JpaRepository<AuthCrawler, Long> {
|
||||||
AuthCrawler findByCrawlerAndTarget(MetaCrawler metaCrawler, Target target);
|
AuthCrawler findByMetaCrawlerIdAndTargetId(Short metaCrawlerId, Long targetId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||||
import com.loafle.overflow.model.infra.Infra;
|
import com.loafle.overflow.model.infra.Infra;
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
import com.loafle.overflow.model.meta.MetaCrawler;
|
||||||
import com.loafle.overflow.model.target.Target;
|
|
||||||
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -25,22 +24,21 @@ public class CentralAuthCrawlerService implements AuthCrawlerService {
|
||||||
private CentralInfraService infraService;
|
private CentralInfraService infraService;
|
||||||
|
|
||||||
public AuthCrawler regist(AuthCrawler authCrawler) {
|
public AuthCrawler regist(AuthCrawler authCrawler) {
|
||||||
|
// if (authCrawler == null) {
|
||||||
|
// return this.authCrawlerDAO.save(authCrawler);
|
||||||
|
// }
|
||||||
|
|
||||||
AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByCrawlerAndTarget(authCrawler.getCrawler(),
|
AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByMetaCrawlerIdAndTargetId(authCrawler.getMetaCrawler().getId(),
|
||||||
authCrawler.getTarget());
|
authCrawler.getTarget().getId());
|
||||||
|
|
||||||
if (authCrawler == null) {
|
|
||||||
return this.authCrawlerDAO.save(authCrawler);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbAuthCrawler.setAuthJson(authCrawler.getAuthJson());
|
dbAuthCrawler.setAuthJson(authCrawler.getAuthJson());
|
||||||
dbAuthCrawler.setCrawler(authCrawler.getCrawler());
|
dbAuthCrawler.setMetaCrawler(authCrawler.getMetaCrawler());
|
||||||
dbAuthCrawler.setTarget(authCrawler.getTarget());
|
dbAuthCrawler.setTarget(authCrawler.getTarget());
|
||||||
|
|
||||||
return this.authCrawlerDAO.save(dbAuthCrawler);
|
return this.authCrawlerDAO.save(dbAuthCrawler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkAuthCrawler(Long infraId, MetaCrawler crawler, String authJson) throws OverflowException {
|
public boolean checkAuthCrawler(Long infraId, MetaCrawler metaCrawler, String authJson) throws OverflowException {
|
||||||
|
|
||||||
Infra infra = this.infraService.read(infraId);
|
Infra infra = this.infraService.read(infraId);
|
||||||
|
|
||||||
|
@ -49,9 +47,9 @@ public class CentralAuthCrawlerService implements AuthCrawlerService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) throws OverflowException {
|
public AuthCrawler readByMetaCrawlerIDAndTargetID(Short metaCrawlerID, Long targetID) throws OverflowException {
|
||||||
|
|
||||||
return this.authCrawlerDAO.findByCrawlerAndTarget(metaCrawler, target);
|
return this.authCrawlerDAO.findByMetaCrawlerIdAndTargetId(metaCrawlerID, targetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,13 @@ public class CentralDiscoveryService implements DiscoveryService {
|
||||||
discoveryService);
|
discoveryService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WebappAPI
|
||||||
|
public void stopDiscovery(String probeID) throws OverflowException {
|
||||||
|
String requesterSessionID = SessionMetadata.getSessionID();
|
||||||
|
|
||||||
|
messagePublisher.publishToProbe(probeID, "DiscoveryService.StopDiscovery", requesterSessionID);
|
||||||
|
}
|
||||||
|
|
||||||
@ProbeAPI
|
@ProbeAPI
|
||||||
public void discoveryStart(String requesterSessionID, Date startDate) throws OverflowException {
|
public void discoveryStart(String requesterSessionID, Date startDate) throws OverflowException {
|
||||||
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStart", startDate);
|
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveryStart", startDate);
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
package com.loafle.overflow.central.module.domain.dao;
|
package com.loafle.overflow.central.module.domain.dao;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.model.domain.DomainMember;
|
import com.loafle.overflow.model.domain.DomainMember;
|
||||||
import com.loafle.overflow.model.member.Member;
|
import com.loafle.overflow.model.member.Member;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,13 +14,9 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface DomainMemberDAO extends JpaRepository<DomainMember, Long> {
|
public interface DomainMemberDAO extends JpaRepository<DomainMember, Long> {
|
||||||
|
|
||||||
@Query("SELECT dm from DomainMember dm where dm.member.email = (:email)")
|
DomainMember findByMemberEmail(String memberEmail);
|
||||||
DomainMember findByMemberEmail(@Param("email") String email);
|
|
||||||
|
|
||||||
@Query("SELECT dm.domain from DomainMember dm where dm.member.id = (:memberID)")
|
Domain findDomainByMemberId(Long memberId);
|
||||||
Domain findDomainByMemberId(@Param("memberID") Long memberID);
|
|
||||||
|
|
||||||
|
List<Member> findAllMemberByDomainId(Long domainID);
|
||||||
@Query("SELECT dm.member from DomainMember dm where dm.domain.id = (:domainID)")
|
|
||||||
List<Member> findAllMemberByDomainId(@Param("domainID") Long domainID);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.loafle.overflow.central.module.domain.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO;
|
import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.member.dao.MemberDAO;
|
|
||||||
|
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.model.domain.DomainMember;
|
import com.loafle.overflow.model.domain.DomainMember;
|
||||||
import com.loafle.overflow.model.member.Member;
|
import com.loafle.overflow.model.member.Member;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.loafle.overflow.central.module.email.dao;
|
package com.loafle.overflow.central.module.email.dao;
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.model.email.EmailAuth;
|
import com.loafle.overflow.model.email.EmailAuth;
|
||||||
import com.loafle.overflow.model.member.Member;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -15,7 +13,6 @@ import java.util.List;
|
||||||
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
|
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
|
||||||
EmailAuth findByEmailAuthKey(String emailAuthKey);
|
EmailAuth findByEmailAuthKey(String emailAuthKey);
|
||||||
|
|
||||||
List<EmailAuth> findByMember(Member member);
|
List<EmailAuth> findByMemberId(Long memberId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.email.service;
|
package com.loafle.overflow.central.module.email.service;
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.utils.EmailSender;
|
import com.loafle.overflow.central.commons.utils.EmailSender;
|
||||||
import com.loafle.overflow.central.commons.utils.GenerateKey;
|
import com.loafle.overflow.central.commons.utils.GenerateKey;
|
||||||
import com.loafle.overflow.central.module.domain.dao.DomainDAO;
|
import com.loafle.overflow.central.module.domain.dao.DomainDAO;
|
||||||
|
@ -45,19 +44,19 @@ public class EmailAuthService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmailSender emailSender;
|
private EmailSender emailSender;
|
||||||
|
|
||||||
|
// private static final String WEB_NG_MEMBER_ADDR =
|
||||||
// private static final String WEB_NG_MEMBER_ADDR = "http://127.0.0.1:4200/auth/";
|
// "http://127.0.0.1:4200/auth/";
|
||||||
|
|
||||||
public EmailAuth read(Long id) {
|
public EmailAuth read(Long id) {
|
||||||
return this.emailAuthDAO.findOne(id);
|
return this.emailAuthDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailAuth readBySignupAuthKey(String token) throws OverflowException {
|
public EmailAuth readBySignupAuthKey(String token) throws OverflowException {
|
||||||
// System.out.println("authKey = [" + token + "]");
|
// System.out.println("authKey = [" + token + "]");
|
||||||
// String deStr = URLDecoder.decode(token, "UTF-8");
|
// String deStr = URLDecoder.decode(token, "UTF-8");
|
||||||
// System.out.println("deStr = [" + deStr + "]");
|
// System.out.println("deStr = [" + deStr + "]");
|
||||||
//
|
//
|
||||||
// EmailAuth auth = this.emailAuthDAO.findByEmailAuthKey(deStr);
|
// EmailAuth auth = this.emailAuthDAO.findByEmailAuthKey(deStr);
|
||||||
|
|
||||||
EmailAuth auth = this.readByToken(token);
|
EmailAuth auth = this.readByToken(token);
|
||||||
|
|
||||||
|
@ -66,14 +65,13 @@ public class EmailAuthService {
|
||||||
boolean res = this.isValidateTime(auth);
|
boolean res = this.isValidateTime(auth);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new OverflowException(
|
throw new OverflowException("The authentication expiration time has expired, or the token has been verified.",
|
||||||
"The authentication expiration time has expired, or the token has been verified.",
|
|
||||||
new Throwable());
|
new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.setAuthConfirmDate(new Date());
|
auth.setAuthConfirmDate(new Date());
|
||||||
this.emailAuthDAO.save(auth);
|
this.emailAuthDAO.save(auth);
|
||||||
auth.getMember().setStatus(new MetaMemberStatus((short)2));
|
auth.getMember().setMetaMemberStatus(new MetaMemberStatus((short) 2));
|
||||||
this.memberDAO.save(auth.getMember());
|
this.memberDAO.save(auth.getMember());
|
||||||
|
|
||||||
Domain domain = new Domain();
|
Domain domain = new Domain();
|
||||||
|
@ -97,8 +95,7 @@ public class EmailAuthService {
|
||||||
boolean res = this.isValidateTime(auth);
|
boolean res = this.isValidateTime(auth);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new OverflowException(
|
throw new OverflowException("The authentication expiration time has expired, or the token has been verified.",
|
||||||
"The authentication expiration time has expired, or the token has been verified.",
|
|
||||||
new Throwable());
|
new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +112,7 @@ public class EmailAuthService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
encode = URLEncoder.encode(token, "UTF-8");
|
encode = URLEncoder.encode(token, "UTF-8");
|
||||||
}catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +123,7 @@ public class EmailAuthService {
|
||||||
// dZQgXM1o/Cx48X8DM+6ec/oPfqA2l/LdWtijOZ2EnWk=
|
// dZQgXM1o/Cx48X8DM+6ec/oPfqA2l/LdWtijOZ2EnWk=
|
||||||
|
|
||||||
public List<EmailAuth> readByMember(Long memberId) {
|
public List<EmailAuth> readByMember(Long memberId) {
|
||||||
return this.emailAuthDAO.findByMember(new Member(memberId));
|
return this.emailAuthDAO.findByMemberId(memberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailAuth modify(EmailAuth emailAuth) {
|
public EmailAuth modify(EmailAuth emailAuth) {
|
||||||
|
@ -165,7 +162,7 @@ public class EmailAuthService {
|
||||||
|
|
||||||
private EmailAuth sendEMail(Member member, int status) throws OverflowException {
|
private EmailAuth sendEMail(Member member, int status) throws OverflowException {
|
||||||
String key = GenerateKey.getKey();
|
String key = GenerateKey.getKey();
|
||||||
// String enMail = emailSender.encrypt(key);
|
// String enMail = emailSender.encrypt(key);
|
||||||
|
|
||||||
String mailSubject = null;
|
String mailSubject = null;
|
||||||
String entry = null;
|
String entry = null;
|
||||||
|
@ -174,14 +171,14 @@ public class EmailAuthService {
|
||||||
EmailAuth auth = new EmailAuth();
|
EmailAuth auth = new EmailAuth();
|
||||||
auth.setMember(member);
|
auth.setMember(member);
|
||||||
auth.setEmailAuthKey(key);
|
auth.setEmailAuthKey(key);
|
||||||
auth.setEmailStatus(new MetaEmailStatus(status));
|
auth.setMetaEmailStatus(new MetaEmailStatus(status));
|
||||||
|
|
||||||
// System.out.println("encode = [" + encode + "]");
|
// System.out.println("encode = [" + encode + "]");
|
||||||
String encode = "";
|
String encode = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
encode = URLEncoder.encode(key, "UTF-8");
|
encode = URLEncoder.encode(key, "UTF-8");
|
||||||
}catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +214,6 @@ public class EmailAuthService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// EmailAuth auth = new EmailAuth();
|
// EmailAuth auth = new EmailAuth();
|
||||||
// auth.setMember(member);
|
// auth.setMember(member);
|
||||||
// String en = emailSender.encrypt(member.getEmail());
|
// String en = emailSender.encrypt(member.getEmail());
|
||||||
|
@ -230,9 +225,11 @@ public class EmailAuthService {
|
||||||
// Mail mail = new Mail();
|
// Mail mail = new Mail();
|
||||||
// mail.setMailTo(member.getEmail());
|
// mail.setMailTo(member.getEmail());
|
||||||
// mail.setMailSubject("Confirm Email");
|
// mail.setMailSubject("Confirm Email");
|
||||||
//// mail.setMailContent("http://127.0.0.1:19080/account/confirm_signup?key="+ encode +"\r\nConfirm Email");
|
//// mail.setMailContent("http://127.0.0.1:19080/account/confirm_signup?key="+
|
||||||
|
// encode +"\r\nConfirm Email");
|
||||||
//
|
//
|
||||||
// String uri = WEB_GO_MEMBER_ADDR + "confirm_signup?key=" + encode + "\r\nConfirm Email";
|
// String uri = WEB_GO_MEMBER_ADDR + "confirm_signup?key=" + encode +
|
||||||
|
// "\r\nConfirm Email";
|
||||||
// Map<String, Object> model = new HashMap<>();
|
// Map<String, Object> model = new HashMap<>();
|
||||||
// model.put("firstName", auth.getMember().getName());
|
// model.put("firstName", auth.getMember().getName());
|
||||||
// model.put("lastName", auth.getMember().getCompanyName());
|
// model.put("lastName", auth.getMember().getCompanyName());
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class GenerateUtil {
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
resultMap = this.metaSensorItemKeyService.readAllMapByCrawler(metaCrawler);
|
resultMap = this.metaSensorItemKeyService.readAllMapByMetaCrawlerID(metaCrawler.getId());
|
||||||
this.mappingMap.put(metaCrawler.getId(), resultMap);
|
this.mappingMap.put(metaCrawler.getId(), resultMap);
|
||||||
|
|
||||||
return resultMap;
|
return resultMap;
|
||||||
|
@ -85,7 +85,7 @@ public class GenerateUtil {
|
||||||
MetaSensorItemKey itemKey = null;
|
MetaSensorItemKey itemKey = null;
|
||||||
|
|
||||||
for(SensorItem sItem : sensorItems) {
|
for(SensorItem sItem : sensorItems) {
|
||||||
itemKey = keyMap.get(sItem.getItem().getId());
|
itemKey = keyMap.get(sItem.getMetaSensorDisplayItem().getId());
|
||||||
if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||||
metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class GenerateUtil {
|
||||||
public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
|
public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
|
||||||
Keys keys = new Keys();
|
Keys keys = new Keys();
|
||||||
keys.setKey(itemKey.getKey());
|
keys.setKey(itemKey.getKey());
|
||||||
keys.setMetric(itemKey.getItem().getKey());
|
keys.setMetric(itemKey.getMetaSensorItem().getKey());
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,12 @@ public class InfraHostGenerator {
|
||||||
schedule.setInterval("5");
|
schedule.setInterval("5");
|
||||||
sensorConfig.setSchedule(schedule);
|
sensorConfig.setSchedule(schedule);
|
||||||
|
|
||||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||||
sensorConfig.setCrawler(crawler);
|
sensorConfig.setCrawler(crawler);
|
||||||
|
|
||||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||||
|
|
||||||
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
if (dbSensor.getMetaCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||||
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class InfraHostGenerator {
|
||||||
|
|
||||||
private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws Exception {
|
private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws Exception {
|
||||||
|
|
||||||
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
|
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(), dbSensor.getTarget().getId());
|
||||||
|
|
||||||
if (authCrawler == null) {
|
if (authCrawler == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -89,7 +89,7 @@ public class InfraHostGenerator {
|
||||||
|
|
||||||
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(), new TypeReference<Map<String, String>>(){});
|
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(), new TypeReference<Map<String, String>>(){});
|
||||||
|
|
||||||
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
if (dbSensor.getMetaCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||||
connection.setPort(135);
|
connection.setPort(135);
|
||||||
connection.setPortType(PortType.TCP);
|
connection.setPortType(PortType.TCP);
|
||||||
connection.setSsl(false);
|
connection.setSsl(false);
|
||||||
|
|
|
@ -66,14 +66,14 @@ public class InfraServiceGenerator {
|
||||||
schedule.setInterval("5");
|
schedule.setInterval("5");
|
||||||
sensorConfig.setSchedule(schedule);
|
sensorConfig.setSchedule(schedule);
|
||||||
|
|
||||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||||
sensorConfig.setCrawler(crawler);
|
sensorConfig.setCrawler(crawler);
|
||||||
|
|
||||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||||
|
|
||||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
if(dbSensor.getMetaCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||||
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
} else if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
} else if (dbSensor.getMetaCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||||
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class InfraServiceGenerator {
|
||||||
|
|
||||||
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
|
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
|
||||||
|
|
||||||
AuthCrawler authCrawler = this.authCrawlerService.readAuth(sensor.getCrawler(), sensor.getTarget());
|
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(), sensor.getTarget().getId());
|
||||||
|
|
||||||
if(authCrawler == null) {
|
if(authCrawler == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -90,7 +90,7 @@ public class InfraServiceGenerator {
|
||||||
|
|
||||||
Target target = new Target();
|
Target target = new Target();
|
||||||
Connection connection = new Connection();
|
Connection connection = new Connection();
|
||||||
connection.setIp(infraService.getHost().getIpv4());
|
connection.setIp(infraService.getInfraHost().getIpv4());
|
||||||
connection.setPort(infraService.getPort());
|
connection.setPort(infraService.getPort());
|
||||||
connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
||||||
connection.setSsl(infraService.isTlsType());
|
connection.setSsl(infraService.isTlsType());
|
||||||
|
@ -101,11 +101,11 @@ public class InfraServiceGenerator {
|
||||||
|
|
||||||
Map<String, Object> auth = new HashMap<>();
|
Map<String, Object> auth = new HashMap<>();
|
||||||
|
|
||||||
if(sensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
if(sensor.getMetaCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||||
auth.put("url", "jdbc:mysql://"+ infraService.getHost().getIpv4() +":" + infraService.getPort());
|
auth.put("url", "jdbc:mysql://"+ infraService.getInfraHost().getIpv4() +":" + infraService.getPort());
|
||||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||||
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
} else if (sensor.getMetaCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||||
connection.setPort(9840);
|
connection.setPort(9840);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class InfraServiceJMXGenerator {
|
||||||
|
|
||||||
keys = new Keys();
|
keys = new Keys();
|
||||||
keys.setKey(tempItemKey.getKey());
|
keys.setKey(tempItemKey.getKey());
|
||||||
keys.setMetric(tempItemKey.getItem().getKey());
|
keys.setMetric(tempItemKey.getMetaSensorItem().getKey());
|
||||||
|
|
||||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class SensorConfigGenerator {
|
||||||
pageParams.setCountPerPage(Integer.MAX_VALUE);
|
pageParams.setCountPerPage(Integer.MAX_VALUE);
|
||||||
pageParams.setSortCol("id");
|
pageParams.setSortCol("id");
|
||||||
pageParams.setSortDirection("descending");
|
pageParams.setSortDirection("descending");
|
||||||
Page<SensorItem> dbItemList = this.sensorItemService.readAllBySensor(sensor, pageParams);
|
Page<SensorItem> dbItemList = this.sensorItemService.readAllBySensorID(sensor.getId(), pageParams);
|
||||||
|
|
||||||
List<SensorItem> sensorItems = dbItemList.getContent();
|
List<SensorItem> sensorItems = dbItemList.getContent();
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ public class SensorConfigGenerator {
|
||||||
Infra infra = this.infraService.readByTargetID(dbSensor.getTarget().getId());
|
Infra infra = this.infraService.readByTargetID(dbSensor.getTarget().getId());
|
||||||
|
|
||||||
// 7 = Infra OS Service
|
// 7 = Infra OS Service
|
||||||
if(infra.getInfraType().getId() == 7) {
|
if(infra.getMetaInfraType().getId() == 7) {
|
||||||
return this.infraServiceGenerator.process(dbSensor, sensorItems, infra);
|
return this.infraServiceGenerator.process(dbSensor, sensorItems, infra);
|
||||||
}
|
}
|
||||||
if(infra.getInfraType().getId() == 2) {
|
if(infra.getMetaInfraType().getId() == 2) {
|
||||||
return this.infraHostGenerator.process(dbSensor, sensorItems, infra);
|
return this.infraHostGenerator.process(dbSensor, sensorItems, infra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
package com.loafle.overflow.central.module.history.dao;
|
package com.loafle.overflow.central.module.history.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
|
||||||
import com.loafle.overflow.model.history.History;
|
import com.loafle.overflow.model.history.History;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 8. 23.
|
* Created by insanity on 17. 8. 23.
|
||||||
*/
|
*/
|
||||||
|
@ -18,11 +14,9 @@ import org.springframework.stereotype.Repository;
|
||||||
public interface HistoryDAO extends JpaRepository<History, Long> {
|
public interface HistoryDAO extends JpaRepository<History, Long> {
|
||||||
Page<History> findAllByProbeId(Long probeID, Pageable pageable);
|
Page<History> findAllByProbeId(Long probeID, Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probeID} and h.type.id = :#{#type.id}")
|
Page<History> findAllByProbeIdAndMetaHistoryTypeId(Long probeID, Integer metaHistoryTypeId, Pageable pageable);
|
||||||
Page<History> findAllByProbeIdAndType(@Param("probeID") Long probeID, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageable);
|
|
||||||
|
|
||||||
Page<History> findAllByDomainId(Long domainID, Pageable pageRequest);
|
Page<History> findAllByDomainId(Long domainID, Pageable pageRequest);
|
||||||
|
|
||||||
@Query("SELECT h FROM History h WHERE h.domain.id = :#{#domainID} and h.type.id = :#{#type.id}")
|
Page<History> findAllByDomainIdAndMetaHistoryTypeId(Long domainID, Integer metaHistoryTypeId, Pageable pageRequest);
|
||||||
Page<History> findAllByDomainIdAndType(@Param("domainID") Long domainID, @Param("type") com.loafle.overflow.model.meta.MetaHistoryType type, Pageable pageRequest);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.loafle.overflow.central.module.history.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||||
import com.loafle.overflow.central.module.history.dao.HistoryDAO;
|
import com.loafle.overflow.central.module.history.dao.HistoryDAO;
|
||||||
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.core.model.PageParams;
|
import com.loafle.overflow.core.model.PageParams;
|
||||||
import com.loafle.overflow.model.domain.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.model.history.History;
|
import com.loafle.overflow.model.history.History;
|
||||||
|
@ -18,25 +19,25 @@ public class CentralHistoryService implements HistoryService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HistoryDAO historyDAO;
|
private HistoryDAO historyDAO;
|
||||||
|
|
||||||
public History regist(History history) {
|
public History regist(History history) throws OverflowException {
|
||||||
return this.historyDAO.save(history);
|
return this.historyDAO.save(history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Page<History> readAllByProbeIDAndType(Long probeID, MetaHistoryType type, PageParams pageParams) {
|
public Page<History> readAllByProbeIDAndMetaHistoryTypeID(Long probeID, Integer metaHistoryTypeID, PageParams pageParams) throws OverflowException {
|
||||||
return this.historyDAO.findAllByProbeIdAndType(probeID, type, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByProbeIdAndMetaHistoryTypeId(probeID, metaHistoryTypeID, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<History> readAllByProbeID(Long probeID, PageParams pageParams) {
|
public Page<History> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
|
||||||
return this.historyDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByProbeId(probeID, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<History> readAllByDomainID(Long domainID, PageParams pageParams) {
|
public Page<History> readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
|
||||||
return this.historyDAO.findAllByDomainId(domainID, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByDomainId(domainID, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<History> readAllByDomainIDAndType(Long domainID, MetaHistoryType type, PageParams pageParams) {
|
public Page<History> readAllByDomainIDAndMetaHistoryTypeID(Long domainID, Integer metaHistoryTypeID, PageParams pageParams) throws OverflowException {
|
||||||
return this.historyDAO.findAllByDomainIdAndType(domainID, type, PageUtil.getPageRequest(pageParams));
|
return this.historyDAO.findAllByDomainIdAndMetaHistoryTypeId(domainID, metaHistoryTypeID, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import com.loafle.overflow.model.target.Target;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -21,13 +19,10 @@ public interface InfraDAO extends JpaRepository<Infra, Long> {
|
||||||
|
|
||||||
Page<Infra> findAllByProbeId(Long probeID, Pageable pageable);
|
Page<Infra> findAllByProbeId(Long probeID, Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT i FROM INFRA i WHERE i.probe IN (:probeList) AND i.target != NULL")
|
Page<Infra> findAllByProbeInAndTargetNotNull(List<Probe> probes, Pageable pageable);
|
||||||
Page<Infra> findAllByProbeList(@Param("probeList") List<Probe> probeList, Pageable pageable);
|
|
||||||
|
|
||||||
|
List<Target> findAllTargetByProbeIn(List<Probe> probes);
|
||||||
@Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)")
|
|
||||||
List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
|
|
||||||
|
|
||||||
Infra findByTargetId(Long targetID);
|
Infra findByTargetId(Long targetID);
|
||||||
// List<Infra> findAllByProbe(List<Probe> probeList);
|
|
||||||
}
|
}
|
|
@ -2,9 +2,6 @@ package com.loafle.overflow.central.module.infra.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.infra.InfraOSPort;
|
import com.loafle.overflow.model.infra.InfraOSPort;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
// import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +9,5 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
|
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
|
||||||
@Query("SELECT p from com.loafle.overflow.model.infra.InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)")
|
InfraOSPort findByInfraOSIdAndPortAndPortType(Long infraOSId, Integer port, String portType);
|
||||||
InfraOSPort findByPort(@Param("osId") Long osId,@Param("portNumber") Integer portNumber,@Param("portType") String portType);
|
|
||||||
}
|
}
|
|
@ -2,8 +2,6 @@ package com.loafle.overflow.central.module.infra.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.infra.InfraService;
|
import com.loafle.overflow.model.infra.InfraService;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +9,5 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface InfraServiceDAO extends JpaRepository<InfraService, Long> {
|
public interface InfraServiceDAO extends JpaRepository<InfraService, Long> {
|
||||||
@Query("SELECT ins from com.loafle.overflow.model.infra.InfraService ins WHERE ins.host.id = (:hostId) AND ins.port = (:portNumber) AND ins.portType = (:portType)")
|
InfraService findByInfraHostIdAndPortAndPortType(Long infraHostId, Integer port, String portType);
|
||||||
InfraService findByService(@Param("hostId") Long hostId,@Param("portNumber") Integer portNumber,@Param("portType") String portType);
|
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.infra.service;
|
package com.loafle.overflow.central.module.infra.service;
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.infra.dao.InfraHostDAO;
|
import com.loafle.overflow.central.module.infra.dao.InfraHostDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.infra.InfraHost;
|
import com.loafle.overflow.model.infra.InfraHost;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class CentralInfraOSApplicationService implements InfraOSApplicationServi
|
||||||
return this.infraOSApplicationDAO.save(infraOSApplication);
|
return this.infraOSApplicationDAO.save(infraOSApplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InfraOSApplication read(Long id)throws OverflowException {
|
public InfraOSApplication read(Long id) throws OverflowException {
|
||||||
return this.infraOSApplicationDAO.findOne(id);
|
return this.infraOSApplicationDAO.findOne(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ public class CentralInfraOSPortService implements InfraOSPortService {
|
||||||
return this.infraOSPortDAO.findOne(id);
|
return this.infraOSPortDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InfraOSPort readByPort(Long osId, int portNumber, String portType) throws OverflowException {
|
public InfraOSPort readByInfraOSIDAndPortAndPortType(Long infraOSID, Integer port, String portType)
|
||||||
return this.infraOSPortDAO.findByPort(osId, portNumber, portType);
|
throws OverflowException {
|
||||||
|
return this.infraOSPortDAO.findByInfraOSIdAndPortAndPortType(infraOSID, port, portType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,32 +50,31 @@ public class CentralInfraService implements InfraService {
|
||||||
public Page<Infra> readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
|
public Page<Infra> readAllByDomainID(Long domainID, PageParams pageParams) throws OverflowException {
|
||||||
List<Probe> probeList = this.probeService.readAllByDomainID(domainID);
|
List<Probe> probeList = this.probeService.readAllByDomainID(domainID);
|
||||||
|
|
||||||
if(probeList == null || probeList.size() <= 0) {
|
if (probeList == null || probeList.size() <= 0) {
|
||||||
throw new OverflowException("ProbeNotFoundException", new Throwable());
|
throw new OverflowException("ProbeNotFoundException", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
Page<Infra> infraList = this.infraDAO.findAllByProbeList(probeList, PageUtil.getPageRequest(pageParams));
|
Page<Infra> infraList = this.infraDAO.findAllByProbeInAndTargetNotNull(probeList, PageUtil.getPageRequest(pageParams));
|
||||||
for (Infra infra: infraList) {
|
for (Infra infra : infraList) {
|
||||||
infra.getTarget().setSensors(this.sensorDAO.findAllByTargetId(infra.getTarget().getId()));
|
infra.getTarget().setSensors(this.sensorDAO.findAllByTargetId(infra.getTarget().getId()));
|
||||||
}
|
}
|
||||||
return infraList;
|
return infraList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Target> readAllTargetByDomainID(Long domainID) throws OverflowException {
|
public List<Target> readAllTargetByDomainID(Long domainID) throws OverflowException {
|
||||||
|
|
||||||
List<Probe> probeList = this.probeService.readAllByDomainID(domainID);
|
List<Probe> probes = this.probeService.readAllByDomainID(domainID);
|
||||||
|
|
||||||
if(probeList == null || probeList.size() <= 0) {
|
if (probes == null || probes.size() <= 0) {
|
||||||
throw new OverflowException("ProbeNotFoundException", new Throwable());
|
throw new OverflowException("ProbeNotFoundException", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.infraDAO.findAllTargetByProbeList(probeList);
|
return this.infraDAO.findAllTargetByProbeIn(probes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Target> readAllTargetByProbeList(List<Probe> probeList) throws OverflowException {
|
public List<Target> readAllTargetByProbes(List<Probe> probes) throws OverflowException {
|
||||||
return this.infraDAO.findAllTargetByProbeList(probeList);
|
return this.infraDAO.findAllTargetByProbeIn(probes);
|
||||||
// return null;
|
// return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Infra readByTargetID(Long targetID) throws OverflowException {
|
public Infra readByTargetID(Long targetID) throws OverflowException {
|
||||||
|
|
|
@ -24,7 +24,8 @@ public class CentralInfraServiceService implements InfraServiceService {
|
||||||
return this.infraServiceDAO.findOne(id);
|
return this.infraServiceDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InfraService readByService(Long hostId, int portNumber, String portType) throws OverflowException {
|
public InfraService readByInfraHostIDAndPortAndPortType(Long infraHostID, int port, String portType)
|
||||||
return this.infraServiceDAO.findByService(hostId, portNumber, portType);
|
throws OverflowException {
|
||||||
|
return this.infraServiceDAO.findByInfraHostIdAndPortAndPortType(infraHostID, port, portType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.loafle.overflow.central.module.member.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.member.Member;
|
import com.loafle.overflow.model.member.Member;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +10,5 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface MemberDAO extends JpaRepository<Member, Long> {
|
public interface MemberDAO extends JpaRepository<Member, Long> {
|
||||||
@Query("select m from Member m WHERE m.email = :signinId")
|
Member findByEmail(String email);
|
||||||
Member findByEmail(@Param("signinId") String signinId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.loafle.overflow.central.module.member.dao;
|
package com.loafle.overflow.central.module.member.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.member.Member;
|
|
||||||
import com.loafle.overflow.model.member.MemberTotp;
|
import com.loafle.overflow.model.member.MemberTotp;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,8 +9,7 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MemberTotpDAO extends JpaRepository<MemberTotp, Long> {
|
public interface MemberTotpDAO extends JpaRepository<MemberTotp, Long> {
|
||||||
@Query("select m from MemberTotp m WHERE m.secretCode = :secretCode")
|
MemberTotp findBySecretCode(String secretCode);
|
||||||
MemberTotp findBySecretCode(@Param("secretCode") String secretCode);
|
|
||||||
|
|
||||||
MemberTotp findByMember(Member member);
|
MemberTotp findByMemberEmail(String memberEmail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class CentralMemberService implements MemberService {
|
||||||
throw new OverflowException("SignInIdNotExistException()", new Throwable());
|
throw new OverflowException("SignInIdNotExistException()", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m.getStatus().getId() == 1 ) {
|
if ( m.getMetaMemberStatus().getId() == 1 ) {
|
||||||
throw new OverflowException("EmailNotConfirmedException()", new Throwable());
|
throw new OverflowException("EmailNotConfirmedException()", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ public class CentralMemberService implements MemberService {
|
||||||
}
|
}
|
||||||
member.setPw(passwordEncoder.encode(pw));
|
member.setPw(passwordEncoder.encode(pw));
|
||||||
|
|
||||||
if (member.getStatus() == null) {
|
if (member.getMetaMemberStatus() == null) {
|
||||||
member.setStatus(new MetaMemberStatus((short) 1));
|
member.setMetaMemberStatus(new MetaMemberStatus((short) 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
member.setTotpType(false);
|
member.setTotpType(false);
|
||||||
|
@ -204,9 +204,9 @@ public class CentralMemberService implements MemberService {
|
||||||
member.setPw(preMember.getPw());
|
member.setPw(preMember.getPw());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (member.getStatus() == null || member.getStatus().getId() <= 0) {
|
if (member.getMetaMemberStatus() == null || member.getMetaMemberStatus().getId() <= 0) {
|
||||||
member.setStatus(new MetaMemberStatus());
|
member.setMetaMemberStatus(new MetaMemberStatus());
|
||||||
member.getStatus().setId(preMember.getStatus().getId());
|
member.getMetaMemberStatus().setId(preMember.getMetaMemberStatus().getId());
|
||||||
}
|
}
|
||||||
return this.modify(member);
|
return this.modify(member);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
return this.totpDAO.findOne(id);
|
return this.totpDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkCodeForMember(Member member, String code) throws OverflowException {
|
public boolean checkCodeForMember(String memberEmail, String code) throws OverflowException {
|
||||||
MemberTotp totp = this.totpDAO.findByMember(member);
|
MemberTotp totp = this.totpDAO.findByMemberEmail(memberEmail);
|
||||||
if (null == totp && (totp.getSecretCode() == null || totp.getSecretCode().equals(""))) {
|
if (null == totp && (totp.getSecretCode() == null || totp.getSecretCode().equals(""))) {
|
||||||
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
|
||||||
import com.loafle.overflow.model.meta.MetaCrawlerInputItem;
|
import com.loafle.overflow.model.meta.MetaCrawlerInputItem;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -12,5 +11,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaCrawlerInputItemDAO extends JpaRepository<MetaCrawlerInputItem, Integer> {
|
public interface MetaCrawlerInputItemDAO extends JpaRepository<MetaCrawlerInputItem, Integer> {
|
||||||
List<MetaCrawlerInputItem> findAllByCrawler(MetaCrawler crawler);
|
List<MetaCrawlerInputItem> findAllByMetaCrawlerId(Short metaCrawlerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaInfraType;
|
|
||||||
import com.loafle.overflow.model.meta.MetaInfraVendor;
|
import com.loafle.overflow.model.meta.MetaInfraVendor;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -12,5 +11,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaInfraVendorDAO extends JpaRepository<MetaInfraVendor, Integer> {
|
public interface MetaInfraVendorDAO extends JpaRepository<MetaInfraVendor, Integer> {
|
||||||
List<MetaInfraVendor> findAllByInfraType(MetaInfraType infraType);
|
List<MetaInfraVendor> findAllByMetaInfraTypeId(Integer MetaInfraTypeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaProbeOs;
|
|
||||||
import com.loafle.overflow.model.meta.MetaProbePackage;
|
import com.loafle.overflow.model.meta.MetaProbePackage;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -12,5 +11,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaProbePackageDAO extends JpaRepository<MetaProbePackage, Long> {
|
public interface MetaProbePackageDAO extends JpaRepository<MetaProbePackage, Long> {
|
||||||
List<MetaProbePackage> findAllByOs(MetaProbeOs metaProbeOs);
|
List<MetaProbePackage> findAllByMetaProbeOsId(Short metaProbeOsId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -12,5 +11,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaSensorDisplayItemDAO extends JpaRepository<MetaSensorDisplayItem, Long> {
|
public interface MetaSensorDisplayItemDAO extends JpaRepository<MetaSensorDisplayItem, Long> {
|
||||||
public List<MetaSensorDisplayItem> findAllByCrawler(MetaCrawler crawler);
|
public List<MetaSensorDisplayItem> findAllByMetaCrawlerId(Short metaCrawlerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
|
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,6 +12,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
|
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
|
||||||
@Query("SELECT m.itemKey from MetaSensorDisplayMapping m where m.displayItem = (:displayItem)")
|
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long metaSensorDisplayItemId);
|
||||||
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByDisplayItem(@Param("displayItem") MetaSensorDisplayItem displayItem);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -12,6 +11,5 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaSensorItemKeyDAO extends JpaRepository<MetaSensorItemKey, Long> {
|
public interface MetaSensorItemKeyDAO extends JpaRepository<MetaSensorItemKey, Long> {
|
||||||
// @Query("SELECT msik.item.id, msik.key from MetaSensorItemKey msik WHERE msik.crawler.id = (:metaCrawler.id)")
|
List<MetaSensorItemKey> findAllByMetaCrawlerId(Short metaCrawlerId);
|
||||||
List<MetaSensorItemKey> findAllByCrawler(MetaCrawler metaCrawler);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.meta.dao;
|
package com.loafle.overflow.central.module.meta.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaInfraVendor;
|
|
||||||
import com.loafle.overflow.model.meta.MetaVendorCrawler;
|
import com.loafle.overflow.model.meta.MetaVendorCrawler;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -11,6 +10,6 @@ import java.util.List;
|
||||||
* Created by insanity on 17. 6. 23.
|
* Created by insanity on 17. 6. 23.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface MetaVendorCrawlerDAO extends JpaRepository<MetaVendorCrawler, Integer>{
|
public interface MetaVendorCrawlerDAO extends JpaRepository<MetaVendorCrawler, Integer> {
|
||||||
List<MetaVendorCrawler> findAllByInfraVendor(MetaInfraVendor infraVendor);
|
List<MetaVendorCrawler> findAllByMetaInfraVendorId(Integer metaInfraVendorId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class CentralMetaCrawlerInputItemService implements MetaCrawlerInputItemS
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetaCrawlerInputItemDAO crawlerInputItemDAO;
|
private MetaCrawlerInputItemDAO crawlerInputItemDAO;
|
||||||
|
|
||||||
public List<MetaCrawlerInputItem> readAllByMetaCrawler(MetaCrawler metaCrawler) throws OverflowException {
|
public List<MetaCrawlerInputItem> readAllByMetaCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||||
return this.crawlerInputItemDAO.findAllByCrawler(metaCrawler);
|
return this.crawlerInputItemDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class CentralMetaHistoryTypeService implements MetaHistoryTypeService {
|
||||||
return this.hisotyTypeDAO.save(type);
|
return this.hisotyTypeDAO.save(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaHistoryType> registAll(List<MetaHistoryType> types) throws OverflowException {
|
public List<MetaHistoryType> registAll(List<MetaHistoryType> metaHistoryTypes) throws OverflowException {
|
||||||
return this.hisotyTypeDAO.save(types);
|
return this.hisotyTypeDAO.save(metaHistoryTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.dao.MetaInfraVendorDAO;
|
import com.loafle.overflow.central.module.meta.dao.MetaInfraVendorDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.meta.MetaInfraType;
|
|
||||||
import com.loafle.overflow.model.meta.MetaInfraVendor;
|
import com.loafle.overflow.model.meta.MetaInfraVendor;
|
||||||
import com.loafle.overflow.service.central.meta.MetaInfraVendorService;
|
import com.loafle.overflow.service.central.meta.MetaInfraVendorService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -20,8 +19,8 @@ public class CentralMetaInfraVendorService implements MetaInfraVendorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetaInfraVendorDAO infraVendorDAO;
|
private MetaInfraVendorDAO infraVendorDAO;
|
||||||
|
|
||||||
public List<MetaInfraVendor> readAllByMetaInfraType(MetaInfraType infraType) throws OverflowException {
|
public List<MetaInfraVendor> readAllByMetaInfraTypeID(Integer metaInfraTypeID) throws OverflowException {
|
||||||
return this.infraVendorDAO.findAllByInfraType(infraType);
|
return this.infraVendorDAO.findAllByMetaInfraTypeId(metaInfraTypeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class CentralMetaProbePackageService implements MetaProbePackageService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetaProbePackageDAO probePackageDAO;
|
private MetaProbePackageDAO probePackageDAO;
|
||||||
|
|
||||||
public List<MetaProbePackage> readAllByOs(MetaProbeOs metaProbeOs) throws OverflowException {
|
public List<MetaProbePackage> readAllByMetaProbeOsID(Short metaProbeOsID) throws OverflowException {
|
||||||
return this.probePackageDAO.findAllByOs(metaProbeOs);
|
return this.probePackageDAO.findAllByMetaProbeOsId(metaProbeOsID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class CentralMetaSensorDisplayItemService implements MetaSensorDisplayIte
|
||||||
return this.displayItemDAO.findOne(id);
|
return this.displayItemDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaSensorDisplayItem> readAllByCrawler(MetaCrawler crawler) throws OverflowException {
|
public List<MetaSensorDisplayItem> readAllByCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||||
return this.displayItemDAO.findAllByCrawler(crawler);
|
return this.displayItemDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class CentralMetaSensorDisplayMappingService implements MetaSensorDisplay
|
||||||
return this.mappingDAO.save(m);
|
return this.mappingDAO.save(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByDisplayItem(MetaSensorDisplayItem displayItem) throws OverflowException {
|
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByDisplayItemID(Long metaSensorDisplayItemID) throws OverflowException {
|
||||||
return this.mappingDAO.findAllMetaSensorItemKeyByDisplayItem(displayItem);
|
return this.mappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemKeyDAO;
|
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemKeyDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -22,19 +21,18 @@ public class CentralMetaSensorItemKeyService implements MetaSensorItemKeyService
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetaSensorItemKeyDAO metaSensorItemKeyDAO;
|
private MetaSensorItemKeyDAO metaSensorItemKeyDAO;
|
||||||
|
|
||||||
public List<MetaSensorItemKey> readAllByCrawler(MetaCrawler metaCrawler) throws OverflowException {
|
public List<MetaSensorItemKey> readAllByMetaCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||||
return this.metaSensorItemKeyDAO.findAllByCrawler(metaCrawler);
|
return this.metaSensorItemKeyDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Integer, MetaSensorItemKey> readAllMapByMetaCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||||
public Map<Integer, MetaSensorItemKey> readAllMapByCrawler(MetaCrawler metaCrawler) throws OverflowException {
|
|
||||||
|
|
||||||
Map<Integer, MetaSensorItemKey> resultMap = new HashMap<>();
|
Map<Integer, MetaSensorItemKey> resultMap = new HashMap<>();
|
||||||
|
|
||||||
List<MetaSensorItemKey> resultList = this.metaSensorItemKeyDAO.findAllByCrawler(metaCrawler);
|
List<MetaSensorItemKey> resultList = this.metaSensorItemKeyDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||||
|
|
||||||
for(MetaSensorItemKey oa : resultList) {
|
for (MetaSensorItemKey oa : resultList) {
|
||||||
resultMap.put(oa.getItem().getId(), oa);
|
resultMap.put(oa.getMetaSensorItem().getId(), oa);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultMap;
|
return resultMap;
|
||||||
|
|
|
@ -20,9 +20,9 @@ public class CentralMetaVendorCrawlerService implements MetaVendorCrawlerService
|
||||||
@Autowired
|
@Autowired
|
||||||
private MetaVendorCrawlerDAO crawlerDAO;
|
private MetaVendorCrawlerDAO crawlerDAO;
|
||||||
|
|
||||||
public List<MetaVendorCrawler> readAllByInfraVendor(MetaInfraVendor infraVendor) throws OverflowException {
|
public List<MetaVendorCrawler> readAllByMetaInfraVendorID(Integer metaInfraVendorID) throws OverflowException {
|
||||||
|
|
||||||
return this.crawlerDAO.findAllByInfraVendor(infraVendor);
|
return this.crawlerDAO.findAllByMetaInfraVendorId(metaInfraVendorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetaVendorCrawler regist(MetaVendorCrawler metaVendorCrawler) throws OverflowException {
|
public MetaVendorCrawler regist(MetaVendorCrawler metaVendorCrawler) throws OverflowException {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.loafle.overflow.central.module.noauthprobe.dao;
|
||||||
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,8 +15,7 @@ public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
||||||
|
|
||||||
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
||||||
|
|
||||||
@Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :domainID and n.status.id = 3") // 3 = Process
|
List<NoAuthProbe> findAllByDomainIdAndMetaNoAuthProbeStatusId(Long domainID, Short metaNoAuthProbeStatusId);
|
||||||
List<NoAuthProbe> findAllByDomainId(@Param("domainID") Long domainID);
|
|
||||||
|
|
||||||
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
|
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
|
||||||
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
|
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
noAuthProbe.setDomain(apiKey.getDomain());
|
noAuthProbe.setDomain(apiKey.getDomain());
|
||||||
|
|
||||||
noAuthProbe.setTempProbeKey(GenerateKey.getKey());
|
noAuthProbe.setTempProbeKey(GenerateKey.getKey());
|
||||||
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 3));
|
noAuthProbe.setMetaNoAuthProbeStatus(new MetaNoAuthProbeStatus((short) 3));
|
||||||
|
|
||||||
messagePublisher.publishToDomainMembers(apiKey.getDomain().getId(), "NoAuthProbeService.regist", noAuthProbe);
|
messagePublisher.publishToDomainMembers(apiKey.getDomain().getId(), "NoAuthProbeService.regist", noAuthProbe);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
|
|
||||||
public List<NoAuthProbe> readAllByDomainID(Long domainID) throws OverflowException {
|
public List<NoAuthProbe> readAllByDomainID(Long domainID) throws OverflowException {
|
||||||
|
|
||||||
return this.noAuthProbeDAO.findAllByDomainId(domainID);
|
return this.noAuthProbeDAO.findAllByDomainIdAndMetaNoAuthProbeStatusId(domainID, (short) 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoAuthProbe read(Long id) {
|
public NoAuthProbe read(Long id) {
|
||||||
|
@ -119,15 +119,17 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
InfraHost host = this.newInfraHost(os, noAuthProbeDescription.getNetwork());
|
InfraHost host = this.newInfraHost(os, noAuthProbeDescription.getNetwork());
|
||||||
this.newProbeHost(host, probe);
|
this.newProbeHost(host, probe);
|
||||||
|
|
||||||
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 1));
|
noAuthProbe.setMetaNoAuthProbeStatus(new MetaNoAuthProbeStatus((short) 1));
|
||||||
this.noAuthProbeDAO.save(noAuthProbe);
|
this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Accept", probe.getProbeKey());
|
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Accept",
|
||||||
|
probe.getProbeKey());
|
||||||
|
|
||||||
return this.readAllByDomainID(noAuthProbe.getDomain().getId());
|
return this.readAllByDomainID(noAuthProbe.getDomain().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Probe newProbe(NoAuthProbe noauthprobe, NoAuthProbeDescription noAuthProbeDescription) throws OverflowException {
|
private Probe newProbe(NoAuthProbe noauthprobe, NoAuthProbeDescription noAuthProbeDescription)
|
||||||
|
throws OverflowException {
|
||||||
|
|
||||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString());
|
String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString());
|
||||||
|
@ -142,7 +144,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
probe.setDomain(new Domain(apiKey.getDomain().getId()));
|
probe.setDomain(new Domain(apiKey.getDomain().getId()));
|
||||||
probe.setAuthorizeMember(new Member(domainMember.getMember().getId()));
|
probe.setAuthorizeMember(new Member(domainMember.getMember().getId()));
|
||||||
probe.setTargetCount(0);
|
probe.setTargetCount(0);
|
||||||
probe.setStatus(new MetaProbeStatus((short) 1));
|
probe.setMetaProbeStatus(new MetaProbeStatus((short) 1));
|
||||||
|
|
||||||
String dispName = noAuthProbeDescription.getHost().getName();
|
String dispName = noAuthProbeDescription.getHost().getName();
|
||||||
dispName += " probe";
|
dispName += " probe";
|
||||||
|
@ -156,31 +158,30 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private InfraMachine newInfraMachine(NoAuthProbe noauthprobe) throws OverflowException {
|
private InfraMachine newInfraMachine(NoAuthProbe noauthprobe) throws OverflowException {
|
||||||
MetaInfraType infraType = new MetaInfraType();
|
MetaInfraType metaInfraType = new MetaInfraType(1);
|
||||||
infraType.setId(1);
|
|
||||||
|
|
||||||
InfraMachine infraMachine = new InfraMachine();
|
InfraMachine infraMachine = new InfraMachine();
|
||||||
infraMachine.setMeta(noauthprobe.getDescription());
|
infraMachine.setMeta(noauthprobe.getDescription());
|
||||||
infraMachine.setInfraType(infraType);
|
infraMachine.setMetaInfraType(metaInfraType);
|
||||||
|
|
||||||
return this.infraMachineService.regist(infraMachine);
|
return this.infraMachineService.regist(infraMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InfraOS newInfraOS(InfraMachine infraMachine, NoAuthProbeDescriptionHost noAuthProbeDescriptionHost) throws OverflowException {
|
private InfraOS newInfraOS(InfraMachine infraMachine, NoAuthProbeDescriptionHost noAuthProbeDescriptionHost)
|
||||||
MetaInfraType infraType = new MetaInfraType();
|
throws OverflowException {
|
||||||
infraType.setId(3);
|
MetaInfraType metaInfraType = new MetaInfraType(3);
|
||||||
|
|
||||||
InfraOS infraOS = new InfraOS();
|
InfraOS infraOS = new InfraOS();
|
||||||
infraOS.setMachine(infraMachine);
|
infraOS.setInfraMachine(infraMachine);
|
||||||
infraOS.setInfraType(infraType);
|
infraOS.setMetaInfraType(metaInfraType);
|
||||||
infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(noAuthProbeDescriptionHost.getOS()));
|
infraOS.setMetaInfraVendor(MetaInfraVendor.CreateInfraVendorByOS(noAuthProbeDescriptionHost.getOS()));
|
||||||
|
|
||||||
return this.infraOSService.regist(infraOS);
|
return this.infraOSService.regist(infraOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InfraHost newInfraHost(InfraOS infraOS, NoAuthProbeDescriptionNetwork noAuthProbeDescriptionNetwork) throws OverflowException {
|
private InfraHost newInfraHost(InfraOS infraOS, NoAuthProbeDescriptionNetwork noAuthProbeDescriptionNetwork)
|
||||||
MetaInfraType infraType = new MetaInfraType();
|
throws OverflowException {
|
||||||
infraType.setId(2);
|
MetaInfraType metaInfraType = new MetaInfraType(2);
|
||||||
|
|
||||||
InfraHost infraHost = new InfraHost();
|
InfraHost infraHost = new InfraHost();
|
||||||
String addrStr = noAuthProbeDescriptionNetwork.getAddress();
|
String addrStr = noAuthProbeDescriptionNetwork.getAddress();
|
||||||
|
@ -188,8 +189,8 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
|
|
||||||
infraHost.setIpv4(addrArr[0]);
|
infraHost.setIpv4(addrArr[0]);
|
||||||
infraHost.setMac(noAuthProbeDescriptionNetwork.getMacAddress());
|
infraHost.setMac(noAuthProbeDescriptionNetwork.getMacAddress());
|
||||||
infraHost.setOs(infraOS);
|
infraHost.setInfraOS(infraOS);
|
||||||
infraHost.setInfraType(infraType);
|
infraHost.setMetaInfraType(metaInfraType);
|
||||||
|
|
||||||
return this.infraHostService.regist(infraHost);
|
return this.infraHostService.regist(infraHost);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +207,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
public List<NoAuthProbe> denyNoauthProbe(Long noAuthProbeID) throws OverflowException {
|
public List<NoAuthProbe> denyNoauthProbe(Long noAuthProbeID) throws OverflowException {
|
||||||
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findOne(noAuthProbeID);
|
NoAuthProbe noAuthProbe = this.noAuthProbeDAO.findOne(noAuthProbeID);
|
||||||
|
|
||||||
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2));
|
noAuthProbe.setMetaNoAuthProbeStatus(new MetaNoAuthProbeStatus((short) 2));
|
||||||
this.noAuthProbeDAO.save(noAuthProbe);
|
this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Deny");
|
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Deny");
|
||||||
|
@ -224,7 +225,8 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
noAuthProbe.setConnectAddress(connectAddress);
|
noAuthProbe.setConnectAddress(connectAddress);
|
||||||
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onConnect", noAuthProbe);
|
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onConnect",
|
||||||
|
noAuthProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect(String tempKey) throws OverflowException {
|
public void onDisconnect(String tempKey) throws OverflowException {
|
||||||
|
@ -233,7 +235,8 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
||||||
noAuthProbe.setConnectAddress(null);
|
noAuthProbe.setConnectAddress(null);
|
||||||
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
noAuthProbe = this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
||||||
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onDisconnect", noAuthProbe);
|
messagePublisher.publishToDomainMembers(noAuthProbe.getDomain().getId(), "NoAuthProbeService.onDisconnect",
|
||||||
|
noAuthProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package com.loafle.overflow.central.module.notification.dao;
|
package com.loafle.overflow.central.module.notification.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.member.Member;
|
|
||||||
import com.loafle.overflow.model.notification.Notification;
|
import com.loafle.overflow.model.notification.Notification;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,13 +15,11 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
||||||
|
|
||||||
List<Notification> findAllByMember(Member member);
|
List<Notification> findAllByMemberEmail(String memberEmail);
|
||||||
|
|
||||||
Page<Notification> findAllByMember(Member member, Pageable pageRequest);
|
Page<Notification> findAllByMemberEmail(String memberEmail, Pageable pageRequest);
|
||||||
|
|
||||||
@Query("SELECT n FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
Page<Notification> findAllByMemberEmailAndConfirmDateNull(String memberEmail, Pageable pageRequest);
|
||||||
Page<Notification> findAllUnconfirmedByMember(@Param("member") Member member, Pageable pageRequest);
|
|
||||||
|
|
||||||
@Query("SELECT COUNT(n) FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
Long countByMemberEmailAndConfirmDateNull(String memberEmail);
|
||||||
int findAllUnconfirmedCountByMember(@Param("member") Member member);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,37 +28,42 @@ public class CentralNotificationService implements NotificationService {
|
||||||
return this.notificationDAO.save(notification);
|
return this.notificationDAO.save(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllByMember(Member member, PageParams pageParams) throws OverflowException {
|
public Page<Notification> readAllByMemberEmail(String memberEmail, PageParams pageParams) throws OverflowException {
|
||||||
return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams));
|
return this.notificationDAO.findAllByMemberEmail(memberEmail, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) throws OverflowException {
|
public Page<Notification> readAllUnconfirmedByMemberEmail(String memberEmail, PageParams pageParams)
|
||||||
return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams));
|
throws OverflowException {
|
||||||
|
return this.notificationDAO.findAllByMemberEmailAndConfirmDateNull(memberEmail,
|
||||||
|
PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readUnconfirmedCount(Member member) throws OverflowException {
|
public Long readUnconfirmedCountByMemberEmail(String memberEmail) throws OverflowException {
|
||||||
return this.notificationDAO.findAllUnconfirmedCountByMember(member);
|
return this.notificationDAO.countByMemberEmailAndConfirmDateNull(memberEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> markAllAsRead(Member member, PageParams pageParams) throws OverflowException {
|
public Page<Notification> markAllAsReadByMemberEmail(String memberEmail, PageParams pageParams)
|
||||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
throws OverflowException {
|
||||||
|
List<Notification> list = this.notificationDAO.findAllByMemberEmail(memberEmail);
|
||||||
for (Notification n : list) {
|
for (Notification n : list) {
|
||||||
n.setConfirmDate(new Date());
|
n.setConfirmDate(new Date());
|
||||||
}
|
}
|
||||||
this.notificationDAO.save(list);
|
this.notificationDAO.save(list);
|
||||||
return this.readAllByMember(member, pageParams);
|
return this.readAllByMemberEmail(memberEmail, pageParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) throws OverflowException {
|
public Page<Notification> markAllAsUnreadMemberEmail(String memberEmail, PageParams pageParams)
|
||||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
throws OverflowException {
|
||||||
|
List<Notification> list = this.notificationDAO.findAllByMemberEmail(memberEmail);
|
||||||
for (Notification n : list) {
|
for (Notification n : list) {
|
||||||
n.setConfirmDate(null);
|
n.setConfirmDate(null);
|
||||||
}
|
}
|
||||||
this.notificationDAO.save(list);
|
this.notificationDAO.save(list);
|
||||||
return this.readAllByMember(member, pageParams);
|
return this.readAllByMemberEmail(memberEmail, pageParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Notification markAsRead(Notification notification) throws OverflowException {
|
public Notification markAsRead(Long notificationID) throws OverflowException {
|
||||||
|
Notification notification = this.notificationDAO.findOne(notificationID);
|
||||||
notification.setConfirmDate(new Date());
|
notification.setConfirmDate(new Date());
|
||||||
return this.notificationDAO.save(notification);
|
return this.notificationDAO.save(notification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,8 @@ import java.util.List;
|
||||||
import com.loafle.overflow.model.probe.ProbeHost;
|
import com.loafle.overflow.model.probe.ProbeHost;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by snoop on 17. 8. 21.
|
* Created by snoop on 17. 8. 21.
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +14,5 @@ import org.springframework.stereotype.Repository;
|
||||||
public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> {
|
public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> {
|
||||||
ProbeHost findByProbeId(Long probeID);
|
ProbeHost findByProbeId(Long probeID);
|
||||||
|
|
||||||
@Query("SELECT h FROM ProbeHost h WHERE h.probe.domain.id = (:domainID)")
|
List<ProbeHost> findAllByProbeDomainId(Long domainID);
|
||||||
List<ProbeHost> findAllByDomainId(@Param("domainID")Long domainID);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,5 @@ import com.loafle.overflow.model.probe.ProbeTask;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> {
|
public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> {
|
||||||
List<ProbeTask> findAllByProbeId(Long probeID);
|
List<ProbeTask> findAllByProbeId(Long probeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@ import java.util.List;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
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.model.probe.ProbeHost;
|
import com.loafle.overflow.model.probe.ProbeHost;
|
||||||
import com.loafle.overflow.service.central.probe.ProbeHostService;
|
import com.loafle.overflow.service.central.probe.ProbeHostService;
|
||||||
|
|
||||||
|
@ -34,7 +32,6 @@ public class CentralProbeHostService implements ProbeHostService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProbeHost> readAllByDomainID(Long domainID) throws OverflowException {
|
public List<ProbeHost> readAllByDomainID(Long domainID) throws OverflowException {
|
||||||
return this.probeHostDAO.findAllByDomainId(domainID);
|
return this.probeHostDAO.findAllByProbeDomainId(domainID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.loafle.overflow.central.module.probe.service;
|
||||||
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
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.model.probe.Probe;
|
||||||
import com.loafle.overflow.service.central.probe.ProbeService;
|
import com.loafle.overflow.service.central.probe.ProbeService;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.probe.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
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.model.probe.ProbeTask;
|
||||||
import com.loafle.overflow.service.central.probe.ProbeTaskService;
|
import com.loafle.overflow.service.central.probe.ProbeTaskService;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.sensor.dao;
|
package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,8 +16,8 @@ import com.loafle.overflow.model.target.Target;
|
||||||
@Repository
|
@Repository
|
||||||
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
||||||
Page<Sensor> findAllByTargetId(Long targetID, Pageable pageable);
|
Page<Sensor> findAllByTargetId(Long targetID, Pageable pageable);
|
||||||
|
|
||||||
List<Sensor> findAllByTargetId(Long targetID);
|
List<Sensor> findAllByTargetId(Long targetID);
|
||||||
|
|
||||||
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
|
Page<Sensor> findAllByTargetIn(List<Target> targets, Pageable pageable);
|
||||||
Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.sensor.dao;
|
package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
@ -13,5 +12,5 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface SensorItemDAO extends JpaRepository<SensorItem, Long> {
|
public interface SensorItemDAO extends JpaRepository<SensorItem, Long> {
|
||||||
Page<SensorItem> findAllBySensor(Sensor sensor, Pageable pageable);
|
Page<SensorItem> findAllBySensorId(Long sensorId, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.overflow.central.module.sensor.dao;
|
package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
||||||
|
|
||||||
|
@ -15,5 +14,5 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
|
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
|
||||||
|
|
||||||
List<MetaSensorItemKey> findAllByDisplayItem(MetaSensorDisplayItem displayItem);
|
List<MetaSensorItemKey> findAllByMetaSensorDisplayItemId(Long metaSensorDisplayItemId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,17 +28,19 @@ public class CentralSensorItemDependencyService implements SensorItemDependencyS
|
||||||
return this.sensorItemDependencyDAO.save(dependency);
|
return this.sensorItemDependencyDAO.save(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaSensorItemKey> readAllByDisplayItem(MetaSensorDisplayItem displayItem) throws OverflowException {
|
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByMetaSensorDisplayItemID(Long metaSensorDisplayItemID)
|
||||||
return this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem);
|
throws OverflowException {
|
||||||
|
return this.sensorItemDependencyDAO.findAllByMetaSensorDisplayItemId(metaSensorDisplayItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<MetaSensorItemKey>> readAllByDisplayItems(
|
public Map<String, List<MetaSensorItemKey>> readAllMapByMetaSensorDisplayItems(
|
||||||
List<MetaSensorDisplayItem> displayItems) throws OverflowException {
|
List<MetaSensorDisplayItem> metaSensorDisplayItems) throws OverflowException {
|
||||||
|
|
||||||
Map<String, List<MetaSensorItemKey>> map = new HashMap<String, List<MetaSensorItemKey>>();
|
Map<String, List<MetaSensorItemKey>> map = new HashMap<String, List<MetaSensorItemKey>>();
|
||||||
|
|
||||||
for (MetaSensorDisplayItem displayItem : displayItems) {
|
for (MetaSensorDisplayItem displayItem : metaSensorDisplayItems) {
|
||||||
List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem);
|
List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO
|
||||||
|
.findAllByMetaSensorDisplayItemId(displayItem.getId());
|
||||||
map.put(displayItem.getKey(), itemKeys);
|
map.put(displayItem.getKey(), itemKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class CentralSensorItemService implements SensorItemService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public SensorItem regist(SensorItem sensorItem) throws OverflowException {
|
public SensorItem regist(SensorItem sensorItem) throws OverflowException {
|
||||||
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
|
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
|
||||||
s.setItemCount((short)(s.getItemCount() + 1));
|
s.setItemCount((short) (s.getItemCount() + 1));
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
return this.sensorItemDAO.save(sensorItem);
|
return this.sensorItemDAO.save(sensorItem);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CentralSensorItemService implements SensorItemService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean registAll(List<SensorItem> sensorItemList) throws OverflowException {
|
public boolean registAll(List<SensorItem> sensorItemList) throws OverflowException {
|
||||||
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
|
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
|
||||||
s.setItemCount((short)sensorItemList.size());
|
s.setItemCount((short) sensorItemList.size());
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
this.sensorItemDAO.save(sensorItemList);
|
this.sensorItemDAO.save(sensorItemList);
|
||||||
return true;
|
return true;
|
||||||
|
@ -48,14 +48,14 @@ public class CentralSensorItemService implements SensorItemService {
|
||||||
return this.sensorItemDAO.findOne(Long.valueOf(id));
|
return this.sensorItemDAO.findOne(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<SensorItem> readAllBySensor(Sensor sensor, PageParams pageParams) throws OverflowException {
|
public Page<SensorItem> readAllBySensorID(Long sensorID, PageParams pageParams) throws OverflowException {
|
||||||
return this.sensorItemDAO.findAllBySensor(sensor, PageUtil.getPageRequest(pageParams));
|
return this.sensorItemDAO.findAllBySensorId(sensorID, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void remove(SensorItem sensorItem) throws OverflowException {
|
public void remove(SensorItem sensorItem) throws OverflowException {
|
||||||
Sensor s = sensorItem.getSensor();
|
Sensor s = sensorItem.getSensor();
|
||||||
s.setItemCount((short)(s.getItemCount() - 1));
|
s.setItemCount((short) (s.getItemCount() - 1));
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
this.sensorItemDAO.delete(sensorItem);
|
this.sensorItemDAO.delete(sensorItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,13 +63,13 @@ public class CentralSensorService implements SensorService {
|
||||||
throw new OverflowException("", new Throwable());
|
throw new OverflowException("", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList);
|
List<Target> targetList = this.infraService.readAllTargetByProbes(probeList);
|
||||||
|
|
||||||
if (targetList == null || targetList.size() <= 0) {
|
if (targetList == null || targetList.size() <= 0) {
|
||||||
throw new OverflowException("", new Throwable());
|
throw new OverflowException("", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams));
|
return this.sensorDAO.findAllByTargetIn(targetList, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Sensor> readAllByInfraID(Long infraID, PageParams pageParams) throws OverflowException {
|
public Page<Sensor> readAllByInfraID(Long infraID, PageParams pageParams) throws OverflowException {
|
||||||
|
@ -100,14 +100,14 @@ public class CentralSensorService implements SensorService {
|
||||||
public Sensor start(Long sensorID) throws OverflowException {
|
public Sensor start(Long sensorID) throws OverflowException {
|
||||||
Sensor sensor = this.sensorDAO.findOne(sensorID);
|
Sensor sensor = this.sensorDAO.findOne(sensorID);
|
||||||
MetaSensorStatus status = new MetaSensorStatus((short) 1);
|
MetaSensorStatus status = new MetaSensorStatus((short) 1);
|
||||||
sensor.setStatus(status);
|
sensor.setMetaSensorStatus(status);
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor stop(Long sensorID) throws OverflowException {
|
public Sensor stop(Long sensorID) throws OverflowException {
|
||||||
Sensor sensor = this.sensorDAO.findOne(sensorID);
|
Sensor sensor = this.sensorDAO.findOne(sensorID);
|
||||||
MetaSensorStatus status = new MetaSensorStatus((short) 2);
|
MetaSensorStatus status = new MetaSensorStatus((short) 2);
|
||||||
sensor.setStatus(status);
|
sensor.setMetaSensorStatus(status);
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
* Created by snoop on 17. 6. 28.
|
* Created by snoop on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("TargetDiscoveryService")
|
@Service("TargetDiscoveryService")
|
||||||
public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
public class CentralTargetDiscoveryService implements TargetDiscoveryService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetService targetService;
|
private TargetService targetService;
|
||||||
|
@ -50,7 +50,7 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
|
|
||||||
InfraHost infraHost = null;
|
InfraHost infraHost = null;
|
||||||
|
|
||||||
for(Host host : hosts) {
|
for (Host host : hosts) {
|
||||||
|
|
||||||
infraHost = this.createAndReadHost(host, probe);
|
infraHost = this.createAndReadHost(host, probe);
|
||||||
|
|
||||||
|
@ -62,29 +62,29 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
|
|
||||||
private void createService(InfraHost infraHost, Port port, Probe probe) throws OverflowException {
|
private void createService(InfraHost infraHost, Port port, Probe probe) throws OverflowException {
|
||||||
|
|
||||||
|
MetaInfraType typeService = new MetaInfraType(7);
|
||||||
MetaInfraType typeService = new MetaInfraType();
|
|
||||||
typeService.setId(7);
|
|
||||||
|
|
||||||
String portType = "UDP";
|
String portType = "UDP";
|
||||||
|
|
||||||
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP || port.getPortType() == null) {
|
if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP || port.getPortType() == null) {
|
||||||
portType = "TCP";
|
portType = "TCP";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(port.getServiceList() == null) {
|
if (port.getServiceList() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(String key : port.getServices().keySet()) {
|
// for(String key : port.getServices().keySet()) {
|
||||||
for(com.loafle.overflow.model.discovery.Service service : port.getServiceList()) {
|
for (com.loafle.overflow.model.discovery.Service service : port.getServiceList()) {
|
||||||
|
|
||||||
// com.loafle.overflow.module.discovery.model.Service service = port.getServices().get(key);
|
// com.loafle.overflow.module.discovery.model.Service service =
|
||||||
|
// port.getServices().get(key);
|
||||||
|
|
||||||
InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType);
|
InfraService dbInfraService = this.infraServiceService
|
||||||
|
.readByInfraHostIDAndPortAndPortType(infraHost.getId(), port.getPortNumber(), portType);
|
||||||
|
|
||||||
if(dbInfraService != null) {
|
if (dbInfraService != null) {
|
||||||
if(service.isTarget() && dbInfraService.getTarget() == null) {
|
if (service.isTarget() && dbInfraService.getTarget() == null) {
|
||||||
Target targetService = new Target();
|
Target targetService = new Target();
|
||||||
targetService.setDisplayName(service.getServiceName());
|
targetService.setDisplayName(service.getServiceName());
|
||||||
this.targetService.regist(targetService, probe);
|
this.targetService.regist(targetService, probe);
|
||||||
|
@ -95,18 +95,18 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
}
|
}
|
||||||
|
|
||||||
InfraService infraService = new InfraService();
|
InfraService infraService = new InfraService();
|
||||||
infraService.setHost(infraHost);
|
infraService.setInfraHost(infraHost);
|
||||||
infraService.setPort(port.getPortNumber());
|
infraService.setPort(port.getPortNumber());
|
||||||
infraService.setPortType(portType);
|
infraService.setPortType(portType);
|
||||||
infraService.setInfraType(typeService);
|
infraService.setMetaInfraType(typeService);
|
||||||
infraService.setProbe(probe);
|
infraService.setProbe(probe);
|
||||||
|
|
||||||
if (port.getPortType() == PortType.TLS) {
|
if (port.getPortType() == PortType.TLS) {
|
||||||
infraService.setTlsType(true);
|
infraService.setTlsType(true);
|
||||||
}
|
}
|
||||||
infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
|
infraService.setMetaInfraVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
|
||||||
|
|
||||||
if(service.isTarget()) {
|
if (service.isTarget()) {
|
||||||
Target targetService = new Target();
|
Target targetService = new Target();
|
||||||
targetService.setDisplayName(service.getServiceName());
|
targetService.setDisplayName(service.getServiceName());
|
||||||
this.targetService.regist(targetService, probe);
|
this.targetService.regist(targetService, probe);
|
||||||
|
@ -121,43 +121,43 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
|
|
||||||
private void createPort(InfraHost infraHost, Host host, Probe probe) throws OverflowException {
|
private void createPort(InfraHost infraHost, Host host, Probe probe) throws OverflowException {
|
||||||
|
|
||||||
// if(host.getPorts() == null) {
|
// if(host.getPorts() == null) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
String portType = "UDP";
|
String portType = "UDP";
|
||||||
|
|
||||||
MetaInfraType typePort = new MetaInfraType();
|
MetaInfraType typePort = new MetaInfraType(6);
|
||||||
typePort.setId(6);
|
|
||||||
|
|
||||||
InfraOS infraOS = infraHost.getOs();
|
InfraOS infraOS = infraHost.getInfraOS();
|
||||||
|
|
||||||
// for( String key: host.getPorts().keySet()) {
|
// for( String key: host.getPorts().keySet()) {
|
||||||
|
|
||||||
if(host.getPortList() == null) {
|
if (host.getPortList() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( Port port: host.getPortList()) {
|
for (Port port : host.getPortList()) {
|
||||||
// Port port = host.getPorts().get(key);
|
// Port port = host.getPorts().get(key);
|
||||||
|
|
||||||
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||||
portType = "TCP";
|
portType = "TCP";
|
||||||
}
|
}
|
||||||
|
|
||||||
InfraOSPort dbInfraOSPort = this.infraOSPortService.readByPort(infraOS.getId(), port.getPortNumber(), portType);
|
InfraOSPort dbInfraOSPort = this.infraOSPortService.readByInfraOSIDAndPortAndPortType(infraOS.getId(), port.getPortNumber(),
|
||||||
if(dbInfraOSPort == null) {
|
portType);
|
||||||
|
if (dbInfraOSPort == null) {
|
||||||
InfraOSPort infraOSPort = new InfraOSPort();
|
InfraOSPort infraOSPort = new InfraOSPort();
|
||||||
infraOSPort.setOs(infraOS);
|
infraOSPort.setInfraOS(infraOS);
|
||||||
infraOSPort.setPort(port.getPortNumber());
|
infraOSPort.setPort(port.getPortNumber());
|
||||||
infraOSPort.setPortType(portType);
|
infraOSPort.setPortType(portType);
|
||||||
infraOSPort.setProbe(probe);
|
infraOSPort.setProbe(probe);
|
||||||
infraOSPort.setInfraType(typePort);
|
infraOSPort.setMetaInfraType(typePort);
|
||||||
|
|
||||||
if (port.getPortType() == PortType.TLS) {
|
if (port.getPortType() == PortType.TLS) {
|
||||||
infraOSPort.setTlsType(true);
|
infraOSPort.setTlsType(true);
|
||||||
}
|
}
|
||||||
infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
|
infraOSPort.setMetaInfraVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
|
||||||
this.infraOSPortService.regist(infraOSPort);
|
this.infraOSPortService.regist(infraOSPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +167,10 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
|
|
||||||
private InfraHost createAndReadHost(Host host, Probe probe) throws OverflowException {
|
private InfraHost createAndReadHost(Host host, Probe probe) throws OverflowException {
|
||||||
|
|
||||||
|
|
||||||
InfraHost infraHost = this.infraHostService.readByIp(host.getIpv4());
|
InfraHost infraHost = this.infraHostService.readByIp(host.getIpv4());
|
||||||
if(infraHost != null) {
|
if (infraHost != null) {
|
||||||
|
|
||||||
if(host.isTarget() && infraHost.getTarget() == null) {
|
if (host.isTarget() && infraHost.getTarget() == null) {
|
||||||
Target target = new Target();
|
Target target = new Target();
|
||||||
target.setDisplayName(host.getIpv4() + "-Host");
|
target.setDisplayName(host.getIpv4() + "-Host");
|
||||||
|
|
||||||
|
@ -182,38 +181,34 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
|
|
||||||
return infraHost;
|
return infraHost;
|
||||||
} else {
|
} else {
|
||||||
MetaInfraType typeMachine = new MetaInfraType();
|
MetaInfraType typeMachine = new MetaInfraType(1); // 1 = Machine;
|
||||||
typeMachine.setId(1); // 1 = Machine;
|
|
||||||
|
|
||||||
MetaInfraType typeOS = new MetaInfraType();
|
MetaInfraType typeOS = new MetaInfraType(3);// 3 = Os
|
||||||
typeOS.setId(3); // 3 = Os
|
|
||||||
|
|
||||||
MetaInfraType typeHost = new MetaInfraType();
|
MetaInfraType typeHost = new MetaInfraType(2); // 2 = Host
|
||||||
typeHost.setId(2); // 2 = Host
|
|
||||||
|
|
||||||
InfraMachine infraMachine = new InfraMachine();
|
InfraMachine infraMachine = new InfraMachine();
|
||||||
infraMachine.setProbe(probe);
|
infraMachine.setProbe(probe);
|
||||||
infraMachine.setInfraType(typeMachine);
|
infraMachine.setMetaInfraType(typeMachine);
|
||||||
infraMachine.setMeta(host.getIpv4()+"-MACHINE");
|
infraMachine.setMeta(host.getIpv4() + "-MACHINE");
|
||||||
this.infraMachineService.regist(infraMachine);
|
this.infraMachineService.regist(infraMachine);
|
||||||
|
|
||||||
InfraOS infraOS = new InfraOS();
|
InfraOS infraOS = new InfraOS();
|
||||||
infraOS.setMachine(infraMachine);
|
infraOS.setInfraMachine(infraMachine);
|
||||||
infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
|
infraOS.setMetaInfraVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
|
||||||
infraOS.setInfraType(typeOS);
|
infraOS.setMetaInfraType(typeOS);
|
||||||
infraOS.setProbe(probe);
|
infraOS.setProbe(probe);
|
||||||
infraOS.setMeta(host.getIpv4()+"-OS");
|
infraOS.setMeta(host.getIpv4() + "-OS");
|
||||||
this.infraOSService.regist(infraOS);
|
this.infraOSService.regist(infraOS);
|
||||||
|
|
||||||
InfraHost newInfraHost = new InfraHost();
|
InfraHost newInfraHost = new InfraHost();
|
||||||
newInfraHost.setIpv4(host.getIpv4());
|
newInfraHost.setIpv4(host.getIpv4());
|
||||||
newInfraHost.setMac(host.getMac());
|
newInfraHost.setMac(host.getMac());
|
||||||
newInfraHost.setOs(infraOS);
|
newInfraHost.setInfraOS(infraOS);
|
||||||
newInfraHost.setInfraType(typeHost);
|
newInfraHost.setMetaInfraType(typeHost);
|
||||||
newInfraHost.setProbe(probe);
|
newInfraHost.setProbe(probe);
|
||||||
|
|
||||||
|
if (host.isTarget()) {
|
||||||
if(host.isTarget()) {
|
|
||||||
Target target = new Target();
|
Target target = new Target();
|
||||||
target.setDisplayName(host.getIpv4() + "-Host");
|
target.setDisplayName(host.getIpv4() + "-Host");
|
||||||
|
|
||||||
|
@ -225,10 +220,7 @@ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
|
||||||
infraHost = newInfraHost;
|
infraHost = newInfraHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return infraHost;
|
return infraHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ import com.loafle.overflow.central.module.probe.service.CentralProbeService;
|
||||||
import com.loafle.overflow.central.module.target.dao.TargetDAO;
|
import com.loafle.overflow.central.module.target.dao.TargetDAO;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.discovery.Host;
|
import com.loafle.overflow.model.discovery.Host;
|
||||||
import com.loafle.overflow.model.infra.InfraHost;
|
|
||||||
import com.loafle.overflow.model.meta.MetaInfraType;
|
|
||||||
import com.loafle.overflow.model.probe.Probe;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
import com.loafle.overflow.model.target.Target;
|
import com.loafle.overflow.model.target.Target;
|
||||||
import com.loafle.overflow.service.central.target.TargetService;
|
import com.loafle.overflow.service.central.target.TargetService;
|
||||||
|
@ -76,24 +74,19 @@ public class CentralTargetService implements TargetService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services) {
|
public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts,
|
||||||
|
List<com.loafle.overflow.model.discovery.Service> services) throws OverflowException {
|
||||||
/*
|
/*
|
||||||
해당 host의 mac에 해당하는 infraHost가 이미 존재하는지 검사
|
* 해당 host의 mac에 해당하는 infraHost가 이미 존재하는지 검사 infraHost가 없다면 create infraHost가
|
||||||
infraHost가 없다면 create
|
* 있다면 update infraHost.getTarget()이 있어도 무조건 새로운 target으로 연결
|
||||||
infraHost가 있다면 update
|
*
|
||||||
infraHost.getTarget()이 있어도 무조건 새로운 target으로 연결
|
*
|
||||||
|
* for(Host host : hosts) { Target target = new Target();
|
||||||
|
*
|
||||||
for(Host host : hosts) {
|
* MetaInfraType infraType = new MetaInfraType(); infraType.setId(2); InfraHost
|
||||||
Target target = new Target();
|
* infraHost = new InfraHost(); infraHost.setInfraType(infraType);
|
||||||
|
* infraHost.setProbe(new Probe(probeId)); infraHost.setTarget(target); }
|
||||||
MetaInfraType infraType = new MetaInfraType();
|
|
||||||
infraType.setId(2);
|
|
||||||
InfraHost infraHost = new InfraHost();
|
|
||||||
infraHost.setInfraType(infraType);
|
|
||||||
infraHost.setProbe(new Probe(probeId));
|
|
||||||
infraHost.setTarget(target);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user