Skip to content

Commit

Permalink
DeviceSubscription 데이터 수정 iotoasis#360
Browse files Browse the repository at this point in the history
  • Loading branch information
pahnjy01 committed Feb 6, 2017
1 parent 4451ebd commit d9438b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public void deviceUpdate(DeviceStatusData deviceStatusData) {
* Device Subscription 해제 요청
*/
response = deviceSubscriptionRelease(deviceUri + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS);

} else {
logger.debug("Device Status = " + device.getDeviceStatus() + " DeviceCommand = " + deviceStatusData.getCon());
logger.debug(LogPrint.LogMethodNamePrint() + "The state or command of the device is different.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,10 @@ public ResultMessage deviceControlRequest(String requestUrl, DeviceControlMessag
//
logger.info("<================ Device Control Request Start ================>");
logger.debug(LogPrint.LogMethodNamePrint() + " | RequestUri = " + requestUrl + " , deviceControlMessage = " + deviceControlMessage.toString());
ResultMessage resultMessage = new ResultMessage();
String requestBody = new Gson().toJson(deviceControlMessage);
String responseData = clientService.requestPostServiceReceiveString(requestUrl, requestBody);
logger.debug(LogPrint.LogMethodNamePrint() + " | Device Control Request responseData = " + responseData);
try {
resultMessage = mapper.readValue(responseData, ResultMessage.class);
} catch (IOException e) {
e.printStackTrace();
resultMessage.setCode(ClientProfile.RESPONSE_FIALURE_CODE);
}
ResultMessage resultMessage = parsingResultMessage(responseData);
logger.debug(LogPrint.LogMethodNamePrint() + " | Device Control Request Result = " + resultMessage);
logger.info("<================ Device Control Request End ================>");
return resultMessage;
Expand All @@ -72,13 +66,7 @@ public String deviceSubscriptionRequest(String deviceUri, String commandId) {
String responseData = clientService.requestPostServiceReceiveString(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_SUBSCRIPTION_URI, requestBody);
// ResponseData{ "code" : "2000", "message" : "", "content" : "" }
logger.debug(LogPrint.LogMethodNamePrint() + " | Subscription Request : Response Data = " + responseData);
ResultMessage resultMessage = new ResultMessage();
try {
resultMessage = mapper.readValue(responseData, ResultMessage.class);
} catch (IOException e) {
e.printStackTrace();
resultMessage.setCode(ClientProfile.RESPONSE_FIALURE_CODE);
}
ResultMessage resultMessage = parsingResultMessage(responseData);
logger.debug(LogPrint.LogMethodNamePrint() + " | Device Subscription Request Result = " + resultMessage.getCode());
logger.info("<================ Device Subscription Request End ================>");
return resultMessage.getCode();
Expand All @@ -97,8 +85,22 @@ public String deviceSubscriptionReleaseRequest(String deviceUri) {
// DeviceLogic에 생성되거나 제어되면 서브스크립트 걸어야 겠군.
// 현제 정책이 안되어 있어서. 등록되면 걸지.. 제어시 걸지는 고려 필요.
String responseData = clientService.requestPostServiceReceiveString(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_SUBSCRIPTION_RELEASE_URI, requestBody);
logger.debug(LogPrint.LogMethodNamePrint() + " | Device SubscriptionRelease Request Result = " + responseData);
ResultMessage resultMessage = parsingResultMessage(responseData);
logger.debug(LogPrint.LogMethodNamePrint() + " | Device SubscriptionRelease Request Result = " + resultMessage.getCode());
logger.info("<================ Device SubscriptionRelease Request End ================>");
return responseData;
return resultMessage.getCode();
}


private ResultMessage parsingResultMessage(String response){
ResultMessage resultMessage = new ResultMessage();
try {
resultMessage = mapper.readValue(response, ResultMessage.class);
} catch (IOException e) {
e.printStackTrace();
resultMessage.setCode(ClientProfile.RESPONSE_FIALURE_CODE);
}
return resultMessage;
}

}

0 comments on commit d9438b9

Please sign in to comment.