model change
This commit is contained in:
parent
afa93db77e
commit
0d444fc58e
|
@ -1,6 +1,7 @@
|
||||||
package com.loafle.overflow.central.commons.utils;
|
package com.loafle.overflow.central.commons.utils;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.model.PageParams;
|
import com.loafle.overflow.core.model.PageParams;
|
||||||
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.noauthprobe.dao;
|
package com.loafle.overflow.central.module.noauthprobe.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe;
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
@ -14,12 +15,14 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
|
||||||
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
|
|
||||||
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
|
|
||||||
|
|
||||||
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
|
|
||||||
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
NoAuthProbe findByTempProbeKey(String tempProbeKey);
|
||||||
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
|
|
||||||
@Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :#{#domain.id} and n.status.id = 3") // 3 = Process
|
@Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :#{#domain.id} and n.status.id = 3") // 3 = Process
|
||||||
List<NoAuthProbe> findAllByDomain(@Param("domain") Domain domain);
|
List<NoAuthProbe> findAllByDomain(@Param("domain") Domain domain);
|
||||||
|
|
||||||
|
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
|
||||||
|
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
|
||||||
|
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
|
||||||
|
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.noauthprobe.model;
|
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus;
|
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "NOAUTH_PROBE", schema = "public")
|
|
||||||
public class NoAuthProbe {
|
|
||||||
private long id;
|
|
||||||
private String description;
|
|
||||||
private MetaNoAuthProbeStatus status;
|
|
||||||
private String tempProbeKey;
|
|
||||||
private Date createDate;
|
|
||||||
private String apiKey;
|
|
||||||
private Domain domain;
|
|
||||||
private Probe probe;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", nullable = true, length = 1000)
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "STATUS", nullable = false)
|
|
||||||
public MetaNoAuthProbeStatus getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(MetaNoAuthProbeStatus status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "TEMP_PROBE_KEY", nullable = false, length = 50, unique = true)
|
|
||||||
public String getTempProbeKey() {
|
|
||||||
return tempProbeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTempProbeKey(String tempProbeKey) {
|
|
||||||
this.tempProbeKey = tempProbeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "API_KEY", nullable = true, length = 50)
|
|
||||||
public String getApiKey() {
|
|
||||||
return apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiKey(String apiKey) {
|
|
||||||
this.apiKey = apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "DOMAIN_ID", nullable=false)
|
|
||||||
public Domain getDomain() {
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomain(Domain domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "PROBE_ID", nullable = true)
|
|
||||||
public Probe getProbe() {
|
|
||||||
return probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProbe(Probe probe) {
|
|
||||||
this.probe = probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean equals(Object o) {
|
|
||||||
// if (this == o) return true;
|
|
||||||
// if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
//
|
|
||||||
// NoAuthProbe that = (NoAuthProbe) o;
|
|
||||||
//
|
|
||||||
// if (id != that.id) return false;
|
|
||||||
// if (domainId != that.domainId) return false;
|
|
||||||
// if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
|
|
||||||
// if (macAddress != null ? !macAddress.equals(that.macAddress) : that.macAddress != null) return false;
|
|
||||||
// if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) return false;
|
|
||||||
// if (status != null ? !status.equals(that.status) : that.status != null) return false;
|
|
||||||
// if (tempProbeKey != null ? !tempProbeKey.equals(that.tempProbeKey) : that.tempProbeKey != null) return false;
|
|
||||||
// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
|
|
||||||
// if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) return false;
|
|
||||||
// if (probeId != null ? !probeId.equals(that.probeId) : that.probeId != null) return false;
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int hashCode() {
|
|
||||||
// int result = (int) (id ^ (id >>> 32));
|
|
||||||
// result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
|
|
||||||
// result = 31 * result + (macAddress != null ? macAddress.hashCode() : 0);
|
|
||||||
// result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0);
|
|
||||||
// result = 31 * result + (status != null ? status.hashCode() : 0);
|
|
||||||
// result = 31 * result + (tempProbeKey != null ? tempProbeKey.hashCode() : 0);
|
|
||||||
// result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
|
|
||||||
// result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0);
|
|
||||||
// result = 31 * result + (int) (domainId ^ (domainId >>> 32));
|
|
||||||
// result = 31 * result + (probeId != null ? probeId.hashCode() : 0);
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -5,19 +5,22 @@ import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||||
import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
|
import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
|
||||||
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
|
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
|
||||||
import com.loafle.overflow.central.commons.utils.GenerateKey;
|
import com.loafle.overflow.central.commons.utils.GenerateKey;
|
||||||
import com.loafle.overflow.central.module.apikey.model.ApiKey;
|
|
||||||
import com.loafle.overflow.central.module.apikey.service.ApiKeyService;
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.domain.model.DomainMember;
|
|
||||||
import com.loafle.overflow.central.module.domain.service.DomainMemberService;
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
import com.loafle.overflow.central.module.member.service.MemberService;
|
import com.loafle.overflow.central.module.member.service.MemberService;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaProbeStatus;
|
|
||||||
import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO;
|
import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO;
|
||||||
import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
import com.loafle.overflow.model.apikey.ApiKey;
|
||||||
import com.loafle.overflow.central.module.probe.service.ProbeService;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
|
import com.loafle.overflow.model.domain.DomainMember;
|
||||||
|
import com.loafle.overflow.model.member.Member;
|
||||||
|
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
|
||||||
|
import com.loafle.overflow.model.meta.MetaProbeStatus;
|
||||||
|
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||||
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.service.central.apikey.ApiKeyService;
|
||||||
|
import com.loafle.overflow.service.central.domain.DomainMemberService;
|
||||||
|
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
|
||||||
|
import com.loafle.overflow.service.central.probe.ProbeService;
|
||||||
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.codehaus.jackson.type.TypeReference;
|
import org.codehaus.jackson.type.TypeReference;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -34,7 +37,7 @@ import java.util.UUID;
|
||||||
* Created by snoop on 17. 6. 28.
|
* Created by snoop on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("NoAuthProbeService")
|
@Service("NoAuthProbeService")
|
||||||
public class NoAuthProbeService {
|
public class CentralNoAuthProbeService implements NoAuthProbeService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NoAuthProbeDAO noAuthProbeDAO;
|
private NoAuthProbeDAO noAuthProbeDAO;
|
||||||
|
@ -55,7 +58,7 @@ public class NoAuthProbeService {
|
||||||
private DomainMemberService domainMemberService;
|
private DomainMemberService domainMemberService;
|
||||||
|
|
||||||
@ProbeAPI
|
@ProbeAPI
|
||||||
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
|
public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException{
|
||||||
|
|
||||||
ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey());
|
ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey());
|
||||||
noAuthProbe.setDomain(apiKey.getDomain());
|
noAuthProbe.setDomain(apiKey.getDomain());
|
||||||
|
@ -69,17 +72,17 @@ public class NoAuthProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<NoAuthProbe> readAllByDomain(Domain domain) {
|
public List<NoAuthProbe> readAllByDomain(Domain domain) throws OverflowException {
|
||||||
|
|
||||||
return this.noAuthProbeDAO.findAllByDomain(domain);
|
return this.noAuthProbeDAO.findAllByDomain(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoAuthProbe read(long id) {
|
public NoAuthProbe read(long id) throws OverflowException {
|
||||||
return this.noAuthProbeDAO.findOne(id);
|
return this.noAuthProbeDAO.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WebappAPI
|
@WebappAPI
|
||||||
public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException {
|
public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws OverflowException {
|
||||||
String memberEmail = SessionMetadata.getTargetID();
|
String memberEmail = SessionMetadata.getTargetID();
|
||||||
|
|
||||||
// Todo domain injection & member injection
|
// Todo domain injection & member injection
|
||||||
|
@ -125,7 +128,7 @@ public class NoAuthProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@WebappAPI
|
@WebappAPI
|
||||||
public List<NoAuthProbe> denyNoauthProbe(NoAuthProbe noAuthProbe) {
|
public List<NoAuthProbe> denyNoauthProbe(NoAuthProbe noAuthProbe) throws OverflowException {
|
||||||
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2));
|
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2));
|
||||||
this.noAuthProbeDAO.save(noAuthProbe);
|
this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.notification.dao;
|
package com.loafle.overflow.central.module.notification.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
import com.loafle.overflow.model.member.Member;
|
||||||
import com.loafle.overflow.central.module.notification.model.Notification;
|
import com.loafle.overflow.model.notification.Notification;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.notification.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by insanity on 17. 8. 25.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "NOTIFICATION", schema = "public")
|
|
||||||
public class Notification {
|
|
||||||
private long id;
|
|
||||||
private Date createDate;
|
|
||||||
private String title;
|
|
||||||
private String message;
|
|
||||||
private Member member;
|
|
||||||
private Date confirmDate;
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "TITLE", nullable = false, length = 50)
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "MESSAGE", nullable = false, length = 255)
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "MEMBER_ID", nullable = false)
|
|
||||||
public Member getMember() {
|
|
||||||
return member;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMember(Member member) {
|
|
||||||
this.member = member;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CONFIRM_DATE", nullable = true)
|
|
||||||
public Date getConfirmDate() {
|
|
||||||
return confirmDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfirmDate(Date confirmDate) {
|
|
||||||
this.confirmDate = confirmDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "URL", nullable = false, length = 255)
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.loafle.overflow.central.module.notification.service;
|
package com.loafle.overflow.central.module.notification.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.model.PageParams;
|
|
||||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
import com.loafle.overflow.central.module.notification.dao.NotificationDAO;
|
import com.loafle.overflow.central.module.notification.dao.NotificationDAO;
|
||||||
import com.loafle.overflow.central.module.notification.model.Notification;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
|
import com.loafle.overflow.core.model.PageParams;
|
||||||
|
import com.loafle.overflow.model.member.Member;
|
||||||
|
import com.loafle.overflow.model.notification.Notification;
|
||||||
|
import com.loafle.overflow.service.central.notification.NotificationService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -16,28 +19,28 @@ import java.util.List;
|
||||||
* Created by insanity on 17. 8. 25.
|
* Created by insanity on 17. 8. 25.
|
||||||
*/
|
*/
|
||||||
@Service("NotificationService")
|
@Service("NotificationService")
|
||||||
public class NotificationService {
|
public class CentralNotificationService implements NotificationService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NotificationDAO notificationDAO;
|
private NotificationDAO notificationDAO;
|
||||||
|
|
||||||
public Notification regist(Notification notification) {
|
public Notification regist(Notification notification) throws OverflowException {
|
||||||
return this.notificationDAO.save(notification);
|
return this.notificationDAO.save(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllByMember(Member member, PageParams pageParams) {
|
public Page<Notification> readAllByMember(Member member, PageParams pageParams) throws OverflowException {
|
||||||
return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams));
|
return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) {
|
public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) throws OverflowException {
|
||||||
return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams));
|
return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readUnconfirmedCount(Member member) {
|
public int readUnconfirmedCount(Member member) throws OverflowException {
|
||||||
return this.notificationDAO.findAllUnconfirmedCountByMember(member);
|
return this.notificationDAO.findAllUnconfirmedCountByMember(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> markAllAsRead(Member member, PageParams pageParams) {
|
public Page<Notification> markAllAsRead(Member member, PageParams pageParams) throws OverflowException {
|
||||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
||||||
for (Notification n : list) {
|
for (Notification n : list) {
|
||||||
n.setConfirmDate(new Date());
|
n.setConfirmDate(new Date());
|
||||||
|
@ -46,7 +49,7 @@ public class NotificationService {
|
||||||
return this.readAllByMember(member, pageParams);
|
return this.readAllByMember(member, pageParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) {
|
public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) throws OverflowException {
|
||||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
||||||
for (Notification n : list) {
|
for (Notification n : list) {
|
||||||
n.setConfirmDate(null);
|
n.setConfirmDate(null);
|
||||||
|
@ -55,8 +58,9 @@ public class NotificationService {
|
||||||
return this.readAllByMember(member, pageParams);
|
return this.readAllByMember(member, pageParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Notification markAsRead(Notification notification) {
|
public Notification markAsRead(Notification notification) throws OverflowException {
|
||||||
notification.setConfirmDate(new Date());
|
notification.setConfirmDate(new Date());
|
||||||
return this.notificationDAO.save(notification);
|
return this.notificationDAO.save(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.probe.dao;
|
package com.loafle.overflow.central.module.probe.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -13,9 +14,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProbeDAO extends JpaRepository<Probe, Long> {
|
public interface ProbeDAO extends JpaRepository<Probe, Long> {
|
||||||
// public List<Agent> findAgentListByMemberId(Member member);
|
|
||||||
|
|
||||||
Probe findByProbeKey(String probeKey);
|
Probe findByProbeKey(String probeKey);
|
||||||
|
|
||||||
List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
|
List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.probe.dao;
|
package com.loafle.overflow.central.module.probe.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
import com.loafle.overflow.central.module.probe.model.ProbeHost;
|
import com.loafle.overflow.model.probe.ProbeHost;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -10,6 +11,5 @@ import org.springframework.stereotype.Repository;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> {
|
public interface ProbeHostDAO extends JpaRepository<ProbeHost, Long> {
|
||||||
|
|
||||||
ProbeHost findByProbe(Probe probe);
|
ProbeHost findByProbe(Probe probe);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package com.loafle.overflow.central.module.probe.dao;
|
package com.loafle.overflow.central.module.probe.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import com.loafle.overflow.central.module.probe.model.ProbeTask;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.model.probe.ProbeTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by snoop on 17. 6. 26.
|
* Created by snoop on 17. 6. 26.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> {
|
public interface ProbeTaskDAO extends JpaRepository<ProbeTask, Long> {
|
||||||
|
|
||||||
List<ProbeTask> findAllByProbe(Probe probe);
|
List<ProbeTask> findAllByProbe(Probe probe);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||||
* Created by snoop on 17. 9. 14.
|
* Created by snoop on 17. 9. 14.
|
||||||
*/
|
*/
|
||||||
public class ProbeNotFoundException extends OverflowRuntimeException {
|
public class ProbeNotFoundException extends OverflowRuntimeException {
|
||||||
public ProbeNotFoundException() {
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ProbeNotFoundException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,190 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.probe.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaProbeStatus;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "PROBE", schema = "public")
|
|
||||||
public class Probe {
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private MetaProbeStatus status;
|
|
||||||
private String description;
|
|
||||||
private Date createDate;
|
|
||||||
private Domain domain;
|
|
||||||
private String probeKey;
|
|
||||||
private String encryptionKey;
|
|
||||||
private String displayName;
|
|
||||||
private String cidr;
|
|
||||||
private Date authorizeDate;
|
|
||||||
private Member authorizeMember;
|
|
||||||
|
|
||||||
private List<Infra> targets;
|
|
||||||
|
|
||||||
// private InfraHost host;
|
|
||||||
// private int targetCount;
|
|
||||||
// private int sensorCount;
|
|
||||||
|
|
||||||
public Probe() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Probe(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "STATUS", nullable = false)
|
|
||||||
public MetaProbeStatus getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(MetaProbeStatus status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", nullable = true, length = 50)
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "DOMAIN_ID", nullable = false)
|
|
||||||
public Domain getDomain() {
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomain(Domain domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "PROBE_KEY", nullable = false, unique = true)
|
|
||||||
public String getProbeKey() {
|
|
||||||
return probeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProbeKey(String probeKey) {
|
|
||||||
this.probeKey = probeKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true)
|
|
||||||
public String getEncryptionKey() {
|
|
||||||
return encryptionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEncryptionKey(String encryptionKey) {
|
|
||||||
this.encryptionKey = encryptionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
public List<Infra> getTargets() {
|
|
||||||
return targets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTargets(List<Infra> targets) {
|
|
||||||
this.targets = targets;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Column(name = "TARGET_COUNT", nullable = false)
|
|
||||||
// public int getTargetCount() {
|
|
||||||
// return targetCount;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setTargetCount(int targetCount) {
|
|
||||||
// this.targetCount = targetCount;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Column(name = "SENSOR_COUNT", nullable = false)
|
|
||||||
// public int getSensorCount() {
|
|
||||||
// return sensorCount;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setSensorCount(int sensorCount) {
|
|
||||||
// this.sensorCount = sensorCount;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Column(name = "DISPLAY_NAME")
|
|
||||||
public String getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayName(String displayName) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "CIDR")
|
|
||||||
public String getCidr() {
|
|
||||||
return cidr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCidr(String cidr) {
|
|
||||||
this.cidr = cidr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "AUTHORIZE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getAuthorizeDate() {
|
|
||||||
return authorizeDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorizeDate(Date authorizeDate) {
|
|
||||||
this.authorizeDate = authorizeDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "AUTHORIZE_MEMBER_ID", nullable = false)
|
|
||||||
public Member getAuthorizeMember() {
|
|
||||||
return authorizeMember;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorizeMember(Member authorizeMember) {
|
|
||||||
this.authorizeMember = authorizeMember;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// @ManyToOne
|
|
||||||
// @JoinColumn(name = "HOST_ID", nullable = false)
|
|
||||||
// public InfraHost getHost() {
|
|
||||||
// return host;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setHost(InfraHost host) {
|
|
||||||
// this.host = host;
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.probe.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.infra.model.InfraHost;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by insanity on 17. 8. 21.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "PROBE_INFRAHOST", schema = "public")
|
|
||||||
public class ProbeHost {
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private Probe probe;
|
|
||||||
private InfraHost host;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OneToOne
|
|
||||||
@JoinColumn(name = "PROBE_ID", nullable = false)
|
|
||||||
public Probe getProbe() {
|
|
||||||
return probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProbe(Probe probe) {
|
|
||||||
this.probe = probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OneToOne
|
|
||||||
@JoinColumn(name = "HOST_ID", nullable = false)
|
|
||||||
public InfraHost getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHost(InfraHost infraHost) {
|
|
||||||
this.host = infraHost;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.probe.model;
|
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "PROBE_TASK", schema = "public")
|
|
||||||
public class ProbeTask {
|
|
||||||
private long id;
|
|
||||||
private MetaProbeTaskType taskType;
|
|
||||||
private Probe probe;
|
|
||||||
private String data;
|
|
||||||
private Date createDate;
|
|
||||||
private Date sendDate;
|
|
||||||
private Date startDate;
|
|
||||||
private Date endDate;
|
|
||||||
private Boolean succeed;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "TYPE_ID", nullable = false)
|
|
||||||
public MetaProbeTaskType getTaskType() {
|
|
||||||
return taskType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaskType(MetaProbeTaskType taskType) {
|
|
||||||
this.taskType = taskType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "PROBE_ID", nullable = false)
|
|
||||||
public Probe getProbe() {
|
|
||||||
return probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProbe(Probe probe) {
|
|
||||||
this.probe = probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "DATA", nullable = true, length = 255)
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "SEND_DATE", nullable = true)
|
|
||||||
public Date getSendDate() {
|
|
||||||
return sendDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSendDate(Date sendDate) {
|
|
||||||
this.sendDate = sendDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "START_DATE", nullable = true)
|
|
||||||
public Date getStartDate() {
|
|
||||||
return startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartDate(Date startDate) {
|
|
||||||
this.startDate = startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "END_DATE", nullable = true)
|
|
||||||
public Date getEndDate() {
|
|
||||||
return endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndDate(Date endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "SUCCEED", nullable = true)
|
|
||||||
public Boolean getSucceed() {
|
|
||||||
return succeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSucceed(Boolean succeed) {
|
|
||||||
this.succeed = succeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean equals(Object o) {
|
|
||||||
// if (this == o) return true;
|
|
||||||
// if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
//
|
|
||||||
// ProbeTask that = (ProbeTask) o;
|
|
||||||
//
|
|
||||||
// if (id != that.id) return false;
|
|
||||||
// if (typeId != that.typeId) return false;
|
|
||||||
// if (probeId != that.probeId) return false;
|
|
||||||
// if (data != null ? !data.equals(that.data) : that.data != null) return false;
|
|
||||||
// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
|
|
||||||
// if (sendDate != null ? !sendDate.equals(that.sendDate) : that.sendDate != null) return false;
|
|
||||||
// if (startDate != null ? !startDate.equals(that.startDate) : that.startDate != null) return false;
|
|
||||||
// if (endDate != null ? !endDate.equals(that.endDate) : that.endDate != null) return false;
|
|
||||||
// if (succeed != null ? !succeed.equals(that.succeed) : that.succeed != null) return false;
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int hashCode() {
|
|
||||||
// int result = (int) (id ^ (id >>> 32));
|
|
||||||
// result = 31 * result + (int) typeId;
|
|
||||||
// result = 31 * result + (int) (probeId ^ (probeId >>> 32));
|
|
||||||
// result = 31 * result + (data != null ? data.hashCode() : 0);
|
|
||||||
// result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
|
|
||||||
// result = 31 * result + (sendDate != null ? sendDate.hashCode() : 0);
|
|
||||||
// result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
|
|
||||||
// result = 31 * result + (endDate != null ? endDate.hashCode() : 0);
|
|
||||||
// result = 31 * result + (succeed != null ? succeed.hashCode() : 0);
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.loafle.overflow.central.module.probe.service;
|
package com.loafle.overflow.central.module.probe.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.central.module.probe.model.ProbeHost;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.model.probe.ProbeHost;
|
||||||
|
import com.loafle.overflow.service.central.probe.ProbeHostService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -10,16 +13,16 @@ import org.springframework.stereotype.Service;
|
||||||
* Created by snoop on 17. 8. 21.
|
* Created by snoop on 17. 8. 21.
|
||||||
*/
|
*/
|
||||||
@Service("ProbeHostService")
|
@Service("ProbeHostService")
|
||||||
public class ProbeHostService {
|
public class CentralProbeHostService implements ProbeHostService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProbeHostDAO probeHostDAO;
|
private ProbeHostDAO probeHostDAO;
|
||||||
|
|
||||||
public ProbeHost readByProbe(Probe probe) {
|
public ProbeHost readByProbe(Probe probe) throws OverflowException {
|
||||||
return this.probeHostDAO.findByProbe(probe);
|
return this.probeHostDAO.findByProbe(probe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProbeHost regist(ProbeHost probeHost) {
|
public ProbeHost regist(ProbeHost probeHost) throws OverflowException {
|
||||||
return this.probeHostDAO.save(probeHost);
|
return this.probeHostDAO.save(probeHost);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.loafle.overflow.central.module.probe.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
||||||
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.service.central.probe.ProbeService;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by snoop on 17. 6. 28.
|
||||||
|
*/
|
||||||
|
@Service("ProbeService")
|
||||||
|
public class CentralProbeService implements ProbeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProbeDAO probeDAO;
|
||||||
|
|
||||||
|
public Probe regist(Probe probe) throws OverflowException {
|
||||||
|
return this.probeDAO.save(probe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Probe> regist(List<Probe> probes) throws OverflowException {
|
||||||
|
return this.probeDAO.save(probes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Probe> readAllByDomain(Domain domain) throws OverflowException {
|
||||||
|
List<Probe> probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain);
|
||||||
|
return probes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Probe read(long id) throws OverflowException {
|
||||||
|
return this.probeDAO.findOne(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Probe readByProbeKey(String probeKey) throws OverflowException {
|
||||||
|
return this.probeDAO.findByProbeKey(probeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Probe modify(Probe probe) throws OverflowException {
|
||||||
|
return this.probeDAO.save(probe);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
package com.loafle.overflow.central.module.probe.service;
|
package com.loafle.overflow.central.module.probe.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO;
|
import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.central.module.probe.model.ProbeTask;
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.model.probe.ProbeTask;
|
||||||
|
import com.loafle.overflow.service.central.probe.ProbeTaskService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -12,16 +15,16 @@ import java.util.List;
|
||||||
* Created by snoop on 17. 6. 28.
|
* Created by snoop on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("ProbeTaskService")
|
@Service("ProbeTaskService")
|
||||||
public class ProbeTaskService {
|
public class CentralProbeTaskService implements ProbeTaskService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProbeTaskDAO probeTaskDAO;
|
private ProbeTaskDAO probeTaskDAO;
|
||||||
|
|
||||||
public ProbeTask regist(ProbeTask probeTask) {
|
public ProbeTask regist(ProbeTask probeTask) throws OverflowException {
|
||||||
return this.probeTaskDAO.save(probeTask);
|
return this.probeTaskDAO.save(probeTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProbeTask> readAllByProbe(Probe probe) {
|
public List<ProbeTask> readAllByProbe(Probe probe) throws OverflowException {
|
||||||
return this.probeTaskDAO.findAllByProbe(probe);
|
return this.probeTaskDAO.findAllByProbe(probe);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,53 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.probe.service;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.infra.dao.InfraDAO;
|
|
||||||
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
|
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by snoop on 17. 6. 28.
|
|
||||||
*/
|
|
||||||
@Service("ProbeService")
|
|
||||||
public class ProbeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ProbeDAO probeDAO;
|
|
||||||
@Autowired
|
|
||||||
private InfraDAO infraDAO;
|
|
||||||
|
|
||||||
public Probe regist(Probe probe) {
|
|
||||||
return this.probeDAO.save(probe);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Probe> regist(List<Probe> probes) {
|
|
||||||
return this.probeDAO.save(probes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Probe> readAllByDomain(Domain domain) {
|
|
||||||
List<Probe> probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain);
|
|
||||||
for(Probe probe : probes) {
|
|
||||||
probe.setTargets(this.infraDAO.findAllByProbe(probe));
|
|
||||||
}
|
|
||||||
return probes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Probe read(long id) {
|
|
||||||
Probe probe = this.probeDAO.findOne(id);
|
|
||||||
probe.setTargets(this.infraDAO.findAllByProbe(probe));
|
|
||||||
return probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Probe readByProbeKey(String probeKey) {
|
|
||||||
|
|
||||||
return this.probeDAO.findByProbeKey(probeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Probe modify(Probe probe) {
|
|
||||||
return this.probeDAO.save(probe);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.loafle.overflow.central.module.sensor.dao;
|
package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
|
||||||
import com.loafle.overflow.central.module.target.model.Target;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
@ -12,18 +10,18 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
|
import com.loafle.overflow.model.target.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by root on 17. 6. 9.
|
* Created by root on 17. 6. 9.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
||||||
|
|
||||||
|
|
||||||
Page<Sensor> findAllByTarget(Target target, Pageable pageable);
|
Page<Sensor> findAllByTarget(Target target, Pageable pageable);
|
||||||
List<Sensor> findAllByTarget(Target target);
|
List<Sensor> findAllByTarget(Target target);
|
||||||
|
|
||||||
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
|
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
|
||||||
Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable);
|
Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable);
|
||||||
// List<Sensor> findAllByTargetList(List<Target> targets);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loafle.overflow.central.module.sensor.dao;
|
package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
|
@ -2,7 +2,8 @@ package com.loafle.overflow.central.module.sensor.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.central.module.sensor.model.SensorItemDependency;
|
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.sensor.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorStatus;
|
|
||||||
import com.loafle.overflow.central.module.target.model.Target;
|
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "SENSOR", schema = "public")
|
|
||||||
public class Sensor {
|
|
||||||
private long id;
|
|
||||||
private Date createDate;
|
|
||||||
private String description;
|
|
||||||
private MetaSensorStatus status;
|
|
||||||
private Target target;
|
|
||||||
private MetaCrawler crawler;
|
|
||||||
private String crawlerInputItems;
|
|
||||||
private short itemCount = 0;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", nullable = true, length = 50)
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "STATUS")
|
|
||||||
public MetaSensorStatus getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(MetaSensorStatus status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name = "TARGET_ID", nullable = false)
|
|
||||||
public Target getTarget() {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTarget(Target target) {
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "CRAWLER_ID", nullable = false)
|
|
||||||
public MetaCrawler getCrawler() {
|
|
||||||
return crawler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCrawler(MetaCrawler crawler) {
|
|
||||||
this.crawler = crawler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "CRAWLER_INPUT_ITEMS", nullable = true, length = 50)
|
|
||||||
public String getCrawlerInputItems() {
|
|
||||||
return crawlerInputItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCrawlerInputItems(String crawlerInputItems) {
|
|
||||||
this.crawlerInputItems = crawlerInputItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "ITEM_COUNT", nullable = false)
|
|
||||||
public short getItemCount() {
|
|
||||||
return itemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemCount(short itemCount) {
|
|
||||||
this.itemCount = itemCount;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.sensor.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "SENSOR_ITEM", schema = "public")
|
|
||||||
public class SensorItem {
|
|
||||||
private long id;
|
|
||||||
private Sensor sensor;
|
|
||||||
private MetaSensorDisplayItem item;
|
|
||||||
private Date createDate;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "SENSOR_ID", nullable = false)
|
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
public Sensor getSensor() {
|
|
||||||
return this.sensor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSensor(Sensor sensor) {
|
|
||||||
this.sensor = sensor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "ITEM_ID", nullable = false)
|
|
||||||
public MetaSensorDisplayItem getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(MetaSensorDisplayItem item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.sensor.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by insanity on 17. 9. 20.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "SENSOR_ITEM_DEPENDENCY", schema = "public")
|
|
||||||
public class SensorItemDependency {
|
|
||||||
private long id;
|
|
||||||
private MetaSensorDisplayItem displayItem;
|
|
||||||
private MetaSensorItemKey sensorItem;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "DISPLAY_ITEM_ID", nullable = false)
|
|
||||||
public MetaSensorDisplayItem getDisplayItem() {
|
|
||||||
return displayItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayItem(MetaSensorDisplayItem displayItem) {
|
|
||||||
this.displayItem = displayItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "SENSOR_ITEM_ID", nullable = false)
|
|
||||||
public MetaSensorItemKey getSensorItem() {
|
|
||||||
return sensorItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSensorItem(MetaSensorItemKey sensorItem) {
|
|
||||||
this.sensorItem = sensorItem;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,8 @@ package com.loafle.overflow.central.module.sensor.service;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
|
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
|
||||||
import com.loafle.overflow.central.module.sensor.model.SensorItemDependency;
|
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Service("SensorItemDependencyService")
|
@Service("SensorItemDependencyService")
|
||||||
public class SensorItemDependencyService {
|
public class CentralSensorItemDependencyService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SensorItemDependencyDAO sensorItemDependencyDAO;
|
private SensorItemDependencyDAO sensorItemDependencyDAO;
|
|
@ -4,8 +4,9 @@ import com.loafle.overflow.central.commons.model.PageParams;
|
||||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||||
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
||||||
import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO;
|
import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO;
|
||||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -17,7 +18,7 @@ import java.util.List;
|
||||||
* Created by insanity on 17. 6. 28.
|
* Created by insanity on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("SensorItemService")
|
@Service("SensorItemService")
|
||||||
public class SensorItemService {
|
public class CentralSensorItemService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SensorItemDAO sensorItemDAO;
|
private SensorItemDAO sensorItemDAO;
|
||||||
|
@ -27,7 +28,7 @@ public class SensorItemService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public SensorItem regist(SensorItem sensorItem) {
|
public SensorItem regist(SensorItem sensorItem) {
|
||||||
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
|
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
|
||||||
s.setItemCount((short)(s.getItemCount() + 1));
|
// s.setItemCount((short)(s.getItemCount() + 1));
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
return this.sensorItemDAO.save(sensorItem);
|
return this.sensorItemDAO.save(sensorItem);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +36,7 @@ public class SensorItemService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean registAll(List<SensorItem> sensorItemList) {
|
public boolean registAll(List<SensorItem> sensorItemList) {
|
||||||
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
|
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
|
||||||
s.setItemCount((short)sensorItemList.size());
|
// s.setItemCount((short)sensorItemList.size());
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
this.sensorItemDAO.save(sensorItemList);
|
this.sensorItemDAO.save(sensorItemList);
|
||||||
return true;
|
return true;
|
||||||
|
@ -52,7 +53,7 @@ public class SensorItemService {
|
||||||
@Transactional
|
@Transactional
|
||||||
public void remove(SensorItem sensorItem) {
|
public void remove(SensorItem sensorItem) {
|
||||||
Sensor s = sensorItem.getSensor();
|
Sensor s = sensorItem.getSensor();
|
||||||
s.setItemCount((short)(s.getItemCount() - 1));
|
// s.setItemCount((short)(s.getItemCount() - 1));
|
||||||
this.sensorDAO.save(s);
|
this.sensorDAO.save(s);
|
||||||
this.sensorItemDAO.delete(sensorItem);
|
this.sensorItemDAO.delete(sensorItem);
|
||||||
}
|
}
|
|
@ -2,21 +2,24 @@ package com.loafle.overflow.central.module.sensor.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.model.PageParams;
|
import com.loafle.overflow.central.commons.model.PageParams;
|
||||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.generator.service.SensorConfigGenerator;
|
import com.loafle.overflow.central.module.generator.service.SensorConfigGenerator;
|
||||||
import com.loafle.overflow.central.module.infra.exception.InfraNotFoundException;
|
import com.loafle.overflow.central.module.infra.exception.InfraNotFoundException;
|
||||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
|
||||||
import com.loafle.overflow.central.module.infra.service.InfraService;
|
import com.loafle.overflow.central.module.infra.service.InfraService;
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaSensorStatus;
|
|
||||||
import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService;
|
import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService;
|
||||||
import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException;
|
import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import com.loafle.overflow.central.module.probe.service.ProbeService;
|
|
||||||
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
||||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
|
||||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
|
||||||
import com.loafle.overflow.central.module.target.exception.TargetNotFoundException;
|
import com.loafle.overflow.central.module.target.exception.TargetNotFoundException;
|
||||||
import com.loafle.overflow.central.module.target.model.Target;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
|
import com.loafle.overflow.model.domain.Domain;
|
||||||
|
import com.loafle.overflow.model.infra.Infra;
|
||||||
|
import com.loafle.overflow.model.meta.MetaSensorStatus;
|
||||||
|
import com.loafle.overflow.model.probe.Probe;
|
||||||
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.target.Target;
|
||||||
|
import com.loafle.overflow.service.central.probe.ProbeService;
|
||||||
|
import com.loafle.overflow.service.central.sensor.SensorService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -29,7 +32,7 @@ import java.util.List;
|
||||||
* Created by insanity on 17. 6. 28.
|
* Created by insanity on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("SensorService")
|
@Service("SensorService")
|
||||||
public class SensorService {
|
public class CentralSensorService implements SensorService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
SensorDAO sensorDAO;
|
SensorDAO sensorDAO;
|
||||||
|
@ -41,10 +44,7 @@ public class SensorService {
|
||||||
private InfraService infraService;
|
private InfraService infraService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SensorItemService sensorItemService;
|
private CentralSensorItemService sensorItemService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MetaSensorItemKeyService metaSensorItemKeyService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SensorConfigGenerator sensorConfigGenerator;
|
private SensorConfigGenerator sensorConfigGenerator;
|
||||||
|
@ -53,67 +53,63 @@ public class SensorService {
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) {
|
public Page<Sensor> readAllByDomain(Domain domain, PageParams pageParams) throws OverflowException {
|
||||||
// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Page<Sensor> readAllByDomain(Domain domain, PageParams pageParams) {
|
|
||||||
|
|
||||||
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
||||||
|
|
||||||
if(probeList == null || probeList.size() <= 0) {
|
if (probeList == null || probeList.size() <= 0) {
|
||||||
throw new ProbeNotFoundException();
|
throw new ProbeNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList);
|
List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList);
|
||||||
|
|
||||||
if(targetList == null || targetList.size() <= 0) {
|
if (targetList == null || targetList.size() <= 0) {
|
||||||
throw new TargetNotFoundException();
|
throw new TargetNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams));
|
return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Sensor> readAllByInfra(long infraId, PageParams pageParams) {
|
public Page<Sensor> readAllByInfra(long infraId, PageParams pageParams) throws OverflowException {
|
||||||
Infra dbInfra = this.infraService.read(infraId);
|
Infra dbInfra = this.infraService.read(infraId);
|
||||||
|
|
||||||
if(dbInfra == null || dbInfra.getTarget() == null) {
|
if (dbInfra == null || dbInfra.getTarget() == null) {
|
||||||
throw new InfraNotFoundException();
|
throw new InfraNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams));
|
return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Sensor> readAllByTarget(Target target, PageParams pageParams) {
|
public Page<Sensor> readAllByTarget(Target target, PageParams pageParams) throws OverflowException {
|
||||||
return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
|
return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor read(String id) {
|
public Sensor read(String id) throws OverflowException {
|
||||||
return this.sensorDAO.findOne(Long.valueOf(id));
|
return this.sensorDAO.findOne(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Sensor sensor) {
|
public void remove(Sensor sensor) throws OverflowException {
|
||||||
this.sensorDAO.delete(sensor);
|
this.sensorDAO.delete(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor start(Sensor sensor) {
|
public Sensor start(Sensor sensor) throws OverflowException {
|
||||||
MetaSensorStatus status = new MetaSensorStatus((short)1);
|
MetaSensorStatus status = new MetaSensorStatus((short) 1);
|
||||||
sensor.setStatus(status);
|
sensor.setStatus(status);
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor stop(Sensor sensor) {
|
public Sensor stop(Sensor sensor) throws OverflowException {
|
||||||
MetaSensorStatus status = new MetaSensorStatus((short)2);
|
MetaSensorStatus status = new MetaSensorStatus((short) 2);
|
||||||
sensor.setStatus(status);
|
sensor.setStatus(status);
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson) {
|
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson) throws OverflowException {
|
||||||
|
|
||||||
this.sensorDAO.save(sensor);
|
this.sensorDAO.save(sensor);
|
||||||
|
|
||||||
for(SensorItem sensorItem : sensorItemList) {
|
for (SensorItem sensorItem : sensorItemList) {
|
||||||
sensorItem.setSensor(sensor);
|
sensorItem.setSensor(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,10 +118,13 @@ public class SensorService {
|
||||||
return sensor;
|
return sensor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateSensorConfig(Sensor sensor) throws IOException {
|
public String generateSensorConfig(Sensor sensor) throws OverflowException {
|
||||||
|
|
||||||
return this.sensorConfigGenerator.generate(sensor);
|
return this.sensorConfigGenerator.generate(sensor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) {
|
||||||
|
// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
|
||||||
|
// }
|
||||||
}
|
}
|
|
@ -1,22 +1,12 @@
|
||||||
package com.loafle.overflow.central.module.target.dao;
|
package com.loafle.overflow.central.module.target.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
import com.loafle.overflow.model.target.Target;
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import com.loafle.overflow.central.module.target.model.Target;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by root on 17. 6. 5.
|
* Created by root on 17. 6. 5.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface TargetDAO extends JpaRepository<Target, Long> {
|
public interface TargetDAO extends JpaRepository<Target, Long> {
|
||||||
// List<Target> findAllByProbe(Probe probe);]
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||||
* Created by snoop on 17. 9. 14.
|
* Created by snoop on 17. 9. 14.
|
||||||
*/
|
*/
|
||||||
public class TargetNotFoundException extends OverflowRuntimeException {
|
public class TargetNotFoundException extends OverflowRuntimeException {
|
||||||
public TargetNotFoundException() {
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public TargetNotFoundException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
package com.loafle.overflow.central.module.target.model;
|
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by root on 17. 6. 22.
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table(name = "TARGET", schema = "public")
|
|
||||||
public class Target {
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private Date createDate;
|
|
||||||
private String displayName;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private List<Sensor> sensors;
|
|
||||||
|
|
||||||
/*
|
|
||||||
private long id;
|
|
||||||
private Date createDate;
|
|
||||||
private String displayName;
|
|
||||||
private String description;
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
|
||||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "DISPLAY_NAME")
|
|
||||||
public String getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayName(String displayName) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION")
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @ManyToOne
|
|
||||||
// @JoinColumn(name = "PROBE_ID", nullable = false)
|
|
||||||
// @OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
// public Probe getProbe() {
|
|
||||||
// return probe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setProbe(Probe probe) {
|
|
||||||
// this.probe = probe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @ManyToOne
|
|
||||||
// @JoinColumn(name = "INFRA_ID", nullable = false)
|
|
||||||
// public Infra getInfra() {
|
|
||||||
// return infra;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setInfra(Infra infra) {
|
|
||||||
// this.infra = infra;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
public List<Sensor> getSensors() {
|
|
||||||
return sensors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSensors(List<Sensor> sensors) {
|
|
||||||
this.sensors = sensors;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,220 @@
|
||||||
|
package com.loafle.overflow.central.module.target.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||||
|
import com.loafle.overflow.central.module.discovery.model.Host;
|
||||||
|
import com.loafle.overflow.central.module.discovery.model.Port;
|
||||||
|
import com.loafle.overflow.central.module.discovery.type.PortType;
|
||||||
|
import com.loafle.overflow.central.module.infra.model.*;
|
||||||
|
import com.loafle.overflow.central.module.infra.model.InfraService;
|
||||||
|
import com.loafle.overflow.central.module.infra.service.*;
|
||||||
|
import com.loafle.overflow.central.module.meta.model.MetaInfraType;
|
||||||
|
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by snoop on 17. 6. 28.
|
||||||
|
*/
|
||||||
|
@Service("TargetDiscoveryService")
|
||||||
|
public class CentralTargetDiscoveryService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CentralTargetService targetService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraMachineService infraMachineService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraOSService infraOSService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraHostService infraHostService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private com.loafle.overflow.central.module.infra.service.InfraService infraService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraOSPortService infraOSPortService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraServiceService infraServiceService;
|
||||||
|
|
||||||
|
// @Transactional
|
||||||
|
// public boolean saveAllTarget(List<Host> hosts, Probe probe) {
|
||||||
|
|
||||||
|
// InfraHost infraHost = null;
|
||||||
|
|
||||||
|
// for(Host host : hosts) {
|
||||||
|
|
||||||
|
// infraHost = this.createAndReadHost(host, probe);
|
||||||
|
|
||||||
|
// this.createPort(infraHost, host, probe);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private void createService(InfraHost infraHost, Port port, Probe probe) {
|
||||||
|
|
||||||
|
// if(port.getServices() == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// MetaInfraType typeService = new MetaInfraType();
|
||||||
|
// typeService.setId(7);
|
||||||
|
|
||||||
|
// String portType = "UDP";
|
||||||
|
|
||||||
|
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||||
|
// portType = "TCP";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for(com.loafle.overflow.central.module.discovery.model.Service service : port.getServices()) {
|
||||||
|
|
||||||
|
// InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType);
|
||||||
|
|
||||||
|
// if(dbInfraService != null) {
|
||||||
|
// if(service.isTarget() && dbInfraService.getTarget() == null) {
|
||||||
|
// Target targetService = new Target();
|
||||||
|
// targetService.setDisplayName(service.getServiceName() + "-Service");
|
||||||
|
// this.targetService.regist(targetService);
|
||||||
|
// dbInfraService.setTarget(targetService);
|
||||||
|
// this.infraServiceService.regist(dbInfraService);
|
||||||
|
// }
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// InfraService infraService = new InfraService();
|
||||||
|
// infraService.setHost(infraHost);
|
||||||
|
// infraService.setPort(port.getPortNumber());
|
||||||
|
// infraService.setPortType(portType);
|
||||||
|
// infraService.setInfraType(typeService);
|
||||||
|
// infraService.setProbe(probe);
|
||||||
|
|
||||||
|
// if (port.getPortType() == PortType.TLS) {
|
||||||
|
// infraService.setTlsType(true);
|
||||||
|
// }
|
||||||
|
// infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
|
||||||
|
|
||||||
|
// if(service.isTarget()) {
|
||||||
|
// Target targetService = new Target();
|
||||||
|
// targetService.setDisplayName(service.getServiceName() + "-Service");
|
||||||
|
// this.targetService.regist(targetService);
|
||||||
|
// infraService.setTarget(targetService);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.infraServiceService.regist(infraService);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private void createPort(InfraHost infraHost, Host host, Probe probe) {
|
||||||
|
|
||||||
|
// if(host.getPorts() == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// String portType = "UDP";
|
||||||
|
|
||||||
|
// MetaInfraType typePort = new MetaInfraType();
|
||||||
|
// typePort.setId(6);
|
||||||
|
|
||||||
|
// InfraOS infraOS = infraHost.getOs();
|
||||||
|
|
||||||
|
// for(Port port : host.getPorts()) {
|
||||||
|
|
||||||
|
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||||
|
// portType = "TCP";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// InfraOSPort dbInfraOSPort = this.infraOSPortService.readByPort(infraOS.getId(), port.getPortNumber(), portType);
|
||||||
|
// if(dbInfraOSPort == null) {
|
||||||
|
// InfraOSPort infraOSPort = new InfraOSPort();
|
||||||
|
// infraOSPort.setOs(infraOS);
|
||||||
|
// infraOSPort.setPort(port.getPortNumber());
|
||||||
|
// infraOSPort.setPortType(portType);
|
||||||
|
// infraOSPort.setProbe(probe);
|
||||||
|
// infraOSPort.setInfraType(typePort);
|
||||||
|
|
||||||
|
// if (port.getPortType() == PortType.TLS) {
|
||||||
|
// infraOSPort.setTlsType(true);
|
||||||
|
// }
|
||||||
|
// infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
|
||||||
|
// this.infraOSPortService.regist(infraOSPort);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.createService(infraHost, port, probe);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private InfraHost createAndReadHost(Host host, Probe probe) {
|
||||||
|
|
||||||
|
// InfraHost infraHost = this.infraHostService.readByIp(host.getIp());
|
||||||
|
// if(infraHost != null) {
|
||||||
|
|
||||||
|
// if(host.isTarget() && infraHost.getTarget() == null) {
|
||||||
|
// Target target = new Target();
|
||||||
|
// target.setDisplayName(String.valueOf(host.getIp()) + "-Host");
|
||||||
|
|
||||||
|
// this.targetService.regist(target);
|
||||||
|
// infraHost.setTarget(target);
|
||||||
|
// this.infraHostService.regist(infraHost);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return infraHost;
|
||||||
|
// } else {
|
||||||
|
// MetaInfraType typeMachine = new MetaInfraType();
|
||||||
|
// typeMachine.setId(1); // 1 = Machine;
|
||||||
|
|
||||||
|
// MetaInfraType typeOS = new MetaInfraType();
|
||||||
|
// typeOS.setId(3); // 3 = Os
|
||||||
|
|
||||||
|
// MetaInfraType typeHost = new MetaInfraType();
|
||||||
|
// typeHost.setId(2); // 2 = Host
|
||||||
|
|
||||||
|
// InfraMachine infraMachine = new InfraMachine();
|
||||||
|
// infraMachine.setProbe(probe);
|
||||||
|
// infraMachine.setInfraType(typeMachine);
|
||||||
|
// infraMachine.setMeta(StringConvertor.intToIp(host.getIp())+"-MACHINE");
|
||||||
|
// this.infraMachineService.regist(infraMachine);
|
||||||
|
|
||||||
|
// InfraOS infraOS = new InfraOS();
|
||||||
|
// infraOS.setMachine(infraMachine);
|
||||||
|
// infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
|
||||||
|
// infraOS.setInfraType(typeOS);
|
||||||
|
// infraOS.setProbe(probe);
|
||||||
|
// infraOS.setMeta(StringConvertor.intToIp(host.getIp())+"-OS");
|
||||||
|
// this.infraOSService.regist(infraOS);
|
||||||
|
|
||||||
|
// InfraHost newInfraHost = new InfraHost();
|
||||||
|
// newInfraHost.setIp(host.getIp());
|
||||||
|
// newInfraHost.setMac(host.getMac());
|
||||||
|
// newInfraHost.setOs(infraOS);
|
||||||
|
// newInfraHost.setInfraType(typeHost);
|
||||||
|
// newInfraHost.setProbe(probe);
|
||||||
|
|
||||||
|
// if(host.isTarget()) {
|
||||||
|
// Target target = new Target();
|
||||||
|
// target.setDisplayName(StringConvertor.intToIp(host.getIp()) + "-Host");
|
||||||
|
|
||||||
|
// this.targetService.regist(target);
|
||||||
|
// newInfraHost.setTarget(target);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.infraHostService.regist(newInfraHost);
|
||||||
|
// infraHost = newInfraHost;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return infraHost;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,36 +1,31 @@
|
||||||
package com.loafle.overflow.central.module.target.service;
|
package com.loafle.overflow.central.module.target.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
|
||||||
import com.loafle.overflow.central.module.target.dao.TargetDAO;
|
import com.loafle.overflow.central.module.target.dao.TargetDAO;
|
||||||
import com.loafle.overflow.central.module.target.model.Target;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
|
import com.loafle.overflow.model.target.Target;
|
||||||
|
import com.loafle.overflow.service.central.target.TargetService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 6. 28.
|
* Created by insanity on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Service("TargetService")
|
@Service("TargetService")
|
||||||
public class TargetService {
|
public class CentralTargetService implements TargetService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetDAO targetDAO;
|
private TargetDAO targetDAO;
|
||||||
|
|
||||||
public Target regist(Target target) {
|
public Target regist(Target target) throws OverflowException {
|
||||||
return this.targetDAO.save(target);
|
return this.targetDAO.save(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target read(String id) {
|
public Target read(String id) throws OverflowException {
|
||||||
return this.targetDAO.findOne(Long.valueOf(id));
|
return this.targetDAO.findOne(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public List<Target> readAllByProbe(Probe probe) {
|
public void remove(Target target) throws OverflowException {
|
||||||
// return this.targetDAO.findAllByProbe(probe);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void remove(Target target) {
|
|
||||||
this.targetDAO.delete(target);
|
this.targetDAO.delete(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user