From f4b8e4bb7430e71b05ea0138f10a76e9a7ad6f76 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 15 May 2015 12:04:01 +0530 Subject: [PATCH 1/2] Remove delete device type from DB when un register plugin --- .../carbon/device/mgt/core/DeviceManagementRepository.java | 6 ------ .../wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java index 8b8e22b75e..596d1202a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java @@ -45,12 +45,6 @@ public class DeviceManagementRepository { public void removeDeviceManagementProvider(DeviceMgtService provider) throws DeviceManagementException { String deviceType = provider.getProviderType(); - try { - DeviceManagerUtil.unregisterDeviceType(deviceType); - } catch (DeviceManagementException e) { - throw new DeviceManagementException("Error occurred while removing device management provider '" + - deviceType + "'", e); - } providers.remove(deviceType); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index f716bf6e2e..308ed6813f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -142,7 +142,7 @@ public final class DeviceManagerUtil { try { DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); DeviceType deviceType = deviceTypeDAO.getDeviceType(typeName); - if (deviceType == null) { + if (deviceType != null) { DeviceType dt = new DeviceType(); dt.setName(typeName); deviceTypeDAO.removeDeviceType(typeName); From 1b1b66fc297080a5168b4f0cb86a2e080e0731e8 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 15 May 2015 15:04:13 +0530 Subject: [PATCH 2/2] Handle DB close within rollback transaction --- .../mgt/core/internal/DeviceManagementServiceComponent.java | 2 +- .../mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java | 1 - .../src/test/resources/sql/h2.sql | 2 +- .../src/main/resources/dbscripts/cdm/h2.sql | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 661eb61693..54b279bc45 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -266,7 +266,7 @@ public class DeviceManagementServiceComponent { */ protected void unsetDeviceManager(DeviceMgtService deviceManager) { if (log.isDebugEnabled()) { - log.debug("Unsetting Device Management Service Provider : '" + deviceManager.getProviderType() + "'"); + log.debug("Un setting Device Management Service Provider : '" + deviceManager.getProviderType() + "'"); } try { this.getPluginRepository().removeDeviceManagementProvider(deviceManager); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java index fdf39f8ddf..35f0f0cd10 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java @@ -66,7 +66,6 @@ public class OperationDAOImpl implements OperationDAO { throw new OperationManagementDAOException("Error occurred while adding operation metadata", e); } finally { OperationManagementDAOUtil.cleanupResources(stmt, rs); - OperationManagementDAOFactory.closeConnection(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql index d15a958212..83a5410439 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql @@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATED_TIMESTAMP TIMESTAMP NOT NULL, RECEIVED_TIMESTAMP TIMESTAMP NULL, STATUS VARCHAR(50) NULL, - OPERATION_CODE VARCHAR(25) NOT NULL, + OPERATION_CODE VARCHAR(1000) NOT NULL, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index 14f3265dd3..57845c0d5e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATED_TIMESTAMP TIMESTAMP NOT NULL, RECEIVED_TIMESTAMP TIMESTAMP NULL, STATUS VARCHAR(50) NULL, - OPERATION_CODE VARCHAR(25) NOT NULL, + OPERATION_CODE VARCHAR(1000) NOT NULL, PRIMARY KEY (ID) );