|
|
@ -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) {
|
|
|
|
registry.beginTransaction();
|
|
|
|
return false;
|
|
|
|
registry.put(path, resource);
|
|
|
|
} else {
|
|
|
|
registry.commitTransaction();
|
|
|
|
registry.beginTransaction();
|
|
|
|
return true;
|
|
|
|
registry.put(path, resource);
|
|
|
|
|
|
|
|
registry.commitTransaction();
|
|
|
|
|
|
|
|
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);
|
|
|
|