From d8d8bb6f7ee2516ddecb4f9d48e4feaa23311ae1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Fri, 18 Sep 2015 19:30:21 +0530 Subject: [PATCH 1/7] refactored WindowsDAOFactory --- .../device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java | 4 ---- .../mgt/mobile/impl/windows/util/WindowsPluginConstants.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java index c3fd864d9..3c1ba0424 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/WindowsDAOFactory.java @@ -117,8 +117,6 @@ public class WindowsDAOFactory extends MobileDeviceManagementDAOFactory } } catch (SQLException e) { log.error("Error occurred while committing the transaction", e); - } finally { - closeConnection(); } } @@ -145,8 +143,6 @@ public class WindowsDAOFactory extends MobileDeviceManagementDAOFactory } } catch (SQLException e) { log.warn("Error occurred while roll-backing the transaction", e); - } finally { - closeConnection(); } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java index 05e4f6fe5..50f8f15c3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginConstants.java @@ -25,7 +25,7 @@ public class WindowsPluginConstants { //properties related to database table WINDOWS_DEVICE public static final String MOBILE_DEVICE_ID = "MOBILE_DEVICE_ID"; - public static final String CHANNEL_URI = "CHANNEL_URI "; + public static final String CHANNEL_URI = "CHANNEL_URI"; public static final String DEVICE_INFO = "DEVICE_INFO"; public static final String IMEI = "IMEI"; public static final String IMSI = "IMSI"; From ac88e3217169cce55b844472c07bb660018e970c Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 30 Sep 2015 18:35:03 +0530 Subject: [PATCH 2/7] implimented policyMonitoring service for windows --- .../WindowsPolicyMonitoringService.java | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java index f1034d4ce..fd14cf3e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java @@ -18,26 +18,62 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; +import java.util.ArrayList; import java.util.List; public class WindowsPolicyMonitoringService implements PolicyMonitoringService { + private static Log log = LogFactory.getLog(WindowsPolicyMonitoringService.class); + @Override public void notifyDevices(List list) throws PolicyComplianceException { } @Override - public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException { - return null; + public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload) + throws PolicyComplianceException { + if (log.isDebugEnabled()) { + log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); + } + ComplianceData complianceData = new ComplianceData(); + if (policy == null || compliancePayload == null) { + return complianceData; + } + List complianceFeatures = new ArrayList(); + + JsonElement jsonElement = new JsonParser().parse(compliancePayload.toString()); + JsonArray jsonArray = jsonElement.getAsJsonArray(); + Gson gson = new Gson(); + ComplianceFeature complianceFeature; + for (int x = 0; x < jsonArray.size(); x++) { + complianceFeature = gson.fromJson(jsonArray.get(x), ComplianceFeature.class); + complianceFeatures.add(complianceFeature); + } + complianceData.setComplianceFeatures(complianceFeatures); + + for (ComplianceFeature cf : complianceFeatures) { + if (!cf.isCompliant()) { + complianceData.setStatus(false); + break; + } + } + return complianceData; } @Override From aba2cf44470a8e7aebb69c430a69a2484da88f65 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Fri, 2 Oct 2015 16:21:12 +0530 Subject: [PATCH 3/7] implemented checkCompliancePolicy Service --- .../windows/WindowsPolicyMonitoringService.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java index fd14cf3e6..ecc9e36ad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java @@ -18,10 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; @@ -56,16 +52,7 @@ public class WindowsPolicyMonitoringService implements PolicyMonitoringService { return complianceData; } List complianceFeatures = new ArrayList(); - - JsonElement jsonElement = new JsonParser().parse(compliancePayload.toString()); - JsonArray jsonArray = jsonElement.getAsJsonArray(); - Gson gson = new Gson(); - ComplianceFeature complianceFeature; - for (int x = 0; x < jsonArray.size(); x++) { - complianceFeature = gson.fromJson(jsonArray.get(x), ComplianceFeature.class); - complianceFeatures.add(complianceFeature); - } - complianceData.setComplianceFeatures(complianceFeatures); + complianceData.setComplianceFeatures((List) compliancePayload); for (ComplianceFeature cf : complianceFeatures) { if (!cf.isCompliant()) { From c5397cde671448c04d94144ea74fa591d101f502 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Tue, 6 Oct 2015 18:37:58 +0530 Subject: [PATCH 4/7] refactored checkPolicyCompliance --- .../impl/windows/WindowsPolicyMonitoringService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java index ecc9e36ad..5f91185e9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java @@ -47,19 +47,22 @@ public class WindowsPolicyMonitoringService implements PolicyMonitoringService { if (log.isDebugEnabled()) { log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); } + List complianceFeatures = (List) compliancePayload; + List nonComplianceFeatures = new ArrayList<>(); ComplianceData complianceData = new ComplianceData(); + if (policy == null || compliancePayload == null) { return complianceData; } - List complianceFeatures = new ArrayList(); - complianceData.setComplianceFeatures((List) compliancePayload); for (ComplianceFeature cf : complianceFeatures) { if (!cf.isCompliant()) { complianceData.setStatus(false); + nonComplianceFeatures.add(cf); break; } } + complianceData.setComplianceFeatures(nonComplianceFeatures); return complianceData; } From 023d019864533b16450e657bff82b2acefc1bd49 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Mon, 12 Oct 2015 17:43:19 +0530 Subject: [PATCH 5/7] refactored Windows Device Manager --- .../impl/windows/WindowsDeviceManager.java | 14 +++++-- .../WindowsPolicyMonitoringService.java | 6 +-- .../impl/windows/util/WindowsPluginUtils.java | 39 +++++++++++++++++++ 3 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 3a280812b..855244bb2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -25,7 +25,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; -import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; @@ -55,7 +54,13 @@ public class WindowsDeviceManager implements DeviceManager { public WindowsDeviceManager() { this.daoFactory = new WindowsDAOFactory(); - this.licenseManager = new RegistryBasedLicenseManager(); + //this.licenseManager = new RegistryBasedLicenseManager(); +// License defaultLicense = WindowsPluginUtils.getDefaultLicense(); +// try { +// licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense); +// } catch (LicenseManagementException e) { +// log.error("Error occurred while adding default license for Windows devices", e); +// } } @Override @@ -66,7 +71,7 @@ public class WindowsDeviceManager implements DeviceManager { @Override public boolean saveConfiguration(TenantConfiguration tenantConfiguration) throws DeviceManagementException { - boolean status = false; + boolean status; Resource resource; try { if (log.isDebugEnabled()) { @@ -240,7 +245,8 @@ public class WindowsDeviceManager implements DeviceManager { @Override public License getLicense(String languageCode) throws LicenseManagementException { - return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); + // return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); + return null; } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java index 5f91185e9..b4bb0bac1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java @@ -55,10 +55,10 @@ public class WindowsPolicyMonitoringService implements PolicyMonitoringService { return complianceData; } - for (ComplianceFeature cf : complianceFeatures) { - if (!cf.isCompliant()) { + for (ComplianceFeature complianceFeature : complianceFeatures) { + if (!complianceFeature.isCompliant()) { complianceData.setStatus(false); - nonComplianceFeatures.add(cf); + nonComplianceFeatures.add(complianceFeature); break; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java new file mode 100644 index 000000000..5b0af49ff --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java @@ -0,0 +1,39 @@ +package org.wso2.carbon.device.mgt.mobile.impl.windows.util; + +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService; + +/** + * Contains utility method used by Windows plugin. + */ +public class WindowsPluginUtils { + + public static License getDefaultLicense() { + License license = new License(); + license.setName(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS); + license.setLanguage("en_US"); + license.setVersion("1.0.0"); + license.setText("This End User License Agreement (“Agreement”) is a legal agreement between you (“You”) " + + "and WSO2, Inc., regarding the enrollment of Your personal mobile device (“Device”) in SoR’s " + + "mobile device management program, and the loading to and removal from Your Device and Your use " + + "of certain applications and any associated software and user documentation, whether provided in " + + "“online” or electronic format, used in connection with the operation of or provision of services " + + "to WSO2, Inc., BY SELECTING “I ACCEPT” DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " + + "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " + + "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " + + "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" + + "\n" + + "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" + + "\n" + + "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " + + "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " + + "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " + + "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " + + "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " + + "the cessation of Your relationship with SoR (including termination of Your employment if You are " + + "an employee or expiration or termination of Your applicable franchise or supply agreement if You " + + "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " + + "rights not expressly granted herein."); + return license; + } +} From b644edd5b0b320206b7a8919c2f92a1ebbc6c5b2 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Wed, 14 Oct 2015 19:59:19 +0530 Subject: [PATCH 6/7] refactored code issues --- .../impl/windows/WindowsDeviceManager.java | 19 ++++++++++--------- .../dao/impl/WindowsDeviceDAOImpl.java | 6 ++++-- .../impl/windows/util/WindowsPluginUtils.java | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java index 855244bb2..906bf7f74 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java @@ -25,12 +25,14 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; +import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory; +import org.wso2.carbon.device.mgt.mobile.impl.windows.util.WindowsPluginUtils; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; @@ -54,13 +56,13 @@ public class WindowsDeviceManager implements DeviceManager { public WindowsDeviceManager() { this.daoFactory = new WindowsDAOFactory(); - //this.licenseManager = new RegistryBasedLicenseManager(); -// License defaultLicense = WindowsPluginUtils.getDefaultLicense(); -// try { -// licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense); -// } catch (LicenseManagementException e) { -// log.error("Error occurred while adding default license for Windows devices", e); -// } + this.licenseManager = new RegistryBasedLicenseManager(); + License defaultLicense = WindowsPluginUtils.getDefaultLicense(); + try { + licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense); + } catch (LicenseManagementException e) { + log.error("Error occurred while adding default license for Windows devices", e); + } } @Override @@ -245,8 +247,7 @@ public class WindowsDeviceManager implements DeviceManager { @Override public License getLicense(String languageCode) throws LicenseManagementException { - // return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); - return null; + return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode); } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java index bb9910ac0..897eb7aec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java @@ -53,7 +53,8 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { conn = WindowsDAOFactory.getConnection(); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS, OS_VERSION, DEVICE_NAME " + + "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," + + " OS_VERSION, DEVICE_NAME " + "FROM WINDOWS_DEVICE WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, mblDeviceId); @@ -214,7 +215,8 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { conn = WindowsDAOFactory.getConnection(); String selectDBQuery = "SELECT MOBILE_DEVICE_ID, CHANNEL_URI, DEVICE_INFO, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS, OS_VERSION, DEVICE_NAME " + + "OS_VERSION, DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, SERIAL, MAC_ADDRESS," + + " OS_VERSION, DEVICE_NAME " + "FROM WINDOWS_DEVICE"; stmt = conn.prepareStatement(selectDBQuery); rs = stmt.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java index 5b0af49ff..48de7d53d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/util/WindowsPluginUtils.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * / + */ + package org.wso2.carbon.device.mgt.mobile.impl.windows.util; import org.wso2.carbon.device.mgt.common.license.mgt.License; From fe7283ee017f50693ffb43650154b7e2e8e5a357 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Tue, 20 Oct 2015 01:05:58 +0530 Subject: [PATCH 7/7] refactored code issues --- .../windows/dao/impl/WindowsDeviceDAOImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java index 897eb7aec..237f88168 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/dao/impl/WindowsDeviceDAOImpl.java @@ -63,17 +63,21 @@ public class WindowsDeviceDAOImpl implements MobileDeviceDAO { while (rs.next()) { mobileDevice = new MobileDevice(); mobileDevice.setMobileDeviceId(rs.getString(WindowsPluginConstants.MOBILE_DEVICE_ID)); - mobileDevice.setVendor(rs.getString(WindowsPluginConstants.IMEI)); - mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.IMSI)); - mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.OS_VERSION)); - mobileDevice.setImei(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); - mobileDevice.setImsi(rs.getString(WindowsPluginConstants.VENDOR)); + mobileDevice.setImei(rs.getString(WindowsPluginConstants.IMEI)); + mobileDevice.setImsi(rs.getString(WindowsPluginConstants.IMSI)); + mobileDevice.setModel(rs.getString(WindowsPluginConstants.DEVICE_MODEL)); + mobileDevice.setVendor(rs.getString(WindowsPluginConstants.VENDOR)); + mobileDevice.setLatitude(rs.getString(WindowsPluginConstants.LATITUDE)); + mobileDevice.setLongitude(rs.getString(WindowsPluginConstants.LONGITUDE)); + mobileDevice.setSerial(rs.getString(WindowsPluginConstants.SERIAL)); mobileDevice.setOsVersion(rs.getString(WindowsPluginConstants.LATITUDE)); Map propertyMap = new HashMap(); propertyMap.put(WindowsPluginConstants.CHANNEL_URI, rs.getString(WindowsPluginConstants.CHANNEL_URI)); propertyMap.put(WindowsPluginConstants.DEVICE_INFO, rs.getString(WindowsPluginConstants.DEVICE_INFO)); + propertyMap.put(WindowsPluginConstants.MAC_ADDRESS, rs.getString(WindowsPluginConstants.MAC_ADDRESS)); propertyMap.put(WindowsPluginConstants.DEVICE_NAME, rs.getString(WindowsPluginConstants.DEVICE_NAME)); + mobileDevice.setDeviceProperties(propertyMap); } if (log.isDebugEnabled()) {