From 61567a2040359a67defeb519e9345e72d6b8779b Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 10 Oct 2017 22:23:09 +0530 Subject: [PATCH] Fixing issues --- .../exception/DeviceTypeMgtPluginException.java | 4 ++++ .../type/template/util/DeviceTypeUtils.java | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/exception/DeviceTypeMgtPluginException.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/exception/DeviceTypeMgtPluginException.java index 1919e88f42..a07808a9ff 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/exception/DeviceTypeMgtPluginException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/exception/DeviceTypeMgtPluginException.java @@ -22,6 +22,10 @@ package org.wso2.carbon.device.mgt.extensions.device.type.template.exception; */ public class DeviceTypeMgtPluginException extends Exception{ + public DeviceTypeMgtPluginException(String msg) { + super(msg); + } + public DeviceTypeMgtPluginException(String msg, Exception nestedEx) { super(msg, nestedEx); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/util/DeviceTypeUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/util/DeviceTypeUtils.java index f6dd19a8f4..56ab67d7bf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/util/DeviceTypeUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/util/DeviceTypeUtils.java @@ -104,7 +104,10 @@ public class DeviceTypeUtils { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); org.wso2.carbon.registry.core.service.RegistryService registryService = DeviceTypeExtensionDataHolder .getInstance().getRegistryService(); - return registryService == null ? null : registryService.getConfigSystemRegistry(tenantId); + if (registryService == null) { + throw new DeviceTypeMgtPluginException("Registry Service is not initialized properly"); + } + return registryService.getConfigSystemRegistry(tenantId); } catch (RegistryException e) { throw new DeviceTypeMgtPluginException("Error in retrieving conf registry instance: " + e.getMessage(), e); } @@ -113,14 +116,10 @@ public class DeviceTypeUtils { public static boolean putRegistryResource(String path, Resource resource) throws DeviceTypeMgtPluginException { try { Registry registry = getConfigurationRegistry(); - if (registry == null) { - return false; - } else { - registry.beginTransaction(); - registry.put(path, resource); - registry.commitTransaction(); - return true; - } + registry.beginTransaction(); + registry.put(path, resource); + registry.commitTransaction(); + return true; } catch (RegistryException e) { throw new DeviceTypeMgtPluginException( "Error occurred while persisting registry resource : " + e.getMessage(), e);