From b1625f93dd35cf0e2d774f95eca44ff086c9aa29 Mon Sep 17 00:00:00 2001 From: Madhawa Perera Date: Sat, 15 Sep 2018 14:48:50 +0530 Subject: [PATCH] reformat code --- .../RemoteSessionManagementServiceImpl.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java index 75fbfdccaf..23320c4838 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java @@ -73,6 +73,7 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme sessionQueryParamList.add(session.getQueryString()); sessionQueryParam.put(RemoteSessionConstants.QUERY_STRING, sessionQueryParamList); + // if session initiated using operation id means request came from device. if (operationId == null) { // Validate the token OAuthAuthenticator oAuthAuthenticator = RemoteSessionManagementDataHolder.getInstance().getOauthAuthenticator(); @@ -102,16 +103,8 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme .getMaxMessageBufferSize()); session.setMaxIdleTimeout(RemoteSessionManagementDataHolder.getInstance().getMaxIdleTimeout()); - // if session initiated using operation id means request came from device -// if (operationId != null) { -// // create new device session -// initializeDeviceSession(session, authenticationInfo.getTenantDomain(), deviceType, deviceId, -// operationId); -// } else { - // create new client session - initializeClientSession(session, authenticationInfo.getTenantDomain(), deviceType, - deviceId); -// } + initializeClientSession(session, authenticationInfo.getTenantDomain(), deviceType, deviceId); + log.info("Current remote sessions count: " + RemoteSessionManagementDataHolder.getInstance() .getSessionMap().size()); @@ -145,11 +138,11 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme session.setMaxIdleTimeout(RemoteSessionManagementDataHolder.getInstance().getMaxIdleTimeout()); String uuid = session.getQueryString(); - if(uuid != null && uuid.isEmpty()){ + if (uuid != null && uuid.isEmpty()) { log.error("Could not find a UUID related to the remote session"); } else { String tenantDomain = RemoteSessionManagementDataHolder.getInstance().getUuidToTenantMap().remove(uuid); - if(tenantDomain == null || tenantDomain.isEmpty()){ + if (tenantDomain == null || tenantDomain.isEmpty()) { log.error("Invalid UUID, could not create the remote session"); } else { // create new device session @@ -304,10 +297,11 @@ public class RemoteSessionManagementServiceImpl implements RemoteSessionManageme JSONObject payload = new JSONObject(); payload.put("serverUrl", RemoteSessionManagementDataHolder.getInstance().getServerUrl()); payload.put("uuidToValidateDevice", uuidToValidateDevice); - String uuidToTenantMap = RemoteSessionManagementDataHolder.getInstance().getUuidToTenantMap - ().putIfAbsent(uuidToValidateDevice, tenantDomain); + RemoteSessionManagementDataHolder.getInstance().getUuidToTenantMap + ().put(uuidToValidateDevice, tenantDomain); if (log.isDebugEnabled()) { - log.debug("UUID " + uuidToTenantMap + " is generated against the tenant : " + tenantDomain); + log.debug("UUID " + uuidToValidateDevice + " is generated against the tenant : " + + RemoteSessionManagementDataHolder.getInstance().getUuidToTenantMap().get(uuidToValidateDevice)); } operation.setPayLoad(payload.toString()); String date = new SimpleDateFormat(RemoteSessionConstants.DATE_FORMAT_NOW).format(new Date());