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);