diff --git a/pom.xml b/pom.xml
index 037aa28..dada1fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
com.loafle.overflow
commons-java
- 1.0.116-SNAPSHOT
+ 1.0.117-SNAPSHOT
diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java
index d15c41d..edb7270 100644
--- a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java
+++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java
@@ -1,13 +1,9 @@
package com.loafle.overflow.central.module.sensor.service;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
-import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.crypto.Cipher;
@@ -53,7 +49,7 @@ public class CentralSensorConfigService {
private MessagePublisher messagePublisher;
@Transactional
- public SensorConfig regist(Sensor sensor) throws OverflowException {
+ public SensorConfig regist(Sensor sensor, boolean update) throws OverflowException {
if (null == sensor.getId()) {
throw new OverflowException(String.format("ID[%s] of Sensor is not valid", sensor.getId()));
}
@@ -66,7 +62,8 @@ public class CentralSensorConfigService {
Probe probe = sensor.getTarget().getInfra().getProbe();
String encryptedSensorConfigBase64 = this.toEncryptString(sensorConfig, probe.getEncryptionKey());
- this.messagePublisher.publishToProbe(probe.getProbeKey(), "SensorService.AddSensor", encryptedSensorConfigBase64);
+ String method = update ? "SensorService.UpdateSensor" : "SensorService.AddSensor";
+ this.messagePublisher.publishToProbe(probe.getProbeKey(), method, encryptedSensorConfigBase64);
return sensorConfig;
}
diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java
index 22d399b..c0d3993 100644
--- a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java
+++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java
@@ -59,6 +59,11 @@ public class CentralSensorService implements SensorService {
}
}
+ @Override
+ public Sensor modify(Sensor sensor) throws OverflowException {
+ return this.sensorDAO.save(sensor);
+ }
+
@Transactional
@Override
public Sensor regist(Sensor sensor, List metaDisplayItemMappings) throws OverflowException {
@@ -82,14 +87,15 @@ public class CentralSensorService implements SensorService {
}
// FiXME : process asynchronously
- this.sensorConfigService.regist(retSensor);
+ this.sensorConfigService.regist(retSensor, false);
return retSensor;
}
@Transactional
@Override
- public Sensor modify(Long sensorID, List metaDisplayItemMappings) throws OverflowException {
+ public Sensor modifyItems(Long sensorID, List metaDisplayItemMappings)
+ throws OverflowException {
Sensor sensor = this.read(sensorID);
if (null == sensor) {
throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID));
@@ -98,6 +104,8 @@ public class CentralSensorService implements SensorService {
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
this.sensorItemService.regist(sensor, metaDisplayItemMapping);
}
+
+ this.sensorConfigService.regist(sensor, true);
return sensor;
}