diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java index f77c0d35..8baaea3b 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java @@ -118,9 +118,11 @@ public String deviceExecute(String deviceId,String deviceCommand, String session session.insertSessionData(DefaultSession.DEVICE_RESULT, DefaultSession.CONTROL_EXECUTION); sessionStore.updateSession(session); + /* if(device.checkStatus(deviceCommand)){ return "same device state to is."; } + */ // Device 제어 요청 보냄. ResultMessage resultMessage = deviceControlProxy.deviceControlRequest(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_CONTOL_URI,deviceControlMessage); @@ -137,9 +139,7 @@ public String deviceExecute(String deviceId,String deviceCommand, String session /** * Device Subscription 데이터 저장 */ - if(response.equals(ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE)){ - saveDeviceSubscriptionData(deviceControlMessage.get_commandId(), deviceControlMessage.getCon()); - } + saveDeviceSubscriptionData(deviceControlMessage.get_commandId(), deviceControlMessage.getCon(), response); /* 디바이스 해제는 Controller에서 상태 업데이트 후 해제. @@ -229,8 +229,12 @@ public void deviceUpdate(DeviceStatusData deviceStatusData) { logger.debug(LogPrint.LogMethodNamePrint() + "Device Data Update"); device.setDeviceStatus(deviceStatusData.getCon()); deviceStore.update(device); - deviceSubscriptionRelease(deviceUri + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS); - deviceSubscriptionStore.delete(deviceSubscriptionObject.get_id()); + /** + * Device Subscription 해제 요청 + */ + String response = deviceSubscriptionRelease(deviceUri + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS); + deviceSubscriptionObject.setReleaseResult(response); + deviceSubscriptionStore.update(deviceSubscriptionObject); } else { logger.debug(LogPrint.LogMethodNamePrint() + "The state or command of the device is different."); } @@ -310,8 +314,8 @@ public String getOnem2mDeviceUri(String uri){ return uri.substring(0, stringlength); } - public void saveDeviceSubscriptionData(String deviceUri, String commandId){ - deviceSubscriptionStore.create(new DeviceSubscriptionObject(deviceUri, commandId)); + public void saveDeviceSubscriptionData(String deviceUri, String commandId, String result){ + deviceSubscriptionStore.create(new DeviceSubscriptionObject(deviceUri, commandId, result)); } } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java index 54707a26..035a95ff 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java @@ -6,5 +6,5 @@ public interface DeviceSubscriptionStore { void create(DeviceSubscriptionObject deviceSubscriptionObject); DeviceSubscriptionObject retrieve(String commandId); void delete(String commandId); - + void update(DeviceSubscriptionObject deviceSubscriptionObject); } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java index 490198f7..1ef84a58 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java @@ -34,4 +34,10 @@ public void delete(String commandId) { logger.debug("Command ID = " + commandId); deviceSubscriptionRepository.delete(commandId); } + + @Override + public void update(DeviceSubscriptionObject deviceSubscriptionObject) { + logger.debug("Device = " + deviceSubscriptionObject.toString()); + deviceSubscriptionRepository.save(deviceSubscriptionObject); + } } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java index cb1f29b9..84774ec3 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java @@ -15,18 +15,25 @@ public class DeviceSubscriptionObject { private String deviceStatus; + private String subscriptionResult; + + private String releaseResult; + public DeviceSubscriptionObject() { } - public DeviceSubscriptionObject(String _commandId, String deviceStatus) { + public DeviceSubscriptionObject(String _commandId, String deviceStatus, String subscriptionResult) { this._commandId = _commandId; this.deviceStatus = deviceStatus; + this.subscriptionResult = subscriptionResult; } - public DeviceSubscriptionObject(String _id, String _commandId, String deviceStatus) { + public DeviceSubscriptionObject(String _id, String _commandId, String deviceStatus, String subscriptionResult, String releaseResult) { this._id = _id; this._commandId = _commandId; this.deviceStatus = deviceStatus; + this.subscriptionResult = subscriptionResult; + this.releaseResult = releaseResult; } public String get_commandId() { @@ -53,6 +60,22 @@ public void set_id(String _id) { this._id = _id; } + public String getSubscriptionResult() { + return subscriptionResult; + } + + public void setSubscriptionResult(String subscriptionResult) { + this.subscriptionResult = subscriptionResult; + } + + public String getReleaseResult() { + return releaseResult; + } + + public void setReleaseResult(String releaseResult) { + this.releaseResult = releaseResult; + } + @Override public String toString() { return "DeviceSubscriptionObject{" +