added objectmapper

This commit is contained in:
snoop 2017-09-13 17:08:30 +09:00
parent f7f29a5344
commit 86a8ee756d
3 changed files with 22 additions and 6 deletions

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.module.noauthprobe.service;
import com.loafle.overflow.commons.utils.StringConvertor;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.member.model.Member;
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
@ -9,13 +8,14 @@ import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO;
import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe;
import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.probe.service.ProbeService;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.io.IOException;
import java.util.*;
/**
* Created by snoop on 17. 6. 28.
@ -29,6 +29,9 @@ public class NoAuthProbeService {
@Autowired
private ProbeService probeService;
@Autowired
private ObjectMapper objectMapper;
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
noAuthProbe.setTempProbeKey(UUID.randomUUID().toString());
@ -47,7 +50,7 @@ public class NoAuthProbeService {
return this.noAuthProbeDAO.findOne(id);
}
public List<NoAuthProbe> acceptNoAuthProbes(List<NoAuthProbe> noAuthProbes) {
public List<NoAuthProbe> acceptNoAuthProbes(List<NoAuthProbe> noAuthProbes) throws IOException {
// Todo domain injection & member injection
List<Probe> probes = new ArrayList<>();
@ -66,6 +69,9 @@ public class NoAuthProbeService {
probe.setSensorCount(0);
Map<String, Object> objMap = null;
objMap = this.objectMapper.readValue(noAuth.getDescription(), new TypeReference<HashMap<String,Object>>() {});
// String dispName = noAuth.getHostName().isEmpty() ?
// StringConvertor.intToIp(noAuth.getIpAddress()) : noAuth.getHostName();

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.spring;
import org.codehaus.jackson.map.ObjectMapper;
import org.hibernate.cfg.Environment;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@ -69,6 +70,11 @@ public class JdbcConfiguration implements TransactionManagementConfigurer {
return entityManagerFactoryBean;
}
@Bean
public ObjectMapper getObjectMapper() {
return new ObjectMapper();
}
@Bean
@Qualifier(value = "transactionManager")
public PlatformTransactionManager annotationDrivenTransactionManager() {

View File

@ -29,6 +29,8 @@ public class SensorServiceTest {
@Autowired
SensorService sensorService;
@Autowired
ObjectMapper objectMapper;
@Ignore
@ -56,7 +58,9 @@ public class SensorServiceTest {
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(res);
// String json = objectMapper.writeValueAsString(res);
String json = this.objectMapper.writeValueAsString(res);
System.out.println(json);
}