Fixing issues

revert-70aa11f8
megala21 7 years ago
parent 4d1b9ea03d
commit 61567a2040

@ -22,6 +22,10 @@ package org.wso2.carbon.device.mgt.extensions.device.type.template.exception;
*/ */
public class DeviceTypeMgtPluginException extends Exception{ public class DeviceTypeMgtPluginException extends Exception{
public DeviceTypeMgtPluginException(String msg) {
super(msg);
}
public DeviceTypeMgtPluginException(String msg, Exception nestedEx) { public DeviceTypeMgtPluginException(String msg, Exception nestedEx) {
super(msg, nestedEx); super(msg, nestedEx);
} }

@ -104,7 +104,10 @@ public class DeviceTypeUtils {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
org.wso2.carbon.registry.core.service.RegistryService registryService = DeviceTypeExtensionDataHolder org.wso2.carbon.registry.core.service.RegistryService registryService = DeviceTypeExtensionDataHolder
.getInstance().getRegistryService(); .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) { } catch (RegistryException e) {
throw new DeviceTypeMgtPluginException("Error in retrieving conf registry instance: " + e.getMessage(), 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 { public static boolean putRegistryResource(String path, Resource resource) throws DeviceTypeMgtPluginException {
try { try {
Registry registry = getConfigurationRegistry(); Registry registry = getConfigurationRegistry();
if (registry == null) {
return false;
} else {
registry.beginTransaction(); registry.beginTransaction();
registry.put(path, resource); registry.put(path, resource);
registry.commitTransaction(); registry.commitTransaction();
return true; return true;
}
} catch (RegistryException e) { } catch (RegistryException e) {
throw new DeviceTypeMgtPluginException( throw new DeviceTypeMgtPluginException(
"Error occurred while persisting registry resource : " + e.getMessage(), e); "Error occurred while persisting registry resource : " + e.getMessage(), e);

Loading…
Cancel
Save