From 4226755991d7e935f4d0314a33be02ff7ac1c271 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 29 Apr 2019 22:44:46 +0530 Subject: [PATCH 1/3] Fix windows enrollment issue --- .../device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java index ab81df77c..eddbb4b1a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java @@ -3,6 +3,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsEnrollmentTokenDAO; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsEnrollmentTokenDAOImpl; @@ -15,6 +16,7 @@ public class WindowsTokenServiceImpl implements WindowsTokenService { public WindowsTokenServiceImpl() { windowsEnrollmentTokenDAO = new WindowsEnrollmentTokenDAOImpl(); + WindowsDAOFactory windowsDAOFactory = new WindowsDAOFactory(); } @Override From b04acfdf53aefc38b62910a1f55d9a9f46a3baa0 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 29 Apr 2019 23:25:37 +0530 Subject: [PATCH 2/3] Fix windows enrollment issue --- .../mgt/mobile/windows/impl/WindowsTokenServiceImpl.java | 1 - .../mgt/mobile/windows/impl/dao/WindowsDAOFactory.java | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java index eddbb4b1a..945dfa1ad 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java @@ -16,7 +16,6 @@ public class WindowsTokenServiceImpl implements WindowsTokenService { public WindowsTokenServiceImpl() { windowsEnrollmentTokenDAO = new WindowsEnrollmentTokenDAOImpl(); - WindowsDAOFactory windowsDAOFactory = new WindowsDAOFactory(); } @Override diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java index 760a8a5fd..a49110e22 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java @@ -77,6 +77,15 @@ public class WindowsDAOFactory extends AbstractMobileDeviceManagementDAOFactory if (currentConnection.get() == null) { Connection conn; try { + if (dataSource == null) { + try { + String dataSourceName = "jdbc/MobileWindowsDM_DS"; + Context ctx = new InitialContext(); + dataSource = (DataSource) ctx.lookup(dataSourceName); + } catch (NamingException e) { + throw new MobileDeviceManagementDAOException("Error occurred while initializing datasource", e); + } + } conn = dataSource.getConnection(); currentConnection.set(conn); } catch (SQLException e) { From 9cbb4537907c9ae1877f5b28e397b6726010277a Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 29 Apr 2019 23:27:25 +0530 Subject: [PATCH 3/3] Format code --- .../mgt/mobile/windows/impl/WindowsTokenServiceImpl.java | 6 +++--- .../mgt/mobile/windows/impl/dao/WindowsDAOFactory.java | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java index 945dfa1ad..e76ec4ebd 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java @@ -3,7 +3,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsEnrollmentTokenDAO; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsEnrollmentTokenDAOImpl; @@ -24,7 +23,7 @@ public class WindowsTokenServiceImpl implements WindowsTokenService { WindowsDAOFactory.beginTransaction(); windowsEnrollmentTokenDAO.addCacheToken(entry); WindowsDAOFactory.commitTransaction(); - } finally { + } finally { WindowsDAOFactory.closeConnection(); } } @@ -52,7 +51,8 @@ public class WindowsTokenServiceImpl implements WindowsTokenService { return cacheEntry; } - @Override public MobileCacheEntry getCacheTokenFromDeviceId(String deviceId) + @Override + public MobileCacheEntry getCacheTokenFromDeviceId(String deviceId) throws MobileDeviceManagementDAOException { MobileCacheEntry cacheEntry = null; try { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java index a49110e22..dab36a4b0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java @@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.windows.exception.WindowsDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsDeviceDAOImpl; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsFeatureDAOImpl;