public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException {
   try {
     if (MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
       return MobileDeviceManagementUtil.getConfigurationRegistry().get(path);
     }
     return null;
   } catch (RegistryException e) {
     throw new MobileDeviceMgtPluginException(
         "Error in retrieving registry resource : " + e.getMessage(), e);
   }
 }
 public static Registry getConfigurationRegistry() throws MobileDeviceMgtPluginException {
   try {
     int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
     return MobileDeviceManagementDataHolder.getInstance()
         .getRegistryService()
         .getConfigSystemRegistry(tenantId);
   } catch (RegistryException e) {
     throw new MobileDeviceMgtPluginException(
         "Error in retrieving conf registry instance: " + e.getMessage(), e);
   }
 }
 public static Registry getGovernanceRegistry() throws DynamicClientRegistrationException {
   try {
     int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
     return DynamicClientRegistrationDataHolder.getInstance()
         .getRegistryService()
         .getGovernanceSystemRegistry(tenantId);
   } catch (RegistryException e) {
     throw new DynamicClientRegistrationException(
         "Error in retrieving governance registry instance: " + e.getMessage(), e);
   }
 }
 public static Resource getRegistryResource(String path)
     throws DynamicClientRegistrationException {
   try {
     Registry governanceRegistry = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry();
     if (governanceRegistry.resourceExists(path)) {
       return governanceRegistry.get(path);
     }
     return null;
   } catch (RegistryException e) {
     throw new DynamicClientRegistrationException(
         "Error in retrieving registry resource : " + e.getMessage(), e);
   }
 }
 public static boolean putRegistryResource(String path, Resource resource)
     throws MobileDeviceMgtPluginException {
   boolean status;
   try {
     MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
     MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
     MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
     status = true;
   } catch (RegistryException e) {
     throw new MobileDeviceMgtPluginException(
         "Error occurred while persisting registry resource : " + e.getMessage(), e);
   }
   return status;
 }
 public static boolean putRegistryResource(String path, Resource resource)
     throws DynamicClientRegistrationException {
   boolean status;
   try {
     Registry governanceRegistry = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry();
     governanceRegistry.beginTransaction();
     governanceRegistry.put(path, resource);
     governanceRegistry.commitTransaction();
     status = true;
   } catch (RegistryException e) {
     throw new DynamicClientRegistrationException(
         "Error occurred while persisting registry resource : " + e.getMessage(), e);
   }
   return status;
 }
 public static boolean createRegistryCollection(String path)
     throws MobileDeviceMgtPluginException {
   try {
     if (!MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
       Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection();
       MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
       MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
       MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
     }
     return true;
   } catch (MobileDeviceMgtPluginException e) {
     throw new MobileDeviceMgtPluginException(
         "Error occurred while creating a registry collection : " + e.getMessage(), e);
   } catch (RegistryException e) {
     throw new MobileDeviceMgtPluginException(
         "Error occurred while creating a registry collection : " + e.getMessage(), e);
   }
 }