From dcf0f5039d0ee27dac9b730e487317529137bec8 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Tue, 12 May 2015 18:18:46 +0530 Subject: [PATCH 1/7] * Increased field length* Increased field length* Increased field length* Increased field length* Increased field length* Increased field length* Increased field length* Increased field length --- .../src/test/resources/sql/CreateH2TestDB.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 3005bc42bc..4db13d70f7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID INT(11) NOT NULL AUTO_INCREMENT, PROFILE_ID INT(11) NOT NULL, - FEATURE_CODE VARCHAR(10) NOT NULL, + FEATURE_CODE VARCHAR(30) NOT NULL, DEVICE_TYPE_ID INT NOT NULL, CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), From acc159d132f7cfa6a789e32069d8e736e54b4256 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Wed, 13 May 2015 22:04:15 +0530 Subject: [PATCH 2/7] * Refactored addPolicy --- .../carbon/policy/mgt/common/PolicyAdministratorPoint.java | 2 ++ .../wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java | 2 +- .../policy/mgt/core/impl/PolicyAdministratorPointImpl.java | 4 ++++ .../carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java index 7d1e7244ab..53f8411bbc 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java @@ -62,6 +62,8 @@ public interface PolicyAdministratorPoint { List getPolicies() throws PolicyManagementException; + Policy getPolicy(int policyId) throws PolicyManagementException; + /** * This method gives the device specific policy. * diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index 27edad84f5..eef48b2710 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -445,11 +445,11 @@ public class PolicyDAOImpl implements PolicyDAO { resultSet = stmt.executeQuery(); while (resultSet.next()) { - policy.setId(policyId); policy.setPolicyName(resultSet.getString("NAME")); policy.setTenantId(resultSet.getInt("TENANT_ID")); policy.setPriorityId(resultSet.getInt("PRIORITY")); + policy.setProfileId(resultSet.getInt("PROFILE_ID")); } return policy; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index 0029b26983..c1c8f73d92 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -83,6 +83,10 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { return policyManager.getPolicies(); } + @Override public Policy getPolicy(int policyId) throws PolicyManagementException { + return policyManager.getPolicy(policyId); + } + @Override public List getPoliciesOfDevice(DeviceIdentifier deviceIdentifier) throws PolicyManagementException { return policyManager.getPoliciesOfDevice(deviceIdentifier); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 811a7f087c..fb8b27c2fe 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -372,7 +372,7 @@ public class PolicyManagerImpl implements PolicyManager { policyDAO.getTimesOfPolicy(policy); policyDAO.getLocationsOfPolicy(policy); - Profile profile = profileDAO.getProfiles(policy.getProfile().getProfileId()); + Profile profile = profileDAO.getProfiles(policy.getProfileId()); policy.setProfile(profile); policy.setRoles(roleNames); From bf62561b00108d2c83798c3befb248a4926713ed Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 13 May 2015 23:34:03 +0530 Subject: [PATCH 3/7] Change Next operations method to accept parameter device id --- .../operation/mgt/OperationManagerImpl.java | 22 +++++++++++++++---- .../core/operation/mgt/dao/OperationDAO.java | 2 +- .../mgt/dao/impl/OperationDAOImpl.java | 8 +++---- .../mgt/dao/impl/ProfileOperationDAOImpl.java | 1 - 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 5000bd56a6..6e66527c58 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; 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.DeviceManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -195,20 +196,33 @@ public class OperationManagerImpl implements OperationManager { } @Override - public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { + public Operation getNextPendingOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException { if (log.isDebugEnabled()) { - log.debug("device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]"); + log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType() + "]"); } Operation operation = null; + Device device; try { + device = deviceManagementService.getCoreDevice(deviceIdentifier); + + if (device == null) { + throw new OperationManagementException("Device not found for given device " + + "Identifier:" + deviceIdentifier.getId() + " and given type" + deviceIdentifier.getType()); + } org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO - .getNextOperation(deviceId); + .getNextOperation(device.getId()); if (dtoOperation != null) { operation = OperationDAOUtil.convertOperation(dtoOperation); } return operation; - } catch (OperationManagementDAOException e) { + } catch (DeviceManagementException deviceMgtException) { + String errorMsg = "Error occurred while retrieving the device " + + "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" + + deviceIdentifier.getId(); + log.error(errorMsg, deviceMgtException); + throw new OperationManagementException(errorMsg, deviceMgtException); + } catch (OperationManagementDAOException e) { throw new OperationManagementException("Error occurred while retrieving next pending operation", e); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java index bd7699e670..07572f98c7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -42,6 +42,6 @@ public interface OperationDAO { List getOperationsForStatus(Operation.Status status) throws OperationManagementDAOException; - Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException; + Operation getNextOperation(int deviceId) throws OperationManagementDAOException; } 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 9b996e1069..fdf39f8ddf 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 @@ -462,7 +462,7 @@ public class OperationDAOImpl implements OperationDAO { } @Override - public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { + public Operation getNextOperation(int deviceId) throws OperationManagementDAOException { PreparedStatement stmt = null; ResultSet rs = null; @@ -483,9 +483,9 @@ public class OperationDAOImpl implements OperationDAO { "o.ID =po.OPERATION_ID LEFT OUTER JOIN DM_COMMAND_OPERATION co ON co.OPERATION_ID=o.ID " + "ORDER BY o.CREATED_TIMESTAMP ASC LIMIT 1"); - stmt.setString(1, deviceId.getType()); - stmt.setString(2, deviceId.getId()); - stmt.setString(3, Operation.Status.PENDING.toString()); + stmt.setString(1, Operation.Status.PENDING.toString()); + stmt.setInt(2, deviceId); + rs = stmt.executeQuery(); Operation operation = null; 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/ProfileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java index f59fe6452d..f23e77eafa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java @@ -59,7 +59,6 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { return operationId; } - @Override public Operation getNextOperation(DeviceIdentifier deviceId) throws OperationManagementDAOException { PreparedStatement stmt = null; From 5eed51c3dc1be8aadb460586ea0bfcce7e7f4aa2 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 14 May 2015 18:13:24 +0530 Subject: [PATCH 4/7] Fixing issues surfaced while logging into the management console of the product as a result of an anomaly in the webapp authenticator framework --- .../framework/WebappAuthenticatorFrameworkValve.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java index e14480d822..66982112bd 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticatorFrameworkValve.java @@ -44,9 +44,11 @@ public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve { case SUCCESS: case CONTINUE: this.getNext().invoke(request, response, compositeValve); + break; case FAILURE: AuthenticationFrameworkUtil.handleResponse(request, response, HttpServletResponse.SC_UNAUTHORIZED, "Failed to authorize the incoming request"); + break; } } From a774bc89aa2214f0c57559a85ca0f18289c39b7a Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 15 May 2015 02:43:41 +0530 Subject: [PATCH 5/7] Device Type not present in DB, return null instead of dummy object --- .../mgt/core/dao/impl/DeviceTypeDAOImpl.java | 10 +++---- .../DeviceManagementServiceComponent.java | 3 +-- .../mgt/core/util/DeviceManagerUtil.java | 26 +++++++++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java index caac62456f..f2f0ac8937 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java @@ -120,6 +120,7 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; + DeviceType deviceType = null; try { conn = this.getConnection(); String sql = "SELECT ID From DM_DEVICE_TYPE WHERE NAME = ?"; @@ -127,14 +128,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { stmt.setString(1, type); rs = stmt.executeQuery(); - int id = -1; if (rs.next()) { - id = rs.getInt("ID"); + deviceType = new DeviceType(); + deviceType.setId(rs.getInt("ID")); + deviceType.setName(type); } - DeviceType deviceType = new DeviceType(); - deviceType.setId(id); - deviceType.setName(type); - return deviceType; } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while fetch device type id for device type " + 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 ab985dcda2..661eb61693 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 @@ -55,10 +55,9 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOF import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; +import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.user.core.service.RealmService; - import java.util.ArrayList; import java.util.List; 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 80e2b5b371..f716bf6e2e 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 @@ -111,23 +111,23 @@ public final class DeviceManagerUtil { /** * Adds a new device type to the database if it does not exists. * - * @param deviceType device type + * @param typeName device type * @return status of the operation */ - public static boolean registerDeviceType(String deviceType) throws DeviceManagementException { + public static boolean registerDeviceType(String typeName) throws DeviceManagementException { boolean status; try { DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - DeviceType deviceTypeId = deviceTypeDAO.getDeviceType(deviceType); - if (deviceTypeId == null) { + DeviceType deviceType = deviceTypeDAO.getDeviceType(typeName); + if (deviceType == null) { DeviceType dt = new DeviceType(); - dt.setName(deviceType); + dt.setName(typeName); deviceTypeDAO.addDeviceType(dt); } status = true; } catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while registering the device type '" + - deviceType + "'", e); + typeName + "'", e); } return status; } @@ -135,22 +135,22 @@ public final class DeviceManagerUtil { /** * Un-registers an existing device type from the device management metadata repository. * - * @param deviceType device type + * @param typeName device type * @return status of the operation */ - public static boolean unregisterDeviceType(String deviceType) throws DeviceManagementException { + public static boolean unregisterDeviceType(String typeName) throws DeviceManagementException { try { DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); - DeviceType deviceTypeId = deviceTypeDAO.getDeviceType(deviceType); - if (deviceTypeId == null) { + DeviceType deviceType = deviceTypeDAO.getDeviceType(typeName); + if (deviceType == null) { DeviceType dt = new DeviceType(); - dt.setName(deviceType); - deviceTypeDAO.removeDeviceType(deviceType); + dt.setName(typeName); + deviceTypeDAO.removeDeviceType(typeName); } return true; } catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while registering the device type '" + - deviceType + "'", e); + typeName + "'", e); } } From f4b8e4bb7430e71b05ea0138f10a76e9a7ad6f76 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 15 May 2015 12:04:01 +0530 Subject: [PATCH 6/7] 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 7/7] 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) );