added auth crawler
This commit is contained in:
parent
7f71dc7f47
commit
9eec640d32
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.module.auth.dao;
|
||||
|
||||
import com.loafle.overflow.module.auth.model.AuthCrawler;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Repository
|
||||
public interface AuthCrawlerDAO extends JpaRepository<AuthCrawler, Long> {
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.loafle.overflow.module.auth.model;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "AUTH_CRAWLER", schema = "public")
|
||||
public class AuthCrawler {
|
||||
private long id;
|
||||
private MetaCrawler crawler;
|
||||
private Target target;
|
||||
private String authJson;
|
||||
private Date createDate;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CRAWLER_ID", nullable = false)
|
||||
public MetaCrawler getCrawler() {
|
||||
return crawler;
|
||||
}
|
||||
|
||||
public void setCrawler(MetaCrawler crawler) {
|
||||
this.crawler = crawler;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@JoinColumn(name = "TARGET_ID", nullable = false)
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(Target target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Column(name = "AUTH_JSON", nullable = false)
|
||||
public String getAuthJson() {
|
||||
return authJson;
|
||||
}
|
||||
|
||||
public void setAuthJson(String authJson) {
|
||||
this.authJson = authJson;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.loafle.overflow.module.auth.service;
|
||||
|
||||
import com.loafle.overflow.module.auth.dao.AuthCrawlerDAO;
|
||||
import com.loafle.overflow.module.auth.model.AuthCrawler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Service("AuthCrawlerService")
|
||||
public class AuthCrawlerService {
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerDAO authCrawlerDAO;
|
||||
|
||||
public AuthCrawler regist(AuthCrawler authCrawler) {
|
||||
return this.authCrawlerDAO.save(authCrawler);
|
||||
}
|
||||
}
|
|
@ -113,9 +113,6 @@ public class SensorService {
|
|||
|
||||
public String generateSensorConfig(Sensor sensor) throws IOException {
|
||||
|
||||
|
||||
|
||||
// Sensor dbSensor = this.sensorDAO.findOne(sensor.getId());
|
||||
PageParams pageParams = new PageParams();
|
||||
pageParams.setPageNo(0);
|
||||
pageParams.setCountPerPage(Integer.MAX_VALUE);
|
||||
|
@ -133,16 +130,19 @@ public class SensorService {
|
|||
Infra infra = this.infraService.readByTarget(dbSensor.getTarget());
|
||||
|
||||
// 7 = Infra OS Service
|
||||
if(infra.getInfraType().getId() != 7) {
|
||||
return null;
|
||||
if(infra.getInfraType().getId() == 7) {
|
||||
return this.processService(dbSensor, sensorItems, infra);
|
||||
}
|
||||
|
||||
// InfraHost infraHost = this.getInfraHost(infra);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private String processService(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws IOException {
|
||||
com.loafle.overflow.module.infra.model.InfraService infraService = (com.loafle.overflow.module.infra.model.InfraService)infra;
|
||||
|
||||
Config config = new Config();
|
||||
config.setId(String.valueOf(sensor.getId()));
|
||||
config.setId(String.valueOf(dbSensor.getId()));
|
||||
|
||||
com.loafle.overflow.crawler.config.Target target = new com.loafle.overflow.crawler.config.Target();
|
||||
Connection connection = new Connection();
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.loafle.overflow.module.auth.service;
|
||||
|
||||
import com.loafle.overflow.module.auth.model.AuthCrawler;
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import com.loafle.overflow.spring.AppConfigTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class AuthCrawlerServiceTest {
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerService authCrawlerService;
|
||||
|
||||
@Test
|
||||
public void regist() throws Exception {
|
||||
|
||||
AuthCrawler authCrawler = new AuthCrawler();
|
||||
|
||||
Target target = new Target();
|
||||
target.setId(4);
|
||||
|
||||
authCrawler.setTarget(target);
|
||||
|
||||
|
||||
MetaCrawler metaCrawler = new MetaCrawler();
|
||||
metaCrawler.setId((short)11);
|
||||
|
||||
authCrawler.setCrawler(metaCrawler);
|
||||
|
||||
authCrawler.setAuthJson("{\"DB Name\":\"test\",\"ID\":\"docker\",\"PassWord\":\"qwer5795QWER\"}");
|
||||
|
||||
|
||||
this.authCrawlerService.regist(authCrawler);
|
||||
|
||||
Assert.assertNotEquals(authCrawler.getId(), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user